diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf1d13065..7e80545fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,7 +74,9 @@ jobs: cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - name: Build SDK - run: ./scripts/build + # Where the "Build local Maven repo" step runs it needs the Javadoc, and generating it in + # the same Gradle run as the compile is faster. + run: ./scripts/build ${{ github.repository != 'anthropics/anthropic-sdk-java' && !startsWith(github.ref, 'refs/heads/stl/') && 'dokkaGeneratePublicationJavadoc' || '' }} - name: Build local Maven repo if: |- diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fc6bc1a45..db4a1f8cc 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.68.0" + ".": "2.69.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 22d92ae18..ff96e9e90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,56 @@ # Changelog +## 2.69.0 (2026-10-07) + +Full Changelog: [v2.68.0...v2.69.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.68.0...v2.69.0) + +### Features + +* **api:** add claude-haiku-5-5 and typed computer and browser toolset tool calls ([8c207f2](https://github.com/anthropics/anthropic-sdk-java/commit/8c207f2e239dedd88f7d3bb5c15d49ed44446892)) +* **api:** add disabled to thinking types in model capabilities ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **api:** add display_name to RBAC roles and deprecate name ([20b61fc](https://github.com/anthropics/anthropic-sdk-java/commit/20b61fc8fadb5ad4f75c0fe162e865bec3e7edcc)) +* **api:** add include_default parameter to list workspaces ([c1450d5](https://github.com/anthropics/anthropic-sdk-java/commit/c1450d5e7eee91d777365f300677f3a1f84100e7)) +* **api:** add lifecycle stage fields and filter to /v1/models ([476c9df](https://github.com/anthropics/anthropic-sdk-java/commit/476c9df6b02d2c1d5d41e118b739a8c73c19ae9c)) +* **api:** add line to model objects ([df57dee](https://github.com/anthropics/anthropic-sdk-java/commit/df57deef84fb1f68e7761adba5024bd7ad1a41c9)) +* **api:** add url_sources to the Managed Agents web_fetch tool config ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **api:** add web search and code execution support to model capabilities ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) + + +### Bug Fixes + +* **api:** send the beta header by default when listing spend limits ([bbd9598](https://github.com/anthropics/anthropic-sdk-java/commit/bbd95986796f7b02dbbff9840f2b11bb843265f5)) +* **client:** don't send a default header value again when the caller passes it too ([6560b24](https://github.com/anthropics/anthropic-sdk-java/commit/6560b247049c02f2e79d5a7cda12244c8cf5602d)) +* **client:** fix profile config parsing under ProGuard with older Jackson versions ([#338](https://github.com/anthropics/anthropic-sdk-java/issues/338)) ([a5c7977](https://github.com/anthropics/anthropic-sdk-java/commit/a5c7977fcd7190b8bd3ed39838d11be0bdd9981a)) +* **client:** fix requests failing under ProGuard and R8, and keep much less code ([8dd88f3](https://github.com/anthropics/anthropic-sdk-java/commit/8dd88f3e7ff7fd6fee74e2f7a526ffc3d4adc9c1)) +* **client:** handle mcp tool listing blocks in structured content blocks ([#340](https://github.com/anthropics/anthropic-sdk-java/issues/340)) ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **client:** send array header params as a single comma-separated header ([a012009](https://github.com/anthropics/anthropic-sdk-java/commit/a012009076aa31993bedbf591d61f846e20c2e00)) +* **client:** send default and caller-provided array header values in a single header ([83c1432](https://github.com/anthropics/anthropic-sdk-java/commit/83c1432eac855a114ca7b8e797cc78a623f2b899)) +* **client:** throw an error when a path parameter is "." or ".." ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **docs:** omit empty doc comments for blank descriptions ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) + + +### Chores + +* **api:** mark the Text Completions API as deprecated ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **ci:** generate the Javadoc in the same Gradle run as the compile ([d1f3a63](https://github.com/anthropics/anthropic-sdk-java/commit/d1f3a6329c42ae06d486291c2194f3b0cbb09a59)) +* **docs:** correct example groups in rate limit list description ([ddb499a](https://github.com/anthropics/anthropic-sdk-java/commit/ddb499a6fa826ea874114243b990d77ad47889a2)) +* **docs:** correct when usage and cost report data becomes final ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **docs:** describe a federation rule's target by its type ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **docs:** fix example IDs in sessions, agents and vault credentials ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **docs:** update Managed Agents multiagent and thread descriptions ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **docs:** update the activity summaries endpoint description ([00de508](https://github.com/anthropics/anthropic-sdk-java/commit/00de508f05be834859c73b646c4c7e697206352c)) +* **docs:** update the description of the Model line field ([1c424bf](https://github.com/anthropics/anthropic-sdk-java/commit/1c424bff639f9ed48adf4294e8b204217e62bd49)) +* **internal:** add REVIEW.md with review instructions ([9de8343](https://github.com/anthropics/anthropic-sdk-java/commit/9de83439a4f684c5231f3596f4d0cdb8606550aa)) +* **internal:** run detekt on the core module in eight parallel tasks ([c355f1a](https://github.com/anthropics/anthropic-sdk-java/commit/c355f1ad3c3d66b0fc55e46507f317a605938f06)) +* **tests:** run tests skipped for a query param bug that is now fixed ([9231cff](https://github.com/anthropics/anthropic-sdk-java/commit/9231cffafe40bdae1b7d42759d2ee632656c417a)) +* **tests:** run tests that an older mock server could not serve ([d50ce89](https://github.com/anthropics/anthropic-sdk-java/commit/d50ce890160b0289b4cd572dfb83f7a2bbf15684)) +* **tests:** run the tests skipped for incomplete example responses ([d21d76f](https://github.com/anthropics/anthropic-sdk-java/commit/d21d76f11274bbeb3b23949eadc9cf922d2143a1)) + + +### Documentation + +* **api:** state the agent tools limit as 256 ([537fae7](https://github.com/anthropics/anthropic-sdk-java/commit/537fae7f7e37537a5bf8ba0599544c8d5aff8bae)) + ## 2.68.0 (2026-09-30) Full Changelog: [v2.67.0...v2.68.0](https://github.com/anthropics/anthropic-sdk-java/compare/v2.67.0...v2.68.0) diff --git a/README.md b/README.md index 43cd26372..0a41fbf15 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.68.0") +implementation("com.anthropic:anthropic-java:2.69.0") ``` ### Maven @@ -24,7 +24,7 @@ implementation("com.anthropic:anthropic-java:2.68.0") com.anthropic anthropic-java - 2.68.0 + 2.69.0 ``` diff --git a/REVIEW.md b/REVIEW.md new file mode 100644 index 000000000..d5fc88a83 --- /dev/null +++ b/REVIEW.md @@ -0,0 +1,24 @@ +# Review instructions + +## Report these as Important, as well as functional bugs + +- A violation of this repository's `CLAUDE.md`. Quote the rule +- A new public name, parameter or option that the PR description does not list +- A behavior change that still applies with the PR's feature switched off +- A new runtime check of an API response, or a client-side copy of validation + that the API does +- Code that validates, reorders, defaults or drops part of a request the caller + built +- Code that fails on an enum member, union variant or field this version does + not know +- A fix made to one copy of logic that exists more than once +- A behavior change with no test that fails before it and passes after +- A hand-written list of fields, variants or names that generated code also + carries, with no tripwire test +- A comment that restates the code, or that runs past three lines on a symbol + that is not public + +## Don't report these + +- A missing runtime check of an API response, or missing client-side validation +- What an application can do to its own process, credentials or telemetry diff --git a/anthropic-java-client-okhttp/src/main/resources/META-INF/proguard/anthropic-java-client-okhttp.pro b/anthropic-java-client-okhttp/src/main/resources/META-INF/proguard/anthropic-java-client-okhttp.pro new file mode 100644 index 000000000..6bc10f9a6 --- /dev/null +++ b/anthropic-java-client-okhttp/src/main/resources/META-INF/proguard/anthropic-java-client-okhttp.pro @@ -0,0 +1,3 @@ +# ProGuard narrows the return types of these methods but leaves the casts to their original return types in place, so +# the class fails verification on the first request. This only stops ProGuard from optimizing the methods. +-keepclassmembers,allowshrinking,allowobfuscation class okio.Okio__JvmOkioKt { *; } \ No newline at end of file diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientAsyncImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientAsyncImpl.kt index 088babca2..bec81f6f2 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientAsyncImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientAsyncImpl.kt @@ -25,7 +25,7 @@ class AnthropicClientAsyncImpl(private val clientOptions: ClientOptions) : Anthr else clientOptions .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .putHeader("User-Agent", "AnthropicClientAsyncImpl/Java ${getPackageVersion()}") .build() // Pass the original clientOptions so that this client sets its own User-Agent. diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientImpl.kt index 0c6a8c9fb..8971a85cb 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/client/AnthropicClientImpl.kt @@ -25,7 +25,7 @@ class AnthropicClientImpl(private val clientOptions: ClientOptions) : AnthropicC else clientOptions .toBuilder() - .putHeader("User-Agent", "${javaClass.simpleName}/Java ${getPackageVersion()}") + .putHeader("User-Agent", "AnthropicClientImpl/Java ${getPackageVersion()}") .build() // Pass the original clientOptions so that this client sets its own User-Agent. diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/config/ProfileConfig.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/config/ProfileConfig.kt index 51ae2a094..f2ae0c2c8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/config/ProfileConfig.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/config/ProfileConfig.kt @@ -1,5 +1,6 @@ package com.anthropic.config +import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.json.JsonMapper @@ -14,6 +15,7 @@ enum class AuthenticationType { @JsonIgnoreProperties(ignoreUnknown = true) class IdentityTokenConfig +@JsonCreator private constructor( @JsonProperty("source") private val source: String?, @JsonProperty("path") private val path: String?, @@ -52,6 +54,7 @@ private constructor( @JsonIgnoreProperties(ignoreUnknown = true) class AuthenticationConfig +@JsonCreator private constructor( @JsonProperty("type") private val type: AuthenticationType?, @JsonProperty("federation_rule_id") private val federationRuleId: String?, @@ -156,6 +159,7 @@ private constructor( @JsonIgnoreProperties(ignoreUnknown = true) class ProfileConfig +@JsonCreator private constructor( @JsonProperty("authentication") private val authentication: AuthenticationConfig?, @JsonProperty("base_url") private val baseUrl: String?, diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/Headers.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/Headers.kt index 7dc4e6ace..88709a3b0 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/Headers.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/Headers.kt @@ -43,7 +43,28 @@ private constructor( is JsonBoolean -> put(name, value.value.toString()) is JsonNumber -> put(name, value.value.toString()) is JsonString -> put(name, value.value) - is JsonArray -> value.values.forEach { put(name, it) } + is JsonArray -> + if (value.values.isNotEmpty()) + put( + name, + 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 headers" + ) + } + } + .joinToString(","), + ) is JsonObject -> value.values.forEach { (nestedName, value) -> put("$name.$nestedName", value) } } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/HttpRequest.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/HttpRequest.kt index 687008fdb..343247257 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/HttpRequest.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/core/http/HttpRequest.kt @@ -92,10 +92,12 @@ private constructor( /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) - fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } + fun addPathSegment(pathSegment: String) = apply { + pathSegments.add(checkPathSegment(pathSegment)) + } fun addPathSegments(vararg pathSegments: String) = apply { - this.pathSegments.addAll(pathSegments) + this.pathSegments.addAll(pathSegments.onEach { checkPathSegment(it) }) } fun replaceAllPathSegments(vararg pathSegments: String) = apply { @@ -195,3 +197,12 @@ private constructor( ) } } + +// Throws on a "." or ".." segment: HTTP clients collapse them ("/cards/.." becomes "/"), so the +// request would go to a different path. +private fun checkPathSegment(segment: String): String = + segment.also { + check(it != "." && it != "..") { + "Path segment \"$it\" is a dot-segment and can't be safely passed as a path parameter" + } + } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentArchiveParams.kt index ef73decc7..8e38996ac 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentArchiveParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } 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 0caafebbf..123147160 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 @@ -103,8 +103,7 @@ private constructor( fun metadata(): Optional = body.metadata() /** - * Multiagent orchestration configuration. Currently supports the `coordinator` topology with a - * roster of 1-20 agents. + * Multiagent orchestration configuration. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -128,7 +127,7 @@ private constructor( fun system(): Optional = body.system() /** - * Tool configurations available to the agent. Maximum of 128 tools across all toolsets allowed. + * Tool configurations available to the agent. Maximum of 256 tools across all toolsets allowed. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -389,10 +388,7 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } - /** - * Multiagent orchestration configuration. Currently supports the `coordinator` topology - * with a roster of 1-20 agents. - */ + /** Multiagent orchestration configuration. */ fun multiagent(multiagent: BetaManagedAgentsMultiagentParams?) = apply { body.multiagent(multiagent) } @@ -494,7 +490,7 @@ private constructor( fun system(system: JsonField) = apply { body.system(system) } /** - * Tool configurations available to the agent. Maximum of 128 tools across all toolsets + * Tool configurations available to the agent. Maximum of 256 tools across all toolsets * allowed. */ fun tools(tools: List) = apply { body.tools(tools) } @@ -686,7 +682,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } @@ -792,8 +797,7 @@ private constructor( fun metadata(): Optional = metadata.getOptional("metadata") /** - * Multiagent orchestration configuration. Currently supports the `coordinator` topology - * with a roster of 1-20 agents. + * Multiagent orchestration configuration. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -818,7 +822,7 @@ private constructor( fun system(): Optional = system.getOptional("system") /** - * Tool configurations available to the agent. Maximum of 128 tools across all toolsets + * Tool configurations available to the agent. Maximum of 256 tools across all toolsets * allowed. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if @@ -1059,10 +1063,7 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** - * Multiagent orchestration configuration. Currently supports the `coordinator` topology - * with a roster of 1-20 agents. - */ + /** Multiagent orchestration configuration. */ fun multiagent(multiagent: BetaManagedAgentsMultiagentParams?) = multiagent(JsonField.ofNullable(multiagent)) @@ -1187,7 +1188,7 @@ private constructor( fun system(system: JsonField) = apply { this.system = system } /** - * Tool configurations available to the agent. Maximum of 128 tools across all toolsets + * Tool configurations available to the agent. Maximum of 256 tools across all toolsets * allowed. */ fun tools(tools: List) = tools(JsonField.of(tools)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentListParams.kt index e62ae3ec6..4758b46ac 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentListParams.kt @@ -299,7 +299,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParams.kt index 2a8575ea0..75e14b16b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParams.kt @@ -252,7 +252,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } 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 cde9e5bb2..d69d6a6f1 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 @@ -135,7 +135,7 @@ private constructor( /** * Tool configurations available to the agent. Full replacement. Omit to preserve; send empty - * array or null to clear. Maximum of 128 tools across all toolsets allowed. + * array or null to clear. Maximum of 256 tools across all toolsets allowed. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -535,7 +535,7 @@ private constructor( /** * Tool configurations available to the agent. Full replacement. Omit to preserve; send - * empty array or null to clear. Maximum of 128 tools across all toolsets allowed. + * empty array or null to clear. Maximum of 256 tools across all toolsets allowed. */ fun tools(tools: List?) = apply { body.tools(tools) } @@ -744,7 +744,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } @@ -882,7 +891,7 @@ private constructor( /** * Tool configurations available to the agent. Full replacement. Omit to preserve; send - * empty array or null to clear. Maximum of 128 tools across all toolsets allowed. + * empty array or null to clear. Maximum of 256 tools across all toolsets allowed. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -1277,7 +1286,7 @@ private constructor( /** * Tool configurations available to the agent. Full replacement. Omit to preserve; send - * empty array or null to clear. Maximum of 128 tools across all toolsets allowed. + * empty array or null to clear. Maximum of 256 tools across all toolsets allowed. */ fun tools(tools: List?) = tools(JsonField.ofNullable(tools)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsModel.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsModel.kt index ac3eff51f..88e75967f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsModel.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsModel.kt @@ -25,6 +25,9 @@ class BetaManagedAgentsModel private constructor(private val value: JsonField CLAUDE_HAIKU_5_5 "claude-sonnet-5-5" -> CLAUDE_SONNET_5_5 "claude-opus-5-5" -> CLAUDE_OPUS_5_5 "claude-fable-5-1" -> CLAUDE_FABLE_5_1 @@ -120,6 +124,8 @@ class BetaManagedAgentsModel private constructor(private val value: JsonField Value.CLAUDE_HAIKU_5_5 CLAUDE_SONNET_5_5 -> Value.CLAUDE_SONNET_5_5 CLAUDE_OPUS_5_5 -> Value.CLAUDE_OPUS_5_5 CLAUDE_FABLE_5_1 -> Value.CLAUDE_FABLE_5_1 @@ -259,6 +268,7 @@ class BetaManagedAgentsModel private constructor(private val value: JsonField Known.CLAUDE_HAIKU_5_5 CLAUDE_SONNET_5_5 -> Known.CLAUDE_SONNET_5_5 CLAUDE_OPUS_5_5 -> Known.CLAUDE_OPUS_5_5 CLAUDE_FABLE_5_1 -> Known.CLAUDE_FABLE_5_1 diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfig.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfig.kt index cadb29d60..a33703fa1 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfig.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfig.kt @@ -36,6 +36,7 @@ private constructor( private val name: JsonValue, private val permissionPolicy: JsonField, private val type: JsonValue, + private val urlSources: JsonField, private val allowedDomains: JsonField>, private val blockedDomains: JsonField>, private val maxContentTokens: JsonField, @@ -50,6 +51,9 @@ private constructor( @ExcludeMissing permissionPolicy: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("url_sources") + @ExcludeMissing + urlSources: JsonField = JsonMissing.of(), @JsonProperty("allowed_domains") @ExcludeMissing allowedDomains: JsonField> = JsonMissing.of(), @@ -64,6 +68,7 @@ private constructor( name, permissionPolicy, type, + urlSources, allowedDomains, blockedDomains, maxContentTokens, @@ -106,6 +111,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + /** + * Which sources contribute URLs the tool may fetch, always in the object form. Null when not + * set, which allows every source. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun urlSources(): Optional = + urlSources.getOptional("url_sources") + /** * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -141,6 +156,15 @@ private constructor( @ExcludeMissing fun _permissionPolicy(): JsonField = permissionPolicy + /** + * Returns the raw JSON value of [urlSources]. + * + * Unlike [urlSources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url_sources") + @ExcludeMissing + fun _urlSources(): JsonField = urlSources + /** * Returns the raw JSON value of [allowedDomains]. * @@ -191,6 +215,7 @@ private constructor( * ```java * .enabled() * .permissionPolicy() + * .urlSources() * ``` */ @JvmStatic fun builder() = Builder() @@ -203,6 +228,7 @@ private constructor( private var name: JsonValue = JsonValue.from("web_fetch") private var permissionPolicy: JsonField? = null private var type: JsonValue = JsonValue.from("web_fetch") + private var urlSources: JsonField? = null private var allowedDomains: JsonField>? = null private var blockedDomains: JsonField>? = null private var maxContentTokens: JsonField = JsonMissing.of() @@ -216,6 +242,7 @@ private constructor( name = betaManagedAgentsWebFetchToolConfig.name permissionPolicy = betaManagedAgentsWebFetchToolConfig.permissionPolicy type = betaManagedAgentsWebFetchToolConfig.type + urlSources = betaManagedAgentsWebFetchToolConfig.urlSources allowedDomains = betaManagedAgentsWebFetchToolConfig.allowedDomains .map { it.toMutableList() } @@ -296,6 +323,28 @@ private constructor( */ fun type(type: JsonValue) = apply { this.type = type } + /** + * Which sources contribute URLs the tool may fetch, always in the object form. Null when + * not set, which allows every source. + */ + fun urlSources(urlSources: BetaManagedAgentsWebFetchUrlSources?) = + urlSources(JsonField.ofNullable(urlSources)) + + /** Alias for calling [Builder.urlSources] with `urlSources.orElse(null)`. */ + fun urlSources(urlSources: Optional) = + urlSources(urlSources.getOrNull()) + + /** + * Sets [Builder.urlSources] to an arbitrary JSON value. + * + * You should usually call [Builder.urlSources] with a well-typed + * [BetaManagedAgentsWebFetchUrlSources] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun urlSources(urlSources: JsonField) = apply { + this.urlSources = urlSources + } + fun allowedDomains(allowedDomains: List) = allowedDomains(JsonField.of(allowedDomains)) @@ -401,6 +450,7 @@ private constructor( * ```java * .enabled() * .permissionPolicy() + * .urlSources() * ``` * * @throws IllegalStateException if any required field is unset. @@ -411,6 +461,7 @@ private constructor( name, checkRequired("permissionPolicy", permissionPolicy), type, + checkRequired("urlSources", urlSources), (allowedDomains ?: JsonMissing.of()).map { it.toImmutable() }, (blockedDomains ?: JsonMissing.of()).map { it.toImmutable() }, maxContentTokens, @@ -445,6 +496,7 @@ private constructor( throw AnthropicInvalidDataException("'type' is invalid, received $it") } } + urlSources().ifPresent { it.validate() } allowedDomains() blockedDomains() maxContentTokens() @@ -470,6 +522,7 @@ private constructor( name.let { if (it == JsonValue.from("web_fetch")) 1 else 0 } + (permissionPolicy.asKnown().getOrNull()?.validity() ?: 0) + type.let { if (it == JsonValue.from("web_fetch")) 1 else 0 } + + (urlSources.asKnown().getOrNull()?.validity() ?: 0) + (allowedDomains.asKnown().getOrNull()?.size ?: 0) + (blockedDomains.asKnown().getOrNull()?.size ?: 0) + (if (maxContentTokens.asKnown().isPresent) 1 else 0) @@ -928,6 +981,7 @@ private constructor( name == other.name && permissionPolicy == other.permissionPolicy && type == other.type && + urlSources == other.urlSources && allowedDomains == other.allowedDomains && blockedDomains == other.blockedDomains && maxContentTokens == other.maxContentTokens && @@ -940,6 +994,7 @@ private constructor( name, permissionPolicy, type, + urlSources, allowedDomains, blockedDomains, maxContentTokens, @@ -950,5 +1005,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BetaManagedAgentsWebFetchToolConfig{enabled=$enabled, name=$name, permissionPolicy=$permissionPolicy, type=$type, allowedDomains=$allowedDomains, blockedDomains=$blockedDomains, maxContentTokens=$maxContentTokens, additionalProperties=$additionalProperties}" + "BetaManagedAgentsWebFetchToolConfig{enabled=$enabled, name=$name, permissionPolicy=$permissionPolicy, type=$type, urlSources=$urlSources, allowedDomains=$allowedDomains, blockedDomains=$blockedDomains, maxContentTokens=$maxContentTokens, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParams.kt index a7ec0eb79..ba88722db 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParams.kt @@ -38,6 +38,7 @@ private constructor( private val maxContentTokens: JsonField, private val permissionPolicy: JsonField, private val type: JsonField, + private val urlSources: JsonField, private val additionalProperties: MutableMap, ) { @@ -58,6 +59,9 @@ private constructor( @ExcludeMissing permissionPolicy: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("url_sources") + @ExcludeMissing + urlSources: JsonField = JsonMissing.of(), ) : this( name, allowedDomains, @@ -66,6 +70,7 @@ private constructor( maxContentTokens, permissionPolicy, type, + urlSources, mutableMapOf(), ) @@ -135,6 +140,15 @@ private constructor( */ fun type(): Optional = type.getOptional("type") + /** + * Which sources contribute URLs the tool may fetch. Omit to allow every source. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun urlSources(): Optional = + urlSources.getOptional("url_sources") + /** * Returns the raw JSON value of [allowedDomains]. * @@ -187,6 +201,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [urlSources]. + * + * Unlike [urlSources], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url_sources") + @ExcludeMissing + fun _urlSources(): JsonField = urlSources + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -218,6 +241,8 @@ private constructor( private var maxContentTokens: JsonField = JsonMissing.of() private var permissionPolicy: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() + private var urlSources: JsonField = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -237,6 +262,7 @@ private constructor( maxContentTokens = betaManagedAgentsWebFetchToolConfigParams.maxContentTokens permissionPolicy = betaManagedAgentsWebFetchToolConfigParams.permissionPolicy type = betaManagedAgentsWebFetchToolConfigParams.type + urlSources = betaManagedAgentsWebFetchToolConfigParams.urlSources additionalProperties = betaManagedAgentsWebFetchToolConfigParams.additionalProperties.toMutableMap() } @@ -417,6 +443,25 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** Which sources contribute URLs the tool may fetch. Omit to allow every source. */ + fun urlSources(urlSources: BetaManagedAgentsWebFetchUrlSourcesParams?) = + urlSources(JsonField.ofNullable(urlSources)) + + /** Alias for calling [Builder.urlSources] with `urlSources.orElse(null)`. */ + fun urlSources(urlSources: Optional) = + urlSources(urlSources.getOrNull()) + + /** + * Sets [Builder.urlSources] to an arbitrary JSON value. + * + * You should usually call [Builder.urlSources] with a well-typed + * [BetaManagedAgentsWebFetchUrlSourcesParams] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun urlSources(urlSources: JsonField) = apply { + this.urlSources = urlSources + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -450,6 +495,7 @@ private constructor( maxContentTokens, permissionPolicy, type, + urlSources, additionalProperties.toMutableMap(), ) } @@ -480,6 +526,7 @@ private constructor( maxContentTokens() permissionPolicy().ifPresent { it.validate() } type().ifPresent { it.validate() } + urlSources().ifPresent { it.validate() } validated = true } @@ -504,7 +551,8 @@ private constructor( (if (enabled.asKnown().isPresent) 1 else 0) + (if (maxContentTokens.asKnown().isPresent) 1 else 0) + (permissionPolicy.asKnown().getOrNull()?.validity() ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (urlSources.asKnown().getOrNull()?.validity() ?: 0) /** * Permission policy for this tool. Controls whether tool calls are auto-approved or require @@ -1107,6 +1155,7 @@ private constructor( maxContentTokens == other.maxContentTokens && permissionPolicy == other.permissionPolicy && type == other.type && + urlSources == other.urlSources && additionalProperties == other.additionalProperties } @@ -1119,6 +1168,7 @@ private constructor( maxContentTokens, permissionPolicy, type, + urlSources, additionalProperties, ) } @@ -1126,5 +1176,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BetaManagedAgentsWebFetchToolConfigParams{name=$name, allowedDomains=$allowedDomains, blockedDomains=$blockedDomains, enabled=$enabled, maxContentTokens=$maxContentTokens, permissionPolicy=$permissionPolicy, type=$type, additionalProperties=$additionalProperties}" + "BetaManagedAgentsWebFetchToolConfigParams{name=$name, allowedDomains=$allowedDomains, blockedDomains=$blockedDomains, enabled=$enabled, maxContentTokens=$maxContentTokens, permissionPolicy=$permissionPolicy, type=$type, urlSources=$urlSources, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceAll.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceAll.kt new file mode 100644 index 000000000..4885ae006 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceAll.kt @@ -0,0 +1,171 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 + +/** Every URL from this source may be fetched. This is the default. */ +class BetaManagedAgentsWebFetchUrlSourceAll +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("all") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = 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 + * [BetaManagedAgentsWebFetchUrlSourceAll]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsWebFetchUrlSourceAll]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("all") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWebFetchUrlSourceAll: BetaManagedAgentsWebFetchUrlSourceAll + ) = apply { + type = betaManagedAgentsWebFetchUrlSourceAll.type + additionalProperties = + betaManagedAgentsWebFetchUrlSourceAll.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("all") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BetaManagedAgentsWebFetchUrlSourceAll]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaManagedAgentsWebFetchUrlSourceAll = + BetaManagedAgentsWebFetchUrlSourceAll(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(): BetaManagedAgentsWebFetchUrlSourceAll = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("all")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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.let { if (it == JsonValue.from("all")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceAll && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWebFetchUrlSourceAll{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceExcept.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceExcept.kt new file mode 100644 index 000000000..57f1022a7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceExcept.kt @@ -0,0 +1,261 @@ +package com.anthropic.models.beta.agents + +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 + +/** Every tool's results contribute URLs that may be fetched, except the named tools' results. */ +class BetaManagedAgentsWebFetchUrlSourceExcept +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tools: JsonField>, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tools") + @ExcludeMissing + tools: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(tools, type, mutableMapOf()) + + /** + * The tools whose results do not contribute. Between 1 and 128 entries, each with a different + * name. An empty list is rejected; use "all" to leave out no tool's results. + * + * @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 tools(): List = tools.getRequired("tools") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("except") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tools") + @ExcludeMissing + fun _tools(): JsonField> = tools + + @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 + * [BetaManagedAgentsWebFetchUrlSourceExcept]. + * + * The following fields are required: + * ```java + * .tools() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaManagedAgentsWebFetchUrlSourceExcept] with the + * required [tools] set to the given value. + */ + @JvmStatic + fun of(tools: List) = + builder().tools(tools).build() + } + + /** A builder for [BetaManagedAgentsWebFetchUrlSourceExcept]. */ + class Builder internal constructor() { + + private var tools: + JsonField>? = + null + private var type: JsonValue = JsonValue.from("except") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWebFetchUrlSourceExcept: BetaManagedAgentsWebFetchUrlSourceExcept + ) = apply { + tools = + betaManagedAgentsWebFetchUrlSourceExcept.tools + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsWebFetchUrlSourceExcept.type + additionalProperties = + betaManagedAgentsWebFetchUrlSourceExcept.additionalProperties.toMutableMap() + } + + /** + * The tools whose results do not contribute. Between 1 and 128 entries, each with a + * different name. An empty list is rejected; use "all" to leave out no tool's results. + */ + fun tools(tools: List) = + tools(JsonField.of(tools)) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun tools(tools: JsonField>) = apply { + this.tools = tools.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsWebFetchUrlSourceToolReference] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: BetaManagedAgentsWebFetchUrlSourceToolReference) = apply { + tools = + (tools ?: JsonField.of(mutableListOf())).also { checkKnown("tools", it).add(tool) } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("except") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BetaManagedAgentsWebFetchUrlSourceExcept]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tools() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsWebFetchUrlSourceExcept = + BetaManagedAgentsWebFetchUrlSourceExcept( + checkRequired("tools", tools).map { it.toImmutable() }, + 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(): BetaManagedAgentsWebFetchUrlSourceExcept = apply { + if (validated) { + return@apply + } + + tools().forEach { it.validate() } + _type().let { + if (it != JsonValue.from("except")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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 = + (tools.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + type.let { if (it == JsonValue.from("except")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceExcept && + tools == other.tools && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tools, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWebFetchUrlSourceExcept{tools=$tools, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceNone.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceNone.kt new file mode 100644 index 000000000..ea85956f2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceNone.kt @@ -0,0 +1,171 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 + +/** This source contributes no URLs that may be fetched. */ +class BetaManagedAgentsWebFetchUrlSourceNone +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of() + ) : this(type, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("none") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = 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 + * [BetaManagedAgentsWebFetchUrlSourceNone]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsWebFetchUrlSourceNone]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("none") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWebFetchUrlSourceNone: BetaManagedAgentsWebFetchUrlSourceNone + ) = apply { + type = betaManagedAgentsWebFetchUrlSourceNone.type + additionalProperties = + betaManagedAgentsWebFetchUrlSourceNone.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("none") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BetaManagedAgentsWebFetchUrlSourceNone]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaManagedAgentsWebFetchUrlSourceNone = + BetaManagedAgentsWebFetchUrlSourceNone(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(): BetaManagedAgentsWebFetchUrlSourceNone = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("none")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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.let { if (it == JsonValue.from("none")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceNone && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWebFetchUrlSourceNone{type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceOnly.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceOnly.kt new file mode 100644 index 000000000..a126feffa --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceOnly.kt @@ -0,0 +1,261 @@ +package com.anthropic.models.beta.agents + +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 + +/** Only the named tools' results contribute URLs that may be fetched. */ +class BetaManagedAgentsWebFetchUrlSourceOnly +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tools: JsonField>, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tools") + @ExcludeMissing + tools: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(tools, type, mutableMapOf()) + + /** + * The tools whose results contribute. Between 1 and 128 entries, each with a different name. An + * empty list is rejected; use "none" to allow no tool's results. + * + * @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 tools(): List = tools.getRequired("tools") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("only") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [tools]. + * + * Unlike [tools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tools") + @ExcludeMissing + fun _tools(): JsonField> = tools + + @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 + * [BetaManagedAgentsWebFetchUrlSourceOnly]. + * + * The following fields are required: + * ```java + * .tools() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaManagedAgentsWebFetchUrlSourceOnly] with the + * required [tools] set to the given value. + */ + @JvmStatic + fun of(tools: List) = + builder().tools(tools).build() + } + + /** A builder for [BetaManagedAgentsWebFetchUrlSourceOnly]. */ + class Builder internal constructor() { + + private var tools: + JsonField>? = + null + private var type: JsonValue = JsonValue.from("only") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWebFetchUrlSourceOnly: BetaManagedAgentsWebFetchUrlSourceOnly + ) = apply { + tools = + betaManagedAgentsWebFetchUrlSourceOnly.tools + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + type = betaManagedAgentsWebFetchUrlSourceOnly.type + additionalProperties = + betaManagedAgentsWebFetchUrlSourceOnly.additionalProperties.toMutableMap() + } + + /** + * The tools whose results contribute. Between 1 and 128 entries, each with a different + * name. An empty list is rejected; use "none" to allow no tool's results. + */ + fun tools(tools: List) = + tools(JsonField.of(tools)) + + /** + * Sets [Builder.tools] to an arbitrary JSON value. + * + * You should usually call [Builder.tools] with a well-typed + * `List` value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun tools(tools: JsonField>) = apply { + this.tools = tools.map { it.toMutableList() } + } + + /** + * Adds a single [BetaManagedAgentsWebFetchUrlSourceToolReference] to [tools]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTool(tool: BetaManagedAgentsWebFetchUrlSourceToolReference) = apply { + tools = + (tools ?: JsonField.of(mutableListOf())).also { checkKnown("tools", it).add(tool) } + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("only") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BetaManagedAgentsWebFetchUrlSourceOnly]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tools() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsWebFetchUrlSourceOnly = + BetaManagedAgentsWebFetchUrlSourceOnly( + checkRequired("tools", tools).map { it.toImmutable() }, + 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(): BetaManagedAgentsWebFetchUrlSourceOnly = apply { + if (validated) { + return@apply + } + + tools().forEach { it.validate() } + _type().let { + if (it != JsonValue.from("only")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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 = + (tools.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + type.let { if (it == JsonValue.from("only")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceOnly && + tools == other.tools && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tools, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWebFetchUrlSourceOnly{tools=$tools, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceShorthand.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceShorthand.kt new file mode 100644 index 000000000..80c4118ac --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceShorthand.kt @@ -0,0 +1,163 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +/** + * String form of a url_sources value that has no field other than its type: "all" means {"type": + * "all"} and "none" means {"type": "none"}. + */ +class BetaManagedAgentsWebFetchUrlSourceShorthand +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 ALL = BetaManagedAgentsWebFetchUrlSourceShorthand(JsonField.of("all")) + + @JvmField val NONE = BetaManagedAgentsWebFetchUrlSourceShorthand(JsonField.of("none")) + + @JvmStatic + fun of(value: String): BetaManagedAgentsWebFetchUrlSourceShorthand = + // Intern known values so `==` works + when (value) { + "all" -> ALL + "none" -> NONE + else -> BetaManagedAgentsWebFetchUrlSourceShorthand(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): BetaManagedAgentsWebFetchUrlSourceShorthand = + value.asString().getOrNull()?.let { of(it) } + ?: BetaManagedAgentsWebFetchUrlSourceShorthand(value) + } + + /** An enum containing [BetaManagedAgentsWebFetchUrlSourceShorthand]'s known values. */ + enum class Known { + ALL, + NONE, + } + + /** + * An enum containing [BetaManagedAgentsWebFetchUrlSourceShorthand]'s known values, as well as + * an [_UNKNOWN] member. + * + * An instance of [BetaManagedAgentsWebFetchUrlSourceShorthand] 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 { + ALL, + NONE, + /** + * An enum member indicating that [BetaManagedAgentsWebFetchUrlSourceShorthand] 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) { + ALL -> Value.ALL + NONE -> Value.NONE + 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) { + ALL -> Known.ALL + NONE -> Known.NONE + else -> + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsWebFetchUrlSourceShorthand: $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(): BetaManagedAgentsWebFetchUrlSourceShorthand = 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 BetaManagedAgentsWebFetchUrlSourceShorthand && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilter.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilter.kt new file mode 100644 index 000000000..13d469af1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilter.kt @@ -0,0 +1,529 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.core.getProperty +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +/** Which tools' results contribute URLs that may be fetched. */ +@JsonDeserialize(using = BetaManagedAgentsWebFetchUrlSourceToolFilter.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsWebFetchUrlSourceToolFilter.Serializer::class) +class BetaManagedAgentsWebFetchUrlSourceToolFilter +private constructor( + private val all: BetaManagedAgentsWebFetchUrlSourceAll? = null, + private val none: BetaManagedAgentsWebFetchUrlSourceNone? = null, + private val only: BetaManagedAgentsWebFetchUrlSourceOnly? = null, + private val except: BetaManagedAgentsWebFetchUrlSourceExcept? = null, + private val _json: JsonValue? = null, +) { + + fun type(): Type = + when { + all != null -> Type.ALL + none != null -> Type.NONE + only != null -> Type.ONLY + except != null -> Type.EXCEPT + else -> Type.of(_json?.asObject()?.getOrNull()?.get("type") ?: JsonMissing.of()) + } + + fun tools(): Optional> = + when { + all != null -> Optional.empty() + none != null -> Optional.empty() + only != null -> Optional.of(only.tools()) + except != null -> Optional.of(except.tools()) + else -> + _json + .getProperty>("tools") + .asKnown() + } + + /** Every URL from this source may be fetched. This is the default. */ + fun all(): Optional = Optional.ofNullable(all) + + /** This source contributes no URLs that may be fetched. */ + fun none(): Optional = Optional.ofNullable(none) + + /** Only the named tools' results contribute URLs that may be fetched. */ + fun only(): Optional = Optional.ofNullable(only) + + /** + * Every tool's results contribute URLs that may be fetched, except the named tools' results. + */ + fun except(): Optional = Optional.ofNullable(except) + + fun isAll(): Boolean = all != null + + fun isNone(): Boolean = none != null + + fun isOnly(): Boolean = only != null + + fun isExcept(): Boolean = except != null + + /** Every URL from this source may be fetched. This is the default. */ + fun asAll(): BetaManagedAgentsWebFetchUrlSourceAll = all.getOrThrow("all") + + /** This source contributes no URLs that may be fetched. */ + fun asNone(): BetaManagedAgentsWebFetchUrlSourceNone = none.getOrThrow("none") + + /** Only the named tools' results contribute URLs that may be fetched. */ + fun asOnly(): BetaManagedAgentsWebFetchUrlSourceOnly = only.getOrThrow("only") + + /** + * Every tool's results contribute URLs that may be fetched, except the named tools' results. + */ + fun asExcept(): BetaManagedAgentsWebFetchUrlSourceExcept = except.getOrThrow("except") + + 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 = betaManagedAgentsWebFetchUrlSourceToolFilter.accept(new BetaManagedAgentsWebFetchUrlSourceToolFilter.Visitor>() { + * @Override + * public Optional visitAll(BetaManagedAgentsWebFetchUrlSourceAll all) { + * return Optional.of(all.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 { + all != null -> visitor.visitAll(all) + none != null -> visitor.visitNone(none) + only != null -> visitor.visitOnly(only) + except != null -> visitor.visitExcept(except) + 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(): BetaManagedAgentsWebFetchUrlSourceToolFilter = apply { + if (validated) { + return@apply + } + + when { + all != null -> all.validate() + none != null -> none.validate() + only != null -> only.validate() + except != null -> except.validate() + else -> + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsWebFetchUrlSourceToolFilter: $_json" + ) + } + 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 = + when { + all != null -> all.validity() + none != null -> none.validity() + only != null -> only.validity() + except != null -> except.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceToolFilter && + all == other.all && + none == other.none && + only == other.only && + except == other.except + } + + override fun hashCode(): Int = Objects.hash(all, none, only, except) + + override fun toString(): String = + when { + all != null -> "BetaManagedAgentsWebFetchUrlSourceToolFilter{all=$all}" + none != null -> "BetaManagedAgentsWebFetchUrlSourceToolFilter{none=$none}" + only != null -> "BetaManagedAgentsWebFetchUrlSourceToolFilter{only=$only}" + except != null -> "BetaManagedAgentsWebFetchUrlSourceToolFilter{except=$except}" + _json != null -> "BetaManagedAgentsWebFetchUrlSourceToolFilter{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid BetaManagedAgentsWebFetchUrlSourceToolFilter") + } + + companion object { + + /** Every URL from this source may be fetched. This is the default. */ + @JvmStatic + fun ofAll(all: BetaManagedAgentsWebFetchUrlSourceAll) = + BetaManagedAgentsWebFetchUrlSourceToolFilter(all = all) + + /** This source contributes no URLs that may be fetched. */ + @JvmStatic + fun ofNone(none: BetaManagedAgentsWebFetchUrlSourceNone) = + BetaManagedAgentsWebFetchUrlSourceToolFilter(none = none) + + /** Only the named tools' results contribute URLs that may be fetched. */ + @JvmStatic + fun ofOnly(only: BetaManagedAgentsWebFetchUrlSourceOnly) = + BetaManagedAgentsWebFetchUrlSourceToolFilter(only = only) + + /** + * Returns an immutable instance of [BetaManagedAgentsWebFetchUrlSourceToolFilter] whose + * [ofOnly] variant is built from the given required [tools]. + */ + @JvmStatic + fun ofOnly(tools: List) = + ofOnly(BetaManagedAgentsWebFetchUrlSourceOnly.of(tools)) + + /** + * Every tool's results contribute URLs that may be fetched, except the named tools' + * results. + */ + @JvmStatic + fun ofExcept(except: BetaManagedAgentsWebFetchUrlSourceExcept) = + BetaManagedAgentsWebFetchUrlSourceToolFilter(except = except) + + /** + * Returns an immutable instance of [BetaManagedAgentsWebFetchUrlSourceToolFilter] whose + * [ofExcept] variant is built from the given required [tools]. + */ + @JvmStatic + fun ofExcept(tools: List) = + ofExcept(BetaManagedAgentsWebFetchUrlSourceExcept.of(tools)) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsWebFetchUrlSourceToolFilter] to a value of type [T]. + */ + interface Visitor { + + /** Every URL from this source may be fetched. This is the default. */ + fun visitAll(all: BetaManagedAgentsWebFetchUrlSourceAll): T + + /** This source contributes no URLs that may be fetched. */ + fun visitNone(none: BetaManagedAgentsWebFetchUrlSourceNone): T + + /** Only the named tools' results contribute URLs that may be fetched. */ + fun visitOnly(only: BetaManagedAgentsWebFetchUrlSourceOnly): T + + /** + * Every tool's results contribute URLs that may be fetched, except the named tools' + * results. + */ + fun visitExcept(except: BetaManagedAgentsWebFetchUrlSourceExcept): T + + /** + * Maps an unknown variant of [BetaManagedAgentsWebFetchUrlSourceToolFilter] to a value of + * type [T]. + * + * An instance of [BetaManagedAgentsWebFetchUrlSourceToolFilter] 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 BetaManagedAgentsWebFetchUrlSourceToolFilter: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsWebFetchUrlSourceToolFilter::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsWebFetchUrlSourceToolFilter { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "all" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceToolFilter(all = it, _json = json) + } ?: BetaManagedAgentsWebFetchUrlSourceToolFilter(_json = json) + } + "none" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceToolFilter(none = it, _json = json) + } ?: BetaManagedAgentsWebFetchUrlSourceToolFilter(_json = json) + } + "only" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceToolFilter(only = it, _json = json) + } ?: BetaManagedAgentsWebFetchUrlSourceToolFilter(_json = json) + } + "except" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceToolFilter(except = it, _json = json) + } ?: BetaManagedAgentsWebFetchUrlSourceToolFilter(_json = json) + } + } + + return BetaManagedAgentsWebFetchUrlSourceToolFilter(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsWebFetchUrlSourceToolFilter::class + ) { + + override fun serialize( + value: BetaManagedAgentsWebFetchUrlSourceToolFilter, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.all != null -> generator.writeObject(value.all) + value.none != null -> generator.writeObject(value.none) + value.only != null -> generator.writeObject(value.only) + value.except != null -> generator.writeObject(value.except) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsWebFetchUrlSourceToolFilter" + ) + } + } + } + + class Type 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 ALL = Type(JsonField.of("all")) + + @JvmField val NONE = Type(JsonField.of("none")) + + @JvmField val ONLY = Type(JsonField.of("only")) + + @JvmField val EXCEPT = Type(JsonField.of("except")) + + @JvmStatic + fun of(value: String): Type = + // Intern known values so `==` works + when (value) { + "all" -> ALL + "none" -> NONE + "only" -> ONLY + "except" -> EXCEPT + else -> Type(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Type = + value.asString().getOrNull()?.let { of(it) } ?: Type(value) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ALL, + NONE, + ONLY, + EXCEPT, + } + + /** + * 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 { + ALL, + NONE, + ONLY, + EXCEPT, + /** 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) { + ALL -> Value.ALL + NONE -> Value.NONE + ONLY -> Value.ONLY + EXCEPT -> Value.EXCEPT + 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) { + ALL -> Known.ALL + NONE -> Known.NONE + ONLY -> Known.ONLY + EXCEPT -> Known.EXCEPT + 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() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterParams.kt new file mode 100644 index 000000000..6fa59879c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterParams.kt @@ -0,0 +1,310 @@ +package com.anthropic.models.beta.agents + +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.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 + +/** + * Which tools' results contribute URLs that may be fetched. Accepts the string "all" or "none", or + * an object whose type is "all", "none", "only" or "except". Responses use the object form. + */ +@JsonDeserialize(using = BetaManagedAgentsWebFetchUrlSourceToolFilterParams.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsWebFetchUrlSourceToolFilterParams.Serializer::class) +class BetaManagedAgentsWebFetchUrlSourceToolFilterParams +private constructor( + private val shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand? = null, + private val betaManagedAgentsWebFetchUrlSourceToolFilter: + BetaManagedAgentsWebFetchUrlSourceToolFilter? = + null, + private val _json: JsonValue? = null, +) { + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + fun shorthand(): Optional = + Optional.ofNullable(shorthand) + + /** Which tools' results contribute URLs that may be fetched. */ + fun betaManagedAgentsWebFetchUrlSourceToolFilter(): + Optional = + Optional.ofNullable(betaManagedAgentsWebFetchUrlSourceToolFilter) + + fun isShorthand(): Boolean = shorthand != null + + fun isBetaManagedAgentsWebFetchUrlSourceToolFilter(): Boolean = + betaManagedAgentsWebFetchUrlSourceToolFilter != null + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + fun asShorthand(): BetaManagedAgentsWebFetchUrlSourceShorthand = + shorthand.getOrThrow("shorthand") + + /** Which tools' results contribute URLs that may be fetched. */ + fun asBetaManagedAgentsWebFetchUrlSourceToolFilter(): + BetaManagedAgentsWebFetchUrlSourceToolFilter = + betaManagedAgentsWebFetchUrlSourceToolFilter.getOrThrow( + "betaManagedAgentsWebFetchUrlSourceToolFilter" + ) + + 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 = betaManagedAgentsWebFetchUrlSourceToolFilterParams.accept(new BetaManagedAgentsWebFetchUrlSourceToolFilterParams.Visitor>() { + * @Override + * public Optional visitShorthand(BetaManagedAgentsWebFetchUrlSourceShorthand shorthand) { + * return Optional.of(shorthand.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 { + shorthand != null -> visitor.visitShorthand(shorthand) + betaManagedAgentsWebFetchUrlSourceToolFilter != null -> + visitor.visitBetaManagedAgentsWebFetchUrlSourceToolFilter( + betaManagedAgentsWebFetchUrlSourceToolFilter + ) + 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(): BetaManagedAgentsWebFetchUrlSourceToolFilterParams = apply { + if (validated) { + return@apply + } + + when { + shorthand != null -> shorthand.validate() + betaManagedAgentsWebFetchUrlSourceToolFilter != null -> + betaManagedAgentsWebFetchUrlSourceToolFilter.validate() + else -> + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsWebFetchUrlSourceToolFilterParams: $_json" + ) + } + 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 = + when { + shorthand != null -> shorthand.validity() + betaManagedAgentsWebFetchUrlSourceToolFilter != null -> + betaManagedAgentsWebFetchUrlSourceToolFilter.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceToolFilterParams && + shorthand == other.shorthand && + betaManagedAgentsWebFetchUrlSourceToolFilter == + other.betaManagedAgentsWebFetchUrlSourceToolFilter + } + + override fun hashCode(): Int = + Objects.hash(shorthand, betaManagedAgentsWebFetchUrlSourceToolFilter) + + override fun toString(): String = + when { + shorthand != null -> + "BetaManagedAgentsWebFetchUrlSourceToolFilterParams{shorthand=$shorthand}" + betaManagedAgentsWebFetchUrlSourceToolFilter != null -> + "BetaManagedAgentsWebFetchUrlSourceToolFilterParams{betaManagedAgentsWebFetchUrlSourceToolFilter=$betaManagedAgentsWebFetchUrlSourceToolFilter}" + _json != null -> "BetaManagedAgentsWebFetchUrlSourceToolFilterParams{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsWebFetchUrlSourceToolFilterParams" + ) + } + + companion object { + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + @JvmStatic + fun ofShorthand(shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand) = + BetaManagedAgentsWebFetchUrlSourceToolFilterParams(shorthand = shorthand) + + /** Which tools' results contribute URLs that may be fetched. */ + @JvmStatic + fun ofBetaManagedAgentsWebFetchUrlSourceToolFilter( + betaManagedAgentsWebFetchUrlSourceToolFilter: + BetaManagedAgentsWebFetchUrlSourceToolFilter + ) = + BetaManagedAgentsWebFetchUrlSourceToolFilterParams( + betaManagedAgentsWebFetchUrlSourceToolFilter = + betaManagedAgentsWebFetchUrlSourceToolFilter + ) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsWebFetchUrlSourceToolFilterParams] to a value of type [T]. + */ + interface Visitor { + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + fun visitShorthand(shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand): T + + /** Which tools' results contribute URLs that may be fetched. */ + fun visitBetaManagedAgentsWebFetchUrlSourceToolFilter( + betaManagedAgentsWebFetchUrlSourceToolFilter: + BetaManagedAgentsWebFetchUrlSourceToolFilter + ): T + + /** + * Maps an unknown variant of [BetaManagedAgentsWebFetchUrlSourceToolFilterParams] to a + * value of type [T]. + * + * An instance of [BetaManagedAgentsWebFetchUrlSourceToolFilterParams] 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 BetaManagedAgentsWebFetchUrlSourceToolFilterParams: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsWebFetchUrlSourceToolFilterParams { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceToolFilterParams( + shorthand = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceToolFilterParams( + betaManagedAgentsWebFetchUrlSourceToolFilter = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> BetaManagedAgentsWebFetchUrlSourceToolFilterParams(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams::class + ) { + + override fun serialize( + value: BetaManagedAgentsWebFetchUrlSourceToolFilterParams, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.shorthand != null -> generator.writeObject(value.shorthand) + value.betaManagedAgentsWebFetchUrlSourceToolFilter != null -> + generator.writeObject(value.betaManagedAgentsWebFetchUrlSourceToolFilter) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsWebFetchUrlSourceToolFilterParams" + ) + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolReference.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolReference.kt new file mode 100644 index 000000000..479f88cca --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolReference.kt @@ -0,0 +1,232 @@ +package com.anthropic.models.beta.agents + +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 + +/** Names one tool in an only or except list. */ +class BetaManagedAgentsWebFetchUrlSourceToolReference +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val name: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(name, type, mutableMapOf()) + + /** + * Name of the tool. Compared exactly, so upper and lower case letters are different. + * + * @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 name(): String = name.getRequired("name") + + /** + * Must be "tool_reference". + * + * Expected to always return the following: + * ```java + * JsonValue.from("tool_reference") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @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 + * [BetaManagedAgentsWebFetchUrlSourceToolReference]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaManagedAgentsWebFetchUrlSourceToolReference] with + * the required [name] set to the given value. + */ + @JvmStatic fun of(name: String) = builder().name(name).build() + } + + /** A builder for [BetaManagedAgentsWebFetchUrlSourceToolReference]. */ + class Builder internal constructor() { + + private var name: JsonField? = null + private var type: JsonValue = JsonValue.from("tool_reference") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWebFetchUrlSourceToolReference: + BetaManagedAgentsWebFetchUrlSourceToolReference + ) = apply { + name = betaManagedAgentsWebFetchUrlSourceToolReference.name + type = betaManagedAgentsWebFetchUrlSourceToolReference.type + additionalProperties = + betaManagedAgentsWebFetchUrlSourceToolReference.additionalProperties.toMutableMap() + } + + /** Name of the tool. Compared exactly, so upper and lower case letters are different. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_reference") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BetaManagedAgentsWebFetchUrlSourceToolReference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsWebFetchUrlSourceToolReference = + BetaManagedAgentsWebFetchUrlSourceToolReference( + checkRequired("name", name), + 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(): BetaManagedAgentsWebFetchUrlSourceToolReference = apply { + if (validated) { + return@apply + } + + name() + _type().let { + if (it != JsonValue.from("tool_reference")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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 (name.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("tool_reference")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceToolReference && + name == other.name && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWebFetchUrlSourceToolReference{name=$name, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInput.kt new file mode 100644 index 000000000..545d111c1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInput.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +/** Whether URLs in the text of user messages may be fetched. */ +@JsonDeserialize(using = BetaManagedAgentsWebFetchUrlSourceUserInput.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsWebFetchUrlSourceUserInput.Serializer::class) +class BetaManagedAgentsWebFetchUrlSourceUserInput +private constructor( + private val all: BetaManagedAgentsWebFetchUrlSourceAll? = null, + private val none: BetaManagedAgentsWebFetchUrlSourceNone? = null, + private val _json: JsonValue? = null, +) { + + fun type(): Type = + when { + all != null -> Type.ALL + none != null -> Type.NONE + else -> Type.of(_json?.asObject()?.getOrNull()?.get("type") ?: JsonMissing.of()) + } + + /** Every URL from this source may be fetched. This is the default. */ + fun all(): Optional = Optional.ofNullable(all) + + /** This source contributes no URLs that may be fetched. */ + fun none(): Optional = Optional.ofNullable(none) + + fun isAll(): Boolean = all != null + + fun isNone(): Boolean = none != null + + /** Every URL from this source may be fetched. This is the default. */ + fun asAll(): BetaManagedAgentsWebFetchUrlSourceAll = all.getOrThrow("all") + + /** This source contributes no URLs that may be fetched. */ + fun asNone(): BetaManagedAgentsWebFetchUrlSourceNone = none.getOrThrow("none") + + 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 = betaManagedAgentsWebFetchUrlSourceUserInput.accept(new BetaManagedAgentsWebFetchUrlSourceUserInput.Visitor>() { + * @Override + * public Optional visitAll(BetaManagedAgentsWebFetchUrlSourceAll all) { + * return Optional.of(all.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 { + all != null -> visitor.visitAll(all) + none != null -> visitor.visitNone(none) + 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(): BetaManagedAgentsWebFetchUrlSourceUserInput = apply { + if (validated) { + return@apply + } + + when { + all != null -> all.validate() + none != null -> none.validate() + else -> + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsWebFetchUrlSourceUserInput: $_json" + ) + } + 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 = + when { + all != null -> all.validity() + none != null -> none.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceUserInput && + all == other.all && + none == other.none + } + + override fun hashCode(): Int = Objects.hash(all, none) + + override fun toString(): String = + when { + all != null -> "BetaManagedAgentsWebFetchUrlSourceUserInput{all=$all}" + none != null -> "BetaManagedAgentsWebFetchUrlSourceUserInput{none=$none}" + _json != null -> "BetaManagedAgentsWebFetchUrlSourceUserInput{_unknown=$_json}" + else -> + throw IllegalStateException("Invalid BetaManagedAgentsWebFetchUrlSourceUserInput") + } + + companion object { + + /** Every URL from this source may be fetched. This is the default. */ + @JvmStatic + fun ofAll(all: BetaManagedAgentsWebFetchUrlSourceAll) = + BetaManagedAgentsWebFetchUrlSourceUserInput(all = all) + + /** This source contributes no URLs that may be fetched. */ + @JvmStatic + fun ofNone(none: BetaManagedAgentsWebFetchUrlSourceNone) = + BetaManagedAgentsWebFetchUrlSourceUserInput(none = none) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsWebFetchUrlSourceUserInput] to a value of type [T]. + */ + interface Visitor { + + /** Every URL from this source may be fetched. This is the default. */ + fun visitAll(all: BetaManagedAgentsWebFetchUrlSourceAll): T + + /** This source contributes no URLs that may be fetched. */ + fun visitNone(none: BetaManagedAgentsWebFetchUrlSourceNone): T + + /** + * Maps an unknown variant of [BetaManagedAgentsWebFetchUrlSourceUserInput] to a value of + * type [T]. + * + * An instance of [BetaManagedAgentsWebFetchUrlSourceUserInput] 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 BetaManagedAgentsWebFetchUrlSourceUserInput: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsWebFetchUrlSourceUserInput::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsWebFetchUrlSourceUserInput { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "all" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceUserInput(all = it, _json = json) + } ?: BetaManagedAgentsWebFetchUrlSourceUserInput(_json = json) + } + "none" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceUserInput(none = it, _json = json) + } ?: BetaManagedAgentsWebFetchUrlSourceUserInput(_json = json) + } + } + + return BetaManagedAgentsWebFetchUrlSourceUserInput(_json = json) + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsWebFetchUrlSourceUserInput::class + ) { + + override fun serialize( + value: BetaManagedAgentsWebFetchUrlSourceUserInput, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.all != null -> generator.writeObject(value.all) + value.none != null -> generator.writeObject(value.none) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsWebFetchUrlSourceUserInput" + ) + } + } + } + + class Type 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 ALL = Type(JsonField.of("all")) + + @JvmField val NONE = Type(JsonField.of("none")) + + @JvmStatic + fun of(value: String): Type = + // Intern known values so `==` works + when (value) { + "all" -> ALL + "none" -> NONE + else -> Type(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Type = + value.asString().getOrNull()?.let { of(it) } ?: Type(value) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ALL, + NONE, + } + + /** + * 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 { + ALL, + NONE, + /** 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) { + ALL -> Value.ALL + NONE -> Value.NONE + 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) { + ALL -> Known.ALL + NONE -> Known.NONE + 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() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputParams.kt new file mode 100644 index 000000000..2799f1b93 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputParams.kt @@ -0,0 +1,308 @@ +package com.anthropic.models.beta.agents + +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.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 + +/** + * Whether URLs in the text of user messages may be fetched. Accepts the string "all" or "none", or + * the object {"type": "all"} or {"type": "none"}. Responses use the object form. + */ +@JsonDeserialize(using = BetaManagedAgentsWebFetchUrlSourceUserInputParams.Deserializer::class) +@JsonSerialize(using = BetaManagedAgentsWebFetchUrlSourceUserInputParams.Serializer::class) +class BetaManagedAgentsWebFetchUrlSourceUserInputParams +private constructor( + private val shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand? = null, + private val betaManagedAgentsWebFetchUrlSourceUserInput: + BetaManagedAgentsWebFetchUrlSourceUserInput? = + null, + private val _json: JsonValue? = null, +) { + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + fun shorthand(): Optional = + Optional.ofNullable(shorthand) + + /** Whether URLs in the text of user messages may be fetched. */ + fun betaManagedAgentsWebFetchUrlSourceUserInput(): + Optional = + Optional.ofNullable(betaManagedAgentsWebFetchUrlSourceUserInput) + + fun isShorthand(): Boolean = shorthand != null + + fun isBetaManagedAgentsWebFetchUrlSourceUserInput(): Boolean = + betaManagedAgentsWebFetchUrlSourceUserInput != null + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + fun asShorthand(): BetaManagedAgentsWebFetchUrlSourceShorthand = + shorthand.getOrThrow("shorthand") + + /** Whether URLs in the text of user messages may be fetched. */ + fun asBetaManagedAgentsWebFetchUrlSourceUserInput(): + BetaManagedAgentsWebFetchUrlSourceUserInput = + betaManagedAgentsWebFetchUrlSourceUserInput.getOrThrow( + "betaManagedAgentsWebFetchUrlSourceUserInput" + ) + + 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 = betaManagedAgentsWebFetchUrlSourceUserInputParams.accept(new BetaManagedAgentsWebFetchUrlSourceUserInputParams.Visitor>() { + * @Override + * public Optional visitShorthand(BetaManagedAgentsWebFetchUrlSourceShorthand shorthand) { + * return Optional.of(shorthand.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 { + shorthand != null -> visitor.visitShorthand(shorthand) + betaManagedAgentsWebFetchUrlSourceUserInput != null -> + visitor.visitBetaManagedAgentsWebFetchUrlSourceUserInput( + betaManagedAgentsWebFetchUrlSourceUserInput + ) + 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(): BetaManagedAgentsWebFetchUrlSourceUserInputParams = apply { + if (validated) { + return@apply + } + + when { + shorthand != null -> shorthand.validate() + betaManagedAgentsWebFetchUrlSourceUserInput != null -> + betaManagedAgentsWebFetchUrlSourceUserInput.validate() + else -> + throw AnthropicInvalidDataException( + "Unknown BetaManagedAgentsWebFetchUrlSourceUserInputParams: $_json" + ) + } + 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 = + when { + shorthand != null -> shorthand.validity() + betaManagedAgentsWebFetchUrlSourceUserInput != null -> + betaManagedAgentsWebFetchUrlSourceUserInput.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourceUserInputParams && + shorthand == other.shorthand && + betaManagedAgentsWebFetchUrlSourceUserInput == + other.betaManagedAgentsWebFetchUrlSourceUserInput + } + + override fun hashCode(): Int = + Objects.hash(shorthand, betaManagedAgentsWebFetchUrlSourceUserInput) + + override fun toString(): String = + when { + shorthand != null -> + "BetaManagedAgentsWebFetchUrlSourceUserInputParams{shorthand=$shorthand}" + betaManagedAgentsWebFetchUrlSourceUserInput != null -> + "BetaManagedAgentsWebFetchUrlSourceUserInputParams{betaManagedAgentsWebFetchUrlSourceUserInput=$betaManagedAgentsWebFetchUrlSourceUserInput}" + _json != null -> "BetaManagedAgentsWebFetchUrlSourceUserInputParams{_unknown=$_json}" + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsWebFetchUrlSourceUserInputParams" + ) + } + + companion object { + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + @JvmStatic + fun ofShorthand(shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand) = + BetaManagedAgentsWebFetchUrlSourceUserInputParams(shorthand = shorthand) + + /** Whether URLs in the text of user messages may be fetched. */ + @JvmStatic + fun ofBetaManagedAgentsWebFetchUrlSourceUserInput( + betaManagedAgentsWebFetchUrlSourceUserInput: BetaManagedAgentsWebFetchUrlSourceUserInput + ) = + BetaManagedAgentsWebFetchUrlSourceUserInputParams( + betaManagedAgentsWebFetchUrlSourceUserInput = + betaManagedAgentsWebFetchUrlSourceUserInput + ) + } + + /** + * An interface that defines how to map each variant of + * [BetaManagedAgentsWebFetchUrlSourceUserInputParams] to a value of type [T]. + */ + interface Visitor { + + /** + * String form of a url_sources value that has no field other than its type: "all" means + * {"type": "all"} and "none" means {"type": "none"}. + */ + fun visitShorthand(shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand): T + + /** Whether URLs in the text of user messages may be fetched. */ + fun visitBetaManagedAgentsWebFetchUrlSourceUserInput( + betaManagedAgentsWebFetchUrlSourceUserInput: BetaManagedAgentsWebFetchUrlSourceUserInput + ): T + + /** + * Maps an unknown variant of [BetaManagedAgentsWebFetchUrlSourceUserInputParams] to a value + * of type [T]. + * + * An instance of [BetaManagedAgentsWebFetchUrlSourceUserInputParams] 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 BetaManagedAgentsWebFetchUrlSourceUserInputParams: $json" + ) + } + } + + internal class Deserializer : + BaseDeserializer( + BetaManagedAgentsWebFetchUrlSourceUserInputParams::class + ) { + + override fun ObjectCodec.deserialize( + node: JsonNode + ): BetaManagedAgentsWebFetchUrlSourceUserInputParams { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceUserInputParams( + shorthand = it, + _json = json, + ) + }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + BetaManagedAgentsWebFetchUrlSourceUserInputParams( + betaManagedAgentsWebFetchUrlSourceUserInput = it, + _json = json, + ) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> BetaManagedAgentsWebFetchUrlSourceUserInputParams(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer( + BetaManagedAgentsWebFetchUrlSourceUserInputParams::class + ) { + + override fun serialize( + value: BetaManagedAgentsWebFetchUrlSourceUserInputParams, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.shorthand != null -> generator.writeObject(value.shorthand) + value.betaManagedAgentsWebFetchUrlSourceUserInput != null -> + generator.writeObject(value.betaManagedAgentsWebFetchUrlSourceUserInput) + value._json != null -> generator.writeObject(value._json) + else -> + throw IllegalStateException( + "Invalid BetaManagedAgentsWebFetchUrlSourceUserInputParams" + ) + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSources.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSources.kt new file mode 100644 index 000000000..8e4ef87e0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSources.kt @@ -0,0 +1,444 @@ +package com.anthropic.models.beta.agents + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Which sources contribute URLs the web_fetch tool may fetch. A key that is null was not set and + * allows every URL from that source. + */ +class BetaManagedAgentsWebFetchUrlSources +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val clientToolResults: JsonField, + private val serverToolResults: JsonField, + private val userInput: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("client_tool_results") + @ExcludeMissing + clientToolResults: JsonField = + JsonMissing.of(), + @JsonProperty("server_tool_results") + @ExcludeMissing + serverToolResults: JsonField = + JsonMissing.of(), + @JsonProperty("user_input") + @ExcludeMissing + userInput: JsonField = JsonMissing.of(), + ) : this(clientToolResults, serverToolResults, userInput, mutableMapOf()) + + /** + * Which custom tools' results contribute URLs that may be fetched. Null when not set, which + * allows every custom tool's results. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientToolResults(): Optional = + clientToolResults.getOptional("client_tool_results") + + /** + * Which of the web_search and web_fetch tools' results contribute URLs that may be fetched. + * Null when not set, which allows both. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serverToolResults(): Optional = + serverToolResults.getOptional("server_tool_results") + + /** + * Whether URLs in the text of user messages may be fetched. Null when not set, which allows + * them. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userInput(): Optional = + userInput.getOptional("user_input") + + /** + * Returns the raw JSON value of [clientToolResults]. + * + * Unlike [clientToolResults], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("client_tool_results") + @ExcludeMissing + fun _clientToolResults(): JsonField = + clientToolResults + + /** + * Returns the raw JSON value of [serverToolResults]. + * + * Unlike [serverToolResults], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("server_tool_results") + @ExcludeMissing + fun _serverToolResults(): JsonField = + serverToolResults + + /** + * Returns the raw JSON value of [userInput]. + * + * Unlike [userInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_input") + @ExcludeMissing + fun _userInput(): JsonField = userInput + + @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 + * [BetaManagedAgentsWebFetchUrlSources]. + * + * The following fields are required: + * ```java + * .clientToolResults() + * .serverToolResults() + * .userInput() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsWebFetchUrlSources]. */ + class Builder internal constructor() { + + private var clientToolResults: JsonField? = + null + private var serverToolResults: JsonField? = + null + private var userInput: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWebFetchUrlSources: BetaManagedAgentsWebFetchUrlSources + ) = apply { + clientToolResults = betaManagedAgentsWebFetchUrlSources.clientToolResults + serverToolResults = betaManagedAgentsWebFetchUrlSources.serverToolResults + userInput = betaManagedAgentsWebFetchUrlSources.userInput + additionalProperties = + betaManagedAgentsWebFetchUrlSources.additionalProperties.toMutableMap() + } + + /** + * Which custom tools' results contribute URLs that may be fetched. Null when not set, which + * allows every custom tool's results. + */ + fun clientToolResults(clientToolResults: BetaManagedAgentsWebFetchUrlSourceToolFilter?) = + clientToolResults(JsonField.ofNullable(clientToolResults)) + + /** Alias for calling [Builder.clientToolResults] with `clientToolResults.orElse(null)`. */ + fun clientToolResults( + clientToolResults: Optional + ) = clientToolResults(clientToolResults.getOrNull()) + + /** + * Sets [Builder.clientToolResults] to an arbitrary JSON value. + * + * You should usually call [Builder.clientToolResults] with a well-typed + * [BetaManagedAgentsWebFetchUrlSourceToolFilter] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun clientToolResults( + clientToolResults: JsonField + ) = apply { this.clientToolResults = clientToolResults } + + /** + * Alias for calling [clientToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll(all)`. + */ + fun clientToolResults(all: BetaManagedAgentsWebFetchUrlSourceAll) = + clientToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll(all)) + + /** + * Alias for calling [clientToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofNone(none)`. + */ + fun clientToolResults(none: BetaManagedAgentsWebFetchUrlSourceNone) = + clientToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofNone(none)) + + /** + * Alias for calling [clientToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofOnly(only)`. + */ + fun clientToolResults(only: BetaManagedAgentsWebFetchUrlSourceOnly) = + clientToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofOnly(only)) + + /** + * Alias for calling [clientToolResults] with the following: + * ```java + * BetaManagedAgentsWebFetchUrlSourceOnly.builder() + * .tools(tools) + * .build() + * ``` + */ + fun onlyClientToolResults(tools: List) = + clientToolResults(BetaManagedAgentsWebFetchUrlSourceOnly.builder().tools(tools).build()) + + /** + * Alias for calling [clientToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofExcept(except)`. + */ + fun clientToolResults(except: BetaManagedAgentsWebFetchUrlSourceExcept) = + clientToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofExcept(except)) + + /** + * Alias for calling [clientToolResults] with the following: + * ```java + * BetaManagedAgentsWebFetchUrlSourceExcept.builder() + * .tools(tools) + * .build() + * ``` + */ + fun exceptClientToolResults(tools: List) = + clientToolResults( + BetaManagedAgentsWebFetchUrlSourceExcept.builder().tools(tools).build() + ) + + /** + * Which of the web_search and web_fetch tools' results contribute URLs that may be fetched. + * Null when not set, which allows both. + */ + fun serverToolResults(serverToolResults: BetaManagedAgentsWebFetchUrlSourceToolFilter?) = + serverToolResults(JsonField.ofNullable(serverToolResults)) + + /** Alias for calling [Builder.serverToolResults] with `serverToolResults.orElse(null)`. */ + fun serverToolResults( + serverToolResults: Optional + ) = serverToolResults(serverToolResults.getOrNull()) + + /** + * Sets [Builder.serverToolResults] to an arbitrary JSON value. + * + * You should usually call [Builder.serverToolResults] with a well-typed + * [BetaManagedAgentsWebFetchUrlSourceToolFilter] value instead. This method is primarily + * for setting the field to an undocumented or not yet supported value. + */ + fun serverToolResults( + serverToolResults: JsonField + ) = apply { this.serverToolResults = serverToolResults } + + /** + * Alias for calling [serverToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll(all)`. + */ + fun serverToolResults(all: BetaManagedAgentsWebFetchUrlSourceAll) = + serverToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll(all)) + + /** + * Alias for calling [serverToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofNone(none)`. + */ + fun serverToolResults(none: BetaManagedAgentsWebFetchUrlSourceNone) = + serverToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofNone(none)) + + /** + * Alias for calling [serverToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofOnly(only)`. + */ + fun serverToolResults(only: BetaManagedAgentsWebFetchUrlSourceOnly) = + serverToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofOnly(only)) + + /** + * Alias for calling [serverToolResults] with the following: + * ```java + * BetaManagedAgentsWebFetchUrlSourceOnly.builder() + * .tools(tools) + * .build() + * ``` + */ + fun onlyServerToolResults(tools: List) = + serverToolResults(BetaManagedAgentsWebFetchUrlSourceOnly.builder().tools(tools).build()) + + /** + * Alias for calling [serverToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilter.ofExcept(except)`. + */ + fun serverToolResults(except: BetaManagedAgentsWebFetchUrlSourceExcept) = + serverToolResults(BetaManagedAgentsWebFetchUrlSourceToolFilter.ofExcept(except)) + + /** + * Alias for calling [serverToolResults] with the following: + * ```java + * BetaManagedAgentsWebFetchUrlSourceExcept.builder() + * .tools(tools) + * .build() + * ``` + */ + fun exceptServerToolResults(tools: List) = + serverToolResults( + BetaManagedAgentsWebFetchUrlSourceExcept.builder().tools(tools).build() + ) + + /** + * Whether URLs in the text of user messages may be fetched. Null when not set, which allows + * them. + */ + fun userInput(userInput: BetaManagedAgentsWebFetchUrlSourceUserInput?) = + userInput(JsonField.ofNullable(userInput)) + + /** Alias for calling [Builder.userInput] with `userInput.orElse(null)`. */ + fun userInput(userInput: Optional) = + userInput(userInput.getOrNull()) + + /** + * Sets [Builder.userInput] to an arbitrary JSON value. + * + * You should usually call [Builder.userInput] with a well-typed + * [BetaManagedAgentsWebFetchUrlSourceUserInput] value instead. This method is primarily for + * setting the field to an undocumented or not yet supported value. + */ + fun userInput(userInput: JsonField) = apply { + this.userInput = userInput + } + + /** + * Alias for calling [userInput] with + * `BetaManagedAgentsWebFetchUrlSourceUserInput.ofAll(all)`. + */ + fun userInput(all: BetaManagedAgentsWebFetchUrlSourceAll) = + userInput(BetaManagedAgentsWebFetchUrlSourceUserInput.ofAll(all)) + + /** + * Alias for calling [userInput] with + * `BetaManagedAgentsWebFetchUrlSourceUserInput.ofNone(none)`. + */ + fun userInput(none: BetaManagedAgentsWebFetchUrlSourceNone) = + userInput(BetaManagedAgentsWebFetchUrlSourceUserInput.ofNone(none)) + + 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 [BetaManagedAgentsWebFetchUrlSources]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .clientToolResults() + * .serverToolResults() + * .userInput() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaManagedAgentsWebFetchUrlSources = + BetaManagedAgentsWebFetchUrlSources( + checkRequired("clientToolResults", clientToolResults), + checkRequired("serverToolResults", serverToolResults), + checkRequired("userInput", userInput), + 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(): BetaManagedAgentsWebFetchUrlSources = apply { + if (validated) { + return@apply + } + + clientToolResults().ifPresent { it.validate() } + serverToolResults().ifPresent { it.validate() } + userInput().ifPresent { it.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 = + (clientToolResults.asKnown().getOrNull()?.validity() ?: 0) + + (serverToolResults.asKnown().getOrNull()?.validity() ?: 0) + + (userInput.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSources && + clientToolResults == other.clientToolResults && + serverToolResults == other.serverToolResults && + userInput == other.userInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(clientToolResults, serverToolResults, userInput, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWebFetchUrlSources{clientToolResults=$clientToolResults, serverToolResults=$serverToolResults, userInput=$userInput, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesParams.kt new file mode 100644 index 000000000..2176002db --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesParams.kt @@ -0,0 +1,387 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Which sources contribute URLs the web_fetch tool may fetch. When web_fetch is limited to URLs the + * conversation has already shown the model (in a user message, a custom tool's result, or an + * earlier web_search or web_fetch result), each key narrows one of those sources and defaults to + * "all". Setting all three keys to "none" is rejected. + */ +class BetaManagedAgentsWebFetchUrlSourcesParams +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val clientToolResults: JsonField, + private val serverToolResults: JsonField, + private val userInput: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("client_tool_results") + @ExcludeMissing + clientToolResults: JsonField = + JsonMissing.of(), + @JsonProperty("server_tool_results") + @ExcludeMissing + serverToolResults: JsonField = + JsonMissing.of(), + @JsonProperty("user_input") + @ExcludeMissing + userInput: JsonField = JsonMissing.of(), + ) : this(clientToolResults, serverToolResults, userInput, mutableMapOf()) + + /** + * Which custom tools' results contribute URLs that may be fetched: "all" (the default), "none", + * or an only or except list. Each name in a list must be a custom tool in the same tools array. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun clientToolResults(): Optional = + clientToolResults.getOptional("client_tool_results") + + /** + * Which of the web_search and web_fetch tools' results contribute URLs that may be fetched: + * "all" (the default), "none", or an only or except list. Each name in a list must be + * "web_search" or "web_fetch". + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serverToolResults(): Optional = + serverToolResults.getOptional("server_tool_results") + + /** + * Whether URLs in the text of user messages may be fetched: "all" (the default) or "none". + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun userInput(): Optional = + userInput.getOptional("user_input") + + /** + * Returns the raw JSON value of [clientToolResults]. + * + * Unlike [clientToolResults], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("client_tool_results") + @ExcludeMissing + fun _clientToolResults(): JsonField = + clientToolResults + + /** + * Returns the raw JSON value of [serverToolResults]. + * + * Unlike [serverToolResults], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("server_tool_results") + @ExcludeMissing + fun _serverToolResults(): JsonField = + serverToolResults + + /** + * Returns the raw JSON value of [userInput]. + * + * Unlike [userInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_input") + @ExcludeMissing + fun _userInput(): JsonField = userInput + + @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 + * [BetaManagedAgentsWebFetchUrlSourcesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaManagedAgentsWebFetchUrlSourcesParams]. */ + class Builder internal constructor() { + + private var clientToolResults: + JsonField = + JsonMissing.of() + private var serverToolResults: + JsonField = + JsonMissing.of() + private var userInput: JsonField = + JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaManagedAgentsWebFetchUrlSourcesParams: BetaManagedAgentsWebFetchUrlSourcesParams + ) = apply { + clientToolResults = betaManagedAgentsWebFetchUrlSourcesParams.clientToolResults + serverToolResults = betaManagedAgentsWebFetchUrlSourcesParams.serverToolResults + userInput = betaManagedAgentsWebFetchUrlSourcesParams.userInput + additionalProperties = + betaManagedAgentsWebFetchUrlSourcesParams.additionalProperties.toMutableMap() + } + + /** + * Which custom tools' results contribute URLs that may be fetched: "all" (the default), + * "none", or an only or except list. Each name in a list must be a custom tool in the same + * tools array. + */ + fun clientToolResults( + clientToolResults: BetaManagedAgentsWebFetchUrlSourceToolFilterParams? + ) = clientToolResults(JsonField.ofNullable(clientToolResults)) + + /** Alias for calling [Builder.clientToolResults] with `clientToolResults.orElse(null)`. */ + fun clientToolResults( + clientToolResults: Optional + ) = clientToolResults(clientToolResults.getOrNull()) + + /** + * Sets [Builder.clientToolResults] to an arbitrary JSON value. + * + * You should usually call [Builder.clientToolResults] with a well-typed + * [BetaManagedAgentsWebFetchUrlSourceToolFilterParams] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun clientToolResults( + clientToolResults: JsonField + ) = apply { this.clientToolResults = clientToolResults } + + /** + * Alias for calling [clientToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand(shorthand)`. + */ + fun clientToolResults(shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand) = + clientToolResults( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand(shorthand) + ) + + /** + * Alias for calling [clientToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofBetaManagedAgentsWebFetchUrlSourceToolFilter(betaManagedAgentsWebFetchUrlSourceToolFilter)`. + */ + fun clientToolResults( + betaManagedAgentsWebFetchUrlSourceToolFilter: + BetaManagedAgentsWebFetchUrlSourceToolFilter + ) = + clientToolResults( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams + .ofBetaManagedAgentsWebFetchUrlSourceToolFilter( + betaManagedAgentsWebFetchUrlSourceToolFilter + ) + ) + + /** + * Which of the web_search and web_fetch tools' results contribute URLs that may be fetched: + * "all" (the default), "none", or an only or except list. Each name in a list must be + * "web_search" or "web_fetch". + */ + fun serverToolResults( + serverToolResults: BetaManagedAgentsWebFetchUrlSourceToolFilterParams? + ) = serverToolResults(JsonField.ofNullable(serverToolResults)) + + /** Alias for calling [Builder.serverToolResults] with `serverToolResults.orElse(null)`. */ + fun serverToolResults( + serverToolResults: Optional + ) = serverToolResults(serverToolResults.getOrNull()) + + /** + * Sets [Builder.serverToolResults] to an arbitrary JSON value. + * + * You should usually call [Builder.serverToolResults] with a well-typed + * [BetaManagedAgentsWebFetchUrlSourceToolFilterParams] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun serverToolResults( + serverToolResults: JsonField + ) = apply { this.serverToolResults = serverToolResults } + + /** + * Alias for calling [serverToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand(shorthand)`. + */ + fun serverToolResults(shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand) = + serverToolResults( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand(shorthand) + ) + + /** + * Alias for calling [serverToolResults] with + * `BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofBetaManagedAgentsWebFetchUrlSourceToolFilter(betaManagedAgentsWebFetchUrlSourceToolFilter)`. + */ + fun serverToolResults( + betaManagedAgentsWebFetchUrlSourceToolFilter: + BetaManagedAgentsWebFetchUrlSourceToolFilter + ) = + serverToolResults( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams + .ofBetaManagedAgentsWebFetchUrlSourceToolFilter( + betaManagedAgentsWebFetchUrlSourceToolFilter + ) + ) + + /** + * Whether URLs in the text of user messages may be fetched: "all" (the default) or "none". + */ + fun userInput(userInput: BetaManagedAgentsWebFetchUrlSourceUserInputParams?) = + userInput(JsonField.ofNullable(userInput)) + + /** Alias for calling [Builder.userInput] with `userInput.orElse(null)`. */ + fun userInput(userInput: Optional) = + userInput(userInput.getOrNull()) + + /** + * Sets [Builder.userInput] to an arbitrary JSON value. + * + * You should usually call [Builder.userInput] with a well-typed + * [BetaManagedAgentsWebFetchUrlSourceUserInputParams] value instead. This method is + * primarily for setting the field to an undocumented or not yet supported value. + */ + fun userInput(userInput: JsonField) = + apply { + this.userInput = userInput + } + + /** + * Alias for calling [userInput] with + * `BetaManagedAgentsWebFetchUrlSourceUserInputParams.ofShorthand(shorthand)`. + */ + fun userInput(shorthand: BetaManagedAgentsWebFetchUrlSourceShorthand) = + userInput(BetaManagedAgentsWebFetchUrlSourceUserInputParams.ofShorthand(shorthand)) + + /** + * Alias for calling [userInput] with + * `BetaManagedAgentsWebFetchUrlSourceUserInputParams.ofBetaManagedAgentsWebFetchUrlSourceUserInput(betaManagedAgentsWebFetchUrlSourceUserInput)`. + */ + fun userInput( + betaManagedAgentsWebFetchUrlSourceUserInput: BetaManagedAgentsWebFetchUrlSourceUserInput + ) = + userInput( + BetaManagedAgentsWebFetchUrlSourceUserInputParams + .ofBetaManagedAgentsWebFetchUrlSourceUserInput( + betaManagedAgentsWebFetchUrlSourceUserInput + ) + ) + + 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 [BetaManagedAgentsWebFetchUrlSourcesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaManagedAgentsWebFetchUrlSourcesParams = + BetaManagedAgentsWebFetchUrlSourcesParams( + clientToolResults, + serverToolResults, + userInput, + 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(): BetaManagedAgentsWebFetchUrlSourcesParams = apply { + if (validated) { + return@apply + } + + clientToolResults().ifPresent { it.validate() } + serverToolResults().ifPresent { it.validate() } + userInput().ifPresent { it.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 = + (clientToolResults.asKnown().getOrNull()?.validity() ?: 0) + + (serverToolResults.asKnown().getOrNull()?.validity() ?: 0) + + (userInput.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaManagedAgentsWebFetchUrlSourcesParams && + clientToolResults == other.clientToolResults && + serverToolResults == other.serverToolResults && + userInput == other.userInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(clientToolResults, serverToolResults, userInput, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaManagedAgentsWebFetchUrlSourcesParams{clientToolResults=$clientToolResults, serverToolResults=$serverToolResults, userInput=$userInput, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/versions/VersionListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/versions/VersionListParams.kt index d2dd929a5..5f857aa8d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/versions/VersionListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/agents/versions/VersionListParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParams.kt index 796351256..3c9bcc292 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParams.kt @@ -371,7 +371,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParams.kt index fadca7abc..6bc47797a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParams.kt @@ -237,7 +237,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParams.kt index 34ff601ce..e378a4450 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParams.kt @@ -266,7 +266,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParams.kt index 35fc923c9..8b8993911 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParams.kt @@ -774,7 +774,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListParams.kt index afdc8fcd7..6d4ca0eea 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentListParams.kt @@ -331,7 +331,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParams.kt index 5ca92258f..f670d7f7e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParams.kt index 7cdcfb470..197f13e63 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParams.kt @@ -232,7 +232,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParams.kt index 75c03a235..9e564744f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParams.kt index f0b6ade53..939bd8305 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParams.kt @@ -266,7 +266,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParams.kt index dbd0ffc75..7d656bec7 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParams.kt @@ -788,7 +788,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParams.kt index 59f7b29d4..b450d838a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParams.kt @@ -274,7 +274,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("dreaming-2026-04-21") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCancelParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCancelParams.kt index 0372a9659..18e481a73 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCancelParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCancelParams.kt @@ -274,7 +274,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("dreaming-2026-04-21") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCreateParams.kt index d852bf26e..c06fefca6 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamCreateParams.kt @@ -523,7 +523,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("dreaming-2026-04-21") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamListParams.kt index d208a5b4d..205a5dd3a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamListParams.kt @@ -348,7 +348,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("dreaming-2026-04-21") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParams.kt index 878c49480..3a5d4ba03 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParams.kt @@ -239,7 +239,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("dreaming-2026-04-21") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParams.kt index 90a9a98f7..06f79216c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParams.kt index e6ee125d0..1f77c41e7 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParams.kt @@ -443,7 +443,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParams.kt index 5480fa2af..43168b857 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentListParams.kt index 915117f7e..066bf8d75 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentListParams.kt @@ -275,7 +275,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParams.kt index 66515be29..373109790 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParams.kt @@ -233,7 +233,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParams.kt index 5836b6f14..130295d12 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParams.kt @@ -455,7 +455,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkAckParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkAckParams.kt index d48c1db5f..e69fe9bf5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkAckParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkAckParams.kt @@ -267,7 +267,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParams.kt index 3a3e7b29f..81b170473 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParams.kt @@ -319,7 +319,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkListParams.kt index 01154aba3..f9d45463b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkListParams.kt @@ -245,7 +245,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkPollParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkPollParams.kt index 9d30061cf..213bbe512 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkPollParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkPollParams.kt @@ -292,7 +292,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } anthropicWorkerId?.let { put("Anthropic-Worker-ID", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParams.kt index 337fb52ab..dacd132cd 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParams.kt @@ -258,7 +258,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParams.kt index c34886e5f..435a01fcc 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParams.kt @@ -231,7 +231,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStopParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStopParams.kt index 3533bb1cf..7b31f6e9e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStopParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkStopParams.kt @@ -279,7 +279,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParams.kt index 0b0cffa07..e1f616c71 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParams.kt @@ -279,7 +279,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDeleteParams.kt index 3ee0da3f8..29bc32d9d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDeleteParams.kt @@ -265,7 +265,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDownloadParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDownloadParams.kt index 2f3c36990..aa3940078 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDownloadParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileDownloadParams.kt @@ -232,7 +232,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileListParams.kt index 04978cf2b..1a8f9a95d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileListParams.kt @@ -303,7 +303,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParams.kt index 427cefdcd..705c4cbb9 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParams.kt @@ -234,7 +234,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileUploadParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileUploadParams.kt index ca41e681e..58ef3c188 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileUploadParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/files/FileUploadParams.kt @@ -361,7 +361,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParams.kt index b5e7215c3..ab5c415a5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParams.kt @@ -275,7 +275,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParams.kt index 14c00ec2d..122c4acee 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParams.kt @@ -370,7 +370,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParams.kt index 0d5715ec1..5e4db8d18 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParams.kt @@ -273,7 +273,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParams.kt index eb85dacea..2685a6dbb 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParams.kt @@ -329,7 +329,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParams.kt index b89f2f17b..eb75707e2 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParams.kt @@ -241,7 +241,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParams.kt index 62c30c0c9..1334ef5d9 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParams.kt @@ -388,7 +388,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParams.kt index f5b6a0f33..50fcc4775 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParams.kt @@ -387,7 +387,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParams.kt index ce1c0323b..70601dc5d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParams.kt @@ -318,7 +318,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParams.kt index ff1668c09..5892cccf1 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParams.kt @@ -349,7 +349,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParams.kt index 4bbc799eb..2e5394463 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParams.kt @@ -280,7 +280,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParams.kt index 971f23f67..31bc5eb14 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParams.kt @@ -437,7 +437,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParams.kt index 94affd29f..9cf6e5a86 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParams.kt @@ -409,7 +409,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParams.kt index 9340a7207..2ec4ca7f5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParams.kt @@ -293,7 +293,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParams.kt index 8608cbe37..05cf6c04b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParams.kt @@ -284,7 +284,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("agent-memory-2026-07-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserClickTarget.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserClickTarget.kt new file mode 100644 index 000000000..55298c925 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserClickTarget.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +/** Where to act: either a viewport coordinate or an element reference. */ +@JsonDeserialize(using = BetaBrowserClickTarget.Deserializer::class) +@JsonSerialize(using = BetaBrowserClickTarget.Serializer::class) +class BetaBrowserClickTarget +private constructor( + private val coordinate: BetaBrowserCoordinateTarget? = null, + private val ref: BetaBrowserRefTarget? = null, + private val _json: JsonValue? = null, +) { + + fun type(): Type = + when { + coordinate != null -> Type.COORDINATE + ref != null -> Type.REF + else -> Type.of(_json?.asObject()?.getOrNull()?.get("type") ?: JsonMissing.of()) + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun coordinate(): Optional = Optional.ofNullable(coordinate) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + */ + fun ref(): Optional = Optional.ofNullable(ref) + + fun isCoordinate(): Boolean = coordinate != null + + fun isRef(): Boolean = ref != null + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun asCoordinate(): BetaBrowserCoordinateTarget = coordinate.getOrThrow("coordinate") + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + */ + fun asRef(): BetaBrowserRefTarget = ref.getOrThrow("ref") + + 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 = betaBrowserClickTarget.accept(new BetaBrowserClickTarget.Visitor>() { + * @Override + * public Optional visitCoordinate(BetaBrowserCoordinateTarget coordinate) { + * return Optional.of(coordinate.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 { + coordinate != null -> visitor.visitCoordinate(coordinate) + ref != null -> visitor.visitRef(ref) + 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(): BetaBrowserClickTarget = apply { + if (validated) { + return@apply + } + + when { + coordinate != null -> coordinate.validate() + ref != null -> ref.validate() + else -> throw AnthropicInvalidDataException("Unknown BetaBrowserClickTarget: $_json") + } + 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 = + when { + coordinate != null -> coordinate.validity() + ref != null -> ref.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserClickTarget && coordinate == other.coordinate && ref == other.ref + } + + override fun hashCode(): Int = Objects.hash(coordinate, ref) + + override fun toString(): String = + when { + coordinate != null -> "BetaBrowserClickTarget{coordinate=$coordinate}" + ref != null -> "BetaBrowserClickTarget{ref=$ref}" + _json != null -> "BetaBrowserClickTarget{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaBrowserClickTarget") + } + + companion object { + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + @JvmStatic + fun ofCoordinate(coordinate: BetaBrowserCoordinateTarget) = + BetaBrowserClickTarget(coordinate = coordinate) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + @JvmStatic fun ofRef(ref: BetaBrowserRefTarget) = BetaBrowserClickTarget(ref = ref) + + /** + * Returns an immutable instance of [BetaBrowserClickTarget] whose [ofRef] variant is built + * from the given required [ref]. + */ + @JvmStatic fun ofRef(ref: String) = ofRef(BetaBrowserRefTarget.of(ref)) + } + + /** + * An interface that defines how to map each variant of [BetaBrowserClickTarget] to a value of + * type [T]. + */ + interface Visitor { + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun visitCoordinate(coordinate: BetaBrowserCoordinateTarget): T + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun visitRef(ref: BetaBrowserRefTarget): T + + /** + * Maps an unknown variant of [BetaBrowserClickTarget] to a value of type [T]. + * + * An instance of [BetaBrowserClickTarget] 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 BetaBrowserClickTarget: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BetaBrowserClickTarget::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaBrowserClickTarget { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "coordinate" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserClickTarget(coordinate = it, _json = json) } + ?: BetaBrowserClickTarget(_json = json) + } + "ref" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BetaBrowserClickTarget(ref = it, _json = json) + } ?: BetaBrowserClickTarget(_json = json) + } + } + + return BetaBrowserClickTarget(_json = json) + } + } + + internal class Serializer : + BaseSerializer(BetaBrowserClickTarget::class) { + + override fun serialize( + value: BetaBrowserClickTarget, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.coordinate != null -> generator.writeObject(value.coordinate) + value.ref != null -> generator.writeObject(value.ref) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaBrowserClickTarget") + } + } + } + + class Type 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 COORDINATE = Type(JsonField.of("coordinate")) + + @JvmField val REF = Type(JsonField.of("ref")) + + @JvmStatic + fun of(value: String): Type = + // Intern known values so `==` works + when (value) { + "coordinate" -> COORDINATE + "ref" -> REF + else -> Type(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Type = + value.asString().getOrNull()?.let { of(it) } ?: Type(value) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + COORDINATE, + REF, + } + + /** + * 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 { + COORDINATE, + REF, + /** 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) { + COORDINATE -> Value.COORDINATE + REF -> Value.REF + 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) { + COORDINATE -> Known.COORDINATE + REF -> Known.REF + 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() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabInput.kt new file mode 100644 index 000000000..959368380 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabInput.kt @@ -0,0 +1,186 @@ +package com.anthropic.models.beta.messages + +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 + +/** Close the tab with the given tab_id. */ +class BetaBrowserCloseTabInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * The tab to close. + * + * @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 tabId(): String = tabId.getRequired("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserCloseTabInput]. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserCloseTabInput] with the required [tabId] set + * to the given value. + */ + @JvmStatic fun of(tabId: String) = builder().tabId(tabId).build() + } + + /** A builder for [BetaBrowserCloseTabInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserCloseTabInput: BetaBrowserCloseTabInput) = apply { + tabId = betaBrowserCloseTabInput.tabId + additionalProperties = betaBrowserCloseTabInput.additionalProperties.toMutableMap() + } + + /** The tab to close. */ + fun tabId(tabId: String) = tabId(JsonField.of(tabId)) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserCloseTabInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserCloseTabInput = + BetaBrowserCloseTabInput( + checkRequired("tabId", tabId), + 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(): BetaBrowserCloseTabInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserCloseTabInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserCloseTabInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabToolUseBlock.kt new file mode 100644 index 000000000..fc66207fd --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserCloseTabToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Close the tab with the given tab_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 input(): BetaBrowserCloseTabInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("close_tab") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserCloseTabToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserCloseTabToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("close_tab") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserCloseTabToolUseBlock: BetaBrowserCloseTabToolUseBlock) = + apply { + id = betaBrowserCloseTabToolUseBlock.id + input = betaBrowserCloseTabToolUseBlock.input + name = betaBrowserCloseTabToolUseBlock.name + toolsetName = betaBrowserCloseTabToolUseBlock.toolsetName + type = betaBrowserCloseTabToolUseBlock.type + caller = betaBrowserCloseTabToolUseBlock.caller + additionalProperties = + betaBrowserCloseTabToolUseBlock.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 } + + /** Close the tab with the given tab_id. */ + fun input(input: BetaBrowserCloseTabInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserCloseTabInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("close_tab") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserCloseTabToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserCloseTabToolUseBlock = + BetaBrowserCloseTabToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserCloseTabToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("close_tab")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("close_tab")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserCloseTabToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserCloseTabToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCoordinateTarget.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCoordinateTarget.kt new file mode 100644 index 000000000..8dd131849 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserCoordinateTarget.kt @@ -0,0 +1,258 @@ +package com.anthropic.models.beta.messages + +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 + +/** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ +class BetaBrowserCoordinateTarget +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonValue, + private val x: JsonField, + private val y: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("x") @ExcludeMissing x: JsonField = JsonMissing.of(), + @JsonProperty("y") @ExcludeMissing y: JsonField = JsonMissing.of(), + ) : this(type, x, y, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("coordinate") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Pixels from the left edge of the viewport. + * + * @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 x(): Long = x.getRequired("x") + + /** + * Pixels from the top edge of the viewport. + * + * @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 y(): Long = y.getRequired("y") + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + + @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 [BetaBrowserCoordinateTarget]. + * + * The following fields are required: + * ```java + * .x() + * .y() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserCoordinateTarget]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("coordinate") + private var x: JsonField? = null + private var y: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserCoordinateTarget: BetaBrowserCoordinateTarget) = apply { + type = betaBrowserCoordinateTarget.type + x = betaBrowserCoordinateTarget.x + y = betaBrowserCoordinateTarget.y + additionalProperties = betaBrowserCoordinateTarget.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("coordinate") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Pixels from the left edge of the viewport. */ + fun x(x: Long) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [Long] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun x(x: JsonField) = apply { this.x = x } + + /** Pixels from the top edge of the viewport. */ + fun y(y: Long) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Long] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun y(y: JsonField) = apply { this.y = y } + + 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 [BetaBrowserCoordinateTarget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .x() + * .y() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserCoordinateTarget = + BetaBrowserCoordinateTarget( + type, + checkRequired("x", x), + checkRequired("y", y), + 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(): BetaBrowserCoordinateTarget = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("coordinate")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + x() + y() + 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.let { if (it == JsonValue.from("coordinate")) 1 else 0 } + + (if (x.asKnown().isPresent) 1 else 0) + + (if (y.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserCoordinateTarget && + type == other.type && + x == other.x && + y == other.y && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, x, y, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserCoordinateTarget{type=$type, x=$x, y=$y, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickInput.kt new file mode 100644 index 000000000..fa19b0911 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickInput.kt @@ -0,0 +1,293 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Double left-click at a viewport coordinate or on an element by reference. */ +class BetaBrowserDoubleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BetaBrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserDoubleClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserDoubleClickInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserDoubleClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserDoubleClickInput: BetaBrowserDoubleClickInput) = apply { + target = betaBrowserDoubleClickInput.target + modifiers = betaBrowserDoubleClickInput.modifiers + tabId = betaBrowserDoubleClickInput.tabId + additionalProperties = betaBrowserDoubleClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BetaBrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BetaBrowserCoordinateTarget) = + target(BetaBrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BetaBrowserRefTarget) = target(BetaBrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BetaBrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BetaBrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserDoubleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserDoubleClickInput = + BetaBrowserDoubleClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BetaBrowserDoubleClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserDoubleClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserDoubleClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickToolUseBlock.kt new file mode 100644 index 000000000..d0f794e8a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserDoubleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Double left-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BetaBrowserDoubleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserDoubleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserDoubleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("double_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserDoubleClickToolUseBlock: BetaBrowserDoubleClickToolUseBlock) = + apply { + id = betaBrowserDoubleClickToolUseBlock.id + input = betaBrowserDoubleClickToolUseBlock.input + name = betaBrowserDoubleClickToolUseBlock.name + toolsetName = betaBrowserDoubleClickToolUseBlock.toolsetName + type = betaBrowserDoubleClickToolUseBlock.type + caller = betaBrowserDoubleClickToolUseBlock.caller + additionalProperties = + betaBrowserDoubleClickToolUseBlock.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 } + + /** Double left-click at a viewport coordinate or on an element by reference. */ + fun input(input: BetaBrowserDoubleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserDoubleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserDoubleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserDoubleClickToolUseBlock = + BetaBrowserDoubleClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserDoubleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("double_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("double_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserDoubleClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserDoubleClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadInput.kt new file mode 100644 index 000000000..db5891056 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadInput.kt @@ -0,0 +1,359 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Set the value of a file-input element to one or more files. The target must be an element + * reference; at least one of paths or document_ids is required. + */ +class BetaBrowserFileUploadInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val documentIds: JsonField>, + private val paths: JsonField>, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("document_ids") + @ExcludeMissing + documentIds: JsonField> = JsonMissing.of(), + @JsonProperty("paths") @ExcludeMissing paths: JsonField> = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, documentIds, paths, tabId, mutableMapOf()) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + * + * @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 target(): BetaBrowserRefTarget = target.getRequired("target") + + /** + * References to files the harness has staged, for deployments where the browser executor cannot + * read the caller's filesystem. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun documentIds(): Optional> = documentIds.getOptional("document_ids") + + /** + * File paths on the browser executor's filesystem. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paths(): Optional> = paths.getOptional("paths") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [documentIds]. + * + * Unlike [documentIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("document_ids") + @ExcludeMissing + fun _documentIds(): JsonField> = documentIds + + /** + * Returns the raw JSON value of [paths]. + * + * Unlike [paths], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paths") @ExcludeMissing fun _paths(): JsonField> = paths + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserFileUploadInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserFileUploadInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserRefTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserFileUploadInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var documentIds: JsonField>? = null + private var paths: JsonField>? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserFileUploadInput: BetaBrowserFileUploadInput) = apply { + target = betaBrowserFileUploadInput.target + documentIds = + betaBrowserFileUploadInput.documentIds + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + paths = + betaBrowserFileUploadInput.paths + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + tabId = betaBrowserFileUploadInput.tabId + additionalProperties = betaBrowserFileUploadInput.additionalProperties.toMutableMap() + } + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun target(target: BetaBrowserRefTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserRefTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** + * References to files the harness has staged, for deployments where the browser executor + * cannot read the caller's filesystem. + */ + fun documentIds(documentIds: List?) = documentIds(JsonField.ofNullable(documentIds)) + + /** Alias for calling [Builder.documentIds] with `documentIds.orElse(null)`. */ + fun documentIds(documentIds: Optional>) = documentIds(documentIds.getOrNull()) + + /** + * Sets [Builder.documentIds] to an arbitrary JSON value. + * + * You should usually call [Builder.documentIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun documentIds(documentIds: JsonField>) = apply { + this.documentIds = documentIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [documentIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDocumentId(documentId: String) = apply { + documentIds = + (documentIds ?: JsonField.of(mutableListOf())).also { + checkKnown("documentIds", it).add(documentId) + } + } + + /** File paths on the browser executor's filesystem. */ + fun paths(paths: List?) = paths(JsonField.ofNullable(paths)) + + /** Alias for calling [Builder.paths] with `paths.orElse(null)`. */ + fun paths(paths: Optional>) = paths(paths.getOrNull()) + + /** + * Sets [Builder.paths] to an arbitrary JSON value. + * + * You should usually call [Builder.paths] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun paths(paths: JsonField>) = apply { + this.paths = paths.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [paths]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPath(path: String) = apply { + paths = + (paths ?: JsonField.of(mutableListOf())).also { checkKnown("paths", it).add(path) } + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserFileUploadInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserFileUploadInput = + BetaBrowserFileUploadInput( + checkRequired("target", target), + (documentIds ?: JsonMissing.of()).map { it.toImmutable() }, + (paths ?: JsonMissing.of()).map { it.toImmutable() }, + tabId, + 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(): BetaBrowserFileUploadInput = apply { + if (validated) { + return@apply + } + + target().validate() + documentIds() + paths() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (documentIds.asKnown().getOrNull()?.size ?: 0) + + (paths.asKnown().getOrNull()?.size ?: 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserFileUploadInput && + target == other.target && + documentIds == other.documentIds && + paths == other.paths && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, documentIds, paths, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserFileUploadInput{target=$target, documentIds=$documentIds, paths=$paths, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadToolUseBlock.kt new file mode 100644 index 000000000..cd84149d9 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserFileUploadToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Set the value of a file-input element to one or more files. The target must be an element + * reference; at least one of paths or document_ids is required. + * + * @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 input(): BetaBrowserFileUploadInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("file_upload") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserFileUploadToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserFileUploadToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("file_upload") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserFileUploadToolUseBlock: BetaBrowserFileUploadToolUseBlock) = + apply { + id = betaBrowserFileUploadToolUseBlock.id + input = betaBrowserFileUploadToolUseBlock.input + name = betaBrowserFileUploadToolUseBlock.name + toolsetName = betaBrowserFileUploadToolUseBlock.toolsetName + type = betaBrowserFileUploadToolUseBlock.type + caller = betaBrowserFileUploadToolUseBlock.caller + additionalProperties = + betaBrowserFileUploadToolUseBlock.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 } + + /** + * Set the value of a file-input element to one or more files. The target must be an element + * reference; at least one of paths or document_ids is required. + */ + fun input(input: BetaBrowserFileUploadInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserFileUploadInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("file_upload") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserFileUploadToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserFileUploadToolUseBlock = + BetaBrowserFileUploadToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserFileUploadToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("file_upload")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("file_upload")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserFileUploadToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserFileUploadToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindInput.kt new file mode 100644 index 000000000..61fb8aaf7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindInput.kt @@ -0,0 +1,229 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Find elements matching a natural-language description (e.g. "search bar", "add to cart button") + * and return up to 20 matches with element references. + */ +class BetaBrowserFindInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val query: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(query, tabId, mutableMapOf()) + + /** + * Natural-language description of the element(s) to find. + * + * @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 query(): String = query.getRequired("query") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserFindInput]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserFindInput] with the required [query] set to + * the given value. + */ + @JvmStatic fun of(query: String) = builder().query(query).build() + } + + /** A builder for [BetaBrowserFindInput]. */ + class Builder internal constructor() { + + private var query: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserFindInput: BetaBrowserFindInput) = apply { + query = betaBrowserFindInput.query + tabId = betaBrowserFindInput.tabId + additionalProperties = betaBrowserFindInput.additionalProperties.toMutableMap() + } + + /** Natural-language description of the element(s) to find. */ + fun query(query: String) = query(JsonField.of(query)) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserFindInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserFindInput = + BetaBrowserFindInput( + checkRequired("query", query), + tabId, + 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(): BetaBrowserFindInput = apply { + if (validated) { + return@apply + } + + query() + tabId() + 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 (query.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserFindInput && + query == other.query && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(query, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserFindInput{query=$query, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindToolUseBlock.kt new file mode 100644 index 000000000..755733f8a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserFindToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Find elements matching a natural-language description (e.g. "search bar", "add to cart + * button") and return up to 20 matches with element references. + * + * @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 input(): BetaBrowserFindInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("find") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaBrowserFindToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserFindToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("find") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserFindToolUseBlock: BetaBrowserFindToolUseBlock) = apply { + id = betaBrowserFindToolUseBlock.id + input = betaBrowserFindToolUseBlock.input + name = betaBrowserFindToolUseBlock.name + toolsetName = betaBrowserFindToolUseBlock.toolsetName + type = betaBrowserFindToolUseBlock.type + caller = betaBrowserFindToolUseBlock.caller + additionalProperties = betaBrowserFindToolUseBlock.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 } + + /** + * Find elements matching a natural-language description (e.g. "search bar", "add to cart + * button") and return up to 20 matches with element references. + */ + fun input(input: BetaBrowserFindInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserFindInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("find") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserFindToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserFindToolUseBlock = + BetaBrowserFindToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserFindToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("find")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("find")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserFindToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserFindToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputInput.kt new file mode 100644 index 000000000..2e770f501 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputInput.kt @@ -0,0 +1,283 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Set the value of a form element (input, textarea, select, checkbox). Use a boolean for + * checkboxes, an option value or text for selects. + */ +class BetaBrowserFormInputInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val value: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, value, tabId, mutableMapOf()) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + * + * @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 target(): BetaBrowserRefTarget = target.getRequired("target") + + /** + * The value to set. + * + * @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 value(): BetaBrowserFormInputValue = value.getRequired("value") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") + @ExcludeMissing + fun _value(): JsonField = value + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserFormInputInput]. + * + * The following fields are required: + * ```java + * .target() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserFormInputInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var value: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserFormInputInput: BetaBrowserFormInputInput) = apply { + target = betaBrowserFormInputInput.target + value = betaBrowserFormInputInput.value + tabId = betaBrowserFormInputInput.tabId + additionalProperties = betaBrowserFormInputInput.additionalProperties.toMutableMap() + } + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun target(target: BetaBrowserRefTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserRefTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** The value to set. */ + fun value(value: BetaBrowserFormInputValue) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [BetaBrowserFormInputValue] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `BetaBrowserFormInputValue.ofString(string)`. */ + fun value(string: String) = value(BetaBrowserFormInputValue.ofString(string)) + + /** Alias for calling [value] with `BetaBrowserFormInputValue.ofNumber(number)`. */ + fun value(number: Double) = value(BetaBrowserFormInputValue.ofNumber(number)) + + /** Alias for calling [value] with `BetaBrowserFormInputValue.ofBool(bool)`. */ + fun value(bool: Boolean) = value(BetaBrowserFormInputValue.ofBool(bool)) + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserFormInputInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserFormInputInput = + BetaBrowserFormInputInput( + checkRequired("target", target), + checkRequired("value", value), + tabId, + 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(): BetaBrowserFormInputInput = apply { + if (validated) { + return@apply + } + + target().validate() + value().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserFormInputInput && + target == other.target && + value == other.value && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, value, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserFormInputInput{target=$target, value=$value, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputToolUseBlock.kt new file mode 100644 index 000000000..ea429dd50 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserFormInputToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Set the value of a form element (input, textarea, select, checkbox). Use a boolean for + * checkboxes, an option value or text for selects. + * + * @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 input(): BetaBrowserFormInputInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("form_input") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserFormInputToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserFormInputToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("form_input") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserFormInputToolUseBlock: BetaBrowserFormInputToolUseBlock) = + apply { + id = betaBrowserFormInputToolUseBlock.id + input = betaBrowserFormInputToolUseBlock.input + name = betaBrowserFormInputToolUseBlock.name + toolsetName = betaBrowserFormInputToolUseBlock.toolsetName + type = betaBrowserFormInputToolUseBlock.type + caller = betaBrowserFormInputToolUseBlock.caller + additionalProperties = + betaBrowserFormInputToolUseBlock.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 } + + /** + * Set the value of a form element (input, textarea, select, checkbox). Use a boolean for + * checkboxes, an option value or text for selects. + */ + fun input(input: BetaBrowserFormInputInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserFormInputInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("form_input") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserFormInputToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserFormInputToolUseBlock = + BetaBrowserFormInputToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserFormInputToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("form_input")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("form_input")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserFormInputToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserFormInputToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputValue.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputValue.kt new file mode 100644 index 000000000..708bf84ef --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputValue.kt @@ -0,0 +1,240 @@ +package com.anthropic.models.beta.messages + +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.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 + +@JsonDeserialize(using = BetaBrowserFormInputValue.Deserializer::class) +@JsonSerialize(using = BetaBrowserFormInputValue.Serializer::class) +class BetaBrowserFormInputValue +private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, +) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + 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 = betaBrowserFormInputValue.accept(new BetaBrowserFormInputValue.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) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + 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(): BetaBrowserFormInputValue = apply { + if (validated) { + return@apply + } + + when { + string != null -> {} + number != null -> {} + bool != null -> {} + else -> throw AnthropicInvalidDataException("Unknown BetaBrowserFormInputValue: $_json") + } + 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 = + when { + string != null -> 1 + number != null -> 1 + bool != null -> 1 + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserFormInputValue && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "BetaBrowserFormInputValue{string=$string}" + number != null -> "BetaBrowserFormInputValue{number=$number}" + bool != null -> "BetaBrowserFormInputValue{bool=$bool}" + _json != null -> "BetaBrowserFormInputValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaBrowserFormInputValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = BetaBrowserFormInputValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = BetaBrowserFormInputValue(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = BetaBrowserFormInputValue(bool = bool) + } + + /** + * An interface that defines how to map each variant of [BetaBrowserFormInputValue] to a value + * of type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [BetaBrowserFormInputValue] to a value of type [T]. + * + * An instance of [BetaBrowserFormInputValue] 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 BetaBrowserFormInputValue: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BetaBrowserFormInputValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaBrowserFormInputValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BetaBrowserFormInputValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BetaBrowserFormInputValue(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BetaBrowserFormInputValue(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from object). + 0 -> BetaBrowserFormInputValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(BetaBrowserFormInputValue::class) { + + override fun serialize( + value: BetaBrowserFormInputValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaBrowserFormInputValue") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextInput.kt new file mode 100644 index 000000000..b94b5613b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextInput.kt @@ -0,0 +1,172 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return the page's visible text content as plain text, prioritizing article content. Suited to + * articles, documentation, and other text-heavy pages. + */ +class BetaBrowserGetPageTextInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserGetPageTextInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserGetPageTextInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserGetPageTextInput: BetaBrowserGetPageTextInput) = apply { + tabId = betaBrowserGetPageTextInput.tabId + additionalProperties = betaBrowserGetPageTextInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserGetPageTextInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaBrowserGetPageTextInput = + BetaBrowserGetPageTextInput(tabId, 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(): BetaBrowserGetPageTextInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserGetPageTextInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserGetPageTextInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextToolUseBlock.kt new file mode 100644 index 000000000..952b3b9d3 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserGetPageTextToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Return the page's visible text content as plain text, prioritizing article content. Suited to + * articles, documentation, and other text-heavy pages. + * + * @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 input(): BetaBrowserGetPageTextInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("get_page_text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserGetPageTextToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserGetPageTextToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("get_page_text") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserGetPageTextToolUseBlock: BetaBrowserGetPageTextToolUseBlock) = + apply { + id = betaBrowserGetPageTextToolUseBlock.id + input = betaBrowserGetPageTextToolUseBlock.input + name = betaBrowserGetPageTextToolUseBlock.name + toolsetName = betaBrowserGetPageTextToolUseBlock.toolsetName + type = betaBrowserGetPageTextToolUseBlock.type + caller = betaBrowserGetPageTextToolUseBlock.caller + additionalProperties = + betaBrowserGetPageTextToolUseBlock.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 } + + /** + * Return the page's visible text content as plain text, prioritizing article content. + * Suited to articles, documentation, and other text-heavy pages. + */ + fun input(input: BetaBrowserGetPageTextInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserGetPageTextInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("get_page_text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserGetPageTextToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserGetPageTextToolUseBlock = + BetaBrowserGetPageTextToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserGetPageTextToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("get_page_text")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("get_page_text")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserGetPageTextToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserGetPageTextToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyInput.kt new file mode 100644 index 000000000..0056fe5b5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyInput.kt @@ -0,0 +1,260 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Hold a key or key chord down for a duration, then release it. Uses the same key names and "+" + * chord syntax as the key action. + */ +class BetaBrowserHoldKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val text: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(duration, text, tabId, mutableMapOf()) + + /** + * Seconds to hold the key down (maximum 30). + * + * @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 duration(): Double = duration.getRequired("duration") + + /** + * The key or chord to hold. + * + * @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 text(): String = text.getRequired("text") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserHoldKeyInput]. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserHoldKeyInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var text: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserHoldKeyInput: BetaBrowserHoldKeyInput) = apply { + duration = betaBrowserHoldKeyInput.duration + text = betaBrowserHoldKeyInput.text + tabId = betaBrowserHoldKeyInput.tabId + additionalProperties = betaBrowserHoldKeyInput.additionalProperties.toMutableMap() + } + + /** Seconds to hold the key down (maximum 30). */ + fun duration(duration: Double) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The key or chord to hold. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserHoldKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserHoldKeyInput = + BetaBrowserHoldKeyInput( + checkRequired("duration", duration), + checkRequired("text", text), + tabId, + 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(): BetaBrowserHoldKeyInput = apply { + if (validated) { + return@apply + } + + duration() + text() + tabId() + 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 (duration.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserHoldKeyInput && + duration == other.duration && + text == other.text && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, text, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserHoldKeyInput{duration=$duration, text=$text, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyToolUseBlock.kt new file mode 100644 index 000000000..d4bfb4227 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserHoldKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Hold a key or key chord down for a duration, then release it. Uses the same key names and "+" + * chord syntax as the key action. + * + * @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 input(): BetaBrowserHoldKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserHoldKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserHoldKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("hold_key") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserHoldKeyToolUseBlock: BetaBrowserHoldKeyToolUseBlock) = apply { + id = betaBrowserHoldKeyToolUseBlock.id + input = betaBrowserHoldKeyToolUseBlock.input + name = betaBrowserHoldKeyToolUseBlock.name + toolsetName = betaBrowserHoldKeyToolUseBlock.toolsetName + type = betaBrowserHoldKeyToolUseBlock.type + caller = betaBrowserHoldKeyToolUseBlock.caller + additionalProperties = + betaBrowserHoldKeyToolUseBlock.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 } + + /** + * Hold a key or key chord down for a duration, then release it. Uses the same key names and + * "+" chord syntax as the key action. + */ + fun input(input: BetaBrowserHoldKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserHoldKeyInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserHoldKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserHoldKeyToolUseBlock = + BetaBrowserHoldKeyToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserHoldKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("hold_key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("hold_key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserHoldKeyToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserHoldKeyToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverInput.kt new file mode 100644 index 000000000..d30bd75d0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverInput.kt @@ -0,0 +1,248 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Move the cursor to a coordinate or element without clicking. */ +class BetaBrowserHoverInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BetaBrowserClickTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserHoverInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserHoverInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BetaBrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserHoverInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserHoverInput: BetaBrowserHoverInput) = apply { + target = betaBrowserHoverInput.target + tabId = betaBrowserHoverInput.tabId + additionalProperties = betaBrowserHoverInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BetaBrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BetaBrowserCoordinateTarget) = + target(BetaBrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BetaBrowserRefTarget) = target(BetaBrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BetaBrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BetaBrowserRefTarget.builder().ref(ref).build()) + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserHoverInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserHoverInput = + BetaBrowserHoverInput( + checkRequired("target", target), + tabId, + 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(): BetaBrowserHoverInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserHoverInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserHoverInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverToolUseBlock.kt new file mode 100644 index 000000000..61f1f21a4 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverToolUseBlock.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserHoverToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Move the cursor to a coordinate or element without clicking. + * + * @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 input(): BetaBrowserHoverInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("hover") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaBrowserHoverToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserHoverToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("hover") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserHoverToolUseBlock: BetaBrowserHoverToolUseBlock) = apply { + id = betaBrowserHoverToolUseBlock.id + input = betaBrowserHoverToolUseBlock.input + name = betaBrowserHoverToolUseBlock.name + toolsetName = betaBrowserHoverToolUseBlock.toolsetName + type = betaBrowserHoverToolUseBlock.type + caller = betaBrowserHoverToolUseBlock.caller + additionalProperties = betaBrowserHoverToolUseBlock.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 } + + /** Move the cursor to a coordinate or element without clicking. */ + fun input(input: BetaBrowserHoverInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserHoverInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("hover") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserHoverToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserHoverToolUseBlock = + BetaBrowserHoverToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserHoverToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("hover")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("hover")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserHoverToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserHoverToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecInput.kt new file mode 100644 index 000000000..da075d599 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecInput.kt @@ -0,0 +1,232 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Execute JavaScript in the page context and return the value of the last expression. The code runs + * with access to the DOM, `window`, and page variables. Write the expression you want evaluated — + * do NOT use `return`. + */ +class BetaBrowserJavascriptExecInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(text, tabId, mutableMapOf()) + + /** + * JavaScript to execute in the page context. + * + * @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 text(): String = text.getRequired("text") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 + * [BetaBrowserJavascriptExecInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserJavascriptExecInput] with the required + * [text] set to the given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BetaBrowserJavascriptExecInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserJavascriptExecInput: BetaBrowserJavascriptExecInput) = apply { + text = betaBrowserJavascriptExecInput.text + tabId = betaBrowserJavascriptExecInput.tabId + additionalProperties = + betaBrowserJavascriptExecInput.additionalProperties.toMutableMap() + } + + /** JavaScript to execute in the page context. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserJavascriptExecInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserJavascriptExecInput = + BetaBrowserJavascriptExecInput( + checkRequired("text", text), + tabId, + 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(): BetaBrowserJavascriptExecInput = apply { + if (validated) { + return@apply + } + + text() + tabId() + 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 (text.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserJavascriptExecInput && + text == other.text && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserJavascriptExecInput{text=$text, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecToolUseBlock.kt new file mode 100644 index 000000000..2e14697ac --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecToolUseBlock.kt @@ -0,0 +1,422 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserJavascriptExecToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Execute JavaScript in the page context and return the value of the last expression. The code + * runs with access to the DOM, `window`, and page variables. Write the expression you want + * evaluated — do NOT use `return`. + * + * @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 input(): BetaBrowserJavascriptExecInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("javascript_exec") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserJavascriptExecToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserJavascriptExecToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("javascript_exec") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaBrowserJavascriptExecToolUseBlock: BetaBrowserJavascriptExecToolUseBlock + ) = apply { + id = betaBrowserJavascriptExecToolUseBlock.id + input = betaBrowserJavascriptExecToolUseBlock.input + name = betaBrowserJavascriptExecToolUseBlock.name + toolsetName = betaBrowserJavascriptExecToolUseBlock.toolsetName + type = betaBrowserJavascriptExecToolUseBlock.type + caller = betaBrowserJavascriptExecToolUseBlock.caller + additionalProperties = + betaBrowserJavascriptExecToolUseBlock.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 } + + /** + * Execute JavaScript in the page context and return the value of the last expression. The + * code runs with access to the DOM, `window`, and page variables. Write the expression you + * want evaluated — do NOT use `return`. + */ + fun input(input: BetaBrowserJavascriptExecInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed + * [BetaBrowserJavascriptExecInput] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("javascript_exec") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserJavascriptExecToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserJavascriptExecToolUseBlock = + BetaBrowserJavascriptExecToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserJavascriptExecToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("javascript_exec")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("javascript_exec")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserJavascriptExecToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserJavascriptExecToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyInput.kt new file mode 100644 index 000000000..cbebd7972 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyInput.kt @@ -0,0 +1,275 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Press a key or key chord. Use "+" to combine modifiers with a key (e.g. "ctrl+a", "cmd+shift+p") + * and space to sequence presses (e.g. "Backspace Backspace Delete"). Common names like "Return", + * "Tab", "Escape", "BackSpace" are supported. + */ +class BetaBrowserKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val repeat: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("repeat") @ExcludeMissing repeat: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(text, repeat, tabId, mutableMapOf()) + + /** + * The key, chord, or space-separated sequence to press. + * + * @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 text(): String = text.getRequired("text") + + /** + * Number of times to repeat. Default 1. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun repeat(): Optional = repeat.getOptional("repeat") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [repeat]. + * + * Unlike [repeat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repeat") @ExcludeMissing fun _repeat(): JsonField = repeat + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserKeyInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserKeyInput] with the required [text] set to + * the given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BetaBrowserKeyInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var repeat: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserKeyInput: BetaBrowserKeyInput) = apply { + text = betaBrowserKeyInput.text + repeat = betaBrowserKeyInput.repeat + tabId = betaBrowserKeyInput.tabId + additionalProperties = betaBrowserKeyInput.additionalProperties.toMutableMap() + } + + /** The key, chord, or space-separated sequence to press. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Number of times to repeat. Default 1. */ + fun repeat(repeat: Long?) = repeat(JsonField.ofNullable(repeat)) + + /** + * Alias for [Builder.repeat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun repeat(repeat: Long) = repeat(repeat as Long?) + + /** Alias for calling [Builder.repeat] with `repeat.orElse(null)`. */ + fun repeat(repeat: Optional) = repeat(repeat.getOrNull()) + + /** + * Sets [Builder.repeat] to an arbitrary JSON value. + * + * You should usually call [Builder.repeat] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repeat(repeat: JsonField) = apply { this.repeat = repeat } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserKeyInput = + BetaBrowserKeyInput( + checkRequired("text", text), + repeat, + tabId, + 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(): BetaBrowserKeyInput = apply { + if (validated) { + return@apply + } + + text() + repeat() + tabId() + 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 (text.asKnown().isPresent) 1 else 0) + + (if (repeat.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserKeyInput && + text == other.text && + repeat == other.repeat && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, repeat, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserKeyInput{text=$text, repeat=$repeat, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyToolUseBlock.kt new file mode 100644 index 000000000..e6754ba0b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Press a key or key chord. Use "+" to combine modifiers with a key (e.g. "ctrl+a", + * "cmd+shift+p") and space to sequence presses (e.g. "Backspace Backspace Delete"). Common + * names like "Return", "Tab", "Escape", "BackSpace" are supported. + * + * @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 input(): BetaBrowserKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaBrowserKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("key") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserKeyToolUseBlock: BetaBrowserKeyToolUseBlock) = apply { + id = betaBrowserKeyToolUseBlock.id + input = betaBrowserKeyToolUseBlock.input + name = betaBrowserKeyToolUseBlock.name + toolsetName = betaBrowserKeyToolUseBlock.toolsetName + type = betaBrowserKeyToolUseBlock.type + caller = betaBrowserKeyToolUseBlock.caller + additionalProperties = betaBrowserKeyToolUseBlock.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 } + + /** + * Press a key or key chord. Use "+" to combine modifiers with a key (e.g. "ctrl+a", + * "cmd+shift+p") and space to sequence presses (e.g. "Backspace Backspace Delete"). Common + * names like "Return", "Tab", "Escape", "BackSpace" are supported. + */ + fun input(input: BetaBrowserKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserKeyInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserKeyToolUseBlock = + BetaBrowserKeyToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserKeyToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserKeyToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragInput.kt new file mode 100644 index 000000000..4a401ee55 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragInput.kt @@ -0,0 +1,274 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Press at `from`, drag to `target`, release. Both must be coordinate targets. */ +class BetaBrowserLeftClickDragInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val from: JsonField, + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("from") + @ExcludeMissing + from: JsonField = JsonMissing.of(), + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(from, target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 from(): BetaBrowserCoordinateTarget = from.getRequired("from") + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BetaBrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [from]. + * + * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 + * [BetaBrowserLeftClickDragInput]. + * + * The following fields are required: + * ```java + * .from() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserLeftClickDragInput]. */ + class Builder internal constructor() { + + private var from: JsonField? = null + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserLeftClickDragInput: BetaBrowserLeftClickDragInput) = apply { + from = betaBrowserLeftClickDragInput.from + target = betaBrowserLeftClickDragInput.target + tabId = betaBrowserLeftClickDragInput.tabId + additionalProperties = betaBrowserLeftClickDragInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun from(from: BetaBrowserCoordinateTarget) = from(JsonField.of(from)) + + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [BetaBrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun from(from: JsonField) = apply { this.from = from } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BetaBrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserLeftClickDragInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .from() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftClickDragInput = + BetaBrowserLeftClickDragInput( + checkRequired("from", from), + checkRequired("target", target), + tabId, + 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(): BetaBrowserLeftClickDragInput = apply { + if (validated) { + return@apply + } + + from().validate() + target().validate() + tabId() + 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 = + (from.asKnown().getOrNull()?.validity() ?: 0) + + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftClickDragInput && + from == other.from && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(from, target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftClickDragInput{from=$from, target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragToolUseBlock.kt new file mode 100644 index 000000000..bd18dd50a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserLeftClickDragToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Press at `from`, drag to `target`, release. Both must be coordinate targets. + * + * @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 input(): BetaBrowserLeftClickDragInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserLeftClickDragToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserLeftClickDragToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click_drag") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaBrowserLeftClickDragToolUseBlock: BetaBrowserLeftClickDragToolUseBlock + ) = apply { + id = betaBrowserLeftClickDragToolUseBlock.id + input = betaBrowserLeftClickDragToolUseBlock.input + name = betaBrowserLeftClickDragToolUseBlock.name + toolsetName = betaBrowserLeftClickDragToolUseBlock.toolsetName + type = betaBrowserLeftClickDragToolUseBlock.type + caller = betaBrowserLeftClickDragToolUseBlock.caller + additionalProperties = + betaBrowserLeftClickDragToolUseBlock.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 } + + /** Press at `from`, drag to `target`, release. Both must be coordinate targets. */ + fun input(input: BetaBrowserLeftClickDragInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserLeftClickDragInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserLeftClickDragToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftClickDragToolUseBlock = + BetaBrowserLeftClickDragToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserLeftClickDragToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_click_drag")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click_drag")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftClickDragToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftClickDragToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickInput.kt new file mode 100644 index 000000000..768bdce83 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickInput.kt @@ -0,0 +1,293 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Left-click at a viewport coordinate or on an element by reference. */ +class BetaBrowserLeftClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BetaBrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserLeftClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserLeftClickInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserLeftClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserLeftClickInput: BetaBrowserLeftClickInput) = apply { + target = betaBrowserLeftClickInput.target + modifiers = betaBrowserLeftClickInput.modifiers + tabId = betaBrowserLeftClickInput.tabId + additionalProperties = betaBrowserLeftClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BetaBrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BetaBrowserCoordinateTarget) = + target(BetaBrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BetaBrowserRefTarget) = target(BetaBrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BetaBrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BetaBrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserLeftClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftClickInput = + BetaBrowserLeftClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BetaBrowserLeftClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickToolUseBlock.kt new file mode 100644 index 000000000..09a88de2e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserLeftClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Left-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BetaBrowserLeftClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserLeftClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserLeftClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserLeftClickToolUseBlock: BetaBrowserLeftClickToolUseBlock) = + apply { + id = betaBrowserLeftClickToolUseBlock.id + input = betaBrowserLeftClickToolUseBlock.input + name = betaBrowserLeftClickToolUseBlock.name + toolsetName = betaBrowserLeftClickToolUseBlock.toolsetName + type = betaBrowserLeftClickToolUseBlock.type + caller = betaBrowserLeftClickToolUseBlock.caller + additionalProperties = + betaBrowserLeftClickToolUseBlock.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 } + + /** Left-click at a viewport coordinate or on an element by reference. */ + fun input(input: BetaBrowserLeftClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserLeftClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserLeftClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftClickToolUseBlock = + BetaBrowserLeftClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserLeftClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownInput.kt new file mode 100644 index 000000000..6da38b500 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownInput.kt @@ -0,0 +1,239 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Press and hold the left mouse button at a viewport coordinate. Pair with left_mouse_up to perform + * a custom drag. + */ +class BetaBrowserLeftMouseDownInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BetaBrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 + * [BetaBrowserLeftMouseDownInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserLeftMouseDownInput] with the required + * [target] set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserCoordinateTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserLeftMouseDownInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserLeftMouseDownInput: BetaBrowserLeftMouseDownInput) = apply { + target = betaBrowserLeftMouseDownInput.target + tabId = betaBrowserLeftMouseDownInput.tabId + additionalProperties = betaBrowserLeftMouseDownInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BetaBrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserLeftMouseDownInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftMouseDownInput = + BetaBrowserLeftMouseDownInput( + checkRequired("target", target), + tabId, + 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(): BetaBrowserLeftMouseDownInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftMouseDownInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftMouseDownInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownToolUseBlock.kt new file mode 100644 index 000000000..b7e3fefa0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownToolUseBlock.kt @@ -0,0 +1,420 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserLeftMouseDownToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Press and hold the left mouse button at a viewport coordinate. Pair with left_mouse_up to + * perform a custom drag. + * + * @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 input(): BetaBrowserLeftMouseDownInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserLeftMouseDownToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserLeftMouseDownToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_down") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaBrowserLeftMouseDownToolUseBlock: BetaBrowserLeftMouseDownToolUseBlock + ) = apply { + id = betaBrowserLeftMouseDownToolUseBlock.id + input = betaBrowserLeftMouseDownToolUseBlock.input + name = betaBrowserLeftMouseDownToolUseBlock.name + toolsetName = betaBrowserLeftMouseDownToolUseBlock.toolsetName + type = betaBrowserLeftMouseDownToolUseBlock.type + caller = betaBrowserLeftMouseDownToolUseBlock.caller + additionalProperties = + betaBrowserLeftMouseDownToolUseBlock.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 } + + /** + * Press and hold the left mouse button at a viewport coordinate. Pair with left_mouse_up to + * perform a custom drag. + */ + fun input(input: BetaBrowserLeftMouseDownInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserLeftMouseDownInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserLeftMouseDownToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftMouseDownToolUseBlock = + BetaBrowserLeftMouseDownToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserLeftMouseDownToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_down")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_down")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftMouseDownToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftMouseDownToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpInput.kt new file mode 100644 index 000000000..489d3f351 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpInput.kt @@ -0,0 +1,235 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Release the left mouse button at a viewport coordinate. */ +class BetaBrowserLeftMouseUpInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BetaBrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserLeftMouseUpInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserLeftMouseUpInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserCoordinateTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserLeftMouseUpInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserLeftMouseUpInput: BetaBrowserLeftMouseUpInput) = apply { + target = betaBrowserLeftMouseUpInput.target + tabId = betaBrowserLeftMouseUpInput.tabId + additionalProperties = betaBrowserLeftMouseUpInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BetaBrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserLeftMouseUpInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftMouseUpInput = + BetaBrowserLeftMouseUpInput( + checkRequired("target", target), + tabId, + 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(): BetaBrowserLeftMouseUpInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftMouseUpInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftMouseUpInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpToolUseBlock.kt new file mode 100644 index 000000000..6c68dce49 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserLeftMouseUpToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Release the left mouse button at a viewport coordinate. + * + * @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 input(): BetaBrowserLeftMouseUpInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserLeftMouseUpToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserLeftMouseUpToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_up") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserLeftMouseUpToolUseBlock: BetaBrowserLeftMouseUpToolUseBlock) = + apply { + id = betaBrowserLeftMouseUpToolUseBlock.id + input = betaBrowserLeftMouseUpToolUseBlock.input + name = betaBrowserLeftMouseUpToolUseBlock.name + toolsetName = betaBrowserLeftMouseUpToolUseBlock.toolsetName + type = betaBrowserLeftMouseUpToolUseBlock.type + caller = betaBrowserLeftMouseUpToolUseBlock.caller + additionalProperties = + betaBrowserLeftMouseUpToolUseBlock.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 } + + /** Release the left mouse button at a viewport coordinate. */ + fun input(input: BetaBrowserLeftMouseUpInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserLeftMouseUpInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserLeftMouseUpToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserLeftMouseUpToolUseBlock = + BetaBrowserLeftMouseUpToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserLeftMouseUpToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_up")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_up")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserLeftMouseUpToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserLeftMouseUpToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsInput.kt new file mode 100644 index 000000000..8d4853ca2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsInput.kt @@ -0,0 +1,122 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** List all open tabs with each tab's tab_id, title, and URL. */ +class BetaBrowserListTabsInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [BetaBrowserListTabsInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserListTabsInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserListTabsInput: BetaBrowserListTabsInput) = apply { + additionalProperties = betaBrowserListTabsInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaBrowserListTabsInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaBrowserListTabsInput = + BetaBrowserListTabsInput(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(): BetaBrowserListTabsInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserListTabsInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BetaBrowserListTabsInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsToolUseBlock.kt new file mode 100644 index 000000000..9057c194b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserListTabsToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * List all open tabs with each tab's tab_id, title, and URL. + * + * @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 input(): BetaBrowserListTabsInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("list_tabs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserListTabsToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserListTabsToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("list_tabs") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserListTabsToolUseBlock: BetaBrowserListTabsToolUseBlock) = + apply { + id = betaBrowserListTabsToolUseBlock.id + input = betaBrowserListTabsToolUseBlock.input + name = betaBrowserListTabsToolUseBlock.name + toolsetName = betaBrowserListTabsToolUseBlock.toolsetName + type = betaBrowserListTabsToolUseBlock.type + caller = betaBrowserListTabsToolUseBlock.caller + additionalProperties = + betaBrowserListTabsToolUseBlock.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 } + + /** List all open tabs with each tab's tab_id, title, and URL. */ + fun input(input: BetaBrowserListTabsInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserListTabsInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("list_tabs") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserListTabsToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserListTabsToolUseBlock = + BetaBrowserListTabsToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserListTabsToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("list_tabs")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("list_tabs")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserListTabsToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserListTabsToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickInput.kt new file mode 100644 index 000000000..169294489 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickInput.kt @@ -0,0 +1,293 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Middle-click at a viewport coordinate or on an element by reference. */ +class BetaBrowserMiddleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BetaBrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserMiddleClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserMiddleClickInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserMiddleClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserMiddleClickInput: BetaBrowserMiddleClickInput) = apply { + target = betaBrowserMiddleClickInput.target + modifiers = betaBrowserMiddleClickInput.modifiers + tabId = betaBrowserMiddleClickInput.tabId + additionalProperties = betaBrowserMiddleClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BetaBrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BetaBrowserCoordinateTarget) = + target(BetaBrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BetaBrowserRefTarget) = target(BetaBrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BetaBrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BetaBrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserMiddleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserMiddleClickInput = + BetaBrowserMiddleClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BetaBrowserMiddleClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserMiddleClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserMiddleClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickToolUseBlock.kt new file mode 100644 index 000000000..abbef0d23 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserMiddleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Middle-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BetaBrowserMiddleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserMiddleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserMiddleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("middle_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserMiddleClickToolUseBlock: BetaBrowserMiddleClickToolUseBlock) = + apply { + id = betaBrowserMiddleClickToolUseBlock.id + input = betaBrowserMiddleClickToolUseBlock.input + name = betaBrowserMiddleClickToolUseBlock.name + toolsetName = betaBrowserMiddleClickToolUseBlock.toolsetName + type = betaBrowserMiddleClickToolUseBlock.type + caller = betaBrowserMiddleClickToolUseBlock.caller + additionalProperties = + betaBrowserMiddleClickToolUseBlock.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 } + + /** Middle-click at a viewport coordinate or on an element by reference. */ + fun input(input: BetaBrowserMiddleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserMiddleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserMiddleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserMiddleClickToolUseBlock = + BetaBrowserMiddleClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserMiddleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("middle_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("middle_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserMiddleClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserMiddleClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveInput.kt new file mode 100644 index 000000000..a73fe3e0b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveInput.kt @@ -0,0 +1,235 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Move the pointer to a viewport coordinate without clicking. */ +class BetaBrowserMouseMoveInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BetaBrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserMouseMoveInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserMouseMoveInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserCoordinateTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserMouseMoveInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserMouseMoveInput: BetaBrowserMouseMoveInput) = apply { + target = betaBrowserMouseMoveInput.target + tabId = betaBrowserMouseMoveInput.tabId + additionalProperties = betaBrowserMouseMoveInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BetaBrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserMouseMoveInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserMouseMoveInput = + BetaBrowserMouseMoveInput( + checkRequired("target", target), + tabId, + 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(): BetaBrowserMouseMoveInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserMouseMoveInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserMouseMoveInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveToolUseBlock.kt new file mode 100644 index 000000000..5fdefcb4d --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserMouseMoveToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Move the pointer to a viewport coordinate without clicking. + * + * @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 input(): BetaBrowserMouseMoveInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserMouseMoveToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserMouseMoveToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("mouse_move") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserMouseMoveToolUseBlock: BetaBrowserMouseMoveToolUseBlock) = + apply { + id = betaBrowserMouseMoveToolUseBlock.id + input = betaBrowserMouseMoveToolUseBlock.input + name = betaBrowserMouseMoveToolUseBlock.name + toolsetName = betaBrowserMouseMoveToolUseBlock.toolsetName + type = betaBrowserMouseMoveToolUseBlock.type + caller = betaBrowserMouseMoveToolUseBlock.caller + additionalProperties = + betaBrowserMouseMoveToolUseBlock.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 } + + /** Move the pointer to a viewport coordinate without clicking. */ + fun input(input: BetaBrowserMouseMoveInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserMouseMoveInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserMouseMoveToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserMouseMoveToolUseBlock = + BetaBrowserMouseMoveToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserMouseMoveToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("mouse_move")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("mouse_move")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserMouseMoveToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserMouseMoveToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateInput.kt new file mode 100644 index 000000000..c5b4f3ede --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateInput.kt @@ -0,0 +1,229 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Navigate to a URL, or go back/forward/reload in history. The protocol may be omitted (defaults to + * https://). + */ +class BetaBrowserNavigateInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val url: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(url, tabId, mutableMapOf()) + + /** + * The URL to navigate to, or "back" / "forward" / "reload" for history navigation. + * + * @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 url(): String = url.getRequired("url") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserNavigateInput]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserNavigateInput] with the required [url] set + * to the given value. + */ + @JvmStatic fun of(url: String) = builder().url(url).build() + } + + /** A builder for [BetaBrowserNavigateInput]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserNavigateInput: BetaBrowserNavigateInput) = apply { + url = betaBrowserNavigateInput.url + tabId = betaBrowserNavigateInput.tabId + additionalProperties = betaBrowserNavigateInput.additionalProperties.toMutableMap() + } + + /** The URL to navigate to, or "back" / "forward" / "reload" for history navigation. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserNavigateInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserNavigateInput = + BetaBrowserNavigateInput( + checkRequired("url", url), + tabId, + 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(): BetaBrowserNavigateInput = apply { + if (validated) { + return@apply + } + + url() + tabId() + 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 (url.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserNavigateInput && + url == other.url && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserNavigateInput{url=$url, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateToolUseBlock.kt new file mode 100644 index 000000000..4bd8231b6 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateToolUseBlock.kt @@ -0,0 +1,417 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserNavigateToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Navigate to a URL, or go back/forward/reload in history. The protocol may be omitted + * (defaults to https://). + * + * @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 input(): BetaBrowserNavigateInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("navigate") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserNavigateToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserNavigateToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("navigate") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserNavigateToolUseBlock: BetaBrowserNavigateToolUseBlock) = + apply { + id = betaBrowserNavigateToolUseBlock.id + input = betaBrowserNavigateToolUseBlock.input + name = betaBrowserNavigateToolUseBlock.name + toolsetName = betaBrowserNavigateToolUseBlock.toolsetName + type = betaBrowserNavigateToolUseBlock.type + caller = betaBrowserNavigateToolUseBlock.caller + additionalProperties = + betaBrowserNavigateToolUseBlock.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 } + + /** + * Navigate to a URL, or go back/forward/reload in history. The protocol may be omitted + * (defaults to https://). + */ + fun input(input: BetaBrowserNavigateInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserNavigateInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("navigate") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserNavigateToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserNavigateToolUseBlock = + BetaBrowserNavigateToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserNavigateToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("navigate")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("navigate")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserNavigateToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserNavigateToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabInput.kt new file mode 100644 index 000000000..9ab871f4b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabInput.kt @@ -0,0 +1,121 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Open a new empty tab and return its tab_id. */ +class BetaBrowserNewTabInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [BetaBrowserNewTabInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserNewTabInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserNewTabInput: BetaBrowserNewTabInput) = apply { + additionalProperties = betaBrowserNewTabInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaBrowserNewTabInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaBrowserNewTabInput = + BetaBrowserNewTabInput(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(): BetaBrowserNewTabInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserNewTabInput && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BetaBrowserNewTabInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabToolUseBlock.kt new file mode 100644 index 000000000..d788e820b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabToolUseBlock.kt @@ -0,0 +1,411 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserNewTabToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Open a new empty tab and return its tab_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 input(): BetaBrowserNewTabInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("new_tab") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserNewTabToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserNewTabToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("new_tab") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserNewTabToolUseBlock: BetaBrowserNewTabToolUseBlock) = apply { + id = betaBrowserNewTabToolUseBlock.id + input = betaBrowserNewTabToolUseBlock.input + name = betaBrowserNewTabToolUseBlock.name + toolsetName = betaBrowserNewTabToolUseBlock.toolsetName + type = betaBrowserNewTabToolUseBlock.type + caller = betaBrowserNewTabToolUseBlock.caller + additionalProperties = betaBrowserNewTabToolUseBlock.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 } + + /** Open a new empty tab and return its tab_id. */ + fun input(input: BetaBrowserNewTabInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserNewTabInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("new_tab") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserNewTabToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserNewTabToolUseBlock = + BetaBrowserNewTabToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserNewTabToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("new_tab")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("new_tab")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserNewTabToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserNewTabToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleInput.kt new file mode 100644 index 000000000..c64f934a5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleInput.kt @@ -0,0 +1,173 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return console output (log entries, errors, warnings) accumulated since the driver attached to + * the tab and since the last read, one line per entry. An empty result does not mean no traffic for + * a tab that predates attach. + */ +class BetaBrowserReadConsoleInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserReadConsoleInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserReadConsoleInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserReadConsoleInput: BetaBrowserReadConsoleInput) = apply { + tabId = betaBrowserReadConsoleInput.tabId + additionalProperties = betaBrowserReadConsoleInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserReadConsoleInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaBrowserReadConsoleInput = + BetaBrowserReadConsoleInput(tabId, 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(): BetaBrowserReadConsoleInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserReadConsoleInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserReadConsoleInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleToolUseBlock.kt new file mode 100644 index 000000000..b297395b0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleToolUseBlock.kt @@ -0,0 +1,421 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserReadConsoleToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Return console output (log entries, errors, warnings) accumulated since the driver attached + * to the tab and since the last read, one line per entry. An empty result does not mean no + * traffic for a tab that predates attach. + * + * @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 input(): BetaBrowserReadConsoleInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("read_console") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserReadConsoleToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserReadConsoleToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("read_console") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserReadConsoleToolUseBlock: BetaBrowserReadConsoleToolUseBlock) = + apply { + id = betaBrowserReadConsoleToolUseBlock.id + input = betaBrowserReadConsoleToolUseBlock.input + name = betaBrowserReadConsoleToolUseBlock.name + toolsetName = betaBrowserReadConsoleToolUseBlock.toolsetName + type = betaBrowserReadConsoleToolUseBlock.type + caller = betaBrowserReadConsoleToolUseBlock.caller + additionalProperties = + betaBrowserReadConsoleToolUseBlock.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 } + + /** + * Return console output (log entries, errors, warnings) accumulated since the driver + * attached to the tab and since the last read, one line per entry. An empty result does not + * mean no traffic for a tab that predates attach. + */ + fun input(input: BetaBrowserReadConsoleInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserReadConsoleInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("read_console") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserReadConsoleToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserReadConsoleToolUseBlock = + BetaBrowserReadConsoleToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserReadConsoleToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("read_console")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("read_console")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserReadConsoleToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserReadConsoleToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkInput.kt new file mode 100644 index 000000000..32c601552 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkInput.kt @@ -0,0 +1,173 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return the network requests (method, URL, status, MIME type, timing) recorded since the driver + * attached to the tab and since the last read, one line per entry. An empty result does not mean no + * traffic for a tab that predates attach. + */ +class BetaBrowserReadNetworkInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserReadNetworkInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserReadNetworkInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserReadNetworkInput: BetaBrowserReadNetworkInput) = apply { + tabId = betaBrowserReadNetworkInput.tabId + additionalProperties = betaBrowserReadNetworkInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserReadNetworkInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaBrowserReadNetworkInput = + BetaBrowserReadNetworkInput(tabId, 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(): BetaBrowserReadNetworkInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserReadNetworkInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserReadNetworkInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkToolUseBlock.kt new file mode 100644 index 000000000..4afd5ed07 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkToolUseBlock.kt @@ -0,0 +1,421 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserReadNetworkToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Return the network requests (method, URL, status, MIME type, timing) recorded since the + * driver attached to the tab and since the last read, one line per entry. An empty result does + * not mean no traffic for a tab that predates attach. + * + * @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 input(): BetaBrowserReadNetworkInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("read_network") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserReadNetworkToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserReadNetworkToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("read_network") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserReadNetworkToolUseBlock: BetaBrowserReadNetworkToolUseBlock) = + apply { + id = betaBrowserReadNetworkToolUseBlock.id + input = betaBrowserReadNetworkToolUseBlock.input + name = betaBrowserReadNetworkToolUseBlock.name + toolsetName = betaBrowserReadNetworkToolUseBlock.toolsetName + type = betaBrowserReadNetworkToolUseBlock.type + caller = betaBrowserReadNetworkToolUseBlock.caller + additionalProperties = + betaBrowserReadNetworkToolUseBlock.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 } + + /** + * Return the network requests (method, URL, status, MIME type, timing) recorded since the + * driver attached to the tab and since the last read, one line per entry. An empty result + * does not mean no traffic for a tab that predates attach. + */ + fun input(input: BetaBrowserReadNetworkInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserReadNetworkInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("read_network") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserReadNetworkToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserReadNetworkToolUseBlock = + BetaBrowserReadNetworkToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserReadNetworkToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("read_network")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("read_network")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserReadNetworkToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserReadNetworkToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageFilter.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageFilter.kt new file mode 100644 index 000000000..d14aba8a4 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageFilter.kt @@ -0,0 +1,153 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserReadPageFilter 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 ALL = BetaBrowserReadPageFilter(JsonField.of("all")) + + @JvmField val INTERACTIVE = BetaBrowserReadPageFilter(JsonField.of("interactive")) + + @JvmStatic + fun of(value: String): BetaBrowserReadPageFilter = + // Intern known values so `==` works + when (value) { + "all" -> ALL + "interactive" -> INTERACTIVE + else -> BetaBrowserReadPageFilter(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): BetaBrowserReadPageFilter = + value.asString().getOrNull()?.let { of(it) } ?: BetaBrowserReadPageFilter(value) + } + + /** An enum containing [BetaBrowserReadPageFilter]'s known values. */ + enum class Known { + ALL, + INTERACTIVE, + } + + /** + * An enum containing [BetaBrowserReadPageFilter]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BetaBrowserReadPageFilter] 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 { + ALL, + INTERACTIVE, + /** + * An enum member indicating that [BetaBrowserReadPageFilter] 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) { + ALL -> Value.ALL + INTERACTIVE -> Value.INTERACTIVE + 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) { + ALL -> Known.ALL + INTERACTIVE -> Known.INTERACTIVE + else -> throw AnthropicInvalidDataException("Unknown BetaBrowserReadPageFilter: $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(): BetaBrowserReadPageFilter = 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 BetaBrowserReadPageFilter && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageInput.kt new file mode 100644 index 000000000..e492344ce --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageInput.kt @@ -0,0 +1,299 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return a structured accessibility tree of the page (or the subtree rooted at `ref`), with element + * references like [ref_7] that can be used as targets on later actions. Output is capped at 50,000 + * characters — narrow with `ref` or a smaller `depth` when exceeded. + */ +class BetaBrowserReadPageInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val depth: JsonField, + private val filter: JsonField, + private val ref: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("depth") @ExcludeMissing depth: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + filter: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(depth, filter, ref, tabId, mutableMapOf()) + + /** + * Maximum tree depth. Default 15. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun depth(): Optional = depth.getOptional("depth") + + /** + * Which elements to include. Omitted: every visible element. "interactive": interactive + * elements only. "all": additionally includes off-viewport elements. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * Element reference to read a subtree from. Omit to read from the page root. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [depth]. + * + * Unlike [depth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("depth") @ExcludeMissing fun _depth(): JsonField = depth + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") + @ExcludeMissing + fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserReadPageInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserReadPageInput]. */ + class Builder internal constructor() { + + private var depth: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserReadPageInput: BetaBrowserReadPageInput) = apply { + depth = betaBrowserReadPageInput.depth + filter = betaBrowserReadPageInput.filter + ref = betaBrowserReadPageInput.ref + tabId = betaBrowserReadPageInput.tabId + additionalProperties = betaBrowserReadPageInput.additionalProperties.toMutableMap() + } + + /** Maximum tree depth. Default 15. */ + fun depth(depth: Long?) = depth(JsonField.ofNullable(depth)) + + /** + * Alias for [Builder.depth]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun depth(depth: Long) = depth(depth as Long?) + + /** Alias for calling [Builder.depth] with `depth.orElse(null)`. */ + fun depth(depth: Optional) = depth(depth.getOrNull()) + + /** + * Sets [Builder.depth] to an arbitrary JSON value. + * + * You should usually call [Builder.depth] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun depth(depth: JsonField) = apply { this.depth = depth } + + /** + * Which elements to include. Omitted: every visible element. "interactive": interactive + * elements only. "all": additionally includes off-viewport elements. + */ + fun filter(filter: BetaBrowserReadPageFilter?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [BetaBrowserReadPageFilter] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** Element reference to read a subtree from. Omit to read from the page root. */ + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserReadPageInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaBrowserReadPageInput = + BetaBrowserReadPageInput(depth, filter, ref, tabId, 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(): BetaBrowserReadPageInput = apply { + if (validated) { + return@apply + } + + depth() + filter().ifPresent { it.validate() } + ref() + tabId() + 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 (depth.asKnown().isPresent) 1 else 0) + + (filter.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserReadPageInput && + depth == other.depth && + filter == other.filter && + ref == other.ref && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(depth, filter, ref, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserReadPageInput{depth=$depth, filter=$filter, ref=$ref, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageToolUseBlock.kt new file mode 100644 index 000000000..351657ff5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserReadPageToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Return a structured accessibility tree of the page (or the subtree rooted at `ref`), with + * element references like [ref_7] that can be used as targets on later actions. Output is + * capped at 50,000 characters — narrow with `ref` or a smaller `depth` when exceeded. + * + * @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 input(): BetaBrowserReadPageInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("read_page") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserReadPageToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserReadPageToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("read_page") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserReadPageToolUseBlock: BetaBrowserReadPageToolUseBlock) = + apply { + id = betaBrowserReadPageToolUseBlock.id + input = betaBrowserReadPageToolUseBlock.input + name = betaBrowserReadPageToolUseBlock.name + toolsetName = betaBrowserReadPageToolUseBlock.toolsetName + type = betaBrowserReadPageToolUseBlock.type + caller = betaBrowserReadPageToolUseBlock.caller + additionalProperties = + betaBrowserReadPageToolUseBlock.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 } + + /** + * Return a structured accessibility tree of the page (or the subtree rooted at `ref`), with + * element references like [ref_7] that can be used as targets on later actions. Output is + * capped at 50,000 characters — narrow with `ref` or a smaller `depth` when exceeded. + */ + fun input(input: BetaBrowserReadPageInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserReadPageInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("read_page") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserReadPageToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserReadPageToolUseBlock = + BetaBrowserReadPageToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserReadPageToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("read_page")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("read_page")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserReadPageToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserReadPageToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRefTarget.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRefTarget.kt new file mode 100644 index 000000000..aa21e76d1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRefTarget.kt @@ -0,0 +1,229 @@ +package com.anthropic.models.beta.messages + +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 + +/** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a major + * re-render. + */ +class BetaBrowserRefTarget +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val ref: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(ref, type, mutableMapOf()) + + /** + * An element reference (e.g. "ref_7") returned by a prior `read_page` or `find` result. + * + * @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 ref(): String = ref.getRequired("ref") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ref") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @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 [BetaBrowserRefTarget]. + * + * The following fields are required: + * ```java + * .ref() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserRefTarget] with the required [ref] set to + * the given value. + */ + @JvmStatic fun of(ref: String) = builder().ref(ref).build() + } + + /** A builder for [BetaBrowserRefTarget]. */ + class Builder internal constructor() { + + private var ref: JsonField? = null + private var type: JsonValue = JsonValue.from("ref") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserRefTarget: BetaBrowserRefTarget) = apply { + ref = betaBrowserRefTarget.ref + type = betaBrowserRefTarget.type + additionalProperties = betaBrowserRefTarget.additionalProperties.toMutableMap() + } + + /** An element reference (e.g. "ref_7") returned by a prior `read_page` or `find` result. */ + fun ref(ref: String) = ref(JsonField.of(ref)) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("ref") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BetaBrowserRefTarget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .ref() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserRefTarget = + BetaBrowserRefTarget( + checkRequired("ref", ref), + 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(): BetaBrowserRefTarget = apply { + if (validated) { + return@apply + } + + ref() + _type().let { + if (it != JsonValue.from("ref")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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 (ref.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("ref")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserRefTarget && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(ref, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserRefTarget{ref=$ref, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickInput.kt new file mode 100644 index 000000000..28cc10949 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickInput.kt @@ -0,0 +1,293 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Right-click at a viewport coordinate or on an element by reference. */ +class BetaBrowserRightClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BetaBrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserRightClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserRightClickInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserRightClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserRightClickInput: BetaBrowserRightClickInput) = apply { + target = betaBrowserRightClickInput.target + modifiers = betaBrowserRightClickInput.modifiers + tabId = betaBrowserRightClickInput.tabId + additionalProperties = betaBrowserRightClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BetaBrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BetaBrowserCoordinateTarget) = + target(BetaBrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BetaBrowserRefTarget) = target(BetaBrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BetaBrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BetaBrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserRightClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserRightClickInput = + BetaBrowserRightClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BetaBrowserRightClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserRightClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserRightClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickToolUseBlock.kt new file mode 100644 index 000000000..db053a388 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserRightClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Right-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BetaBrowserRightClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserRightClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserRightClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("right_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserRightClickToolUseBlock: BetaBrowserRightClickToolUseBlock) = + apply { + id = betaBrowserRightClickToolUseBlock.id + input = betaBrowserRightClickToolUseBlock.input + name = betaBrowserRightClickToolUseBlock.name + toolsetName = betaBrowserRightClickToolUseBlock.toolsetName + type = betaBrowserRightClickToolUseBlock.type + caller = betaBrowserRightClickToolUseBlock.caller + additionalProperties = + betaBrowserRightClickToolUseBlock.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 } + + /** Right-click at a viewport coordinate or on an element by reference. */ + fun input(input: BetaBrowserRightClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserRightClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserRightClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserRightClickToolUseBlock = + BetaBrowserRightClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserRightClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("right_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("right_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserRightClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserRightClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotInput.kt new file mode 100644 index 000000000..241b0f51c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotInput.kt @@ -0,0 +1,169 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Capture the current browser viewport. */ +class BetaBrowserScreenshotInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserScreenshotInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserScreenshotInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserScreenshotInput: BetaBrowserScreenshotInput) = apply { + tabId = betaBrowserScreenshotInput.tabId + additionalProperties = betaBrowserScreenshotInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserScreenshotInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaBrowserScreenshotInput = + BetaBrowserScreenshotInput(tabId, 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(): BetaBrowserScreenshotInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserScreenshotInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserScreenshotInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotToolUseBlock.kt new file mode 100644 index 000000000..9b9d726a5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserScreenshotToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Capture the current browser viewport. + * + * @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 input(): BetaBrowserScreenshotInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserScreenshotToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserScreenshotToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("screenshot") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserScreenshotToolUseBlock: BetaBrowserScreenshotToolUseBlock) = + apply { + id = betaBrowserScreenshotToolUseBlock.id + input = betaBrowserScreenshotToolUseBlock.input + name = betaBrowserScreenshotToolUseBlock.name + toolsetName = betaBrowserScreenshotToolUseBlock.toolsetName + type = betaBrowserScreenshotToolUseBlock.type + caller = betaBrowserScreenshotToolUseBlock.caller + additionalProperties = + betaBrowserScreenshotToolUseBlock.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 } + + /** Capture the current browser viewport. */ + fun input(input: BetaBrowserScreenshotInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserScreenshotInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserScreenshotToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserScreenshotToolUseBlock = + BetaBrowserScreenshotToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserScreenshotToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("screenshot")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("screenshot")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserScreenshotToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserScreenshotToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollDirection.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollDirection.kt new file mode 100644 index 000000000..773157306 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollDirection.kt @@ -0,0 +1,169 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserScrollDirection 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 UP = BetaBrowserScrollDirection(JsonField.of("up")) + + @JvmField val DOWN = BetaBrowserScrollDirection(JsonField.of("down")) + + @JvmField val LEFT = BetaBrowserScrollDirection(JsonField.of("left")) + + @JvmField val RIGHT = BetaBrowserScrollDirection(JsonField.of("right")) + + @JvmStatic + fun of(value: String): BetaBrowserScrollDirection = + // Intern known values so `==` works + when (value) { + "up" -> UP + "down" -> DOWN + "left" -> LEFT + "right" -> RIGHT + else -> BetaBrowserScrollDirection(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): BetaBrowserScrollDirection = + value.asString().getOrNull()?.let { of(it) } ?: BetaBrowserScrollDirection(value) + } + + /** An enum containing [BetaBrowserScrollDirection]'s known values. */ + enum class Known { + UP, + DOWN, + LEFT, + RIGHT, + } + + /** + * An enum containing [BetaBrowserScrollDirection]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BetaBrowserScrollDirection] 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 { + UP, + DOWN, + LEFT, + RIGHT, + /** + * An enum member indicating that [BetaBrowserScrollDirection] 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) { + UP -> Value.UP + DOWN -> Value.DOWN + LEFT -> Value.LEFT + RIGHT -> Value.RIGHT + 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) { + UP -> Known.UP + DOWN -> Known.DOWN + LEFT -> Known.LEFT + RIGHT -> Known.RIGHT + else -> + throw AnthropicInvalidDataException("Unknown BetaBrowserScrollDirection: $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(): BetaBrowserScrollDirection = 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 BetaBrowserScrollDirection && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollInput.kt new file mode 100644 index 000000000..caf8fc0f2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollInput.kt @@ -0,0 +1,323 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Scroll at a viewport position. `target` must be a coordinate target. */ +class BetaBrowserScrollInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val scrollDirection: JsonField, + private val target: JsonField, + private val scrollAmount: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("scroll_direction") + @ExcludeMissing + scrollDirection: JsonField = JsonMissing.of(), + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("scroll_amount") + @ExcludeMissing + scrollAmount: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(scrollDirection, target, scrollAmount, tabId, 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 scrollDirection(): BetaBrowserScrollDirection = + scrollDirection.getRequired("scroll_direction") + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BetaBrowserCoordinateTarget = target.getRequired("target") + + /** + * Scroll-wheel notches (1–10). Default 3. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun scrollAmount(): Optional = scrollAmount.getOptional("scroll_amount") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [scrollDirection]. + * + * Unlike [scrollDirection], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_direction") + @ExcludeMissing + fun _scrollDirection(): JsonField = scrollDirection + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [scrollAmount]. + * + * Unlike [scrollAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_amount") + @ExcludeMissing + fun _scrollAmount(): JsonField = scrollAmount + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserScrollInput]. + * + * The following fields are required: + * ```java + * .scrollDirection() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserScrollInput]. */ + class Builder internal constructor() { + + private var scrollDirection: JsonField? = null + private var target: JsonField? = null + private var scrollAmount: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserScrollInput: BetaBrowserScrollInput) = apply { + scrollDirection = betaBrowserScrollInput.scrollDirection + target = betaBrowserScrollInput.target + scrollAmount = betaBrowserScrollInput.scrollAmount + tabId = betaBrowserScrollInput.tabId + additionalProperties = betaBrowserScrollInput.additionalProperties.toMutableMap() + } + + fun scrollDirection(scrollDirection: BetaBrowserScrollDirection) = + scrollDirection(JsonField.of(scrollDirection)) + + /** + * Sets [Builder.scrollDirection] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollDirection] with a well-typed + * [BetaBrowserScrollDirection] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scrollDirection(scrollDirection: JsonField) = apply { + this.scrollDirection = scrollDirection + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BetaBrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Scroll-wheel notches (1–10). Default 3. */ + fun scrollAmount(scrollAmount: Long?) = scrollAmount(JsonField.ofNullable(scrollAmount)) + + /** + * Alias for [Builder.scrollAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun scrollAmount(scrollAmount: Long) = scrollAmount(scrollAmount as Long?) + + /** Alias for calling [Builder.scrollAmount] with `scrollAmount.orElse(null)`. */ + fun scrollAmount(scrollAmount: Optional) = scrollAmount(scrollAmount.getOrNull()) + + /** + * Sets [Builder.scrollAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scrollAmount(scrollAmount: JsonField) = apply { this.scrollAmount = scrollAmount } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserScrollInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scrollDirection() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserScrollInput = + BetaBrowserScrollInput( + checkRequired("scrollDirection", scrollDirection), + checkRequired("target", target), + scrollAmount, + tabId, + 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(): BetaBrowserScrollInput = apply { + if (validated) { + return@apply + } + + scrollDirection().validate() + target().validate() + scrollAmount() + tabId() + 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 = + (scrollDirection.asKnown().getOrNull()?.validity() ?: 0) + + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (scrollAmount.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserScrollInput && + scrollDirection == other.scrollDirection && + target == other.target && + scrollAmount == other.scrollAmount && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scrollDirection, target, scrollAmount, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserScrollInput{scrollDirection=$scrollDirection, target=$target, scrollAmount=$scrollAmount, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToInput.kt new file mode 100644 index 000000000..9fdfbbf5a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToInput.kt @@ -0,0 +1,235 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Scroll an element into view. */ +class BetaBrowserScrollToInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + * + * @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 target(): BetaBrowserRefTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserScrollToInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserScrollToInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserRefTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserScrollToInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserScrollToInput: BetaBrowserScrollToInput) = apply { + target = betaBrowserScrollToInput.target + tabId = betaBrowserScrollToInput.tabId + additionalProperties = betaBrowserScrollToInput.additionalProperties.toMutableMap() + } + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun target(target: BetaBrowserRefTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserRefTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserScrollToInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserScrollToInput = + BetaBrowserScrollToInput( + checkRequired("target", target), + tabId, + 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(): BetaBrowserScrollToInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserScrollToInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserScrollToInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToToolUseBlock.kt new file mode 100644 index 000000000..6e53a0708 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserScrollToToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Scroll an element into view. + * + * @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 input(): BetaBrowserScrollToInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("scroll_to") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserScrollToToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserScrollToToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("scroll_to") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserScrollToToolUseBlock: BetaBrowserScrollToToolUseBlock) = + apply { + id = betaBrowserScrollToToolUseBlock.id + input = betaBrowserScrollToToolUseBlock.input + name = betaBrowserScrollToToolUseBlock.name + toolsetName = betaBrowserScrollToToolUseBlock.toolsetName + type = betaBrowserScrollToToolUseBlock.type + caller = betaBrowserScrollToToolUseBlock.caller + additionalProperties = + betaBrowserScrollToToolUseBlock.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 } + + /** Scroll an element into view. */ + fun input(input: BetaBrowserScrollToInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserScrollToInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scroll_to") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserScrollToToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserScrollToToolUseBlock = + BetaBrowserScrollToToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserScrollToToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("scroll_to")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("scroll_to")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserScrollToToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserScrollToToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToolUseBlock.kt new file mode 100644 index 000000000..c5e4dea9c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToolUseBlock.kt @@ -0,0 +1,411 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserScrollToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Scroll at a viewport position. `target` must be a coordinate target. + * + * @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 input(): BetaBrowserScrollInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserScrollToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserScrollToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("scroll") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserScrollToolUseBlock: BetaBrowserScrollToolUseBlock) = apply { + id = betaBrowserScrollToolUseBlock.id + input = betaBrowserScrollToolUseBlock.input + name = betaBrowserScrollToolUseBlock.name + toolsetName = betaBrowserScrollToolUseBlock.toolsetName + type = betaBrowserScrollToolUseBlock.type + caller = betaBrowserScrollToolUseBlock.caller + additionalProperties = betaBrowserScrollToolUseBlock.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 } + + /** Scroll at a viewport position. `target` must be a coordinate target. */ + fun input(input: BetaBrowserScrollInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserScrollInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserScrollToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserScrollToolUseBlock = + BetaBrowserScrollToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserScrollToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("scroll")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("scroll")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserScrollToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserScrollToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabInput.kt new file mode 100644 index 000000000..2cf9abb87 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabInput.kt @@ -0,0 +1,189 @@ +package com.anthropic.models.beta.messages + +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 + +/** + * Make the tab with the given tab_id the active tab — the tab that actions without a tab_id apply + * to. + */ +class BetaBrowserSwitchTabInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * The tab to switch to. + * + * @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 tabId(): String = tabId.getRequired("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserSwitchTabInput]. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserSwitchTabInput] with the required [tabId] + * set to the given value. + */ + @JvmStatic fun of(tabId: String) = builder().tabId(tabId).build() + } + + /** A builder for [BetaBrowserSwitchTabInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserSwitchTabInput: BetaBrowserSwitchTabInput) = apply { + tabId = betaBrowserSwitchTabInput.tabId + additionalProperties = betaBrowserSwitchTabInput.additionalProperties.toMutableMap() + } + + /** The tab to switch to. */ + fun tabId(tabId: String) = tabId(JsonField.of(tabId)) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserSwitchTabInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserSwitchTabInput = + BetaBrowserSwitchTabInput( + checkRequired("tabId", tabId), + 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(): BetaBrowserSwitchTabInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserSwitchTabInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserSwitchTabInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabToolUseBlock.kt new file mode 100644 index 000000000..5c7d3ff00 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserSwitchTabToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Make the tab with the given tab_id the active tab — the tab that actions without a tab_id + * apply to. + * + * @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 input(): BetaBrowserSwitchTabInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("switch_tab") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserSwitchTabToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserSwitchTabToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("switch_tab") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserSwitchTabToolUseBlock: BetaBrowserSwitchTabToolUseBlock) = + apply { + id = betaBrowserSwitchTabToolUseBlock.id + input = betaBrowserSwitchTabToolUseBlock.input + name = betaBrowserSwitchTabToolUseBlock.name + toolsetName = betaBrowserSwitchTabToolUseBlock.toolsetName + type = betaBrowserSwitchTabToolUseBlock.type + caller = betaBrowserSwitchTabToolUseBlock.caller + additionalProperties = + betaBrowserSwitchTabToolUseBlock.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 } + + /** + * Make the tab with the given tab_id the active tab — the tab that actions without a tab_id + * apply to. + */ + fun input(input: BetaBrowserSwitchTabInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserSwitchTabInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("switch_tab") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserSwitchTabToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserSwitchTabToolUseBlock = + BetaBrowserSwitchTabToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserSwitchTabToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("switch_tab")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("switch_tab")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserSwitchTabToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserSwitchTabToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserToolUseBlock.kt new file mode 100644 index 000000000..f6a297b01 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserToolUseBlock.kt @@ -0,0 +1,1447 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.core.getProperty +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = BetaBrowserToolUseBlock.Deserializer::class) +@JsonSerialize(using = BetaBrowserToolUseBlock.Serializer::class) +class BetaBrowserToolUseBlock +private constructor( + private val navigate: BetaBrowserNavigateToolUseBlock? = null, + private val listTabs: BetaBrowserListTabsToolUseBlock? = null, + private val newTab: BetaBrowserNewTabToolUseBlock? = null, + private val switchTab: BetaBrowserSwitchTabToolUseBlock? = null, + private val closeTab: BetaBrowserCloseTabToolUseBlock? = null, + private val readPage: BetaBrowserReadPageToolUseBlock? = null, + private val getPageText: BetaBrowserGetPageTextToolUseBlock? = null, + private val readConsole: BetaBrowserReadConsoleToolUseBlock? = null, + private val readNetwork: BetaBrowserReadNetworkToolUseBlock? = null, + private val find: BetaBrowserFindToolUseBlock? = null, + private val formInput: BetaBrowserFormInputToolUseBlock? = null, + private val fileUpload: BetaBrowserFileUploadToolUseBlock? = null, + private val scrollTo: BetaBrowserScrollToToolUseBlock? = null, + private val screenshot: BetaBrowserScreenshotToolUseBlock? = null, + private val zoom: BetaBrowserZoomToolUseBlock? = null, + private val leftClick: BetaBrowserLeftClickToolUseBlock? = null, + private val rightClick: BetaBrowserRightClickToolUseBlock? = null, + private val middleClick: BetaBrowserMiddleClickToolUseBlock? = null, + private val doubleClick: BetaBrowserDoubleClickToolUseBlock? = null, + private val tripleClick: BetaBrowserTripleClickToolUseBlock? = null, + private val hover: BetaBrowserHoverToolUseBlock? = null, + private val leftClickDrag: BetaBrowserLeftClickDragToolUseBlock? = null, + private val leftMouseDown: BetaBrowserLeftMouseDownToolUseBlock? = null, + private val leftMouseUp: BetaBrowserLeftMouseUpToolUseBlock? = null, + private val mouseMove: BetaBrowserMouseMoveToolUseBlock? = null, + private val scroll: BetaBrowserScrollToolUseBlock? = null, + private val type: BetaBrowserTypeToolUseBlock? = null, + private val key: BetaBrowserKeyToolUseBlock? = null, + private val holdKey: BetaBrowserHoldKeyToolUseBlock? = null, + private val wait: BetaBrowserWaitToolUseBlock? = null, + private val javascriptExec: BetaBrowserJavascriptExecToolUseBlock? = null, + private val _json: JsonValue? = null, +) { + + fun name(): Name = + when { + navigate != null -> Name.NAVIGATE + listTabs != null -> Name.LIST_TABS + newTab != null -> Name.NEW_TAB + switchTab != null -> Name.SWITCH_TAB + closeTab != null -> Name.CLOSE_TAB + readPage != null -> Name.READ_PAGE + getPageText != null -> Name.GET_PAGE_TEXT + readConsole != null -> Name.READ_CONSOLE + readNetwork != null -> Name.READ_NETWORK + find != null -> Name.FIND + formInput != null -> Name.FORM_INPUT + fileUpload != null -> Name.FILE_UPLOAD + scrollTo != null -> Name.SCROLL_TO + screenshot != null -> Name.SCREENSHOT + zoom != null -> Name.ZOOM + leftClick != null -> Name.LEFT_CLICK + rightClick != null -> Name.RIGHT_CLICK + middleClick != null -> Name.MIDDLE_CLICK + doubleClick != null -> Name.DOUBLE_CLICK + tripleClick != null -> Name.TRIPLE_CLICK + hover != null -> Name.HOVER + leftClickDrag != null -> Name.LEFT_CLICK_DRAG + leftMouseDown != null -> Name.LEFT_MOUSE_DOWN + leftMouseUp != null -> Name.LEFT_MOUSE_UP + mouseMove != null -> Name.MOUSE_MOVE + scroll != null -> Name.SCROLL + type != null -> Name.TYPE + key != null -> Name.KEY + holdKey != null -> Name.HOLD_KEY + wait != null -> Name.WAIT + javascriptExec != null -> Name.JAVASCRIPT_EXEC + else -> Name.of(_json?.asObject()?.getOrNull()?.get("name") ?: JsonMissing.of()) + } + + fun id(): String = + when { + navigate != null -> navigate.id() + listTabs != null -> listTabs.id() + newTab != null -> newTab.id() + switchTab != null -> switchTab.id() + closeTab != null -> closeTab.id() + readPage != null -> readPage.id() + getPageText != null -> getPageText.id() + readConsole != null -> readConsole.id() + readNetwork != null -> readNetwork.id() + find != null -> find.id() + formInput != null -> formInput.id() + fileUpload != null -> fileUpload.id() + scrollTo != null -> scrollTo.id() + screenshot != null -> screenshot.id() + zoom != null -> zoom.id() + leftClick != null -> leftClick.id() + rightClick != null -> rightClick.id() + middleClick != null -> middleClick.id() + doubleClick != null -> doubleClick.id() + tripleClick != null -> tripleClick.id() + hover != null -> hover.id() + leftClickDrag != null -> leftClickDrag.id() + leftMouseDown != null -> leftMouseDown.id() + leftMouseUp != null -> leftMouseUp.id() + mouseMove != null -> mouseMove.id() + scroll != null -> scroll.id() + type != null -> type.id() + key != null -> key.id() + holdKey != null -> holdKey.id() + wait != null -> wait.id() + javascriptExec != null -> javascriptExec.id() + else -> _json.getProperty("id").getRequired("id") + } + + fun caller(): Optional = + when { + navigate != null -> navigate.caller() + listTabs != null -> listTabs.caller() + newTab != null -> newTab.caller() + switchTab != null -> switchTab.caller() + closeTab != null -> closeTab.caller() + readPage != null -> readPage.caller() + getPageText != null -> getPageText.caller() + readConsole != null -> readConsole.caller() + readNetwork != null -> readNetwork.caller() + find != null -> find.caller() + formInput != null -> formInput.caller() + fileUpload != null -> fileUpload.caller() + scrollTo != null -> scrollTo.caller() + screenshot != null -> screenshot.caller() + zoom != null -> zoom.caller() + leftClick != null -> leftClick.caller() + rightClick != null -> rightClick.caller() + middleClick != null -> middleClick.caller() + doubleClick != null -> doubleClick.caller() + tripleClick != null -> tripleClick.caller() + hover != null -> hover.caller() + leftClickDrag != null -> leftClickDrag.caller() + leftMouseDown != null -> leftMouseDown.caller() + leftMouseUp != null -> leftMouseUp.caller() + mouseMove != null -> mouseMove.caller() + scroll != null -> scroll.caller() + type != null -> type.caller() + key != null -> key.caller() + holdKey != null -> holdKey.caller() + wait != null -> wait.caller() + javascriptExec != null -> javascriptExec.caller() + else -> _json.getProperty("caller").asKnown() + } + + fun navigate(): Optional = Optional.ofNullable(navigate) + + fun listTabs(): Optional = Optional.ofNullable(listTabs) + + fun newTab(): Optional = Optional.ofNullable(newTab) + + fun switchTab(): Optional = Optional.ofNullable(switchTab) + + fun closeTab(): Optional = Optional.ofNullable(closeTab) + + fun readPage(): Optional = Optional.ofNullable(readPage) + + fun getPageText(): Optional = + Optional.ofNullable(getPageText) + + fun readConsole(): Optional = + Optional.ofNullable(readConsole) + + fun readNetwork(): Optional = + Optional.ofNullable(readNetwork) + + fun find(): Optional = Optional.ofNullable(find) + + fun formInput(): Optional = Optional.ofNullable(formInput) + + fun fileUpload(): Optional = Optional.ofNullable(fileUpload) + + fun scrollTo(): Optional = Optional.ofNullable(scrollTo) + + fun screenshot(): Optional = Optional.ofNullable(screenshot) + + fun zoom(): Optional = Optional.ofNullable(zoom) + + fun leftClick(): Optional = Optional.ofNullable(leftClick) + + fun rightClick(): Optional = Optional.ofNullable(rightClick) + + fun middleClick(): Optional = + Optional.ofNullable(middleClick) + + fun doubleClick(): Optional = + Optional.ofNullable(doubleClick) + + fun tripleClick(): Optional = + Optional.ofNullable(tripleClick) + + fun hover(): Optional = Optional.ofNullable(hover) + + fun leftClickDrag(): Optional = + Optional.ofNullable(leftClickDrag) + + fun leftMouseDown(): Optional = + Optional.ofNullable(leftMouseDown) + + fun leftMouseUp(): Optional = + Optional.ofNullable(leftMouseUp) + + fun mouseMove(): Optional = Optional.ofNullable(mouseMove) + + fun scroll(): Optional = Optional.ofNullable(scroll) + + fun type(): Optional = Optional.ofNullable(type) + + fun key(): Optional = Optional.ofNullable(key) + + fun holdKey(): Optional = Optional.ofNullable(holdKey) + + fun wait(): Optional = Optional.ofNullable(wait) + + fun javascriptExec(): Optional = + Optional.ofNullable(javascriptExec) + + fun isNavigate(): Boolean = navigate != null + + fun isListTabs(): Boolean = listTabs != null + + fun isNewTab(): Boolean = newTab != null + + fun isSwitchTab(): Boolean = switchTab != null + + fun isCloseTab(): Boolean = closeTab != null + + fun isReadPage(): Boolean = readPage != null + + fun isGetPageText(): Boolean = getPageText != null + + fun isReadConsole(): Boolean = readConsole != null + + fun isReadNetwork(): Boolean = readNetwork != null + + fun isFind(): Boolean = find != null + + fun isFormInput(): Boolean = formInput != null + + fun isFileUpload(): Boolean = fileUpload != null + + fun isScrollTo(): Boolean = scrollTo != null + + fun isScreenshot(): Boolean = screenshot != null + + fun isZoom(): Boolean = zoom != null + + fun isLeftClick(): Boolean = leftClick != null + + fun isRightClick(): Boolean = rightClick != null + + fun isMiddleClick(): Boolean = middleClick != null + + fun isDoubleClick(): Boolean = doubleClick != null + + fun isTripleClick(): Boolean = tripleClick != null + + fun isHover(): Boolean = hover != null + + fun isLeftClickDrag(): Boolean = leftClickDrag != null + + fun isLeftMouseDown(): Boolean = leftMouseDown != null + + fun isLeftMouseUp(): Boolean = leftMouseUp != null + + fun isMouseMove(): Boolean = mouseMove != null + + fun isScroll(): Boolean = scroll != null + + fun isType(): Boolean = type != null + + fun isKey(): Boolean = key != null + + fun isHoldKey(): Boolean = holdKey != null + + fun isWait(): Boolean = wait != null + + fun isJavascriptExec(): Boolean = javascriptExec != null + + fun asNavigate(): BetaBrowserNavigateToolUseBlock = navigate.getOrThrow("navigate") + + fun asListTabs(): BetaBrowserListTabsToolUseBlock = listTabs.getOrThrow("listTabs") + + fun asNewTab(): BetaBrowserNewTabToolUseBlock = newTab.getOrThrow("newTab") + + fun asSwitchTab(): BetaBrowserSwitchTabToolUseBlock = switchTab.getOrThrow("switchTab") + + fun asCloseTab(): BetaBrowserCloseTabToolUseBlock = closeTab.getOrThrow("closeTab") + + fun asReadPage(): BetaBrowserReadPageToolUseBlock = readPage.getOrThrow("readPage") + + fun asGetPageText(): BetaBrowserGetPageTextToolUseBlock = getPageText.getOrThrow("getPageText") + + fun asReadConsole(): BetaBrowserReadConsoleToolUseBlock = readConsole.getOrThrow("readConsole") + + fun asReadNetwork(): BetaBrowserReadNetworkToolUseBlock = readNetwork.getOrThrow("readNetwork") + + fun asFind(): BetaBrowserFindToolUseBlock = find.getOrThrow("find") + + fun asFormInput(): BetaBrowserFormInputToolUseBlock = formInput.getOrThrow("formInput") + + fun asFileUpload(): BetaBrowserFileUploadToolUseBlock = fileUpload.getOrThrow("fileUpload") + + fun asScrollTo(): BetaBrowserScrollToToolUseBlock = scrollTo.getOrThrow("scrollTo") + + fun asScreenshot(): BetaBrowserScreenshotToolUseBlock = screenshot.getOrThrow("screenshot") + + fun asZoom(): BetaBrowserZoomToolUseBlock = zoom.getOrThrow("zoom") + + fun asLeftClick(): BetaBrowserLeftClickToolUseBlock = leftClick.getOrThrow("leftClick") + + fun asRightClick(): BetaBrowserRightClickToolUseBlock = rightClick.getOrThrow("rightClick") + + fun asMiddleClick(): BetaBrowserMiddleClickToolUseBlock = middleClick.getOrThrow("middleClick") + + fun asDoubleClick(): BetaBrowserDoubleClickToolUseBlock = doubleClick.getOrThrow("doubleClick") + + fun asTripleClick(): BetaBrowserTripleClickToolUseBlock = tripleClick.getOrThrow("tripleClick") + + fun asHover(): BetaBrowserHoverToolUseBlock = hover.getOrThrow("hover") + + fun asLeftClickDrag(): BetaBrowserLeftClickDragToolUseBlock = + leftClickDrag.getOrThrow("leftClickDrag") + + fun asLeftMouseDown(): BetaBrowserLeftMouseDownToolUseBlock = + leftMouseDown.getOrThrow("leftMouseDown") + + fun asLeftMouseUp(): BetaBrowserLeftMouseUpToolUseBlock = leftMouseUp.getOrThrow("leftMouseUp") + + fun asMouseMove(): BetaBrowserMouseMoveToolUseBlock = mouseMove.getOrThrow("mouseMove") + + fun asScroll(): BetaBrowserScrollToolUseBlock = scroll.getOrThrow("scroll") + + fun asType(): BetaBrowserTypeToolUseBlock = type.getOrThrow("type") + + fun asKey(): BetaBrowserKeyToolUseBlock = key.getOrThrow("key") + + fun asHoldKey(): BetaBrowserHoldKeyToolUseBlock = holdKey.getOrThrow("holdKey") + + fun asWait(): BetaBrowserWaitToolUseBlock = wait.getOrThrow("wait") + + fun asJavascriptExec(): BetaBrowserJavascriptExecToolUseBlock = + javascriptExec.getOrThrow("javascriptExec") + + 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 = betaBrowserToolUseBlock.accept(new BetaBrowserToolUseBlock.Visitor>() { + * @Override + * public Optional visitNavigate(BetaBrowserNavigateToolUseBlock navigate) { + * return Optional.of(navigate.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 { + navigate != null -> visitor.visitNavigate(navigate) + listTabs != null -> visitor.visitListTabs(listTabs) + newTab != null -> visitor.visitNewTab(newTab) + switchTab != null -> visitor.visitSwitchTab(switchTab) + closeTab != null -> visitor.visitCloseTab(closeTab) + readPage != null -> visitor.visitReadPage(readPage) + getPageText != null -> visitor.visitGetPageText(getPageText) + readConsole != null -> visitor.visitReadConsole(readConsole) + readNetwork != null -> visitor.visitReadNetwork(readNetwork) + find != null -> visitor.visitFind(find) + formInput != null -> visitor.visitFormInput(formInput) + fileUpload != null -> visitor.visitFileUpload(fileUpload) + scrollTo != null -> visitor.visitScrollTo(scrollTo) + screenshot != null -> visitor.visitScreenshot(screenshot) + zoom != null -> visitor.visitZoom(zoom) + leftClick != null -> visitor.visitLeftClick(leftClick) + rightClick != null -> visitor.visitRightClick(rightClick) + middleClick != null -> visitor.visitMiddleClick(middleClick) + doubleClick != null -> visitor.visitDoubleClick(doubleClick) + tripleClick != null -> visitor.visitTripleClick(tripleClick) + hover != null -> visitor.visitHover(hover) + leftClickDrag != null -> visitor.visitLeftClickDrag(leftClickDrag) + leftMouseDown != null -> visitor.visitLeftMouseDown(leftMouseDown) + leftMouseUp != null -> visitor.visitLeftMouseUp(leftMouseUp) + mouseMove != null -> visitor.visitMouseMove(mouseMove) + scroll != null -> visitor.visitScroll(scroll) + type != null -> visitor.visitType(type) + key != null -> visitor.visitKey(key) + holdKey != null -> visitor.visitHoldKey(holdKey) + wait != null -> visitor.visitWait(wait) + javascriptExec != null -> visitor.visitJavascriptExec(javascriptExec) + 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(): BetaBrowserToolUseBlock = apply { + if (validated) { + return@apply + } + + when { + navigate != null -> navigate.validate() + listTabs != null -> listTabs.validate() + newTab != null -> newTab.validate() + switchTab != null -> switchTab.validate() + closeTab != null -> closeTab.validate() + readPage != null -> readPage.validate() + getPageText != null -> getPageText.validate() + readConsole != null -> readConsole.validate() + readNetwork != null -> readNetwork.validate() + find != null -> find.validate() + formInput != null -> formInput.validate() + fileUpload != null -> fileUpload.validate() + scrollTo != null -> scrollTo.validate() + screenshot != null -> screenshot.validate() + zoom != null -> zoom.validate() + leftClick != null -> leftClick.validate() + rightClick != null -> rightClick.validate() + middleClick != null -> middleClick.validate() + doubleClick != null -> doubleClick.validate() + tripleClick != null -> tripleClick.validate() + hover != null -> hover.validate() + leftClickDrag != null -> leftClickDrag.validate() + leftMouseDown != null -> leftMouseDown.validate() + leftMouseUp != null -> leftMouseUp.validate() + mouseMove != null -> mouseMove.validate() + scroll != null -> scroll.validate() + type != null -> type.validate() + key != null -> key.validate() + holdKey != null -> holdKey.validate() + wait != null -> wait.validate() + javascriptExec != null -> javascriptExec.validate() + else -> throw AnthropicInvalidDataException("Unknown BetaBrowserToolUseBlock: $_json") + } + 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 = + when { + navigate != null -> navigate.validity() + listTabs != null -> listTabs.validity() + newTab != null -> newTab.validity() + switchTab != null -> switchTab.validity() + closeTab != null -> closeTab.validity() + readPage != null -> readPage.validity() + getPageText != null -> getPageText.validity() + readConsole != null -> readConsole.validity() + readNetwork != null -> readNetwork.validity() + find != null -> find.validity() + formInput != null -> formInput.validity() + fileUpload != null -> fileUpload.validity() + scrollTo != null -> scrollTo.validity() + screenshot != null -> screenshot.validity() + zoom != null -> zoom.validity() + leftClick != null -> leftClick.validity() + rightClick != null -> rightClick.validity() + middleClick != null -> middleClick.validity() + doubleClick != null -> doubleClick.validity() + tripleClick != null -> tripleClick.validity() + hover != null -> hover.validity() + leftClickDrag != null -> leftClickDrag.validity() + leftMouseDown != null -> leftMouseDown.validity() + leftMouseUp != null -> leftMouseUp.validity() + mouseMove != null -> mouseMove.validity() + scroll != null -> scroll.validity() + type != null -> type.validity() + key != null -> key.validity() + holdKey != null -> holdKey.validity() + wait != null -> wait.validity() + javascriptExec != null -> javascriptExec.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserToolUseBlock && + navigate == other.navigate && + listTabs == other.listTabs && + newTab == other.newTab && + switchTab == other.switchTab && + closeTab == other.closeTab && + readPage == other.readPage && + getPageText == other.getPageText && + readConsole == other.readConsole && + readNetwork == other.readNetwork && + find == other.find && + formInput == other.formInput && + fileUpload == other.fileUpload && + scrollTo == other.scrollTo && + screenshot == other.screenshot && + zoom == other.zoom && + leftClick == other.leftClick && + rightClick == other.rightClick && + middleClick == other.middleClick && + doubleClick == other.doubleClick && + tripleClick == other.tripleClick && + hover == other.hover && + leftClickDrag == other.leftClickDrag && + leftMouseDown == other.leftMouseDown && + leftMouseUp == other.leftMouseUp && + mouseMove == other.mouseMove && + scroll == other.scroll && + type == other.type && + key == other.key && + holdKey == other.holdKey && + wait == other.wait && + javascriptExec == other.javascriptExec + } + + override fun hashCode(): Int = + Objects.hash( + navigate, + listTabs, + newTab, + switchTab, + closeTab, + readPage, + getPageText, + readConsole, + readNetwork, + find, + formInput, + fileUpload, + scrollTo, + screenshot, + zoom, + leftClick, + rightClick, + middleClick, + doubleClick, + tripleClick, + hover, + leftClickDrag, + leftMouseDown, + leftMouseUp, + mouseMove, + scroll, + type, + key, + holdKey, + wait, + javascriptExec, + ) + + override fun toString(): String = + when { + navigate != null -> "BetaBrowserToolUseBlock{navigate=$navigate}" + listTabs != null -> "BetaBrowserToolUseBlock{listTabs=$listTabs}" + newTab != null -> "BetaBrowserToolUseBlock{newTab=$newTab}" + switchTab != null -> "BetaBrowserToolUseBlock{switchTab=$switchTab}" + closeTab != null -> "BetaBrowserToolUseBlock{closeTab=$closeTab}" + readPage != null -> "BetaBrowserToolUseBlock{readPage=$readPage}" + getPageText != null -> "BetaBrowserToolUseBlock{getPageText=$getPageText}" + readConsole != null -> "BetaBrowserToolUseBlock{readConsole=$readConsole}" + readNetwork != null -> "BetaBrowserToolUseBlock{readNetwork=$readNetwork}" + find != null -> "BetaBrowserToolUseBlock{find=$find}" + formInput != null -> "BetaBrowserToolUseBlock{formInput=$formInput}" + fileUpload != null -> "BetaBrowserToolUseBlock{fileUpload=$fileUpload}" + scrollTo != null -> "BetaBrowserToolUseBlock{scrollTo=$scrollTo}" + screenshot != null -> "BetaBrowserToolUseBlock{screenshot=$screenshot}" + zoom != null -> "BetaBrowserToolUseBlock{zoom=$zoom}" + leftClick != null -> "BetaBrowserToolUseBlock{leftClick=$leftClick}" + rightClick != null -> "BetaBrowserToolUseBlock{rightClick=$rightClick}" + middleClick != null -> "BetaBrowserToolUseBlock{middleClick=$middleClick}" + doubleClick != null -> "BetaBrowserToolUseBlock{doubleClick=$doubleClick}" + tripleClick != null -> "BetaBrowserToolUseBlock{tripleClick=$tripleClick}" + hover != null -> "BetaBrowserToolUseBlock{hover=$hover}" + leftClickDrag != null -> "BetaBrowserToolUseBlock{leftClickDrag=$leftClickDrag}" + leftMouseDown != null -> "BetaBrowserToolUseBlock{leftMouseDown=$leftMouseDown}" + leftMouseUp != null -> "BetaBrowserToolUseBlock{leftMouseUp=$leftMouseUp}" + mouseMove != null -> "BetaBrowserToolUseBlock{mouseMove=$mouseMove}" + scroll != null -> "BetaBrowserToolUseBlock{scroll=$scroll}" + type != null -> "BetaBrowserToolUseBlock{type=$type}" + key != null -> "BetaBrowserToolUseBlock{key=$key}" + holdKey != null -> "BetaBrowserToolUseBlock{holdKey=$holdKey}" + wait != null -> "BetaBrowserToolUseBlock{wait=$wait}" + javascriptExec != null -> "BetaBrowserToolUseBlock{javascriptExec=$javascriptExec}" + _json != null -> "BetaBrowserToolUseBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaBrowserToolUseBlock") + } + + companion object { + + @JvmStatic + fun ofNavigate(navigate: BetaBrowserNavigateToolUseBlock) = + BetaBrowserToolUseBlock(navigate = navigate) + + @JvmStatic + fun ofListTabs(listTabs: BetaBrowserListTabsToolUseBlock) = + BetaBrowserToolUseBlock(listTabs = listTabs) + + @JvmStatic + fun ofNewTab(newTab: BetaBrowserNewTabToolUseBlock) = + BetaBrowserToolUseBlock(newTab = newTab) + + @JvmStatic + fun ofSwitchTab(switchTab: BetaBrowserSwitchTabToolUseBlock) = + BetaBrowserToolUseBlock(switchTab = switchTab) + + @JvmStatic + fun ofCloseTab(closeTab: BetaBrowserCloseTabToolUseBlock) = + BetaBrowserToolUseBlock(closeTab = closeTab) + + @JvmStatic + fun ofReadPage(readPage: BetaBrowserReadPageToolUseBlock) = + BetaBrowserToolUseBlock(readPage = readPage) + + @JvmStatic + fun ofGetPageText(getPageText: BetaBrowserGetPageTextToolUseBlock) = + BetaBrowserToolUseBlock(getPageText = getPageText) + + @JvmStatic + fun ofReadConsole(readConsole: BetaBrowserReadConsoleToolUseBlock) = + BetaBrowserToolUseBlock(readConsole = readConsole) + + @JvmStatic + fun ofReadNetwork(readNetwork: BetaBrowserReadNetworkToolUseBlock) = + BetaBrowserToolUseBlock(readNetwork = readNetwork) + + @JvmStatic + fun ofFind(find: BetaBrowserFindToolUseBlock) = BetaBrowserToolUseBlock(find = find) + + @JvmStatic + fun ofFormInput(formInput: BetaBrowserFormInputToolUseBlock) = + BetaBrowserToolUseBlock(formInput = formInput) + + @JvmStatic + fun ofFileUpload(fileUpload: BetaBrowserFileUploadToolUseBlock) = + BetaBrowserToolUseBlock(fileUpload = fileUpload) + + @JvmStatic + fun ofScrollTo(scrollTo: BetaBrowserScrollToToolUseBlock) = + BetaBrowserToolUseBlock(scrollTo = scrollTo) + + @JvmStatic + fun ofScreenshot(screenshot: BetaBrowserScreenshotToolUseBlock) = + BetaBrowserToolUseBlock(screenshot = screenshot) + + @JvmStatic + fun ofZoom(zoom: BetaBrowserZoomToolUseBlock) = BetaBrowserToolUseBlock(zoom = zoom) + + @JvmStatic + fun ofLeftClick(leftClick: BetaBrowserLeftClickToolUseBlock) = + BetaBrowserToolUseBlock(leftClick = leftClick) + + @JvmStatic + fun ofRightClick(rightClick: BetaBrowserRightClickToolUseBlock) = + BetaBrowserToolUseBlock(rightClick = rightClick) + + @JvmStatic + fun ofMiddleClick(middleClick: BetaBrowserMiddleClickToolUseBlock) = + BetaBrowserToolUseBlock(middleClick = middleClick) + + @JvmStatic + fun ofDoubleClick(doubleClick: BetaBrowserDoubleClickToolUseBlock) = + BetaBrowserToolUseBlock(doubleClick = doubleClick) + + @JvmStatic + fun ofTripleClick(tripleClick: BetaBrowserTripleClickToolUseBlock) = + BetaBrowserToolUseBlock(tripleClick = tripleClick) + + @JvmStatic + fun ofHover(hover: BetaBrowserHoverToolUseBlock) = BetaBrowserToolUseBlock(hover = hover) + + @JvmStatic + fun ofLeftClickDrag(leftClickDrag: BetaBrowserLeftClickDragToolUseBlock) = + BetaBrowserToolUseBlock(leftClickDrag = leftClickDrag) + + @JvmStatic + fun ofLeftMouseDown(leftMouseDown: BetaBrowserLeftMouseDownToolUseBlock) = + BetaBrowserToolUseBlock(leftMouseDown = leftMouseDown) + + @JvmStatic + fun ofLeftMouseUp(leftMouseUp: BetaBrowserLeftMouseUpToolUseBlock) = + BetaBrowserToolUseBlock(leftMouseUp = leftMouseUp) + + @JvmStatic + fun ofMouseMove(mouseMove: BetaBrowserMouseMoveToolUseBlock) = + BetaBrowserToolUseBlock(mouseMove = mouseMove) + + @JvmStatic + fun ofScroll(scroll: BetaBrowserScrollToolUseBlock) = + BetaBrowserToolUseBlock(scroll = scroll) + + @JvmStatic + fun ofType(type: BetaBrowserTypeToolUseBlock) = BetaBrowserToolUseBlock(type = type) + + @JvmStatic fun ofKey(key: BetaBrowserKeyToolUseBlock) = BetaBrowserToolUseBlock(key = key) + + @JvmStatic + fun ofHoldKey(holdKey: BetaBrowserHoldKeyToolUseBlock) = + BetaBrowserToolUseBlock(holdKey = holdKey) + + @JvmStatic + fun ofWait(wait: BetaBrowserWaitToolUseBlock) = BetaBrowserToolUseBlock(wait = wait) + + @JvmStatic + fun ofJavascriptExec(javascriptExec: BetaBrowserJavascriptExecToolUseBlock) = + BetaBrowserToolUseBlock(javascriptExec = javascriptExec) + } + + /** + * An interface that defines how to map each variant of [BetaBrowserToolUseBlock] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNavigate(navigate: BetaBrowserNavigateToolUseBlock): T + + fun visitListTabs(listTabs: BetaBrowserListTabsToolUseBlock): T + + fun visitNewTab(newTab: BetaBrowserNewTabToolUseBlock): T + + fun visitSwitchTab(switchTab: BetaBrowserSwitchTabToolUseBlock): T + + fun visitCloseTab(closeTab: BetaBrowserCloseTabToolUseBlock): T + + fun visitReadPage(readPage: BetaBrowserReadPageToolUseBlock): T + + fun visitGetPageText(getPageText: BetaBrowserGetPageTextToolUseBlock): T + + fun visitReadConsole(readConsole: BetaBrowserReadConsoleToolUseBlock): T + + fun visitReadNetwork(readNetwork: BetaBrowserReadNetworkToolUseBlock): T + + fun visitFind(find: BetaBrowserFindToolUseBlock): T + + fun visitFormInput(formInput: BetaBrowserFormInputToolUseBlock): T + + fun visitFileUpload(fileUpload: BetaBrowserFileUploadToolUseBlock): T + + fun visitScrollTo(scrollTo: BetaBrowserScrollToToolUseBlock): T + + fun visitScreenshot(screenshot: BetaBrowserScreenshotToolUseBlock): T + + fun visitZoom(zoom: BetaBrowserZoomToolUseBlock): T + + fun visitLeftClick(leftClick: BetaBrowserLeftClickToolUseBlock): T + + fun visitRightClick(rightClick: BetaBrowserRightClickToolUseBlock): T + + fun visitMiddleClick(middleClick: BetaBrowserMiddleClickToolUseBlock): T + + fun visitDoubleClick(doubleClick: BetaBrowserDoubleClickToolUseBlock): T + + fun visitTripleClick(tripleClick: BetaBrowserTripleClickToolUseBlock): T + + fun visitHover(hover: BetaBrowserHoverToolUseBlock): T + + fun visitLeftClickDrag(leftClickDrag: BetaBrowserLeftClickDragToolUseBlock): T + + fun visitLeftMouseDown(leftMouseDown: BetaBrowserLeftMouseDownToolUseBlock): T + + fun visitLeftMouseUp(leftMouseUp: BetaBrowserLeftMouseUpToolUseBlock): T + + fun visitMouseMove(mouseMove: BetaBrowserMouseMoveToolUseBlock): T + + fun visitScroll(scroll: BetaBrowserScrollToolUseBlock): T + + fun visitType(type: BetaBrowserTypeToolUseBlock): T + + fun visitKey(key: BetaBrowserKeyToolUseBlock): T + + fun visitHoldKey(holdKey: BetaBrowserHoldKeyToolUseBlock): T + + fun visitWait(wait: BetaBrowserWaitToolUseBlock): T + + fun visitJavascriptExec(javascriptExec: BetaBrowserJavascriptExecToolUseBlock): T + + /** + * Maps an unknown variant of [BetaBrowserToolUseBlock] to a value of type [T]. + * + * An instance of [BetaBrowserToolUseBlock] 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 BetaBrowserToolUseBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BetaBrowserToolUseBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaBrowserToolUseBlock { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "navigate" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(navigate = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "list_tabs" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(listTabs = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "new_tab" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(newTab = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "switch_tab" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(switchTab = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "close_tab" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(closeTab = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "read_page" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(readPage = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "get_page_text" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(getPageText = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "read_console" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(readConsole = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "read_network" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(readNetwork = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "find" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(find = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "form_input" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(formInput = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "file_upload" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(fileUpload = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "scroll_to" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(scrollTo = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "screenshot" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(screenshot = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "zoom" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(zoom = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "left_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(leftClick = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "right_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(rightClick = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "middle_click" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(middleClick = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "double_click" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(doubleClick = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "triple_click" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(tripleClick = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "hover" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(hover = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "left_click_drag" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(leftClickDrag = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "left_mouse_down" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(leftMouseDown = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "left_mouse_up" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(leftMouseUp = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "mouse_move" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(mouseMove = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "scroll" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(scroll = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "type" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(type = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "key" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BetaBrowserToolUseBlock(key = it, _json = json) + } ?: BetaBrowserToolUseBlock(_json = json) + } + "hold_key" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(holdKey = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "wait" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaBrowserToolUseBlock(wait = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + "javascript_exec" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaBrowserToolUseBlock(javascriptExec = it, _json = json) } + ?: BetaBrowserToolUseBlock(_json = json) + } + } + + return BetaBrowserToolUseBlock(_json = json) + } + } + + internal class Serializer : + BaseSerializer(BetaBrowserToolUseBlock::class) { + + override fun serialize( + value: BetaBrowserToolUseBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.navigate != null -> generator.writeObject(value.navigate) + value.listTabs != null -> generator.writeObject(value.listTabs) + value.newTab != null -> generator.writeObject(value.newTab) + value.switchTab != null -> generator.writeObject(value.switchTab) + value.closeTab != null -> generator.writeObject(value.closeTab) + value.readPage != null -> generator.writeObject(value.readPage) + value.getPageText != null -> generator.writeObject(value.getPageText) + value.readConsole != null -> generator.writeObject(value.readConsole) + value.readNetwork != null -> generator.writeObject(value.readNetwork) + value.find != null -> generator.writeObject(value.find) + value.formInput != null -> generator.writeObject(value.formInput) + value.fileUpload != null -> generator.writeObject(value.fileUpload) + value.scrollTo != null -> generator.writeObject(value.scrollTo) + value.screenshot != null -> generator.writeObject(value.screenshot) + value.zoom != null -> generator.writeObject(value.zoom) + value.leftClick != null -> generator.writeObject(value.leftClick) + value.rightClick != null -> generator.writeObject(value.rightClick) + value.middleClick != null -> generator.writeObject(value.middleClick) + value.doubleClick != null -> generator.writeObject(value.doubleClick) + value.tripleClick != null -> generator.writeObject(value.tripleClick) + value.hover != null -> generator.writeObject(value.hover) + value.leftClickDrag != null -> generator.writeObject(value.leftClickDrag) + value.leftMouseDown != null -> generator.writeObject(value.leftMouseDown) + value.leftMouseUp != null -> generator.writeObject(value.leftMouseUp) + value.mouseMove != null -> generator.writeObject(value.mouseMove) + value.scroll != null -> generator.writeObject(value.scroll) + value.type != null -> generator.writeObject(value.type) + value.key != null -> generator.writeObject(value.key) + value.holdKey != null -> generator.writeObject(value.holdKey) + value.wait != null -> generator.writeObject(value.wait) + value.javascriptExec != null -> generator.writeObject(value.javascriptExec) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaBrowserToolUseBlock") + } + } + } + + class Name 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 NAVIGATE = Name(JsonField.of("navigate")) + + @JvmField val LIST_TABS = Name(JsonField.of("list_tabs")) + + @JvmField val NEW_TAB = Name(JsonField.of("new_tab")) + + @JvmField val SWITCH_TAB = Name(JsonField.of("switch_tab")) + + @JvmField val CLOSE_TAB = Name(JsonField.of("close_tab")) + + @JvmField val READ_PAGE = Name(JsonField.of("read_page")) + + @JvmField val GET_PAGE_TEXT = Name(JsonField.of("get_page_text")) + + @JvmField val READ_CONSOLE = Name(JsonField.of("read_console")) + + @JvmField val READ_NETWORK = Name(JsonField.of("read_network")) + + @JvmField val FIND = Name(JsonField.of("find")) + + @JvmField val FORM_INPUT = Name(JsonField.of("form_input")) + + @JvmField val FILE_UPLOAD = Name(JsonField.of("file_upload")) + + @JvmField val SCROLL_TO = Name(JsonField.of("scroll_to")) + + @JvmField val SCREENSHOT = Name(JsonField.of("screenshot")) + + @JvmField val ZOOM = Name(JsonField.of("zoom")) + + @JvmField val LEFT_CLICK = Name(JsonField.of("left_click")) + + @JvmField val RIGHT_CLICK = Name(JsonField.of("right_click")) + + @JvmField val MIDDLE_CLICK = Name(JsonField.of("middle_click")) + + @JvmField val DOUBLE_CLICK = Name(JsonField.of("double_click")) + + @JvmField val TRIPLE_CLICK = Name(JsonField.of("triple_click")) + + @JvmField val HOVER = Name(JsonField.of("hover")) + + @JvmField val LEFT_CLICK_DRAG = Name(JsonField.of("left_click_drag")) + + @JvmField val LEFT_MOUSE_DOWN = Name(JsonField.of("left_mouse_down")) + + @JvmField val LEFT_MOUSE_UP = Name(JsonField.of("left_mouse_up")) + + @JvmField val MOUSE_MOVE = Name(JsonField.of("mouse_move")) + + @JvmField val SCROLL = Name(JsonField.of("scroll")) + + @JvmField val TYPE = Name(JsonField.of("type")) + + @JvmField val KEY = Name(JsonField.of("key")) + + @JvmField val HOLD_KEY = Name(JsonField.of("hold_key")) + + @JvmField val WAIT = Name(JsonField.of("wait")) + + @JvmField val JAVASCRIPT_EXEC = Name(JsonField.of("javascript_exec")) + + @JvmStatic + fun of(value: String): Name = + // Intern known values so `==` works + when (value) { + "navigate" -> NAVIGATE + "list_tabs" -> LIST_TABS + "new_tab" -> NEW_TAB + "switch_tab" -> SWITCH_TAB + "close_tab" -> CLOSE_TAB + "read_page" -> READ_PAGE + "get_page_text" -> GET_PAGE_TEXT + "read_console" -> READ_CONSOLE + "read_network" -> READ_NETWORK + "find" -> FIND + "form_input" -> FORM_INPUT + "file_upload" -> FILE_UPLOAD + "scroll_to" -> SCROLL_TO + "screenshot" -> SCREENSHOT + "zoom" -> ZOOM + "left_click" -> LEFT_CLICK + "right_click" -> RIGHT_CLICK + "middle_click" -> MIDDLE_CLICK + "double_click" -> DOUBLE_CLICK + "triple_click" -> TRIPLE_CLICK + "hover" -> HOVER + "left_click_drag" -> LEFT_CLICK_DRAG + "left_mouse_down" -> LEFT_MOUSE_DOWN + "left_mouse_up" -> LEFT_MOUSE_UP + "mouse_move" -> MOUSE_MOVE + "scroll" -> SCROLL + "type" -> TYPE + "key" -> KEY + "hold_key" -> HOLD_KEY + "wait" -> WAIT + "javascript_exec" -> JAVASCRIPT_EXEC + else -> Name(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Name = + value.asString().getOrNull()?.let { of(it) } ?: Name(value) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + NAVIGATE, + LIST_TABS, + NEW_TAB, + SWITCH_TAB, + CLOSE_TAB, + READ_PAGE, + GET_PAGE_TEXT, + READ_CONSOLE, + READ_NETWORK, + FIND, + FORM_INPUT, + FILE_UPLOAD, + SCROLL_TO, + SCREENSHOT, + ZOOM, + LEFT_CLICK, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + HOVER, + LEFT_CLICK_DRAG, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + MOUSE_MOVE, + SCROLL, + TYPE, + KEY, + HOLD_KEY, + WAIT, + JAVASCRIPT_EXEC, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] 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 { + NAVIGATE, + LIST_TABS, + NEW_TAB, + SWITCH_TAB, + CLOSE_TAB, + READ_PAGE, + GET_PAGE_TEXT, + READ_CONSOLE, + READ_NETWORK, + FIND, + FORM_INPUT, + FILE_UPLOAD, + SCROLL_TO, + SCREENSHOT, + ZOOM, + LEFT_CLICK, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + HOVER, + LEFT_CLICK_DRAG, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + MOUSE_MOVE, + SCROLL, + TYPE, + KEY, + HOLD_KEY, + WAIT, + JAVASCRIPT_EXEC, + /** An enum member indicating that [Name] 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) { + NAVIGATE -> Value.NAVIGATE + LIST_TABS -> Value.LIST_TABS + NEW_TAB -> Value.NEW_TAB + SWITCH_TAB -> Value.SWITCH_TAB + CLOSE_TAB -> Value.CLOSE_TAB + READ_PAGE -> Value.READ_PAGE + GET_PAGE_TEXT -> Value.GET_PAGE_TEXT + READ_CONSOLE -> Value.READ_CONSOLE + READ_NETWORK -> Value.READ_NETWORK + FIND -> Value.FIND + FORM_INPUT -> Value.FORM_INPUT + FILE_UPLOAD -> Value.FILE_UPLOAD + SCROLL_TO -> Value.SCROLL_TO + SCREENSHOT -> Value.SCREENSHOT + ZOOM -> Value.ZOOM + LEFT_CLICK -> Value.LEFT_CLICK + RIGHT_CLICK -> Value.RIGHT_CLICK + MIDDLE_CLICK -> Value.MIDDLE_CLICK + DOUBLE_CLICK -> Value.DOUBLE_CLICK + TRIPLE_CLICK -> Value.TRIPLE_CLICK + HOVER -> Value.HOVER + LEFT_CLICK_DRAG -> Value.LEFT_CLICK_DRAG + LEFT_MOUSE_DOWN -> Value.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Value.LEFT_MOUSE_UP + MOUSE_MOVE -> Value.MOUSE_MOVE + SCROLL -> Value.SCROLL + TYPE -> Value.TYPE + KEY -> Value.KEY + HOLD_KEY -> Value.HOLD_KEY + WAIT -> Value.WAIT + JAVASCRIPT_EXEC -> Value.JAVASCRIPT_EXEC + 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) { + NAVIGATE -> Known.NAVIGATE + LIST_TABS -> Known.LIST_TABS + NEW_TAB -> Known.NEW_TAB + SWITCH_TAB -> Known.SWITCH_TAB + CLOSE_TAB -> Known.CLOSE_TAB + READ_PAGE -> Known.READ_PAGE + GET_PAGE_TEXT -> Known.GET_PAGE_TEXT + READ_CONSOLE -> Known.READ_CONSOLE + READ_NETWORK -> Known.READ_NETWORK + FIND -> Known.FIND + FORM_INPUT -> Known.FORM_INPUT + FILE_UPLOAD -> Known.FILE_UPLOAD + SCROLL_TO -> Known.SCROLL_TO + SCREENSHOT -> Known.SCREENSHOT + ZOOM -> Known.ZOOM + LEFT_CLICK -> Known.LEFT_CLICK + RIGHT_CLICK -> Known.RIGHT_CLICK + MIDDLE_CLICK -> Known.MIDDLE_CLICK + DOUBLE_CLICK -> Known.DOUBLE_CLICK + TRIPLE_CLICK -> Known.TRIPLE_CLICK + HOVER -> Known.HOVER + LEFT_CLICK_DRAG -> Known.LEFT_CLICK_DRAG + LEFT_MOUSE_DOWN -> Known.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Known.LEFT_MOUSE_UP + MOUSE_MOVE -> Known.MOUSE_MOVE + SCROLL -> Known.SCROLL + TYPE -> Known.TYPE + KEY -> Known.KEY + HOLD_KEY -> Known.HOLD_KEY + WAIT -> Known.WAIT + JAVASCRIPT_EXEC -> Known.JAVASCRIPT_EXEC + else -> throw AnthropicInvalidDataException("Unknown Name: $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(): Name = 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 Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickInput.kt new file mode 100644 index 000000000..bfc38eea4 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickInput.kt @@ -0,0 +1,296 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triple left-click at a viewport coordinate or on an element by reference (typically selects a + * line or paragraph). + */ +class BetaBrowserTripleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BetaBrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserTripleClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserTripleClickInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BetaBrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BetaBrowserTripleClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserTripleClickInput: BetaBrowserTripleClickInput) = apply { + target = betaBrowserTripleClickInput.target + modifiers = betaBrowserTripleClickInput.modifiers + tabId = betaBrowserTripleClickInput.tabId + additionalProperties = betaBrowserTripleClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BetaBrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BetaBrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BetaBrowserCoordinateTarget) = + target(BetaBrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BetaBrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BetaBrowserRefTarget) = target(BetaBrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BetaBrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BetaBrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserTripleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserTripleClickInput = + BetaBrowserTripleClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BetaBrowserTripleClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserTripleClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserTripleClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickToolUseBlock.kt new file mode 100644 index 000000000..dfc0522a6 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserTripleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Triple left-click at a viewport coordinate or on an element by reference (typically selects a + * line or paragraph). + * + * @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 input(): BetaBrowserTripleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaBrowserTripleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserTripleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("triple_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserTripleClickToolUseBlock: BetaBrowserTripleClickToolUseBlock) = + apply { + id = betaBrowserTripleClickToolUseBlock.id + input = betaBrowserTripleClickToolUseBlock.input + name = betaBrowserTripleClickToolUseBlock.name + toolsetName = betaBrowserTripleClickToolUseBlock.toolsetName + type = betaBrowserTripleClickToolUseBlock.type + caller = betaBrowserTripleClickToolUseBlock.caller + additionalProperties = + betaBrowserTripleClickToolUseBlock.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 } + + /** + * Triple left-click at a viewport coordinate or on an element by reference (typically + * selects a line or paragraph). + */ + fun input(input: BetaBrowserTripleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserTripleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserTripleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserTripleClickToolUseBlock = + BetaBrowserTripleClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserTripleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("triple_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("triple_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserTripleClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserTripleClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeInput.kt new file mode 100644 index 000000000..1d506a182 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeInput.kt @@ -0,0 +1,226 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Type a literal string at the current focus. */ +class BetaBrowserTypeInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(text, tabId, mutableMapOf()) + + /** + * The text to 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 text(): String = text.getRequired("text") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserTypeInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserTypeInput] with the required [text] set to + * the given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BetaBrowserTypeInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserTypeInput: BetaBrowserTypeInput) = apply { + text = betaBrowserTypeInput.text + tabId = betaBrowserTypeInput.tabId + additionalProperties = betaBrowserTypeInput.additionalProperties.toMutableMap() + } + + /** The text to type. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserTypeInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserTypeInput = + BetaBrowserTypeInput( + checkRequired("text", text), + tabId, + 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(): BetaBrowserTypeInput = apply { + if (validated) { + return@apply + } + + text() + tabId() + 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 (text.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserTypeInput && + text == other.text && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserTypeInput{text=$text, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeToolUseBlock.kt new file mode 100644 index 000000000..e50a424ff --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeToolUseBlock.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserTypeToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Type a literal string at the current focus. + * + * @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 input(): BetaBrowserTypeInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("type") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaBrowserTypeToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserTypeToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("type") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserTypeToolUseBlock: BetaBrowserTypeToolUseBlock) = apply { + id = betaBrowserTypeToolUseBlock.id + input = betaBrowserTypeToolUseBlock.input + name = betaBrowserTypeToolUseBlock.name + toolsetName = betaBrowserTypeToolUseBlock.toolsetName + type = betaBrowserTypeToolUseBlock.type + caller = betaBrowserTypeToolUseBlock.caller + additionalProperties = betaBrowserTypeToolUseBlock.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 } + + /** Type a literal string at the current focus. */ + fun input(input: BetaBrowserTypeInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserTypeInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("type") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserTypeToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserTypeToolUseBlock = + BetaBrowserTypeToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserTypeToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("type")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("type")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserTypeToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserTypeToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitInput.kt new file mode 100644 index 000000000..b17718198 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitInput.kt @@ -0,0 +1,226 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Pause for the given duration. */ +class BetaBrowserWaitInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(duration, tabId, mutableMapOf()) + + /** + * Seconds to wait (maximum 30). + * + * @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 duration(): Double = duration.getRequired("duration") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserWaitInput]. + * + * The following fields are required: + * ```java + * .duration() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserWaitInput] with the required [duration] set + * to the given value. + */ + @JvmStatic fun of(duration: Double) = builder().duration(duration).build() + } + + /** A builder for [BetaBrowserWaitInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserWaitInput: BetaBrowserWaitInput) = apply { + duration = betaBrowserWaitInput.duration + tabId = betaBrowserWaitInput.tabId + additionalProperties = betaBrowserWaitInput.additionalProperties.toMutableMap() + } + + /** Seconds to wait (maximum 30). */ + fun duration(duration: Double) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserWaitInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserWaitInput = + BetaBrowserWaitInput( + checkRequired("duration", duration), + tabId, + 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(): BetaBrowserWaitInput = apply { + if (validated) { + return@apply + } + + duration() + tabId() + 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 (duration.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserWaitInput && + duration == other.duration && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserWaitInput{duration=$duration, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitToolUseBlock.kt new file mode 100644 index 000000000..d0baa3022 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitToolUseBlock.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserWaitToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Pause for the given duration. + * + * @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 input(): BetaBrowserWaitInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("wait") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaBrowserWaitToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserWaitToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("wait") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserWaitToolUseBlock: BetaBrowserWaitToolUseBlock) = apply { + id = betaBrowserWaitToolUseBlock.id + input = betaBrowserWaitToolUseBlock.input + name = betaBrowserWaitToolUseBlock.name + toolsetName = betaBrowserWaitToolUseBlock.toolsetName + type = betaBrowserWaitToolUseBlock.type + caller = betaBrowserWaitToolUseBlock.caller + additionalProperties = betaBrowserWaitToolUseBlock.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 } + + /** Pause for the given duration. */ + fun input(input: BetaBrowserWaitInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserWaitInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("wait") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserWaitToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserWaitToolUseBlock = + BetaBrowserWaitToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserWaitToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("wait")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("wait")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserWaitToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserWaitToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomInput.kt new file mode 100644 index 000000000..bbf96ddee --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomInput.kt @@ -0,0 +1,248 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return a cropped screenshot of the given viewport region, scaled up for closer inspection — + * useful for small icons, buttons, or text. Coordinates are in the same viewport-pixel space as a + * full screenshot. + */ +class BetaBrowserZoomInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val region: JsonField>, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("region") @ExcludeMissing region: JsonField> = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(region, tabId, mutableMapOf()) + + /** + * [x0, y0, x1, y1] in viewport pixels. + * + * @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 region(): List = region.getRequired("region") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField> = region + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BetaBrowserZoomInput]. + * + * The following fields are required: + * ```java + * .region() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaBrowserZoomInput] with the required [region] set to + * the given value. + */ + @JvmStatic fun of(region: List) = builder().region(region).build() + } + + /** A builder for [BetaBrowserZoomInput]. */ + class Builder internal constructor() { + + private var region: JsonField>? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserZoomInput: BetaBrowserZoomInput) = apply { + region = + betaBrowserZoomInput.region.map { it.toMutableList() }.takeUnless { it.isMissing() } + tabId = betaBrowserZoomInput.tabId + additionalProperties = betaBrowserZoomInput.additionalProperties.toMutableMap() + } + + /** [x0, y0, x1, y1] in viewport pixels. */ + fun region(region: List) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun region(region: JsonField>) = apply { + this.region = region.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.region]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegion(region: Long) = apply { + this.region = + (this.region ?: JsonField.of(mutableListOf())).also { + checkKnown("region", it).add(region) + } + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BetaBrowserZoomInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .region() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserZoomInput = + BetaBrowserZoomInput( + checkRequired("region", region).map { it.toImmutable() }, + tabId, + 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(): BetaBrowserZoomInput = apply { + if (validated) { + return@apply + } + + region() + tabId() + 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 = + (region.asKnown().getOrNull()?.size ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserZoomInput && + region == other.region && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(region, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserZoomInput{region=$region, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomToolUseBlock.kt new file mode 100644 index 000000000..8c7bc2e12 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaBrowserZoomToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Return a cropped screenshot of the given viewport region, scaled up for closer inspection — + * useful for small icons, buttons, or text. Coordinates are in the same viewport-pixel space as + * a full screenshot. + * + * @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 input(): BetaBrowserZoomInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaBrowserZoomToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaBrowserZoomToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("zoom") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaBrowserZoomToolUseBlock: BetaBrowserZoomToolUseBlock) = apply { + id = betaBrowserZoomToolUseBlock.id + input = betaBrowserZoomToolUseBlock.input + name = betaBrowserZoomToolUseBlock.name + toolsetName = betaBrowserZoomToolUseBlock.toolsetName + type = betaBrowserZoomToolUseBlock.type + caller = betaBrowserZoomToolUseBlock.caller + additionalProperties = betaBrowserZoomToolUseBlock.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 } + + /** + * Return a cropped screenshot of the given viewport region, scaled up for closer inspection + * — useful for small icons, buttons, or text. Coordinates are in the same viewport-pixel + * space as a full screenshot. + */ + fun input(input: BetaBrowserZoomInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaBrowserZoomInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaBrowserZoomToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaBrowserZoomToolUseBlock = + BetaBrowserZoomToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaBrowserZoomToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("zoom")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("zoom")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaBrowserZoomToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaBrowserZoomToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionInput.kt new file mode 100644 index 000000000..64a0cfa53 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionInput.kt @@ -0,0 +1,128 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Get the current (x, y) pixel coordinate of the cursor. */ +class BetaComputerCursorPositionInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 + * [BetaComputerCursorPositionInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerCursorPositionInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerCursorPositionInput: BetaComputerCursorPositionInput) = + apply { + additionalProperties = + betaComputerCursorPositionInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaComputerCursorPositionInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerCursorPositionInput = + BetaComputerCursorPositionInput(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(): BetaComputerCursorPositionInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerCursorPositionInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerCursorPositionInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionToolUseBlock.kt new file mode 100644 index 000000000..5124b7f8f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerCursorPositionToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Get the current (x, y) pixel coordinate of the cursor. + * + * @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 input(): BetaComputerCursorPositionInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("cursor_position") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerCursorPositionToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerCursorPositionToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("cursor_position") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaComputerCursorPositionToolUseBlock: BetaComputerCursorPositionToolUseBlock + ) = apply { + id = betaComputerCursorPositionToolUseBlock.id + input = betaComputerCursorPositionToolUseBlock.input + name = betaComputerCursorPositionToolUseBlock.name + toolsetName = betaComputerCursorPositionToolUseBlock.toolsetName + type = betaComputerCursorPositionToolUseBlock.type + caller = betaComputerCursorPositionToolUseBlock.caller + additionalProperties = + betaComputerCursorPositionToolUseBlock.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 } + + /** Get the current (x, y) pixel coordinate of the cursor. */ + fun input(input: BetaComputerCursorPositionInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed + * [BetaComputerCursorPositionInput] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("cursor_position") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerCursorPositionToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerCursorPositionToolUseBlock = + BetaComputerCursorPositionToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerCursorPositionToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("cursor_position")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("cursor_position")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerCursorPositionToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerCursorPositionToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickInput.kt new file mode 100644 index 000000000..3596440a2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickInput.kt @@ -0,0 +1,241 @@ +package com.anthropic.models.beta.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Double-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ +class BetaComputerDoubleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerDoubleClickInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerDoubleClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerDoubleClickInput: BetaComputerDoubleClickInput) = apply { + coordinate = + betaComputerDoubleClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = betaComputerDoubleClickInput.text + additionalProperties = betaComputerDoubleClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerDoubleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerDoubleClickInput = + BetaComputerDoubleClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): BetaComputerDoubleClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerDoubleClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerDoubleClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickToolUseBlock.kt new file mode 100644 index 000000000..91cd6cfaf --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickToolUseBlock.kt @@ -0,0 +1,420 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerDoubleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Double-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + * + * @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 input(): BetaComputerDoubleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerDoubleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerDoubleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("double_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaComputerDoubleClickToolUseBlock: BetaComputerDoubleClickToolUseBlock + ) = apply { + id = betaComputerDoubleClickToolUseBlock.id + input = betaComputerDoubleClickToolUseBlock.input + name = betaComputerDoubleClickToolUseBlock.name + toolsetName = betaComputerDoubleClickToolUseBlock.toolsetName + type = betaComputerDoubleClickToolUseBlock.type + caller = betaComputerDoubleClickToolUseBlock.caller + additionalProperties = + betaComputerDoubleClickToolUseBlock.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 } + + /** + * Double-click the left mouse button at the specified (x, y) pixel coordinate, or the + * current cursor position if `coordinate` is omitted. + */ + fun input(input: BetaComputerDoubleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerDoubleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerDoubleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerDoubleClickToolUseBlock = + BetaComputerDoubleClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerDoubleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("double_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("double_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerDoubleClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerDoubleClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyInput.kt new file mode 100644 index 000000000..80a77bc21 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyInput.kt @@ -0,0 +1,219 @@ +package com.anthropic.models.beta.messages + +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 + +/** + * Hold down a key or key-combination for a specified duration. Uses the same key syntax as `key`. + */ +class BetaComputerHoldKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(duration, text, mutableMapOf()) + + /** + * Duration to hold the key, in seconds. + * + * @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 duration(): Long = duration.getRequired("duration") + + /** + * The key or key-combination to hold. + * + * @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 text(): String = text.getRequired("text") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerHoldKeyInput]. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerHoldKeyInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var text: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerHoldKeyInput: BetaComputerHoldKeyInput) = apply { + duration = betaComputerHoldKeyInput.duration + text = betaComputerHoldKeyInput.text + additionalProperties = betaComputerHoldKeyInput.additionalProperties.toMutableMap() + } + + /** Duration to hold the key, in seconds. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The key or key-combination to hold. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerHoldKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerHoldKeyInput = + BetaComputerHoldKeyInput( + checkRequired("duration", duration), + checkRequired("text", text), + 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(): BetaComputerHoldKeyInput = apply { + if (validated) { + return@apply + } + + duration() + text() + 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 (duration.asKnown().isPresent) 1 else 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerHoldKeyInput && + duration == other.duration && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerHoldKeyInput{duration=$duration, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyToolUseBlock.kt new file mode 100644 index 000000000..b509f8b95 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyToolUseBlock.kt @@ -0,0 +1,417 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerHoldKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Hold down a key or key-combination for a specified duration. Uses the same key syntax as + * `key`. + * + * @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 input(): BetaComputerHoldKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerHoldKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerHoldKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("hold_key") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerHoldKeyToolUseBlock: BetaComputerHoldKeyToolUseBlock) = + apply { + id = betaComputerHoldKeyToolUseBlock.id + input = betaComputerHoldKeyToolUseBlock.input + name = betaComputerHoldKeyToolUseBlock.name + toolsetName = betaComputerHoldKeyToolUseBlock.toolsetName + type = betaComputerHoldKeyToolUseBlock.type + caller = betaComputerHoldKeyToolUseBlock.caller + additionalProperties = + betaComputerHoldKeyToolUseBlock.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 } + + /** + * Hold down a key or key-combination for a specified duration. Uses the same key syntax as + * `key`. + */ + fun input(input: BetaComputerHoldKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerHoldKeyInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerHoldKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerHoldKeyToolUseBlock = + BetaComputerHoldKeyToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerHoldKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("hold_key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("hold_key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerHoldKeyToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerHoldKeyToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyInput.kt new file mode 100644 index 000000000..10ad89cf6 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyInput.kt @@ -0,0 +1,238 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Press a key or key-combination on the keyboard. Use "+" to combine modifiers with a key (e.g. + * "ctrl+s", "alt+Tab", "ctrl+shift+Escape"). Key names are case-insensitive; common names like + * "Return", "Tab", "Escape", "Up", "Down", "Left", "Right", "Home", "End", "Page_Up", "Page_Down", + * "Delete", "BackSpace" are supported. + */ +class BetaComputerKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val repeat: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("repeat") @ExcludeMissing repeat: JsonField = JsonMissing.of(), + ) : this(text, repeat, mutableMapOf()) + + /** + * The key or key-combination to press. + * + * @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 text(): String = text.getRequired("text") + + /** + * Number of times to repeat the key press. Default is 1. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun repeat(): Optional = repeat.getOptional("repeat") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [repeat]. + * + * Unlike [repeat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repeat") @ExcludeMissing fun _repeat(): JsonField = repeat + + @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 [BetaComputerKeyInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaComputerKeyInput] with the required [text] set to + * the given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BetaComputerKeyInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var repeat: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerKeyInput: BetaComputerKeyInput) = apply { + text = betaComputerKeyInput.text + repeat = betaComputerKeyInput.repeat + additionalProperties = betaComputerKeyInput.additionalProperties.toMutableMap() + } + + /** The key or key-combination to press. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Number of times to repeat the key press. Default is 1. */ + fun repeat(repeat: Long?) = repeat(JsonField.ofNullable(repeat)) + + /** + * Alias for [Builder.repeat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun repeat(repeat: Long) = repeat(repeat as Long?) + + /** Alias for calling [Builder.repeat] with `repeat.orElse(null)`. */ + fun repeat(repeat: Optional) = repeat(repeat.getOrNull()) + + /** + * Sets [Builder.repeat] to an arbitrary JSON value. + * + * You should usually call [Builder.repeat] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repeat(repeat: JsonField) = apply { this.repeat = repeat } + + 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 [BetaComputerKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerKeyInput = + BetaComputerKeyInput( + checkRequired("text", text), + repeat, + 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(): BetaComputerKeyInput = apply { + if (validated) { + return@apply + } + + text() + repeat() + 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 (text.asKnown().isPresent) 1 else 0) + (if (repeat.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerKeyInput && + text == other.text && + repeat == other.repeat && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, repeat, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerKeyInput{text=$text, repeat=$repeat, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyToolUseBlock.kt new file mode 100644 index 000000000..6f9bd7517 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyToolUseBlock.kt @@ -0,0 +1,418 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Press a key or key-combination on the keyboard. Use "+" to combine modifiers with a key (e.g. + * "ctrl+s", "alt+Tab", "ctrl+shift+Escape"). Key names are case-insensitive; common names like + * "Return", "Tab", "Escape", "Up", "Down", "Left", "Right", "Home", "End", "Page_Up", + * "Page_Down", "Delete", "BackSpace" are supported. + * + * @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 input(): BetaComputerKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaComputerKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("key") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerKeyToolUseBlock: BetaComputerKeyToolUseBlock) = apply { + id = betaComputerKeyToolUseBlock.id + input = betaComputerKeyToolUseBlock.input + name = betaComputerKeyToolUseBlock.name + toolsetName = betaComputerKeyToolUseBlock.toolsetName + type = betaComputerKeyToolUseBlock.type + caller = betaComputerKeyToolUseBlock.caller + additionalProperties = betaComputerKeyToolUseBlock.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 } + + /** + * Press a key or key-combination on the keyboard. Use "+" to combine modifiers with a key + * (e.g. "ctrl+s", "alt+Tab", "ctrl+shift+Escape"). Key names are case-insensitive; common + * names like "Return", "Tab", "Escape", "Up", "Down", "Left", "Right", "Home", "End", + * "Page_Up", "Page_Down", "Delete", "BackSpace" are supported. + */ + fun input(input: BetaComputerKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerKeyInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerKeyToolUseBlock = + BetaComputerKeyToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerKeyToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerKeyToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragInput.kt new file mode 100644 index 000000000..d1e4f8750 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragInput.kt @@ -0,0 +1,312 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Click and drag the cursor from `start_coordinate` to `coordinate`. */ +class BetaComputerLeftClickDragInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val startCoordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("start_coordinate") + @ExcludeMissing + startCoordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, startCoordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @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 coordinate(): List = coordinate.getRequired("coordinate") + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @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 startCoordinate(): List = startCoordinate.getRequired("start_coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [startCoordinate]. + * + * Unlike [startCoordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_coordinate") + @ExcludeMissing + fun _startCoordinate(): JsonField> = startCoordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 + * [BetaComputerLeftClickDragInput]. + * + * The following fields are required: + * ```java + * .coordinate() + * .startCoordinate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftClickDragInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var startCoordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerLeftClickDragInput: BetaComputerLeftClickDragInput) = apply { + coordinate = + betaComputerLeftClickDragInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + startCoordinate = + betaComputerLeftClickDragInput.startCoordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = betaComputerLeftClickDragInput.text + additionalProperties = + betaComputerLeftClickDragInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List) = coordinate(JsonField.of(coordinate)) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun startCoordinate(startCoordinate: List) = + startCoordinate(JsonField.of(startCoordinate)) + + /** + * Sets [Builder.startCoordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.startCoordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startCoordinate(startCoordinate: JsonField>) = apply { + this.startCoordinate = startCoordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.startCoordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStartCoordinate(startCoordinate: Long) = apply { + this.startCoordinate = + (this.startCoordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("startCoordinate", it).add(startCoordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerLeftClickDragInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .coordinate() + * .startCoordinate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerLeftClickDragInput = + BetaComputerLeftClickDragInput( + checkRequired("coordinate", coordinate).map { it.toImmutable() }, + checkRequired("startCoordinate", startCoordinate).map { it.toImmutable() }, + text, + 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(): BetaComputerLeftClickDragInput = apply { + if (validated) { + return@apply + } + + coordinate() + startCoordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + + (startCoordinate.asKnown().getOrNull()?.size ?: 0) + + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftClickDragInput && + coordinate == other.coordinate && + startCoordinate == other.startCoordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(coordinate, startCoordinate, text, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftClickDragInput{coordinate=$coordinate, startCoordinate=$startCoordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragToolUseBlock.kt new file mode 100644 index 000000000..d2df91c66 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerLeftClickDragToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Click and drag the cursor from `start_coordinate` to `coordinate`. + * + * @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 input(): BetaComputerLeftClickDragInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerLeftClickDragToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftClickDragToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click_drag") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaComputerLeftClickDragToolUseBlock: BetaComputerLeftClickDragToolUseBlock + ) = apply { + id = betaComputerLeftClickDragToolUseBlock.id + input = betaComputerLeftClickDragToolUseBlock.input + name = betaComputerLeftClickDragToolUseBlock.name + toolsetName = betaComputerLeftClickDragToolUseBlock.toolsetName + type = betaComputerLeftClickDragToolUseBlock.type + caller = betaComputerLeftClickDragToolUseBlock.caller + additionalProperties = + betaComputerLeftClickDragToolUseBlock.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 } + + /** Click and drag the cursor from `start_coordinate` to `coordinate`. */ + fun input(input: BetaComputerLeftClickDragInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed + * [BetaComputerLeftClickDragInput] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerLeftClickDragToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerLeftClickDragToolUseBlock = + BetaComputerLeftClickDragToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerLeftClickDragToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_click_drag")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click_drag")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftClickDragToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftClickDragToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickInput.kt new file mode 100644 index 000000000..1a2053cb3 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickInput.kt @@ -0,0 +1,241 @@ +package com.anthropic.models.beta.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Click the left mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + */ +class BetaComputerLeftClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerLeftClickInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerLeftClickInput: BetaComputerLeftClickInput) = apply { + coordinate = + betaComputerLeftClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = betaComputerLeftClickInput.text + additionalProperties = betaComputerLeftClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerLeftClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerLeftClickInput = + BetaComputerLeftClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): BetaComputerLeftClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickToolUseBlock.kt new file mode 100644 index 000000000..0930e1540 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerLeftClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Click the left mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + * + * @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 input(): BetaComputerLeftClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerLeftClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerLeftClickToolUseBlock: BetaComputerLeftClickToolUseBlock) = + apply { + id = betaComputerLeftClickToolUseBlock.id + input = betaComputerLeftClickToolUseBlock.input + name = betaComputerLeftClickToolUseBlock.name + toolsetName = betaComputerLeftClickToolUseBlock.toolsetName + type = betaComputerLeftClickToolUseBlock.type + caller = betaComputerLeftClickToolUseBlock.caller + additionalProperties = + betaComputerLeftClickToolUseBlock.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 } + + /** + * Click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ + fun input(input: BetaComputerLeftClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerLeftClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerLeftClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerLeftClickToolUseBlock = + BetaComputerLeftClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerLeftClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownInput.kt new file mode 100644 index 000000000..2a921307b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownInput.kt @@ -0,0 +1,127 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Press and hold the left mouse button at the current cursor position. */ +class BetaComputerLeftMouseDownInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 + * [BetaComputerLeftMouseDownInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftMouseDownInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerLeftMouseDownInput: BetaComputerLeftMouseDownInput) = apply { + additionalProperties = + betaComputerLeftMouseDownInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaComputerLeftMouseDownInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerLeftMouseDownInput = + BetaComputerLeftMouseDownInput(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(): BetaComputerLeftMouseDownInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftMouseDownInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftMouseDownInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownToolUseBlock.kt new file mode 100644 index 000000000..d7476f876 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerLeftMouseDownToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Press and hold the left mouse button at the current cursor position. + * + * @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 input(): BetaComputerLeftMouseDownInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerLeftMouseDownToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftMouseDownToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_down") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaComputerLeftMouseDownToolUseBlock: BetaComputerLeftMouseDownToolUseBlock + ) = apply { + id = betaComputerLeftMouseDownToolUseBlock.id + input = betaComputerLeftMouseDownToolUseBlock.input + name = betaComputerLeftMouseDownToolUseBlock.name + toolsetName = betaComputerLeftMouseDownToolUseBlock.toolsetName + type = betaComputerLeftMouseDownToolUseBlock.type + caller = betaComputerLeftMouseDownToolUseBlock.caller + additionalProperties = + betaComputerLeftMouseDownToolUseBlock.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 } + + /** Press and hold the left mouse button at the current cursor position. */ + fun input(input: BetaComputerLeftMouseDownInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed + * [BetaComputerLeftMouseDownInput] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerLeftMouseDownToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerLeftMouseDownToolUseBlock = + BetaComputerLeftMouseDownToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerLeftMouseDownToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_down")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_down")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftMouseDownToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftMouseDownToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpInput.kt new file mode 100644 index 000000000..b254fca93 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpInput.kt @@ -0,0 +1,125 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Release the left mouse button. */ +class BetaComputerLeftMouseUpInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [BetaComputerLeftMouseUpInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftMouseUpInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerLeftMouseUpInput: BetaComputerLeftMouseUpInput) = apply { + additionalProperties = betaComputerLeftMouseUpInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaComputerLeftMouseUpInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerLeftMouseUpInput = + BetaComputerLeftMouseUpInput(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(): BetaComputerLeftMouseUpInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftMouseUpInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftMouseUpInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpToolUseBlock.kt new file mode 100644 index 000000000..bd08ecaca --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerLeftMouseUpToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Release the left mouse button. + * + * @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 input(): BetaComputerLeftMouseUpInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerLeftMouseUpToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerLeftMouseUpToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_up") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaComputerLeftMouseUpToolUseBlock: BetaComputerLeftMouseUpToolUseBlock + ) = apply { + id = betaComputerLeftMouseUpToolUseBlock.id + input = betaComputerLeftMouseUpToolUseBlock.input + name = betaComputerLeftMouseUpToolUseBlock.name + toolsetName = betaComputerLeftMouseUpToolUseBlock.toolsetName + type = betaComputerLeftMouseUpToolUseBlock.type + caller = betaComputerLeftMouseUpToolUseBlock.caller + additionalProperties = + betaComputerLeftMouseUpToolUseBlock.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 } + + /** Release the left mouse button. */ + fun input(input: BetaComputerLeftMouseUpInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerLeftMouseUpInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerLeftMouseUpToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerLeftMouseUpToolUseBlock = + BetaComputerLeftMouseUpToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerLeftMouseUpToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_up")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_up")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerLeftMouseUpToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerLeftMouseUpToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickInput.kt new file mode 100644 index 000000000..800bc9c0f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickInput.kt @@ -0,0 +1,241 @@ +package com.anthropic.models.beta.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Click the middle mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + */ +class BetaComputerMiddleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerMiddleClickInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerMiddleClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerMiddleClickInput: BetaComputerMiddleClickInput) = apply { + coordinate = + betaComputerMiddleClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = betaComputerMiddleClickInput.text + additionalProperties = betaComputerMiddleClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerMiddleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerMiddleClickInput = + BetaComputerMiddleClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): BetaComputerMiddleClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerMiddleClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerMiddleClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickToolUseBlock.kt new file mode 100644 index 000000000..d87ab6429 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickToolUseBlock.kt @@ -0,0 +1,420 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerMiddleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Click the middle mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + * + * @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 input(): BetaComputerMiddleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerMiddleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerMiddleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("middle_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaComputerMiddleClickToolUseBlock: BetaComputerMiddleClickToolUseBlock + ) = apply { + id = betaComputerMiddleClickToolUseBlock.id + input = betaComputerMiddleClickToolUseBlock.input + name = betaComputerMiddleClickToolUseBlock.name + toolsetName = betaComputerMiddleClickToolUseBlock.toolsetName + type = betaComputerMiddleClickToolUseBlock.type + caller = betaComputerMiddleClickToolUseBlock.caller + additionalProperties = + betaComputerMiddleClickToolUseBlock.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 } + + /** + * Click the middle mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ + fun input(input: BetaComputerMiddleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerMiddleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerMiddleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerMiddleClickToolUseBlock = + BetaComputerMiddleClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerMiddleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("middle_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("middle_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerMiddleClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerMiddleClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveInput.kt new file mode 100644 index 000000000..2bd4dee72 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveInput.kt @@ -0,0 +1,214 @@ +package com.anthropic.models.beta.messages + +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 + +/** + * Move the cursor to a specified (x, y) pixel coordinate. Use this ONLY to hover without clicking; + * otherwise use a click action directly. + */ +class BetaComputerMouseMoveInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of() + ) : this(coordinate, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @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 coordinate(): List = coordinate.getRequired("coordinate") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + @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 [BetaComputerMouseMoveInput]. + * + * The following fields are required: + * ```java + * .coordinate() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaComputerMouseMoveInput] with the required + * [coordinate] set to the given value. + */ + @JvmStatic fun of(coordinate: List) = builder().coordinate(coordinate).build() + } + + /** A builder for [BetaComputerMouseMoveInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerMouseMoveInput: BetaComputerMouseMoveInput) = apply { + coordinate = + betaComputerMouseMoveInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + additionalProperties = betaComputerMouseMoveInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List) = coordinate(JsonField.of(coordinate)) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + 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 [BetaComputerMouseMoveInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .coordinate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerMouseMoveInput = + BetaComputerMouseMoveInput( + checkRequired("coordinate", coordinate).map { it.toImmutable() }, + 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(): BetaComputerMouseMoveInput = apply { + if (validated) { + return@apply + } + + coordinate() + 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 = (coordinate.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerMouseMoveInput && + coordinate == other.coordinate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerMouseMoveInput{coordinate=$coordinate, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveToolUseBlock.kt new file mode 100644 index 000000000..e5906eca7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerMouseMoveToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Move the cursor to a specified (x, y) pixel coordinate. Use this ONLY to hover without + * clicking; otherwise use a click action directly. + * + * @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 input(): BetaComputerMouseMoveInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerMouseMoveToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerMouseMoveToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("mouse_move") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerMouseMoveToolUseBlock: BetaComputerMouseMoveToolUseBlock) = + apply { + id = betaComputerMouseMoveToolUseBlock.id + input = betaComputerMouseMoveToolUseBlock.input + name = betaComputerMouseMoveToolUseBlock.name + toolsetName = betaComputerMouseMoveToolUseBlock.toolsetName + type = betaComputerMouseMoveToolUseBlock.type + caller = betaComputerMouseMoveToolUseBlock.caller + additionalProperties = + betaComputerMouseMoveToolUseBlock.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 } + + /** + * Move the cursor to a specified (x, y) pixel coordinate. Use this ONLY to hover without + * clicking; otherwise use a click action directly. + */ + fun input(input: BetaComputerMouseMoveInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerMouseMoveInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerMouseMoveToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerMouseMoveToolUseBlock = + BetaComputerMouseMoveToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerMouseMoveToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("mouse_move")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("mouse_move")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerMouseMoveToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerMouseMoveToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickInput.kt new file mode 100644 index 000000000..c9868f207 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickInput.kt @@ -0,0 +1,241 @@ +package com.anthropic.models.beta.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Click the right mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + */ +class BetaComputerRightClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerRightClickInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerRightClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerRightClickInput: BetaComputerRightClickInput) = apply { + coordinate = + betaComputerRightClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = betaComputerRightClickInput.text + additionalProperties = betaComputerRightClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerRightClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerRightClickInput = + BetaComputerRightClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): BetaComputerRightClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerRightClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerRightClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickToolUseBlock.kt new file mode 100644 index 000000000..5aed0eb1b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickToolUseBlock.kt @@ -0,0 +1,419 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerRightClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Click the right mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + * + * @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 input(): BetaComputerRightClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerRightClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerRightClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("right_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerRightClickToolUseBlock: BetaComputerRightClickToolUseBlock) = + apply { + id = betaComputerRightClickToolUseBlock.id + input = betaComputerRightClickToolUseBlock.input + name = betaComputerRightClickToolUseBlock.name + toolsetName = betaComputerRightClickToolUseBlock.toolsetName + type = betaComputerRightClickToolUseBlock.type + caller = betaComputerRightClickToolUseBlock.caller + additionalProperties = + betaComputerRightClickToolUseBlock.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 } + + /** + * Click the right mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ + fun input(input: BetaComputerRightClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerRightClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerRightClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerRightClickToolUseBlock = + BetaComputerRightClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerRightClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("right_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("right_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerRightClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerRightClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotInput.kt new file mode 100644 index 000000000..fecde8455 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotInput.kt @@ -0,0 +1,125 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Take a screenshot of the screen. */ +class BetaComputerScreenshotInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [BetaComputerScreenshotInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerScreenshotInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerScreenshotInput: BetaComputerScreenshotInput) = apply { + additionalProperties = betaComputerScreenshotInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaComputerScreenshotInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerScreenshotInput = + BetaComputerScreenshotInput(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(): BetaComputerScreenshotInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerScreenshotInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerScreenshotInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotToolUseBlock.kt new file mode 100644 index 000000000..0b489d3e7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerScreenshotToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Take a screenshot of the screen. + * + * @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 input(): BetaComputerScreenshotInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerScreenshotToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerScreenshotToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("screenshot") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerScreenshotToolUseBlock: BetaComputerScreenshotToolUseBlock) = + apply { + id = betaComputerScreenshotToolUseBlock.id + input = betaComputerScreenshotToolUseBlock.input + name = betaComputerScreenshotToolUseBlock.name + toolsetName = betaComputerScreenshotToolUseBlock.toolsetName + type = betaComputerScreenshotToolUseBlock.type + caller = betaComputerScreenshotToolUseBlock.caller + additionalProperties = + betaComputerScreenshotToolUseBlock.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 } + + /** Take a screenshot of the screen. */ + fun input(input: BetaComputerScreenshotInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerScreenshotInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerScreenshotToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerScreenshotToolUseBlock = + BetaComputerScreenshotToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerScreenshotToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("screenshot")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("screenshot")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerScreenshotToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerScreenshotToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollDirection.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollDirection.kt new file mode 100644 index 000000000..b0864c333 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollDirection.kt @@ -0,0 +1,169 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +class BetaComputerScrollDirection 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 UP = BetaComputerScrollDirection(JsonField.of("up")) + + @JvmField val DOWN = BetaComputerScrollDirection(JsonField.of("down")) + + @JvmField val LEFT = BetaComputerScrollDirection(JsonField.of("left")) + + @JvmField val RIGHT = BetaComputerScrollDirection(JsonField.of("right")) + + @JvmStatic + fun of(value: String): BetaComputerScrollDirection = + // Intern known values so `==` works + when (value) { + "up" -> UP + "down" -> DOWN + "left" -> LEFT + "right" -> RIGHT + else -> BetaComputerScrollDirection(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): BetaComputerScrollDirection = + value.asString().getOrNull()?.let { of(it) } ?: BetaComputerScrollDirection(value) + } + + /** An enum containing [BetaComputerScrollDirection]'s known values. */ + enum class Known { + UP, + DOWN, + LEFT, + RIGHT, + } + + /** + * An enum containing [BetaComputerScrollDirection]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [BetaComputerScrollDirection] 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 { + UP, + DOWN, + LEFT, + RIGHT, + /** + * An enum member indicating that [BetaComputerScrollDirection] 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) { + UP -> Value.UP + DOWN -> Value.DOWN + LEFT -> Value.LEFT + RIGHT -> Value.RIGHT + 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) { + UP -> Known.UP + DOWN -> Known.DOWN + LEFT -> Known.LEFT + RIGHT -> Known.RIGHT + else -> + throw AnthropicInvalidDataException("Unknown BetaComputerScrollDirection: $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(): BetaComputerScrollDirection = 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 BetaComputerScrollDirection && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollInput.kt new file mode 100644 index 000000000..be32cb6c0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollInput.kt @@ -0,0 +1,338 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Scroll the screen at the specified (x, y) pixel coordinate, or the current cursor position if + * `coordinate` is omitted. Do NOT use PageUp/PageDown to scroll. + */ +class BetaComputerScrollInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val scrollAmount: JsonField, + private val scrollDirection: JsonField, + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("scroll_amount") + @ExcludeMissing + scrollAmount: JsonField = JsonMissing.of(), + @JsonProperty("scroll_direction") + @ExcludeMissing + scrollDirection: JsonField = JsonMissing.of(), + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(scrollAmount, scrollDirection, coordinate, text, mutableMapOf()) + + /** + * Number of 'clicks' of the scroll wheel. + * + * @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 scrollAmount(): Long = scrollAmount.getRequired("scroll_amount") + + /** + * @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 scrollDirection(): BetaComputerScrollDirection = + scrollDirection.getRequired("scroll_direction") + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [scrollAmount]. + * + * Unlike [scrollAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_amount") + @ExcludeMissing + fun _scrollAmount(): JsonField = scrollAmount + + /** + * Returns the raw JSON value of [scrollDirection]. + * + * Unlike [scrollDirection], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_direction") + @ExcludeMissing + fun _scrollDirection(): JsonField = scrollDirection + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerScrollInput]. + * + * The following fields are required: + * ```java + * .scrollAmount() + * .scrollDirection() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerScrollInput]. */ + class Builder internal constructor() { + + private var scrollAmount: JsonField? = null + private var scrollDirection: JsonField? = null + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerScrollInput: BetaComputerScrollInput) = apply { + scrollAmount = betaComputerScrollInput.scrollAmount + scrollDirection = betaComputerScrollInput.scrollDirection + coordinate = + betaComputerScrollInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = betaComputerScrollInput.text + additionalProperties = betaComputerScrollInput.additionalProperties.toMutableMap() + } + + /** Number of 'clicks' of the scroll wheel. */ + fun scrollAmount(scrollAmount: Long) = scrollAmount(JsonField.of(scrollAmount)) + + /** + * Sets [Builder.scrollAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scrollAmount(scrollAmount: JsonField) = apply { this.scrollAmount = scrollAmount } + + fun scrollDirection(scrollDirection: BetaComputerScrollDirection) = + scrollDirection(JsonField.of(scrollDirection)) + + /** + * Sets [Builder.scrollDirection] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollDirection] with a well-typed + * [BetaComputerScrollDirection] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun scrollDirection(scrollDirection: JsonField) = apply { + this.scrollDirection = scrollDirection + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerScrollInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scrollAmount() + * .scrollDirection() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerScrollInput = + BetaComputerScrollInput( + checkRequired("scrollAmount", scrollAmount), + checkRequired("scrollDirection", scrollDirection), + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): BetaComputerScrollInput = apply { + if (validated) { + return@apply + } + + scrollAmount() + scrollDirection().validate() + coordinate() + text() + 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 (scrollAmount.asKnown().isPresent) 1 else 0) + + (scrollDirection.asKnown().getOrNull()?.validity() ?: 0) + + (coordinate.asKnown().getOrNull()?.size ?: 0) + + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerScrollInput && + scrollAmount == other.scrollAmount && + scrollDirection == other.scrollDirection && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scrollAmount, scrollDirection, coordinate, text, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerScrollInput{scrollAmount=$scrollAmount, scrollDirection=$scrollDirection, coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollToolUseBlock.kt new file mode 100644 index 000000000..13c8766ba --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerScrollToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Scroll the screen at the specified (x, y) pixel coordinate, or the current cursor position if + * `coordinate` is omitted. Do NOT use PageUp/PageDown to scroll. + * + * @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 input(): BetaComputerScrollInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerScrollToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerScrollToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("scroll") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerScrollToolUseBlock: BetaComputerScrollToolUseBlock) = apply { + id = betaComputerScrollToolUseBlock.id + input = betaComputerScrollToolUseBlock.input + name = betaComputerScrollToolUseBlock.name + toolsetName = betaComputerScrollToolUseBlock.toolsetName + type = betaComputerScrollToolUseBlock.type + caller = betaComputerScrollToolUseBlock.caller + additionalProperties = + betaComputerScrollToolUseBlock.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 } + + /** + * Scroll the screen at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. Do NOT use PageUp/PageDown to scroll. + */ + fun input(input: BetaComputerScrollInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerScrollInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerScrollToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerScrollToolUseBlock = + BetaComputerScrollToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerScrollToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("scroll")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("scroll")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerScrollToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerScrollToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerToolUseBlock.kt new file mode 100644 index 000000000..be598fae4 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerToolUseBlock.kt @@ -0,0 +1,953 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.core.getProperty +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = BetaComputerToolUseBlock.Deserializer::class) +@JsonSerialize(using = BetaComputerToolUseBlock.Serializer::class) +class BetaComputerToolUseBlock +private constructor( + private val key: BetaComputerKeyToolUseBlock? = null, + private val holdKey: BetaComputerHoldKeyToolUseBlock? = null, + private val type: BetaComputerTypeToolUseBlock? = null, + private val cursorPosition: BetaComputerCursorPositionToolUseBlock? = null, + private val mouseMove: BetaComputerMouseMoveToolUseBlock? = null, + private val leftMouseDown: BetaComputerLeftMouseDownToolUseBlock? = null, + private val leftMouseUp: BetaComputerLeftMouseUpToolUseBlock? = null, + private val leftClick: BetaComputerLeftClickToolUseBlock? = null, + private val leftClickDrag: BetaComputerLeftClickDragToolUseBlock? = null, + private val rightClick: BetaComputerRightClickToolUseBlock? = null, + private val middleClick: BetaComputerMiddleClickToolUseBlock? = null, + private val doubleClick: BetaComputerDoubleClickToolUseBlock? = null, + private val tripleClick: BetaComputerTripleClickToolUseBlock? = null, + private val scroll: BetaComputerScrollToolUseBlock? = null, + private val wait: BetaComputerWaitToolUseBlock? = null, + private val screenshot: BetaComputerScreenshotToolUseBlock? = null, + private val zoom: BetaComputerZoomToolUseBlock? = null, + private val _json: JsonValue? = null, +) { + + fun name(): Name = + when { + key != null -> Name.KEY + holdKey != null -> Name.HOLD_KEY + type != null -> Name.TYPE + cursorPosition != null -> Name.CURSOR_POSITION + mouseMove != null -> Name.MOUSE_MOVE + leftMouseDown != null -> Name.LEFT_MOUSE_DOWN + leftMouseUp != null -> Name.LEFT_MOUSE_UP + leftClick != null -> Name.LEFT_CLICK + leftClickDrag != null -> Name.LEFT_CLICK_DRAG + rightClick != null -> Name.RIGHT_CLICK + middleClick != null -> Name.MIDDLE_CLICK + doubleClick != null -> Name.DOUBLE_CLICK + tripleClick != null -> Name.TRIPLE_CLICK + scroll != null -> Name.SCROLL + wait != null -> Name.WAIT + screenshot != null -> Name.SCREENSHOT + zoom != null -> Name.ZOOM + else -> Name.of(_json?.asObject()?.getOrNull()?.get("name") ?: JsonMissing.of()) + } + + fun id(): String = + when { + key != null -> key.id() + holdKey != null -> holdKey.id() + type != null -> type.id() + cursorPosition != null -> cursorPosition.id() + mouseMove != null -> mouseMove.id() + leftMouseDown != null -> leftMouseDown.id() + leftMouseUp != null -> leftMouseUp.id() + leftClick != null -> leftClick.id() + leftClickDrag != null -> leftClickDrag.id() + rightClick != null -> rightClick.id() + middleClick != null -> middleClick.id() + doubleClick != null -> doubleClick.id() + tripleClick != null -> tripleClick.id() + scroll != null -> scroll.id() + wait != null -> wait.id() + screenshot != null -> screenshot.id() + zoom != null -> zoom.id() + else -> _json.getProperty("id").getRequired("id") + } + + fun caller(): Optional = + when { + key != null -> key.caller() + holdKey != null -> holdKey.caller() + type != null -> type.caller() + cursorPosition != null -> cursorPosition.caller() + mouseMove != null -> mouseMove.caller() + leftMouseDown != null -> leftMouseDown.caller() + leftMouseUp != null -> leftMouseUp.caller() + leftClick != null -> leftClick.caller() + leftClickDrag != null -> leftClickDrag.caller() + rightClick != null -> rightClick.caller() + middleClick != null -> middleClick.caller() + doubleClick != null -> doubleClick.caller() + tripleClick != null -> tripleClick.caller() + scroll != null -> scroll.caller() + wait != null -> wait.caller() + screenshot != null -> screenshot.caller() + zoom != null -> zoom.caller() + else -> _json.getProperty("caller").asKnown() + } + + fun key(): Optional = Optional.ofNullable(key) + + fun holdKey(): Optional = Optional.ofNullable(holdKey) + + fun type(): Optional = Optional.ofNullable(type) + + fun cursorPosition(): Optional = + Optional.ofNullable(cursorPosition) + + fun mouseMove(): Optional = Optional.ofNullable(mouseMove) + + fun leftMouseDown(): Optional = + Optional.ofNullable(leftMouseDown) + + fun leftMouseUp(): Optional = + Optional.ofNullable(leftMouseUp) + + fun leftClick(): Optional = Optional.ofNullable(leftClick) + + fun leftClickDrag(): Optional = + Optional.ofNullable(leftClickDrag) + + fun rightClick(): Optional = Optional.ofNullable(rightClick) + + fun middleClick(): Optional = + Optional.ofNullable(middleClick) + + fun doubleClick(): Optional = + Optional.ofNullable(doubleClick) + + fun tripleClick(): Optional = + Optional.ofNullable(tripleClick) + + fun scroll(): Optional = Optional.ofNullable(scroll) + + fun wait(): Optional = Optional.ofNullable(wait) + + fun screenshot(): Optional = Optional.ofNullable(screenshot) + + fun zoom(): Optional = Optional.ofNullable(zoom) + + fun isKey(): Boolean = key != null + + fun isHoldKey(): Boolean = holdKey != null + + fun isType(): Boolean = type != null + + fun isCursorPosition(): Boolean = cursorPosition != null + + fun isMouseMove(): Boolean = mouseMove != null + + fun isLeftMouseDown(): Boolean = leftMouseDown != null + + fun isLeftMouseUp(): Boolean = leftMouseUp != null + + fun isLeftClick(): Boolean = leftClick != null + + fun isLeftClickDrag(): Boolean = leftClickDrag != null + + fun isRightClick(): Boolean = rightClick != null + + fun isMiddleClick(): Boolean = middleClick != null + + fun isDoubleClick(): Boolean = doubleClick != null + + fun isTripleClick(): Boolean = tripleClick != null + + fun isScroll(): Boolean = scroll != null + + fun isWait(): Boolean = wait != null + + fun isScreenshot(): Boolean = screenshot != null + + fun isZoom(): Boolean = zoom != null + + fun asKey(): BetaComputerKeyToolUseBlock = key.getOrThrow("key") + + fun asHoldKey(): BetaComputerHoldKeyToolUseBlock = holdKey.getOrThrow("holdKey") + + fun asType(): BetaComputerTypeToolUseBlock = type.getOrThrow("type") + + fun asCursorPosition(): BetaComputerCursorPositionToolUseBlock = + cursorPosition.getOrThrow("cursorPosition") + + fun asMouseMove(): BetaComputerMouseMoveToolUseBlock = mouseMove.getOrThrow("mouseMove") + + fun asLeftMouseDown(): BetaComputerLeftMouseDownToolUseBlock = + leftMouseDown.getOrThrow("leftMouseDown") + + fun asLeftMouseUp(): BetaComputerLeftMouseUpToolUseBlock = leftMouseUp.getOrThrow("leftMouseUp") + + fun asLeftClick(): BetaComputerLeftClickToolUseBlock = leftClick.getOrThrow("leftClick") + + fun asLeftClickDrag(): BetaComputerLeftClickDragToolUseBlock = + leftClickDrag.getOrThrow("leftClickDrag") + + fun asRightClick(): BetaComputerRightClickToolUseBlock = rightClick.getOrThrow("rightClick") + + fun asMiddleClick(): BetaComputerMiddleClickToolUseBlock = middleClick.getOrThrow("middleClick") + + fun asDoubleClick(): BetaComputerDoubleClickToolUseBlock = doubleClick.getOrThrow("doubleClick") + + fun asTripleClick(): BetaComputerTripleClickToolUseBlock = tripleClick.getOrThrow("tripleClick") + + fun asScroll(): BetaComputerScrollToolUseBlock = scroll.getOrThrow("scroll") + + fun asWait(): BetaComputerWaitToolUseBlock = wait.getOrThrow("wait") + + fun asScreenshot(): BetaComputerScreenshotToolUseBlock = screenshot.getOrThrow("screenshot") + + fun asZoom(): BetaComputerZoomToolUseBlock = zoom.getOrThrow("zoom") + + 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 = betaComputerToolUseBlock.accept(new BetaComputerToolUseBlock.Visitor>() { + * @Override + * public Optional visitKey(BetaComputerKeyToolUseBlock key) { + * return Optional.of(key.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 { + key != null -> visitor.visitKey(key) + holdKey != null -> visitor.visitHoldKey(holdKey) + type != null -> visitor.visitType(type) + cursorPosition != null -> visitor.visitCursorPosition(cursorPosition) + mouseMove != null -> visitor.visitMouseMove(mouseMove) + leftMouseDown != null -> visitor.visitLeftMouseDown(leftMouseDown) + leftMouseUp != null -> visitor.visitLeftMouseUp(leftMouseUp) + leftClick != null -> visitor.visitLeftClick(leftClick) + leftClickDrag != null -> visitor.visitLeftClickDrag(leftClickDrag) + rightClick != null -> visitor.visitRightClick(rightClick) + middleClick != null -> visitor.visitMiddleClick(middleClick) + doubleClick != null -> visitor.visitDoubleClick(doubleClick) + tripleClick != null -> visitor.visitTripleClick(tripleClick) + scroll != null -> visitor.visitScroll(scroll) + wait != null -> visitor.visitWait(wait) + screenshot != null -> visitor.visitScreenshot(screenshot) + zoom != null -> visitor.visitZoom(zoom) + 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(): BetaComputerToolUseBlock = apply { + if (validated) { + return@apply + } + + when { + key != null -> key.validate() + holdKey != null -> holdKey.validate() + type != null -> type.validate() + cursorPosition != null -> cursorPosition.validate() + mouseMove != null -> mouseMove.validate() + leftMouseDown != null -> leftMouseDown.validate() + leftMouseUp != null -> leftMouseUp.validate() + leftClick != null -> leftClick.validate() + leftClickDrag != null -> leftClickDrag.validate() + rightClick != null -> rightClick.validate() + middleClick != null -> middleClick.validate() + doubleClick != null -> doubleClick.validate() + tripleClick != null -> tripleClick.validate() + scroll != null -> scroll.validate() + wait != null -> wait.validate() + screenshot != null -> screenshot.validate() + zoom != null -> zoom.validate() + else -> throw AnthropicInvalidDataException("Unknown BetaComputerToolUseBlock: $_json") + } + 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 = + when { + key != null -> key.validity() + holdKey != null -> holdKey.validity() + type != null -> type.validity() + cursorPosition != null -> cursorPosition.validity() + mouseMove != null -> mouseMove.validity() + leftMouseDown != null -> leftMouseDown.validity() + leftMouseUp != null -> leftMouseUp.validity() + leftClick != null -> leftClick.validity() + leftClickDrag != null -> leftClickDrag.validity() + rightClick != null -> rightClick.validity() + middleClick != null -> middleClick.validity() + doubleClick != null -> doubleClick.validity() + tripleClick != null -> tripleClick.validity() + scroll != null -> scroll.validity() + wait != null -> wait.validity() + screenshot != null -> screenshot.validity() + zoom != null -> zoom.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerToolUseBlock && + key == other.key && + holdKey == other.holdKey && + type == other.type && + cursorPosition == other.cursorPosition && + mouseMove == other.mouseMove && + leftMouseDown == other.leftMouseDown && + leftMouseUp == other.leftMouseUp && + leftClick == other.leftClick && + leftClickDrag == other.leftClickDrag && + rightClick == other.rightClick && + middleClick == other.middleClick && + doubleClick == other.doubleClick && + tripleClick == other.tripleClick && + scroll == other.scroll && + wait == other.wait && + screenshot == other.screenshot && + zoom == other.zoom + } + + override fun hashCode(): Int = + Objects.hash( + key, + holdKey, + type, + cursorPosition, + mouseMove, + leftMouseDown, + leftMouseUp, + leftClick, + leftClickDrag, + rightClick, + middleClick, + doubleClick, + tripleClick, + scroll, + wait, + screenshot, + zoom, + ) + + override fun toString(): String = + when { + key != null -> "BetaComputerToolUseBlock{key=$key}" + holdKey != null -> "BetaComputerToolUseBlock{holdKey=$holdKey}" + type != null -> "BetaComputerToolUseBlock{type=$type}" + cursorPosition != null -> "BetaComputerToolUseBlock{cursorPosition=$cursorPosition}" + mouseMove != null -> "BetaComputerToolUseBlock{mouseMove=$mouseMove}" + leftMouseDown != null -> "BetaComputerToolUseBlock{leftMouseDown=$leftMouseDown}" + leftMouseUp != null -> "BetaComputerToolUseBlock{leftMouseUp=$leftMouseUp}" + leftClick != null -> "BetaComputerToolUseBlock{leftClick=$leftClick}" + leftClickDrag != null -> "BetaComputerToolUseBlock{leftClickDrag=$leftClickDrag}" + rightClick != null -> "BetaComputerToolUseBlock{rightClick=$rightClick}" + middleClick != null -> "BetaComputerToolUseBlock{middleClick=$middleClick}" + doubleClick != null -> "BetaComputerToolUseBlock{doubleClick=$doubleClick}" + tripleClick != null -> "BetaComputerToolUseBlock{tripleClick=$tripleClick}" + scroll != null -> "BetaComputerToolUseBlock{scroll=$scroll}" + wait != null -> "BetaComputerToolUseBlock{wait=$wait}" + screenshot != null -> "BetaComputerToolUseBlock{screenshot=$screenshot}" + zoom != null -> "BetaComputerToolUseBlock{zoom=$zoom}" + _json != null -> "BetaComputerToolUseBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaComputerToolUseBlock") + } + + companion object { + + @JvmStatic fun ofKey(key: BetaComputerKeyToolUseBlock) = BetaComputerToolUseBlock(key = key) + + @JvmStatic + fun ofHoldKey(holdKey: BetaComputerHoldKeyToolUseBlock) = + BetaComputerToolUseBlock(holdKey = holdKey) + + @JvmStatic + fun ofType(type: BetaComputerTypeToolUseBlock) = BetaComputerToolUseBlock(type = type) + + @JvmStatic + fun ofCursorPosition(cursorPosition: BetaComputerCursorPositionToolUseBlock) = + BetaComputerToolUseBlock(cursorPosition = cursorPosition) + + @JvmStatic + fun ofMouseMove(mouseMove: BetaComputerMouseMoveToolUseBlock) = + BetaComputerToolUseBlock(mouseMove = mouseMove) + + @JvmStatic + fun ofLeftMouseDown(leftMouseDown: BetaComputerLeftMouseDownToolUseBlock) = + BetaComputerToolUseBlock(leftMouseDown = leftMouseDown) + + @JvmStatic + fun ofLeftMouseUp(leftMouseUp: BetaComputerLeftMouseUpToolUseBlock) = + BetaComputerToolUseBlock(leftMouseUp = leftMouseUp) + + @JvmStatic + fun ofLeftClick(leftClick: BetaComputerLeftClickToolUseBlock) = + BetaComputerToolUseBlock(leftClick = leftClick) + + @JvmStatic + fun ofLeftClickDrag(leftClickDrag: BetaComputerLeftClickDragToolUseBlock) = + BetaComputerToolUseBlock(leftClickDrag = leftClickDrag) + + @JvmStatic + fun ofRightClick(rightClick: BetaComputerRightClickToolUseBlock) = + BetaComputerToolUseBlock(rightClick = rightClick) + + @JvmStatic + fun ofMiddleClick(middleClick: BetaComputerMiddleClickToolUseBlock) = + BetaComputerToolUseBlock(middleClick = middleClick) + + @JvmStatic + fun ofDoubleClick(doubleClick: BetaComputerDoubleClickToolUseBlock) = + BetaComputerToolUseBlock(doubleClick = doubleClick) + + @JvmStatic + fun ofTripleClick(tripleClick: BetaComputerTripleClickToolUseBlock) = + BetaComputerToolUseBlock(tripleClick = tripleClick) + + @JvmStatic + fun ofScroll(scroll: BetaComputerScrollToolUseBlock) = + BetaComputerToolUseBlock(scroll = scroll) + + @JvmStatic + fun ofWait(wait: BetaComputerWaitToolUseBlock) = BetaComputerToolUseBlock(wait = wait) + + @JvmStatic + fun ofScreenshot(screenshot: BetaComputerScreenshotToolUseBlock) = + BetaComputerToolUseBlock(screenshot = screenshot) + + @JvmStatic + fun ofZoom(zoom: BetaComputerZoomToolUseBlock) = BetaComputerToolUseBlock(zoom = zoom) + } + + /** + * An interface that defines how to map each variant of [BetaComputerToolUseBlock] to a value of + * type [T]. + */ + interface Visitor { + + fun visitKey(key: BetaComputerKeyToolUseBlock): T + + fun visitHoldKey(holdKey: BetaComputerHoldKeyToolUseBlock): T + + fun visitType(type: BetaComputerTypeToolUseBlock): T + + fun visitCursorPosition(cursorPosition: BetaComputerCursorPositionToolUseBlock): T + + fun visitMouseMove(mouseMove: BetaComputerMouseMoveToolUseBlock): T + + fun visitLeftMouseDown(leftMouseDown: BetaComputerLeftMouseDownToolUseBlock): T + + fun visitLeftMouseUp(leftMouseUp: BetaComputerLeftMouseUpToolUseBlock): T + + fun visitLeftClick(leftClick: BetaComputerLeftClickToolUseBlock): T + + fun visitLeftClickDrag(leftClickDrag: BetaComputerLeftClickDragToolUseBlock): T + + fun visitRightClick(rightClick: BetaComputerRightClickToolUseBlock): T + + fun visitMiddleClick(middleClick: BetaComputerMiddleClickToolUseBlock): T + + fun visitDoubleClick(doubleClick: BetaComputerDoubleClickToolUseBlock): T + + fun visitTripleClick(tripleClick: BetaComputerTripleClickToolUseBlock): T + + fun visitScroll(scroll: BetaComputerScrollToolUseBlock): T + + fun visitWait(wait: BetaComputerWaitToolUseBlock): T + + fun visitScreenshot(screenshot: BetaComputerScreenshotToolUseBlock): T + + fun visitZoom(zoom: BetaComputerZoomToolUseBlock): T + + /** + * Maps an unknown variant of [BetaComputerToolUseBlock] to a value of type [T]. + * + * An instance of [BetaComputerToolUseBlock] 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 BetaComputerToolUseBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BetaComputerToolUseBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaComputerToolUseBlock { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "key" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(key = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "hold_key" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(holdKey = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "type" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(type = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "cursor_position" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(cursorPosition = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "mouse_move" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(mouseMove = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "left_mouse_down" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(leftMouseDown = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "left_mouse_up" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(leftMouseUp = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "left_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(leftClick = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "left_click_drag" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(leftClickDrag = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "right_click" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(rightClick = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "middle_click" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(middleClick = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "double_click" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(doubleClick = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "triple_click" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(tripleClick = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "scroll" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(scroll = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "wait" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(wait = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "screenshot" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { BetaComputerToolUseBlock(screenshot = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + "zoom" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaComputerToolUseBlock(zoom = it, _json = json) } + ?: BetaComputerToolUseBlock(_json = json) + } + } + + return BetaComputerToolUseBlock(_json = json) + } + } + + internal class Serializer : + BaseSerializer(BetaComputerToolUseBlock::class) { + + override fun serialize( + value: BetaComputerToolUseBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.key != null -> generator.writeObject(value.key) + value.holdKey != null -> generator.writeObject(value.holdKey) + value.type != null -> generator.writeObject(value.type) + value.cursorPosition != null -> generator.writeObject(value.cursorPosition) + value.mouseMove != null -> generator.writeObject(value.mouseMove) + value.leftMouseDown != null -> generator.writeObject(value.leftMouseDown) + value.leftMouseUp != null -> generator.writeObject(value.leftMouseUp) + value.leftClick != null -> generator.writeObject(value.leftClick) + value.leftClickDrag != null -> generator.writeObject(value.leftClickDrag) + value.rightClick != null -> generator.writeObject(value.rightClick) + value.middleClick != null -> generator.writeObject(value.middleClick) + value.doubleClick != null -> generator.writeObject(value.doubleClick) + value.tripleClick != null -> generator.writeObject(value.tripleClick) + value.scroll != null -> generator.writeObject(value.scroll) + value.wait != null -> generator.writeObject(value.wait) + value.screenshot != null -> generator.writeObject(value.screenshot) + value.zoom != null -> generator.writeObject(value.zoom) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaComputerToolUseBlock") + } + } + } + + class Name 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 KEY = Name(JsonField.of("key")) + + @JvmField val HOLD_KEY = Name(JsonField.of("hold_key")) + + @JvmField val TYPE = Name(JsonField.of("type")) + + @JvmField val CURSOR_POSITION = Name(JsonField.of("cursor_position")) + + @JvmField val MOUSE_MOVE = Name(JsonField.of("mouse_move")) + + @JvmField val LEFT_MOUSE_DOWN = Name(JsonField.of("left_mouse_down")) + + @JvmField val LEFT_MOUSE_UP = Name(JsonField.of("left_mouse_up")) + + @JvmField val LEFT_CLICK = Name(JsonField.of("left_click")) + + @JvmField val LEFT_CLICK_DRAG = Name(JsonField.of("left_click_drag")) + + @JvmField val RIGHT_CLICK = Name(JsonField.of("right_click")) + + @JvmField val MIDDLE_CLICK = Name(JsonField.of("middle_click")) + + @JvmField val DOUBLE_CLICK = Name(JsonField.of("double_click")) + + @JvmField val TRIPLE_CLICK = Name(JsonField.of("triple_click")) + + @JvmField val SCROLL = Name(JsonField.of("scroll")) + + @JvmField val WAIT = Name(JsonField.of("wait")) + + @JvmField val SCREENSHOT = Name(JsonField.of("screenshot")) + + @JvmField val ZOOM = Name(JsonField.of("zoom")) + + @JvmStatic + fun of(value: String): Name = + // Intern known values so `==` works + when (value) { + "key" -> KEY + "hold_key" -> HOLD_KEY + "type" -> TYPE + "cursor_position" -> CURSOR_POSITION + "mouse_move" -> MOUSE_MOVE + "left_mouse_down" -> LEFT_MOUSE_DOWN + "left_mouse_up" -> LEFT_MOUSE_UP + "left_click" -> LEFT_CLICK + "left_click_drag" -> LEFT_CLICK_DRAG + "right_click" -> RIGHT_CLICK + "middle_click" -> MIDDLE_CLICK + "double_click" -> DOUBLE_CLICK + "triple_click" -> TRIPLE_CLICK + "scroll" -> SCROLL + "wait" -> WAIT + "screenshot" -> SCREENSHOT + "zoom" -> ZOOM + else -> Name(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Name = + value.asString().getOrNull()?.let { of(it) } ?: Name(value) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + KEY, + HOLD_KEY, + TYPE, + CURSOR_POSITION, + MOUSE_MOVE, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + LEFT_CLICK, + LEFT_CLICK_DRAG, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + SCROLL, + WAIT, + SCREENSHOT, + ZOOM, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] 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 { + KEY, + HOLD_KEY, + TYPE, + CURSOR_POSITION, + MOUSE_MOVE, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + LEFT_CLICK, + LEFT_CLICK_DRAG, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + SCROLL, + WAIT, + SCREENSHOT, + ZOOM, + /** An enum member indicating that [Name] 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) { + KEY -> Value.KEY + HOLD_KEY -> Value.HOLD_KEY + TYPE -> Value.TYPE + CURSOR_POSITION -> Value.CURSOR_POSITION + MOUSE_MOVE -> Value.MOUSE_MOVE + LEFT_MOUSE_DOWN -> Value.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Value.LEFT_MOUSE_UP + LEFT_CLICK -> Value.LEFT_CLICK + LEFT_CLICK_DRAG -> Value.LEFT_CLICK_DRAG + RIGHT_CLICK -> Value.RIGHT_CLICK + MIDDLE_CLICK -> Value.MIDDLE_CLICK + DOUBLE_CLICK -> Value.DOUBLE_CLICK + TRIPLE_CLICK -> Value.TRIPLE_CLICK + SCROLL -> Value.SCROLL + WAIT -> Value.WAIT + SCREENSHOT -> Value.SCREENSHOT + ZOOM -> Value.ZOOM + 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) { + KEY -> Known.KEY + HOLD_KEY -> Known.HOLD_KEY + TYPE -> Known.TYPE + CURSOR_POSITION -> Known.CURSOR_POSITION + MOUSE_MOVE -> Known.MOUSE_MOVE + LEFT_MOUSE_DOWN -> Known.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Known.LEFT_MOUSE_UP + LEFT_CLICK -> Known.LEFT_CLICK + LEFT_CLICK_DRAG -> Known.LEFT_CLICK_DRAG + RIGHT_CLICK -> Known.RIGHT_CLICK + MIDDLE_CLICK -> Known.MIDDLE_CLICK + DOUBLE_CLICK -> Known.DOUBLE_CLICK + TRIPLE_CLICK -> Known.TRIPLE_CLICK + SCROLL -> Known.SCROLL + WAIT -> Known.WAIT + SCREENSHOT -> Known.SCREENSHOT + ZOOM -> Known.ZOOM + else -> throw AnthropicInvalidDataException("Unknown Name: $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(): Name = 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 Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickInput.kt new file mode 100644 index 000000000..e4dcc9efc --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickInput.kt @@ -0,0 +1,241 @@ +package com.anthropic.models.beta.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triple-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ +class BetaComputerTripleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerTripleClickInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerTripleClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerTripleClickInput: BetaComputerTripleClickInput) = apply { + coordinate = + betaComputerTripleClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = betaComputerTripleClickInput.text + additionalProperties = betaComputerTripleClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerTripleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BetaComputerTripleClickInput = + BetaComputerTripleClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): BetaComputerTripleClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerTripleClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerTripleClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickToolUseBlock.kt new file mode 100644 index 000000000..6092e63d8 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickToolUseBlock.kt @@ -0,0 +1,420 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerTripleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Triple-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + * + * @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 input(): BetaComputerTripleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 + * [BetaComputerTripleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerTripleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("triple_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + betaComputerTripleClickToolUseBlock: BetaComputerTripleClickToolUseBlock + ) = apply { + id = betaComputerTripleClickToolUseBlock.id + input = betaComputerTripleClickToolUseBlock.input + name = betaComputerTripleClickToolUseBlock.name + toolsetName = betaComputerTripleClickToolUseBlock.toolsetName + type = betaComputerTripleClickToolUseBlock.type + caller = betaComputerTripleClickToolUseBlock.caller + additionalProperties = + betaComputerTripleClickToolUseBlock.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 } + + /** + * Triple-click the left mouse button at the specified (x, y) pixel coordinate, or the + * current cursor position if `coordinate` is omitted. + */ + fun input(input: BetaComputerTripleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerTripleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerTripleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerTripleClickToolUseBlock = + BetaComputerTripleClickToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerTripleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("triple_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("triple_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerTripleClickToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerTripleClickToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeInput.kt new file mode 100644 index 000000000..238f5ef89 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeInput.kt @@ -0,0 +1,183 @@ +package com.anthropic.models.beta.messages + +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 + +/** Type a string of text on the keyboard. */ +class BetaComputerTypeInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of() + ) : this(text, mutableMapOf()) + + /** + * The text to 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 text(): String = text.getRequired("text") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [BetaComputerTypeInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaComputerTypeInput] with the required [text] set to + * the given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BetaComputerTypeInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerTypeInput: BetaComputerTypeInput) = apply { + text = betaComputerTypeInput.text + additionalProperties = betaComputerTypeInput.additionalProperties.toMutableMap() + } + + /** The text to type. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [BetaComputerTypeInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerTypeInput = + BetaComputerTypeInput(checkRequired("text", text), 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(): BetaComputerTypeInput = apply { + if (validated) { + return@apply + } + + text() + 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 (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerTypeInput && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerTypeInput{text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeToolUseBlock.kt new file mode 100644 index 000000000..89947d5c1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeToolUseBlock.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerTypeToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Type a string of text on the keyboard. + * + * @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 input(): BetaComputerTypeInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("type") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaComputerTypeToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerTypeToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("type") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerTypeToolUseBlock: BetaComputerTypeToolUseBlock) = apply { + id = betaComputerTypeToolUseBlock.id + input = betaComputerTypeToolUseBlock.input + name = betaComputerTypeToolUseBlock.name + toolsetName = betaComputerTypeToolUseBlock.toolsetName + type = betaComputerTypeToolUseBlock.type + caller = betaComputerTypeToolUseBlock.caller + additionalProperties = betaComputerTypeToolUseBlock.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 } + + /** Type a string of text on the keyboard. */ + fun input(input: BetaComputerTypeInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerTypeInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("type") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerTypeToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerTypeToolUseBlock = + BetaComputerTypeToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerTypeToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("type")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("type")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerTypeToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerTypeToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitInput.kt new file mode 100644 index 000000000..9e521fd02 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitInput.kt @@ -0,0 +1,186 @@ +package com.anthropic.models.beta.messages + +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 + +/** Wait for a specified duration. */ +class BetaComputerWaitInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of() + ) : this(duration, mutableMapOf()) + + /** + * Duration to wait, in seconds. + * + * @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 duration(): Long = duration.getRequired("duration") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + @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 [BetaComputerWaitInput]. + * + * The following fields are required: + * ```java + * .duration() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaComputerWaitInput] with the required [duration] set + * to the given value. + */ + @JvmStatic fun of(duration: Long) = builder().duration(duration).build() + } + + /** A builder for [BetaComputerWaitInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerWaitInput: BetaComputerWaitInput) = apply { + duration = betaComputerWaitInput.duration + additionalProperties = betaComputerWaitInput.additionalProperties.toMutableMap() + } + + /** Duration to wait, in seconds. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + 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 [BetaComputerWaitInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerWaitInput = + BetaComputerWaitInput( + checkRequired("duration", duration), + 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(): BetaComputerWaitInput = apply { + if (validated) { + return@apply + } + + duration() + 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 (duration.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerWaitInput && + duration == other.duration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerWaitInput{duration=$duration, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitToolUseBlock.kt new file mode 100644 index 000000000..da31df453 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitToolUseBlock.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerWaitToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Wait for a specified duration. + * + * @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 input(): BetaComputerWaitInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("wait") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaComputerWaitToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerWaitToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("wait") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerWaitToolUseBlock: BetaComputerWaitToolUseBlock) = apply { + id = betaComputerWaitToolUseBlock.id + input = betaComputerWaitToolUseBlock.input + name = betaComputerWaitToolUseBlock.name + toolsetName = betaComputerWaitToolUseBlock.toolsetName + type = betaComputerWaitToolUseBlock.type + caller = betaComputerWaitToolUseBlock.caller + additionalProperties = betaComputerWaitToolUseBlock.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 } + + /** Wait for a specified duration. */ + fun input(input: BetaComputerWaitInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerWaitInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("wait") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerWaitToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerWaitToolUseBlock = + BetaComputerWaitToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerWaitToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("wait")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("wait")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerWaitToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerWaitToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomInput.kt new file mode 100644 index 000000000..d20be593d --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomInput.kt @@ -0,0 +1,211 @@ +package com.anthropic.models.beta.messages + +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 + +/** + * Take a screenshot of a rectangular region. Region coordinates are in the full-screenshot space + * (not physical display pixels). The crop is scaled up to fill the image budget so fine details + * become legible. + */ +class BetaComputerZoomInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val region: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("region") @ExcludeMissing region: JsonField> = JsonMissing.of() + ) : this(region, mutableMapOf()) + + /** + * (x0, y0, x1, y1): The region to capture. + * + * @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 region(): List = region.getRequired("region") + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField> = region + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BetaComputerZoomInput]. + * + * The following fields are required: + * ```java + * .region() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BetaComputerZoomInput] with the required [region] set + * to the given value. + */ + @JvmStatic fun of(region: List) = builder().region(region).build() + } + + /** A builder for [BetaComputerZoomInput]. */ + class Builder internal constructor() { + + private var region: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerZoomInput: BetaComputerZoomInput) = apply { + region = + betaComputerZoomInput.region + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + additionalProperties = betaComputerZoomInput.additionalProperties.toMutableMap() + } + + /** (x0, y0, x1, y1): The region to capture. */ + fun region(region: List) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun region(region: JsonField>) = apply { + this.region = region.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.region]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegion(region: Long) = apply { + this.region = + (this.region ?: JsonField.of(mutableListOf())).also { + checkKnown("region", it).add(region) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BetaComputerZoomInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .region() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerZoomInput = + BetaComputerZoomInput( + checkRequired("region", region).map { it.toImmutable() }, + 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(): BetaComputerZoomInput = apply { + if (validated) { + return@apply + } + + region() + 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 = (region.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerZoomInput && + region == other.region && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerZoomInput{region=$region, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomToolUseBlock.kt new file mode 100644 index 000000000..25a7d2acc --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.beta.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class BetaComputerZoomToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val caller: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("caller") + @ExcludeMissing + caller: JsonField = JsonMissing.of(), + ) : this(id, input, name, toolsetName, type, caller, 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") + + /** + * Take a screenshot of a rectangular region. Region coordinates are in the full-screenshot + * space (not physical display pixels). The crop is scaled up to fill the image budget so fine + * details become legible. + * + * @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 input(): BetaComputerZoomInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun caller(): Optional = caller.getOptional("caller") + + /** + * 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 [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + /** + * Returns the raw JSON value of [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + @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 [BetaComputerZoomToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaComputerZoomToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("zoom") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var caller: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaComputerZoomToolUseBlock: BetaComputerZoomToolUseBlock) = apply { + id = betaComputerZoomToolUseBlock.id + input = betaComputerZoomToolUseBlock.input + name = betaComputerZoomToolUseBlock.name + toolsetName = betaComputerZoomToolUseBlock.toolsetName + type = betaComputerZoomToolUseBlock.type + caller = betaComputerZoomToolUseBlock.caller + additionalProperties = betaComputerZoomToolUseBlock.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 } + + /** + * Take a screenshot of a rectangular region. Region coordinates are in the full-screenshot + * space (not physical display pixels). The crop is scaled up to fill the image budget so + * fine details become legible. + */ + fun input(input: BetaComputerZoomInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BetaComputerZoomInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: BetaToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [BetaToolUseCaller] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `BetaToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: BetaDirectCaller) = caller(BetaToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: BetaServerToolCaller) = + caller(BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(BetaServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: BetaServerToolCaller20260120) = + caller(BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * BetaServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(BetaServerToolCaller20260120.builder().toolId(toolId).build()) + + 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 [BetaComputerZoomToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaComputerZoomToolUseBlock = + BetaComputerZoomToolUseBlock( + checkRequired("id", id), + checkRequired("input", input), + name, + toolsetName, + type, + caller, + 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(): BetaComputerZoomToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + input().validate() + _name().let { + if (it != JsonValue.from("zoom")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + caller().ifPresent { it.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 = + (if (id.asKnown().isPresent) 1 else 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("zoom")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaComputerZoomToolUseBlock && + id == other.id && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + caller == other.caller && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, input, name, toolsetName, type, caller, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaComputerZoomToolUseBlock{id=$id, input=$input, name=$name, toolsetName=$toolsetName, type=$type, caller=$caller, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaToolUseCaller.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaToolUseCaller.kt new file mode 100644 index 000000000..ff16f63ee --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaToolUseCaller.kt @@ -0,0 +1,450 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.core.getProperty +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +/** Which party invoked the tool call: the model directly, or a server tool on its behalf. */ +@JsonDeserialize(using = BetaToolUseCaller.Deserializer::class) +@JsonSerialize(using = BetaToolUseCaller.Serializer::class) +class BetaToolUseCaller +private constructor( + private val direct: BetaDirectCaller? = null, + private val codeExecution20250825: BetaServerToolCaller? = null, + private val codeExecution20260120: BetaServerToolCaller20260120? = null, + private val _json: JsonValue? = null, +) { + + fun type(): Type = + when { + direct != null -> Type.DIRECT + codeExecution20250825 != null -> Type.CODE_EXECUTION_20250825 + codeExecution20260120 != null -> Type.CODE_EXECUTION_20260120 + else -> Type.of(_json?.asObject()?.getOrNull()?.get("type") ?: JsonMissing.of()) + } + + fun toolId(): Optional = + when { + direct != null -> Optional.empty() + codeExecution20250825 != null -> Optional.of(codeExecution20250825.toolId()) + codeExecution20260120 != null -> Optional.of(codeExecution20260120.toolId()) + else -> _json.getProperty("tool_id").asKnown() + } + + /** Tool invocation directly from the model. */ + fun direct(): Optional = Optional.ofNullable(direct) + + /** Tool invocation generated by a server-side tool. */ + fun codeExecution20250825(): Optional = + Optional.ofNullable(codeExecution20250825) + + fun codeExecution20260120(): Optional = + Optional.ofNullable(codeExecution20260120) + + fun isDirect(): Boolean = direct != null + + fun isCodeExecution20250825(): Boolean = codeExecution20250825 != null + + fun isCodeExecution20260120(): Boolean = codeExecution20260120 != null + + /** Tool invocation directly from the model. */ + fun asDirect(): BetaDirectCaller = direct.getOrThrow("direct") + + /** Tool invocation generated by a server-side tool. */ + fun asCodeExecution20250825(): BetaServerToolCaller = + codeExecution20250825.getOrThrow("codeExecution20250825") + + fun asCodeExecution20260120(): BetaServerToolCaller20260120 = + codeExecution20260120.getOrThrow("codeExecution20260120") + + 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 = betaToolUseCaller.accept(new BetaToolUseCaller.Visitor>() { + * @Override + * public Optional visitDirect(BetaDirectCaller direct) { + * return Optional.of(direct.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 { + direct != null -> visitor.visitDirect(direct) + codeExecution20250825 != null -> + visitor.visitCodeExecution20250825(codeExecution20250825) + codeExecution20260120 != null -> + visitor.visitCodeExecution20260120(codeExecution20260120) + 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(): BetaToolUseCaller = apply { + if (validated) { + return@apply + } + + when { + direct != null -> direct.validate() + codeExecution20250825 != null -> codeExecution20250825.validate() + codeExecution20260120 != null -> codeExecution20260120.validate() + else -> throw AnthropicInvalidDataException("Unknown BetaToolUseCaller: $_json") + } + 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 = + when { + direct != null -> direct.validity() + codeExecution20250825 != null -> codeExecution20250825.validity() + codeExecution20260120 != null -> codeExecution20260120.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaToolUseCaller && + direct == other.direct && + codeExecution20250825 == other.codeExecution20250825 && + codeExecution20260120 == other.codeExecution20260120 + } + + override fun hashCode(): Int = + Objects.hash(direct, codeExecution20250825, codeExecution20260120) + + override fun toString(): String = + when { + direct != null -> "BetaToolUseCaller{direct=$direct}" + codeExecution20250825 != null -> + "BetaToolUseCaller{codeExecution20250825=$codeExecution20250825}" + codeExecution20260120 != null -> + "BetaToolUseCaller{codeExecution20260120=$codeExecution20260120}" + _json != null -> "BetaToolUseCaller{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaToolUseCaller") + } + + companion object { + + /** Tool invocation directly from the model. */ + @JvmStatic fun ofDirect(direct: BetaDirectCaller) = BetaToolUseCaller(direct = direct) + + /** Tool invocation generated by a server-side tool. */ + @JvmStatic + fun ofCodeExecution20250825(codeExecution20250825: BetaServerToolCaller) = + BetaToolUseCaller(codeExecution20250825 = codeExecution20250825) + + /** + * Returns an immutable instance of [BetaToolUseCaller] whose [ofCodeExecution20250825] + * variant is built from the given required [toolId]. + */ + @JvmStatic + fun ofCodeExecution20250825(toolId: String) = + ofCodeExecution20250825(BetaServerToolCaller.of(toolId)) + + @JvmStatic + fun ofCodeExecution20260120(codeExecution20260120: BetaServerToolCaller20260120) = + BetaToolUseCaller(codeExecution20260120 = codeExecution20260120) + + /** + * Returns an immutable instance of [BetaToolUseCaller] whose [ofCodeExecution20260120] + * variant is built from the given required [toolId]. + */ + @JvmStatic + fun ofCodeExecution20260120(toolId: String) = + ofCodeExecution20260120(BetaServerToolCaller20260120.of(toolId)) + } + + /** + * An interface that defines how to map each variant of [BetaToolUseCaller] to a value of type + * [T]. + */ + interface Visitor { + + /** Tool invocation directly from the model. */ + fun visitDirect(direct: BetaDirectCaller): T + + /** Tool invocation generated by a server-side tool. */ + fun visitCodeExecution20250825(codeExecution20250825: BetaServerToolCaller): T + + fun visitCodeExecution20260120(codeExecution20260120: BetaServerToolCaller20260120): T + + /** + * Maps an unknown variant of [BetaToolUseCaller] to a value of type [T]. + * + * An instance of [BetaToolUseCaller] 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 BetaToolUseCaller: $json") + } + } + + internal class Deserializer : BaseDeserializer(BetaToolUseCaller::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaToolUseCaller { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "direct" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BetaToolUseCaller(direct = it, _json = json) + } ?: BetaToolUseCaller(_json = json) + } + "code_execution_20250825" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BetaToolUseCaller(codeExecution20250825 = it, _json = json) + } ?: BetaToolUseCaller(_json = json) + } + "code_execution_20260120" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BetaToolUseCaller(codeExecution20260120 = it, _json = json) } + ?: BetaToolUseCaller(_json = json) + } + } + + return BetaToolUseCaller(_json = json) + } + } + + internal class Serializer : BaseSerializer(BetaToolUseCaller::class) { + + override fun serialize( + value: BetaToolUseCaller, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.direct != null -> generator.writeObject(value.direct) + value.codeExecution20250825 != null -> + generator.writeObject(value.codeExecution20250825) + value.codeExecution20260120 != null -> + generator.writeObject(value.codeExecution20260120) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaToolUseCaller") + } + } + } + + class Type 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 DIRECT = Type(JsonField.of("direct")) + + @JvmField val CODE_EXECUTION_20250825 = Type(JsonField.of("code_execution_20250825")) + + @JvmField val CODE_EXECUTION_20260120 = Type(JsonField.of("code_execution_20260120")) + + @JvmStatic + fun of(value: String): Type = + // Intern known values so `==` works + when (value) { + "direct" -> DIRECT + "code_execution_20250825" -> CODE_EXECUTION_20250825 + "code_execution_20260120" -> CODE_EXECUTION_20260120 + else -> Type(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Type = + value.asString().getOrNull()?.let { of(it) } ?: Type(value) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DIRECT, + CODE_EXECUTION_20250825, + CODE_EXECUTION_20260120, + } + + /** + * 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 { + DIRECT, + CODE_EXECUTION_20250825, + CODE_EXECUTION_20260120, + /** 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) { + DIRECT -> Value.DIRECT + CODE_EXECUTION_20250825 -> Value.CODE_EXECUTION_20250825 + CODE_EXECUTION_20260120 -> Value.CODE_EXECUTION_20260120 + 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) { + DIRECT -> Known.DIRECT + CODE_EXECUTION_20250825 -> Known.CODE_EXECUTION_20250825 + CODE_EXECUTION_20260120 -> Known.CODE_EXECUTION_20260120 + 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() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaToolsetToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaToolsetToolUseBlock.kt new file mode 100644 index 000000000..95dbe93b0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/BetaToolsetToolUseBlock.kt @@ -0,0 +1,246 @@ +package com.anthropic.models.beta.messages + +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.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 + +@JsonDeserialize(using = BetaToolsetToolUseBlock.Deserializer::class) +@JsonSerialize(using = BetaToolsetToolUseBlock.Serializer::class) +class BetaToolsetToolUseBlock +private constructor( + private val browser: BetaBrowserToolUseBlock? = null, + private val computer: BetaComputerToolUseBlock? = null, + private val betaToolUseBlock: BetaToolUseBlock? = null, + private val _json: JsonValue? = null, +) { + + fun browser(): Optional = Optional.ofNullable(browser) + + fun computer(): Optional = Optional.ofNullable(computer) + + fun betaToolUseBlock(): Optional = Optional.ofNullable(betaToolUseBlock) + + fun isBrowser(): Boolean = browser != null + + fun isComputer(): Boolean = computer != null + + fun isBetaToolUseBlock(): Boolean = betaToolUseBlock != null + + fun asBrowser(): BetaBrowserToolUseBlock = browser.getOrThrow("browser") + + fun asComputer(): BetaComputerToolUseBlock = computer.getOrThrow("computer") + + fun asBetaToolUseBlock(): BetaToolUseBlock = betaToolUseBlock.getOrThrow("betaToolUseBlock") + + 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 = betaToolsetToolUseBlock.accept(new BetaToolsetToolUseBlock.Visitor>() { + * @Override + * public Optional visitBrowser(BetaBrowserToolUseBlock browser) { + * return Optional.of(browser.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 { + browser != null -> visitor.visitBrowser(browser) + computer != null -> visitor.visitComputer(computer) + betaToolUseBlock != null -> visitor.visitBetaToolUseBlock(betaToolUseBlock) + 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(): BetaToolsetToolUseBlock = apply { + if (validated) { + return@apply + } + + when { + browser != null -> browser.validate() + computer != null -> computer.validate() + betaToolUseBlock != null -> betaToolUseBlock.validate() + else -> throw AnthropicInvalidDataException("Unknown BetaToolsetToolUseBlock: $_json") + } + 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 = + when { + browser != null -> browser.validity() + computer != null -> computer.validity() + betaToolUseBlock != null -> betaToolUseBlock.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaToolsetToolUseBlock && + browser == other.browser && + computer == other.computer && + betaToolUseBlock == other.betaToolUseBlock + } + + override fun hashCode(): Int = Objects.hash(browser, computer, betaToolUseBlock) + + override fun toString(): String = + when { + browser != null -> "BetaToolsetToolUseBlock{browser=$browser}" + computer != null -> "BetaToolsetToolUseBlock{computer=$computer}" + betaToolUseBlock != null -> + "BetaToolsetToolUseBlock{betaToolUseBlock=$betaToolUseBlock}" + _json != null -> "BetaToolsetToolUseBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BetaToolsetToolUseBlock") + } + + companion object { + + @JvmStatic + fun ofBrowser(browser: BetaBrowserToolUseBlock) = BetaToolsetToolUseBlock(browser = browser) + + @JvmStatic + fun ofComputer(computer: BetaComputerToolUseBlock) = + BetaToolsetToolUseBlock(computer = computer) + + @JvmStatic + fun ofBetaToolUseBlock(betaToolUseBlock: BetaToolUseBlock) = + BetaToolsetToolUseBlock(betaToolUseBlock = betaToolUseBlock) + } + + /** + * An interface that defines how to map each variant of [BetaToolsetToolUseBlock] to a value of + * type [T]. + */ + interface Visitor { + + fun visitBrowser(browser: BetaBrowserToolUseBlock): T + + fun visitComputer(computer: BetaComputerToolUseBlock): T + + fun visitBetaToolUseBlock(betaToolUseBlock: BetaToolUseBlock): T + + /** + * Maps an unknown variant of [BetaToolsetToolUseBlock] to a value of type [T]. + * + * An instance of [BetaToolsetToolUseBlock] 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 BetaToolsetToolUseBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BetaToolsetToolUseBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BetaToolsetToolUseBlock { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BetaToolsetToolUseBlock(browser = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BetaToolsetToolUseBlock(computer = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BetaToolsetToolUseBlock(betaToolUseBlock = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> BetaToolsetToolUseBlock(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(BetaToolsetToolUseBlock::class) { + + override fun serialize( + value: BetaToolsetToolUseBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.browser != null -> generator.writeObject(value.browser) + value.computer != null -> generator.writeObject(value.computer) + value.betaToolUseBlock != null -> generator.writeObject(value.betaToolUseBlock) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BetaToolsetToolUseBlock") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParams.kt index 6994e19ac..0a11976b0 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParams.kt @@ -1431,7 +1431,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } userProfileId?.let { put("anthropic-user-profile-id", it) } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCreateParams.kt index 3f1f58a2b..9100f70be 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/MessageCreateParams.kt @@ -2194,7 +2194,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } userProfileId?.let { put("anthropic-user-profile-id", it) } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/StructuredContentBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/StructuredContentBlock.kt index ac18c5a82..9aa85491c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/StructuredContentBlock.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/StructuredContentBlock.kt @@ -240,6 +240,7 @@ internal constructor( isContainerUpload() -> visitor.visitContainerUpload(asContainerUpload()) isCompaction() -> visitor.visitCompaction(asCompaction()) isFallback() -> visitor.visitFallback(asFallback()) + isMcpToolListing() -> visitor.visitMcpToolListing(asMcpToolListing()) else -> visitor.unknown(_json().getOrNull()) } @@ -332,6 +333,10 @@ internal constructor( override fun visitFallback(fallback: BetaFallbackBlock) { fallback.validate() } + + override fun visitMcpToolListing(mcpToolListing: BetaMcpToolListingBlock) { + mcpToolListing.validate() + } } ) validated = true @@ -423,6 +428,9 @@ internal constructor( /** @see BetaContentBlock.Visitor.visitFallback */ fun visitFallback(fallback: BetaFallbackBlock): T + /** @see BetaContentBlock.Visitor.visitMcpToolListing */ + fun visitMcpToolListing(mcpToolListing: BetaMcpToolListingBlock): T + /** @see BetaContentBlock.Visitor.unknown */ fun unknown(json: JsonValue?): T { throw AnthropicInvalidDataException("Unknown BetaContentBlock: $json") diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParams.kt index 8dde3f3ad..7642da687 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParams.kt @@ -277,7 +277,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("message-batches-2024-09-24") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParams.kt index c3b06b2b7..7ecd5656e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParams.kt @@ -413,7 +413,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("message-batches-2024-09-24") - it) } + .joinToString(","), + ) + } + } userProfileId?.let { put("anthropic-user-profile-id", it) } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParams.kt index 4260123dc..2f8f6cb2e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParams.kt @@ -274,7 +274,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("message-batches-2024-09-24") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchListParams.kt index 077234111..f247fa71a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchListParams.kt @@ -284,7 +284,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("message-batches-2024-09-24") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParams.kt index 17f9e9b31..8fb6c8d87 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParams.kt @@ -242,7 +242,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("message-batches-2024-09-24") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParams.kt index 7531be9eb..da96a647a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParams.kt @@ -239,7 +239,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("message-batches-2024-09-24") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelCapabilities.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelCapabilities.kt index 4f62c87a9..a0ff05f3a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelCapabilities.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelCapabilities.kt @@ -27,6 +27,7 @@ private constructor( private val effort: JsonField, private val imageInput: JsonField, private val pdfInput: JsonField, + private val serverTools: JsonField, private val structuredOutputs: JsonField, private val thinking: JsonField, private val additionalProperties: MutableMap, @@ -58,6 +59,9 @@ private constructor( @JsonProperty("pdf_input") @ExcludeMissing pdfInput: JsonField = JsonMissing.of(), + @JsonProperty("server_tools") + @ExcludeMissing + serverTools: JsonField = JsonMissing.of(), @JsonProperty("structured_outputs") @ExcludeMissing structuredOutputs: JsonField = JsonMissing.of(), @@ -73,6 +77,7 @@ private constructor( effort, imageInput, pdfInput, + serverTools, structuredOutputs, thinking, mutableMapOf(), @@ -95,7 +100,9 @@ private constructor( fun citations(): BetaCapabilitySupport = citations.getRequired("citations") /** - * Whether the model supports code execution tools. + * Whether code that the model runs in the code execution tool can call the request's other + * tools, as in programmatic tool calling and dynamic filtering for web search and web fetch. + * Support for the code execution tool itself is in `server_tools.code_execution`. * * @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). @@ -144,6 +151,16 @@ private constructor( */ fun pdfInput(): BetaCapabilitySupport = pdfInput.getRequired("pdf_input") + /** + * Whether this model supports the web search and code execution server tools. `supported` is + * true when the model supports at least one of the tools. A supported tool can still be + * rejected for your organization, for example when an admin has turned web search off. + * + * @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 serverTools(): BetaServerToolsCapability = serverTools.getRequired("server_tools") + /** * Whether the model supports structured output / JSON mode / strict tool schemas. * @@ -230,6 +247,15 @@ private constructor( @ExcludeMissing fun _pdfInput(): JsonField = pdfInput + /** + * Returns the raw JSON value of [serverTools]. + * + * Unlike [serverTools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("server_tools") + @ExcludeMissing + fun _serverTools(): JsonField = serverTools + /** * Returns the raw JSON value of [structuredOutputs]. * @@ -276,6 +302,7 @@ private constructor( * .effort() * .imageInput() * .pdfInput() + * .serverTools() * .structuredOutputs() * .thinking() * ``` @@ -294,6 +321,7 @@ private constructor( private var effort: JsonField? = null private var imageInput: JsonField? = null private var pdfInput: JsonField? = null + private var serverTools: JsonField? = null private var structuredOutputs: JsonField? = null private var thinking: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -308,6 +336,7 @@ private constructor( effort = betaModelCapabilities.effort imageInput = betaModelCapabilities.imageInput pdfInput = betaModelCapabilities.pdfInput + serverTools = betaModelCapabilities.serverTools structuredOutputs = betaModelCapabilities.structuredOutputs thinking = betaModelCapabilities.thinking additionalProperties = betaModelCapabilities.additionalProperties.toMutableMap() @@ -339,7 +368,11 @@ private constructor( this.citations = citations } - /** Whether the model supports code execution tools. */ + /** + * Whether code that the model runs in the code execution tool can call the request's other + * tools, as in programmatic tool calling and dynamic filtering for web search and web + * fetch. Support for the code execution tool itself is in `server_tools.code_execution`. + */ fun codeExecution(codeExecution: BetaCapabilitySupport) = codeExecution(JsonField.of(codeExecution)) @@ -432,6 +465,25 @@ private constructor( this.pdfInput = pdfInput } + /** + * Whether this model supports the web search and code execution server tools. `supported` + * is true when the model supports at least one of the tools. A supported tool can still be + * rejected for your organization, for example when an admin has turned web search off. + */ + fun serverTools(serverTools: BetaServerToolsCapability) = + serverTools(JsonField.of(serverTools)) + + /** + * Sets [Builder.serverTools] to an arbitrary JSON value. + * + * You should usually call [Builder.serverTools] with a well-typed + * [BetaServerToolsCapability] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun serverTools(serverTools: JsonField) = apply { + this.serverTools = serverTools + } + /** Whether the model supports structured output / JSON mode / strict tool schemas. */ fun structuredOutputs(structuredOutputs: BetaCapabilitySupport) = structuredOutputs(JsonField.of(structuredOutputs)) @@ -495,6 +547,7 @@ private constructor( * .effort() * .imageInput() * .pdfInput() + * .serverTools() * .structuredOutputs() * .thinking() * ``` @@ -511,6 +564,7 @@ private constructor( checkRequired("effort", effort), checkRequired("imageInput", imageInput), checkRequired("pdfInput", pdfInput), + checkRequired("serverTools", serverTools), checkRequired("structuredOutputs", structuredOutputs), checkRequired("thinking", thinking), additionalProperties.toMutableMap(), @@ -540,6 +594,7 @@ private constructor( effort().validate() imageInput().validate() pdfInput().validate() + serverTools().validate() structuredOutputs().validate() thinking().validate() validated = true @@ -568,6 +623,7 @@ private constructor( (effort.asKnown().getOrNull()?.validity() ?: 0) + (imageInput.asKnown().getOrNull()?.validity() ?: 0) + (pdfInput.asKnown().getOrNull()?.validity() ?: 0) + + (serverTools.asKnown().getOrNull()?.validity() ?: 0) + (structuredOutputs.asKnown().getOrNull()?.validity() ?: 0) + (thinking.asKnown().getOrNull()?.validity() ?: 0) @@ -585,6 +641,7 @@ private constructor( effort == other.effort && imageInput == other.imageInput && pdfInput == other.pdfInput && + serverTools == other.serverTools && structuredOutputs == other.structuredOutputs && thinking == other.thinking && additionalProperties == other.additionalProperties @@ -600,6 +657,7 @@ private constructor( effort, imageInput, pdfInput, + serverTools, structuredOutputs, thinking, additionalProperties, @@ -609,5 +667,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BetaModelCapabilities{batch=$batch, citations=$citations, codeExecution=$codeExecution, compaction=$compaction, contextManagement=$contextManagement, effort=$effort, imageInput=$imageInput, pdfInput=$pdfInput, structuredOutputs=$structuredOutputs, thinking=$thinking, additionalProperties=$additionalProperties}" + "BetaModelCapabilities{batch=$batch, citations=$citations, codeExecution=$codeExecution, compaction=$compaction, contextManagement=$contextManagement, effort=$effort, imageInput=$imageInput, pdfInput=$pdfInput, serverTools=$serverTools, structuredOutputs=$structuredOutputs, thinking=$thinking, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelInfo.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelInfo.kt index fb46f8ce1..54657a07d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelInfo.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelInfo.kt @@ -1,5 +1,6 @@ package com.anthropic.models.beta.models +import com.anthropic.core.Enum import com.anthropic.core.ExcludeMissing import com.anthropic.core.JsonField import com.anthropic.core.JsonMissing @@ -25,9 +26,13 @@ private constructor( private val allowedFallbackModels: JsonField>, private val capabilities: JsonField, private val createdAt: JsonField, + private val deprecatedAt: JsonField, private val displayName: JsonField, + private val lifecycle: JsonField, + private val line: JsonField, private val maxInputTokens: JsonField, private val maxTokens: JsonField, + private val retiresAt: JsonField, private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -44,22 +49,36 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("deprecated_at") + @ExcludeMissing + deprecatedAt: JsonField = JsonMissing.of(), @JsonProperty("display_name") @ExcludeMissing displayName: JsonField = JsonMissing.of(), + @JsonProperty("lifecycle") + @ExcludeMissing + lifecycle: JsonField = JsonMissing.of(), + @JsonProperty("line") @ExcludeMissing line: JsonField = JsonMissing.of(), @JsonProperty("max_input_tokens") @ExcludeMissing maxInputTokens: JsonField = JsonMissing.of(), @JsonProperty("max_tokens") @ExcludeMissing maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("retires_at") + @ExcludeMissing + retiresAt: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this( id, allowedFallbackModels, capabilities, createdAt, + deprecatedAt, displayName, + lifecycle, + line, maxInputTokens, maxTokens, + retiresAt, type, mutableMapOf(), ) @@ -100,6 +119,15 @@ private constructor( */ fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + /** + * RFC 3339 datetime string representing the time of the model's most recent deprecation. + * Populated for `deprecated` and `retired` models; `null` while the model is `active`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deprecatedAt(): Optional = deprecatedAt.getOptional("deprecated_at") + /** * A human-readable name for the model. * @@ -108,6 +136,30 @@ private constructor( */ fun displayName(): String = displayName.getRequired("display_name") + /** + * The model's current lifecycle stage. + * - `active`: The model is available for use, open to new adopters, and not scheduled for + * retirement. + * - `deprecated`: The model remains callable for organizations with existing access, but is + * headed for retirement and closed to new adopters. + * - `retired`: The model is no longer available for use; inference requests naming it fail. It + * remains in the catalogue as the historical record of its retirement. + * + * @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 lifecycle(): Lifecycle = lifecycle.getRequired("lifecycle") + + /** + * The model line this model belongs to, such as `opus` for both Claude Opus 4.5 and Claude Opus + * 4.6. More lines may be added. `null` when the model belongs to no line; do not infer a line + * from the `id`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun line(): Optional = line.getOptional("line") + /** * Maximum input context window size in tokens for this model. * @@ -124,6 +176,17 @@ private constructor( */ fun maxTokens(): Optional = maxTokens.getOptional("max_tokens") + /** + * RFC 3339 datetime string representing the model's currently scheduled retirement date. The + * schedule can be revised until retirement occurs; `null` while the model is `active` or while + * no retirement is scheduled. A past date on a `deprecated` model means retirement is overdue, + * not that it has occurred: `lifecycle` is the retirement signal. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun retiresAt(): Optional = retiresAt.getOptional("retires_at") + /** * Object type. * @@ -174,6 +237,15 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [deprecatedAt]. + * + * Unlike [deprecatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("deprecated_at") + @ExcludeMissing + fun _deprecatedAt(): JsonField = deprecatedAt + /** * Returns the raw JSON value of [displayName]. * @@ -183,6 +255,20 @@ private constructor( @ExcludeMissing fun _displayName(): JsonField = displayName + /** + * Returns the raw JSON value of [lifecycle]. + * + * Unlike [lifecycle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lifecycle") @ExcludeMissing fun _lifecycle(): JsonField = lifecycle + + /** + * Returns the raw JSON value of [line]. + * + * Unlike [line], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line") @ExcludeMissing fun _line(): JsonField = line + /** * Returns the raw JSON value of [maxInputTokens]. * @@ -199,6 +285,15 @@ private constructor( */ @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + /** + * Returns the raw JSON value of [retiresAt]. + * + * Unlike [retiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retires_at") + @ExcludeMissing + fun _retiresAt(): JsonField = retiresAt + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -222,9 +317,13 @@ private constructor( * .allowedFallbackModels() * .capabilities() * .createdAt() + * .deprecatedAt() * .displayName() + * .lifecycle() + * .line() * .maxInputTokens() * .maxTokens() + * .retiresAt() * ``` */ @JvmStatic fun builder() = Builder() @@ -237,9 +336,13 @@ private constructor( private var allowedFallbackModels: JsonField>? = null private var capabilities: JsonField? = null private var createdAt: JsonField? = null + private var deprecatedAt: JsonField? = null private var displayName: JsonField? = null + private var lifecycle: JsonField? = null + private var line: JsonField? = null private var maxInputTokens: JsonField? = null private var maxTokens: JsonField? = null + private var retiresAt: JsonField? = null private var type: JsonValue = JsonValue.from("model") private var additionalProperties: MutableMap = mutableMapOf() @@ -252,9 +355,13 @@ private constructor( .takeUnless { it.isMissing() } capabilities = betaModelInfo.capabilities createdAt = betaModelInfo.createdAt + deprecatedAt = betaModelInfo.deprecatedAt displayName = betaModelInfo.displayName + lifecycle = betaModelInfo.lifecycle + line = betaModelInfo.line maxInputTokens = betaModelInfo.maxInputTokens maxTokens = betaModelInfo.maxTokens + retiresAt = betaModelInfo.retiresAt type = betaModelInfo.type additionalProperties = betaModelInfo.additionalProperties.toMutableMap() } @@ -344,6 +451,28 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** + * RFC 3339 datetime string representing the time of the model's most recent deprecation. + * Populated for `deprecated` and `retired` models; `null` while the model is `active`. + */ + fun deprecatedAt(deprecatedAt: OffsetDateTime?) = + deprecatedAt(JsonField.ofNullable(deprecatedAt)) + + /** Alias for calling [Builder.deprecatedAt] with `deprecatedAt.orElse(null)`. */ + fun deprecatedAt(deprecatedAt: Optional) = + deprecatedAt(deprecatedAt.getOrNull()) + + /** + * Sets [Builder.deprecatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deprecatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deprecatedAt(deprecatedAt: JsonField) = apply { + this.deprecatedAt = deprecatedAt + } + /** A human-readable name for the model. */ fun displayName(displayName: String) = displayName(JsonField.of(displayName)) @@ -356,6 +485,45 @@ private constructor( */ fun displayName(displayName: JsonField) = apply { this.displayName = displayName } + /** + * The model's current lifecycle stage. + * - `active`: The model is available for use, open to new adopters, and not scheduled for + * retirement. + * - `deprecated`: The model remains callable for organizations with existing access, but is + * headed for retirement and closed to new adopters. + * - `retired`: The model is no longer available for use; inference requests naming it fail. + * It remains in the catalogue as the historical record of its retirement. + */ + fun lifecycle(lifecycle: Lifecycle) = lifecycle(JsonField.of(lifecycle)) + + /** + * Sets [Builder.lifecycle] to an arbitrary JSON value. + * + * You should usually call [Builder.lifecycle] with a well-typed [Lifecycle] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lifecycle(lifecycle: JsonField) = apply { this.lifecycle = lifecycle } + + /** + * The model line this model belongs to, such as `opus` for both Claude Opus 4.5 and Claude + * Opus 4.6. More lines may be added. `null` when the model belongs to no line; do not infer + * a line from the `id`. + */ + fun line(line: BetaModelLine?) = line(JsonField.ofNullable(line)) + + /** Alias for calling [Builder.line] with `line.orElse(null)`. */ + fun line(line: Optional) = line(line.getOrNull()) + + /** + * Sets [Builder.line] to an arbitrary JSON value. + * + * You should usually call [Builder.line] with a well-typed [BetaModelLine] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun line(line: JsonField) = apply { this.line = line } + /** Maximum input context window size in tokens for this model. */ fun maxInputTokens(maxInputTokens: Long?) = maxInputTokens(JsonField.ofNullable(maxInputTokens)) @@ -403,6 +571,26 @@ private constructor( */ fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + /** + * RFC 3339 datetime string representing the model's currently scheduled retirement date. + * The schedule can be revised until retirement occurs; `null` while the model is `active` + * or while no retirement is scheduled. A past date on a `deprecated` model means retirement + * is overdue, not that it has occurred: `lifecycle` is the retirement signal. + */ + fun retiresAt(retiresAt: OffsetDateTime?) = retiresAt(JsonField.ofNullable(retiresAt)) + + /** Alias for calling [Builder.retiresAt] with `retiresAt.orElse(null)`. */ + fun retiresAt(retiresAt: Optional) = retiresAt(retiresAt.getOrNull()) + + /** + * Sets [Builder.retiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.retiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun retiresAt(retiresAt: JsonField) = apply { this.retiresAt = retiresAt } + /** * Sets the field to an arbitrary JSON value. * @@ -447,9 +635,13 @@ private constructor( * .allowedFallbackModels() * .capabilities() * .createdAt() + * .deprecatedAt() * .displayName() + * .lifecycle() + * .line() * .maxInputTokens() * .maxTokens() + * .retiresAt() * ``` * * @throws IllegalStateException if any required field is unset. @@ -462,9 +654,13 @@ private constructor( }, checkRequired("capabilities", capabilities), checkRequired("createdAt", createdAt), + checkRequired("deprecatedAt", deprecatedAt), checkRequired("displayName", displayName), + checkRequired("lifecycle", lifecycle), + checkRequired("line", line), checkRequired("maxInputTokens", maxInputTokens), checkRequired("maxTokens", maxTokens), + checkRequired("retiresAt", retiresAt), type, additionalProperties.toMutableMap(), ) @@ -489,9 +685,13 @@ private constructor( allowedFallbackModels() capabilities().ifPresent { it.validate() } createdAt() + deprecatedAt() displayName() + lifecycle().validate() + line().ifPresent { it.validate() } maxInputTokens() maxTokens() + retiresAt() _type().let { if (it != JsonValue.from("model")) { throw AnthropicInvalidDataException("'type' is invalid, received $it") @@ -519,11 +719,181 @@ private constructor( (allowedFallbackModels.asKnown().getOrNull()?.size ?: 0) + (capabilities.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (deprecatedAt.asKnown().isPresent) 1 else 0) + (if (displayName.asKnown().isPresent) 1 else 0) + + (lifecycle.asKnown().getOrNull()?.validity() ?: 0) + + (line.asKnown().getOrNull()?.validity() ?: 0) + (if (maxInputTokens.asKnown().isPresent) 1 else 0) + (if (maxTokens.asKnown().isPresent) 1 else 0) + + (if (retiresAt.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("model")) 1 else 0 } + /** + * The model's current lifecycle stage. + * - `active`: The model is available for use, open to new adopters, and not scheduled for + * retirement. + * - `deprecated`: The model remains callable for organizations with existing access, but is + * headed for retirement and closed to new adopters. + * - `retired`: The model is no longer available for use; inference requests naming it fail. It + * remains in the catalogue as the historical record of its retirement. + */ + class Lifecycle 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 ACTIVE = Lifecycle(JsonField.of("active")) + + @JvmField val DEPRECATED = Lifecycle(JsonField.of("deprecated")) + + @JvmField val RETIRED = Lifecycle(JsonField.of("retired")) + + @JvmStatic + fun of(value: String): Lifecycle = + // Intern known values so `==` works + when (value) { + "active" -> ACTIVE + "deprecated" -> DEPRECATED + "retired" -> RETIRED + else -> Lifecycle(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Lifecycle = + value.asString().getOrNull()?.let { of(it) } ?: Lifecycle(value) + } + + /** An enum containing [Lifecycle]'s known values. */ + enum class Known { + ACTIVE, + DEPRECATED, + RETIRED, + } + + /** + * An enum containing [Lifecycle]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Lifecycle] 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 { + ACTIVE, + DEPRECATED, + RETIRED, + /** + * An enum member indicating that [Lifecycle] 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) { + ACTIVE -> Value.ACTIVE + DEPRECATED -> Value.DEPRECATED + RETIRED -> Value.RETIRED + 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) { + ACTIVE -> Known.ACTIVE + DEPRECATED -> Known.DEPRECATED + RETIRED -> Known.RETIRED + else -> throw AnthropicInvalidDataException("Unknown Lifecycle: $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(): Lifecycle = 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 Lifecycle && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -534,9 +904,13 @@ private constructor( allowedFallbackModels == other.allowedFallbackModels && capabilities == other.capabilities && createdAt == other.createdAt && + deprecatedAt == other.deprecatedAt && displayName == other.displayName && + lifecycle == other.lifecycle && + line == other.line && maxInputTokens == other.maxInputTokens && maxTokens == other.maxTokens && + retiresAt == other.retiresAt && type == other.type && additionalProperties == other.additionalProperties } @@ -547,9 +921,13 @@ private constructor( allowedFallbackModels, capabilities, createdAt, + deprecatedAt, displayName, + lifecycle, + line, maxInputTokens, maxTokens, + retiresAt, type, additionalProperties, ) @@ -558,5 +936,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "BetaModelInfo{id=$id, allowedFallbackModels=$allowedFallbackModels, capabilities=$capabilities, createdAt=$createdAt, displayName=$displayName, maxInputTokens=$maxInputTokens, maxTokens=$maxTokens, type=$type, additionalProperties=$additionalProperties}" + "BetaModelInfo{id=$id, allowedFallbackModels=$allowedFallbackModels, capabilities=$capabilities, createdAt=$createdAt, deprecatedAt=$deprecatedAt, displayName=$displayName, lifecycle=$lifecycle, line=$line, maxInputTokens=$maxInputTokens, maxTokens=$maxTokens, retiresAt=$retiresAt, type=$type, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelLine.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelLine.kt new file mode 100644 index 000000000..130025a4e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaModelLine.kt @@ -0,0 +1,173 @@ +package com.anthropic.models.beta.models + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +/** A Claude model line, such as `opus` or `sonnet`. More lines may be added as new values. */ +class BetaModelLine 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 HAIKU = BetaModelLine(JsonField.of("haiku")) + + @JvmField val SONNET = BetaModelLine(JsonField.of("sonnet")) + + @JvmField val OPUS = BetaModelLine(JsonField.of("opus")) + + @JvmField val FABLE = BetaModelLine(JsonField.of("fable")) + + @JvmField val MYTHOS = BetaModelLine(JsonField.of("mythos")) + + @JvmStatic + fun of(value: String): BetaModelLine = + // Intern known values so `==` works + when (value) { + "haiku" -> HAIKU + "sonnet" -> SONNET + "opus" -> OPUS + "fable" -> FABLE + "mythos" -> MYTHOS + else -> BetaModelLine(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): BetaModelLine = + value.asString().getOrNull()?.let { of(it) } ?: BetaModelLine(value) + } + + /** An enum containing [BetaModelLine]'s known values. */ + enum class Known { + HAIKU, + SONNET, + OPUS, + FABLE, + MYTHOS, + } + + /** + * An enum containing [BetaModelLine]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BetaModelLine] 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 { + HAIKU, + SONNET, + OPUS, + FABLE, + MYTHOS, + /** + * An enum member indicating that [BetaModelLine] 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) { + HAIKU -> Value.HAIKU + SONNET -> Value.SONNET + OPUS -> Value.OPUS + FABLE -> Value.FABLE + MYTHOS -> Value.MYTHOS + 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) { + HAIKU -> Known.HAIKU + SONNET -> Known.SONNET + OPUS -> Known.OPUS + FABLE -> Known.FABLE + MYTHOS -> Known.MYTHOS + else -> throw AnthropicInvalidDataException("Unknown BetaModelLine: $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(): BetaModelLine = 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 BetaModelLine && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaServerToolsCapability.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaServerToolsCapability.kt new file mode 100644 index 000000000..d1244d17e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaServerToolsCapability.kt @@ -0,0 +1,281 @@ +package com.anthropic.models.beta.models + +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 + +/** Web search and code execution tool support, with one entry per tool. */ +class BetaServerToolsCapability +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val codeExecution: JsonField, + private val supported: JsonField, + private val webSearch: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code_execution") + @ExcludeMissing + codeExecution: JsonField = JsonMissing.of(), + @JsonProperty("supported") @ExcludeMissing supported: JsonField = JsonMissing.of(), + @JsonProperty("web_search") + @ExcludeMissing + webSearch: JsonField = JsonMissing.of(), + ) : this(codeExecution, supported, webSearch, mutableMapOf()) + + /** + * Whether the model supports the code execution tool: true when the model supports at least one + * version of the tool, not necessarily every 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 codeExecution(): BetaCapabilitySupport = codeExecution.getRequired("code_execution") + + /** + * Whether this capability is supported by the model. + * + * @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 supported(): Boolean = supported.getRequired("supported") + + /** + * Whether the model supports the web search tool: true when the model supports at least one + * version of the tool, not necessarily every 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 webSearch(): BetaCapabilitySupport = webSearch.getRequired("web_search") + + /** + * Returns the raw JSON value of [codeExecution]. + * + * Unlike [codeExecution], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code_execution") + @ExcludeMissing + fun _codeExecution(): JsonField = codeExecution + + /** + * Returns the raw JSON value of [supported]. + * + * Unlike [supported], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("supported") @ExcludeMissing fun _supported(): JsonField = supported + + /** + * Returns the raw JSON value of [webSearch]. + * + * Unlike [webSearch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("web_search") + @ExcludeMissing + fun _webSearch(): JsonField = webSearch + + @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 [BetaServerToolsCapability]. + * + * The following fields are required: + * ```java + * .codeExecution() + * .supported() + * .webSearch() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BetaServerToolsCapability]. */ + class Builder internal constructor() { + + private var codeExecution: JsonField? = null + private var supported: JsonField? = null + private var webSearch: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(betaServerToolsCapability: BetaServerToolsCapability) = apply { + codeExecution = betaServerToolsCapability.codeExecution + supported = betaServerToolsCapability.supported + webSearch = betaServerToolsCapability.webSearch + additionalProperties = betaServerToolsCapability.additionalProperties.toMutableMap() + } + + /** + * Whether the model supports the code execution tool: true when the model supports at least + * one version of the tool, not necessarily every version. + */ + fun codeExecution(codeExecution: BetaCapabilitySupport) = + codeExecution(JsonField.of(codeExecution)) + + /** + * Sets [Builder.codeExecution] to an arbitrary JSON value. + * + * You should usually call [Builder.codeExecution] with a well-typed [BetaCapabilitySupport] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun codeExecution(codeExecution: JsonField) = apply { + this.codeExecution = codeExecution + } + + /** Whether this capability is supported by the model. */ + fun supported(supported: Boolean) = supported(JsonField.of(supported)) + + /** + * Sets [Builder.supported] to an arbitrary JSON value. + * + * You should usually call [Builder.supported] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun supported(supported: JsonField) = apply { this.supported = supported } + + /** + * Whether the model supports the web search tool: true when the model supports at least one + * version of the tool, not necessarily every version. + */ + fun webSearch(webSearch: BetaCapabilitySupport) = webSearch(JsonField.of(webSearch)) + + /** + * Sets [Builder.webSearch] to an arbitrary JSON value. + * + * You should usually call [Builder.webSearch] with a well-typed [BetaCapabilitySupport] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webSearch(webSearch: JsonField) = apply { + this.webSearch = webSearch + } + + 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 [BetaServerToolsCapability]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .codeExecution() + * .supported() + * .webSearch() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BetaServerToolsCapability = + BetaServerToolsCapability( + checkRequired("codeExecution", codeExecution), + checkRequired("supported", supported), + checkRequired("webSearch", webSearch), + 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(): BetaServerToolsCapability = apply { + if (validated) { + return@apply + } + + codeExecution().validate() + supported() + webSearch().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 = + (codeExecution.asKnown().getOrNull()?.validity() ?: 0) + + (if (supported.asKnown().isPresent) 1 else 0) + + (webSearch.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BetaServerToolsCapability && + codeExecution == other.codeExecution && + supported == other.supported && + webSearch == other.webSearch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(codeExecution, supported, webSearch, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BetaServerToolsCapability{codeExecution=$codeExecution, supported=$supported, webSearch=$webSearch, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaThinkingTypes.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaThinkingTypes.kt index e4b55d1ad..6ddb30ab8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaThinkingTypes.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/BetaThinkingTypes.kt @@ -14,11 +14,15 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull -/** Supported thinking type configurations. */ +/** + * Which `thinking.type` values the model accepts on requests. Read each key on its own: for + * example, `enabled` can be false while `disabled` is true. + */ class BetaThinkingTypes @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adaptive: JsonField, + private val disabled: JsonField, private val enabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -28,13 +32,17 @@ private constructor( @JsonProperty("adaptive") @ExcludeMissing adaptive: JsonField = JsonMissing.of(), + @JsonProperty("disabled") + @ExcludeMissing + disabled: JsonField = JsonMissing.of(), @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), - ) : this(adaptive, enabled, mutableMapOf()) + ) : this(adaptive, disabled, enabled, mutableMapOf()) /** - * Whether the model supports thinking with type 'adaptive' (auto). + * Whether the model accepts thinking with type 'adaptive' (the model decides whether and how + * much to think). * * @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). @@ -42,7 +50,18 @@ private constructor( fun adaptive(): BetaCapabilitySupport = adaptive.getRequired("adaptive") /** - * Whether the model supports thinking with type 'enabled'. + * Whether the model accepts thinking with type 'disabled' (thinking turned off). False exactly + * when a request that sends it gets a 400 from this model. True on a model that does not + * support thinking. + * + * @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 disabled(): BetaCapabilitySupport = disabled.getRequired("disabled") + + /** + * Whether the model accepts thinking with type 'enabled' (extended thinking with a caller-set + * `budget_tokens`). * * @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). @@ -58,6 +77,15 @@ private constructor( @ExcludeMissing fun _adaptive(): JsonField = adaptive + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") + @ExcludeMissing + fun _disabled(): JsonField = disabled + /** * Returns the raw JSON value of [enabled]. * @@ -87,6 +115,7 @@ private constructor( * The following fields are required: * ```java * .adaptive() + * .disabled() * .enabled() * ``` */ @@ -97,17 +126,22 @@ private constructor( class Builder internal constructor() { private var adaptive: JsonField? = null + private var disabled: JsonField? = null private var enabled: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(betaThinkingTypes: BetaThinkingTypes) = apply { adaptive = betaThinkingTypes.adaptive + disabled = betaThinkingTypes.disabled enabled = betaThinkingTypes.enabled additionalProperties = betaThinkingTypes.additionalProperties.toMutableMap() } - /** Whether the model supports thinking with type 'adaptive' (auto). */ + /** + * Whether the model accepts thinking with type 'adaptive' (the model decides whether and + * how much to think). + */ fun adaptive(adaptive: BetaCapabilitySupport) = adaptive(JsonField.of(adaptive)) /** @@ -121,7 +155,28 @@ private constructor( this.adaptive = adaptive } - /** Whether the model supports thinking with type 'enabled'. */ + /** + * Whether the model accepts thinking with type 'disabled' (thinking turned off). False + * exactly when a request that sends it gets a 400 from this model. True on a model that + * does not support thinking. + */ + fun disabled(disabled: BetaCapabilitySupport) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [BetaCapabilitySupport] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun disabled(disabled: JsonField) = apply { + this.disabled = disabled + } + + /** + * Whether the model accepts thinking with type 'enabled' (extended thinking with a + * caller-set `budget_tokens`). + */ fun enabled(enabled: BetaCapabilitySupport) = enabled(JsonField.of(enabled)) /** @@ -160,6 +215,7 @@ private constructor( * The following fields are required: * ```java * .adaptive() + * .disabled() * .enabled() * ``` * @@ -168,6 +224,7 @@ private constructor( fun build(): BetaThinkingTypes = BetaThinkingTypes( checkRequired("adaptive", adaptive), + checkRequired("disabled", disabled), checkRequired("enabled", enabled), additionalProperties.toMutableMap(), ) @@ -189,6 +246,7 @@ private constructor( } adaptive().validate() + disabled().validate() enabled().validate() validated = true } @@ -209,6 +267,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (adaptive.asKnown().getOrNull()?.validity() ?: 0) + + (disabled.asKnown().getOrNull()?.validity() ?: 0) + (enabled.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -218,14 +277,17 @@ private constructor( return other is BetaThinkingTypes && adaptive == other.adaptive && + disabled == other.disabled && enabled == other.enabled && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(adaptive, enabled, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(adaptive, disabled, enabled, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "BetaThinkingTypes{adaptive=$adaptive, enabled=$enabled, additionalProperties=$additionalProperties}" + "BetaThinkingTypes{adaptive=$adaptive, disabled=$disabled, enabled=$enabled, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelListParams.kt index 12b2f4da9..d1182a8a8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelListParams.kt @@ -1,10 +1,14 @@ package com.anthropic.models.beta.models +import com.anthropic.core.Enum +import com.anthropic.core.JsonField import com.anthropic.core.Params import com.anthropic.core.http.Headers import com.anthropic.core.http.QueryParams import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.AnthropicBeta +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -19,6 +23,7 @@ class ModelListParams private constructor( private val afterId: String?, private val beforeId: String?, + private val lifecycle: List?, private val limit: Long?, private val betas: List?, private val workspaceId: String?, @@ -38,6 +43,13 @@ private constructor( */ fun beforeId(): Optional = Optional.ofNullable(beforeId) + /** + * Filter the list to models in any of the given lifecycle stages (`active`, `deprecated`, or + * `retired`). Up to 3 values. When omitted, the list contains the `active` and `deprecated` + * models; `retired` models appear only when `retired` is requested explicitly. + */ + fun lifecycle(): Optional> = Optional.ofNullable(lifecycle) + /** * Number of items to return per page. * @@ -78,6 +90,7 @@ private constructor( private var afterId: String? = null private var beforeId: String? = null + private var lifecycle: MutableList? = null private var limit: Long? = null private var betas: MutableList? = null private var workspaceId: String? = null @@ -88,6 +101,7 @@ private constructor( internal fun from(modelListParams: ModelListParams) = apply { afterId = modelListParams.afterId beforeId = modelListParams.beforeId + lifecycle = modelListParams.lifecycle?.toMutableList() limit = modelListParams.limit betas = modelListParams.betas?.toMutableList() workspaceId = modelListParams.workspaceId @@ -113,6 +127,27 @@ private constructor( /** Alias for calling [Builder.beforeId] with `beforeId.orElse(null)`. */ fun beforeId(beforeId: Optional) = beforeId(beforeId.getOrNull()) + /** + * Filter the list to models in any of the given lifecycle stages (`active`, `deprecated`, + * or `retired`). Up to 3 values. When omitted, the list contains the `active` and + * `deprecated` models; `retired` models appear only when `retired` is requested explicitly. + */ + fun lifecycle(lifecycle: List?) = apply { + this.lifecycle = lifecycle?.toMutableList() + } + + /** Alias for calling [Builder.lifecycle] with `lifecycle.orElse(null)`. */ + fun lifecycle(lifecycle: Optional>) = lifecycle(lifecycle.getOrNull()) + + /** + * Adds a single [Lifecycle] to [Builder.lifecycle]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLifecycle(lifecycle: Lifecycle) = apply { + this.lifecycle = (this.lifecycle ?: mutableListOf()).apply { add(lifecycle) } + } + /** * Number of items to return per page. * @@ -273,6 +308,7 @@ private constructor( ModelListParams( afterId, beforeId, + lifecycle?.toImmutable(), limit, betas?.toImmutable(), workspaceId, @@ -284,7 +320,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } @@ -295,11 +335,169 @@ private constructor( .apply { afterId?.let { put("after_id", it) } beforeId?.let { put("before_id", it) } + lifecycle?.forEach { put("lifecycle[]", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) } .build() + class Lifecycle 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 ACTIVE = Lifecycle(JsonField.of("active")) + + @JvmField val DEPRECATED = Lifecycle(JsonField.of("deprecated")) + + @JvmField val RETIRED = Lifecycle(JsonField.of("retired")) + + @JvmStatic + fun of(value: String): Lifecycle = + // Intern known values so `==` works + when (value) { + "active" -> ACTIVE + "deprecated" -> DEPRECATED + "retired" -> RETIRED + else -> Lifecycle(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Lifecycle = + value.asString().getOrNull()?.let { of(it) } ?: Lifecycle(value) + } + + /** An enum containing [Lifecycle]'s known values. */ + enum class Known { + ACTIVE, + DEPRECATED, + RETIRED, + } + + /** + * An enum containing [Lifecycle]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Lifecycle] 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 { + ACTIVE, + DEPRECATED, + RETIRED, + /** + * An enum member indicating that [Lifecycle] 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) { + ACTIVE -> Value.ACTIVE + DEPRECATED -> Value.DEPRECATED + RETIRED -> Value.RETIRED + 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) { + ACTIVE -> Known.ACTIVE + DEPRECATED -> Known.DEPRECATED + RETIRED -> Known.RETIRED + else -> throw AnthropicInvalidDataException("Unknown Lifecycle: $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(): Lifecycle = 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 Lifecycle && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -308,6 +506,7 @@ private constructor( return other is ModelListParams && afterId == other.afterId && beforeId == other.beforeId && + lifecycle == other.lifecycle && limit == other.limit && betas == other.betas && workspaceId == other.workspaceId && @@ -319,6 +518,7 @@ private constructor( Objects.hash( afterId, beforeId, + lifecycle, limit, betas, workspaceId, @@ -327,5 +527,5 @@ private constructor( ) override fun toString() = - "ModelListParams{afterId=$afterId, beforeId=$beforeId, limit=$limit, betas=$betas, workspaceId=$workspaceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ModelListParams{afterId=$afterId, beforeId=$beforeId, lifecycle=$lifecycle, limit=$limit, betas=$betas, workspaceId=$workspaceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelRetrieveParams.kt index 60ff88909..90d1cd348 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/models/ModelRetrieveParams.kt @@ -237,7 +237,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/costreport/CostReportListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/costreport/CostReportListPageResponse.kt index da7671284..ded28a8a9 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/costreport/CostReportListPageResponse.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/costreport/CostReportListPageResponse.kt @@ -58,8 +58,9 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case every bucket's `results` list is empty. * Buckets beyond this watermark are incomplete; for stable results, set `ending_at` to this - * value or earlier. Data is typically refreshed every 4 hours but not final until about 30 days - * after the usage date (late-arriving events, reconciliation adjustments). + * value or earlier. Data is typically refreshed every 4 hours. Values can be revised as late + * events arrive and reconciliation runs, until about 7 days after the end of the calendar month + * the usage falls in; for example, values for October 1 can change until about November 7. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -222,8 +223,10 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case every bucket's `results` list is * empty. Buckets beyond this watermark are incomplete; for stable results, set `ending_at` - * to this value or earlier. Data is typically refreshed every 4 hours but not final until - * about 30 days after the usage date (late-arriving events, reconciliation adjustments). + * to this value or earlier. Data is typically refreshed every 4 hours. Values can be + * revised as late events arrive and reconciliation runs, until about 7 days after the end + * of the calendar month the usage falls in; for example, values for October 1 can change + * until about November 7. */ fun dataRefreshedAt(dataRefreshedAt: OffsetDateTime?) = dataRefreshedAt(JsonField.ofNullable(dataRefreshedAt)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/summaries/SummaryListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/summaries/SummaryListParams.kt index 7f3a25540..54ba9150d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/summaries/SummaryListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/summaries/SummaryListParams.kt @@ -15,12 +15,12 @@ import kotlin.jvm.optionals.getOrNull * * Returns one entry per day from `starting_date` (inclusive) to `ending_date` (exclusive) in * `data`, the same `data` / `next_page` envelope as the other analytics list endpoints; the series - * is currently returned in full, so `next_page` is always null (`summaries` is a deprecated alias - * of `data`). Data is typically available with a 1-day lag and may be revised by a few percent over - * the following days: when `ending_date` is omitted it defaults to the most recent available day + - * 1, so the last entry covers the most recent available day. The series can be scoped to an RBAC - * group via `filter[]=rbac_group_id:{id}`. Available to organizations on a Claude Enterprise plan. - * Requires an API key with the `read:analytics` scope. + * is currently returned in full, so `next_page` is always null. Data is typically available with a + * 1-day lag and may be revised by a few percent over the following days: when `ending_date` is + * omitted it defaults to the most recent available day + 1, so the last entry covers the most + * recent available day. The series can be scoped to an RBAC group via + * `filter[]=rbac_group_id:{id}`. Available to organizations on a Claude Enterprise plan. Requires + * an API key with the `read:analytics` scope. */ class SummaryListParams private constructor( diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usagereport/UsageReportListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usagereport/UsageReportListPageResponse.kt index 227b247b6..19d0e1278 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usagereport/UsageReportListPageResponse.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usagereport/UsageReportListPageResponse.kt @@ -58,8 +58,9 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case every bucket's `results` list is empty. * Buckets beyond this watermark are incomplete; for stable results, set `ending_at` to this - * value or earlier. Data is typically refreshed every 4 hours but not final until about 30 days - * after the usage date (late-arriving events, reconciliation adjustments). + * value or earlier. Data is typically refreshed every 4 hours. Values can be revised as late + * events arrive and reconciliation runs, until about 7 days after the end of the calendar month + * the usage falls in; for example, values for October 1 can change until about November 7. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -222,8 +223,10 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case every bucket's `results` list is * empty. Buckets beyond this watermark are incomplete; for stable results, set `ending_at` - * to this value or earlier. Data is typically refreshed every 4 hours but not final until - * about 30 days after the usage date (late-arriving events, reconciliation adjustments). + * to this value or earlier. Data is typically refreshed every 4 hours. Values can be + * revised as late events arrive and reconciliation runs, until about 7 days after the end + * of the calendar month the usage falls in; for example, values for October 1 can change + * until about November 7. */ fun dataRefreshedAt(dataRefreshedAt: OffsetDateTime?) = dataRefreshedAt(JsonField.ofNullable(dataRefreshedAt)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usercostreport/UserCostReportListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usercostreport/UserCostReportListPageResponse.kt index 5f555d7e1..a5142dd75 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usercostreport/UserCostReportListPageResponse.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/usercostreport/UserCostReportListPageResponse.kt @@ -60,8 +60,9 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case `data` is empty. Data beyond this * watermark is incomplete; for stable results, set `ending_at` to this value or earlier. Data - * is typically refreshed every 4 hours but not final until about 30 days after the usage date - * (late-arriving events, reconciliation adjustments). + * is typically refreshed every 4 hours. Values can be revised as late events arrive and + * reconciliation runs, until about 7 days after the end of the calendar month the usage falls + * in; for example, values for October 1 can change until about November 7. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -227,8 +228,9 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case `data` is empty. Data beyond this * watermark is incomplete; for stable results, set `ending_at` to this value or earlier. - * Data is typically refreshed every 4 hours but not final until about 30 days after the - * usage date (late-arriving events, reconciliation adjustments). + * Data is typically refreshed every 4 hours. Values can be revised as late events arrive + * and reconciliation runs, until about 7 days after the end of the calendar month the usage + * falls in; for example, values for October 1 can change until about November 7. */ fun dataRefreshedAt(dataRefreshedAt: OffsetDateTime?) = dataRefreshedAt(JsonField.ofNullable(dataRefreshedAt)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/userusagereport/UserUsageReportListPageResponse.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/userusagereport/UserUsageReportListPageResponse.kt index 04855f236..5b3c6dad0 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/userusagereport/UserUsageReportListPageResponse.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/analytics/userusagereport/UserUsageReportListPageResponse.kt @@ -60,8 +60,9 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case `data` is empty. Data beyond this * watermark is incomplete; for stable results, set `ending_at` to this value or earlier. Data - * is typically refreshed every 4 hours but not final until about 30 days after the usage date - * (late-arriving events, reconciliation adjustments). + * is typically refreshed every 4 hours. Values can be revised as late events arrive and + * reconciliation runs, until about 7 days after the end of the calendar month the usage falls + * in; for example, values for October 1 can change until about November 7. * * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -228,8 +229,9 @@ private constructor( * RFC 3339 timestamp of the export this response was served from. Null when no export yet * covers any part of the requested range, in which case `data` is empty. Data beyond this * watermark is incomplete; for stable results, set `ending_at` to this value or earlier. - * Data is typically refreshed every 4 hours but not final until about 30 days after the - * usage date (late-arriving events, reconciliation adjustments). + * Data is typically refreshed every 4 hours. Values can be revised as late events arrive + * and reconciliation runs, until about 7 days after the end of the calendar month the usage + * falls in; for example, values for October 1 can change until about November 7. */ fun dataRefreshedAt(dataRefreshedAt: OffsetDateTime?) = dataRefreshedAt(JsonField.ofNullable(dataRefreshedAt)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParams.kt index 4c3c99976..b175f606a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParams.kt @@ -255,7 +255,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParams.kt index 93fa56859..c4729e22c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParams.kt @@ -488,7 +488,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParams.kt index 663307a11..5ac543e00 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParams.kt @@ -252,7 +252,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParams.kt index 81af3bca7..c7def19bd 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParams.kt @@ -218,7 +218,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParams.kt index 5ba6e5771..b4fc6c388 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParams.kt @@ -562,7 +562,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/BetaFederationRule.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/BetaFederationRule.kt index c4ba07320..0c6efec78 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/BetaFederationRule.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/BetaFederationRule.kt @@ -241,8 +241,8 @@ private constructor( fun oauthScope(): String = oauthScope.getRequired("oauth_scope") /** - * Identity that tokens minted via this rule act as. Currently always a `service_account` - * target. + * What this rule targets. Check `type` before reading the other fields. Tokens minted via a + * rule whose target `type` is `service_account` act as that service account. * * @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). @@ -754,8 +754,8 @@ private constructor( fun oauthScope(oauthScope: JsonField) = apply { this.oauthScope = oauthScope } /** - * Identity that tokens minted via this rule act as. Currently always a `service_account` - * target. + * What this rule targets. Check `type` before reading the other fields. Tokens minted via a + * rule whose target `type` is `service_account` act as that service account. */ fun target(target: BetaServiceAccountTarget) = target(JsonField.of(target)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParams.kt index 74284f708..121d3df8e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParams.kt @@ -255,7 +255,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParams.kt index 1890c9270..5216d790e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParams.kt @@ -602,7 +602,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParams.kt index a49b1a649..bad6359b3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParams.kt @@ -266,7 +266,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParams.kt index 1b15e574f..f7eb8381b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParams.kt @@ -216,7 +216,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParams.kt index 83c717bd1..e7f3e82d2 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParams.kt @@ -617,7 +617,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParams.kt index 47030cb72..81c771d8d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParams.kt @@ -309,7 +309,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParams.kt index b5024bbcc..a0650f5c0 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParams.kt @@ -254,7 +254,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParams.kt index b64c341dc..21f7acafc 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParams.kt @@ -276,7 +276,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParams.kt index 811712fb6..c825a8c1f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParams.kt @@ -320,7 +320,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParams.kt index 934728e18..45382ee9a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParams.kt @@ -252,7 +252,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParams.kt index e9c47e886..5084d3124 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParams.kt @@ -323,7 +323,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParams.kt index 37f5ccf17..ff1237c0f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParams.kt @@ -333,7 +333,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParams.kt index 1a2e83d5f..2f9c83d79 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParams.kt @@ -352,7 +352,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParams.kt index b3a5b42dd..b402a4437 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParams.kt @@ -426,7 +426,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParams.kt index 2a962d1c7..7046412fa 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParams.kt @@ -259,7 +259,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParams.kt index ff7126ed7..fea261560 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParams.kt @@ -387,7 +387,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParams.kt index 1f484d684..939bd8375 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParams.kt @@ -246,7 +246,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParams.kt index 4c1149d9b..87bc86324 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParams.kt @@ -328,7 +328,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParams.kt index 78371ddd3..56de369e5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParams.kt @@ -318,7 +318,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParams.kt index d0a29754e..5ee379ee8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParams.kt @@ -302,7 +302,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParams.kt index 5805bebef..7e768bb17 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParams.kt @@ -348,7 +348,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParams.kt index 48fe9dfbf..83dc42db4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParams.kt @@ -315,7 +315,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParams.kt index 062590221..d50499342 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParams.kt @@ -397,7 +397,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParams.kt index bcd1dccea..d8464009c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParams.kt @@ -284,7 +284,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParams.kt index c7e4932f5..8dcdd3d83 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParams.kt @@ -289,7 +289,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParams.kt index 4faf9df69..0ec58a4fc 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParams.kt @@ -270,7 +270,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("ce-plugins-2026-09-01") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/ratelimits/RateLimitListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/ratelimits/RateLimitListParams.kt index 8819afda6..24d43e20a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/ratelimits/RateLimitListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/ratelimits/RateLimitListParams.kt @@ -15,8 +15,8 @@ import kotlin.jvm.optionals.getOrNull * List Messages API rate limits for your organization. * * Each entry corresponds to one rate-limit group (either a model family or an API-surface category - * such as the Files API or Message Batches) and contains the set of limiter values that apply to - * it. + * such as the Message Batches API or the web search tool) and contains the set of limiter values + * that apply to it. * * When `limit` is omitted, every matching entry is returned in a single page; when `limit` * truncates the result, follow `next_page` to fetch the remaining entries. diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRole.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRole.kt index 2da814e7e..d7e3e68e3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRole.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRole.kt @@ -19,6 +19,7 @@ class BetaRbacRole private constructor( private val id: JsonField, private val createdAt: JsonField, + private val displayName: JsonField, private val name: JsonField, private val type: JsonValue, private val updatedAt: JsonField, @@ -31,12 +32,15 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("display_name") + @ExcludeMissing + displayName: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), - ) : this(id, createdAt, name, type, updatedAt, mutableMapOf()) + ) : this(id, createdAt, displayName, name, type, updatedAt, mutableMapOf()) /** * ID of the RBAC Role. @@ -55,11 +59,23 @@ private constructor( fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") /** - * Name of the RBAC Role. + * Name of the RBAC Role. For a role created by Anthropic, this name can differ from the label + * claude.ai shows, and Anthropic may change the name. To keep a lasting reference to a role, + * store its `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 displayName(): String = displayName.getRequired("display_name") + + /** + * Deprecated: use `display_name` instead. Name of the RBAC Role; always the same value as + * `display_name`. * * @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). */ + @Deprecated("Use `display_name` instead; `name` always has the same value.") fun name(): String = name.getRequired("name") /** @@ -101,12 +117,24 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [displayName]. + * + * Unlike [displayName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName + /** * Returns the raw JSON value of [name]. * * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @Deprecated("Use `display_name` instead; `name` always has the same value.") + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name /** * Returns the raw JSON value of [updatedAt]. @@ -138,6 +166,7 @@ private constructor( * ```java * .id() * .createdAt() + * .displayName() * .name() * .updatedAt() * ``` @@ -150,6 +179,7 @@ private constructor( private var id: JsonField? = null private var createdAt: JsonField? = null + private var displayName: JsonField? = null private var name: JsonField? = null private var type: JsonValue = JsonValue.from("rbac_role") private var updatedAt: JsonField? = null @@ -159,6 +189,7 @@ private constructor( internal fun from(betaRbacRole: BetaRbacRole) = apply { id = betaRbacRole.id createdAt = betaRbacRole.createdAt + displayName = betaRbacRole.displayName name = betaRbacRole.name type = betaRbacRole.type updatedAt = betaRbacRole.updatedAt @@ -188,7 +219,27 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - /** Name of the RBAC Role. */ + /** + * Name of the RBAC Role. For a role created by Anthropic, this name can differ from the + * label claude.ai shows, and Anthropic may change the name. To keep a lasting reference to + * a role, store its `id`. + */ + fun displayName(displayName: String) = displayName(JsonField.of(displayName)) + + /** + * Sets [Builder.displayName] to an arbitrary JSON value. + * + * You should usually call [Builder.displayName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun displayName(displayName: JsonField) = apply { this.displayName = displayName } + + /** + * Deprecated: use `display_name` instead. Name of the RBAC Role; always the same value as + * `display_name`. + */ + @Deprecated("Use `display_name` instead; `name` always has the same value.") fun name(name: String) = name(JsonField.of(name)) /** @@ -197,6 +248,7 @@ private constructor( * You should usually call [Builder.name] with a well-typed [String] value instead. This * method is primarily for setting the field to an undocumented or not yet supported value. */ + @Deprecated("Use `display_name` instead; `name` always has the same value.") fun name(name: JsonField) = apply { this.name = name } /** @@ -253,6 +305,7 @@ private constructor( * ```java * .id() * .createdAt() + * .displayName() * .name() * .updatedAt() * ``` @@ -263,6 +316,7 @@ private constructor( BetaRbacRole( checkRequired("id", id), checkRequired("createdAt", createdAt), + checkRequired("displayName", displayName), checkRequired("name", name), type, checkRequired("updatedAt", updatedAt), @@ -287,6 +341,7 @@ private constructor( id() createdAt() + displayName() name() _type().let { if (it != JsonValue.from("rbac_role")) { @@ -314,6 +369,7 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (displayName.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("rbac_role")) 1 else 0 } + (if (updatedAt.asKnown().isPresent) 1 else 0) @@ -326,6 +382,7 @@ private constructor( return other is BetaRbacRole && id == other.id && createdAt == other.createdAt && + displayName == other.displayName && name == other.name && type == other.type && updatedAt == other.updatedAt && @@ -333,11 +390,11 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(id, createdAt, name, type, updatedAt, additionalProperties) + Objects.hash(id, createdAt, displayName, name, type, updatedAt, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "BetaRbacRole{id=$id, createdAt=$createdAt, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "BetaRbacRole{id=$id, createdAt=$createdAt, displayName=$displayName, name=$name, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParams.kt index ee22dbccd..f9f277797 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParams.kt @@ -256,7 +256,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParams.kt index cdbde80a9..e96183c82 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParams.kt @@ -354,7 +354,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParams.kt index 1bdeabc68..617e68028 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParams.kt @@ -253,7 +253,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParams.kt index 5a0d6d7e5..db8d9ebc6 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParams.kt @@ -218,7 +218,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParams.kt index 426f8eed3..c9edb1f1c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParams.kt @@ -341,7 +341,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParams.kt index 8332408e6..1817c16bf 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParams.kt @@ -342,7 +342,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParams.kt index 818540b01..ba83eba96 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParams.kt @@ -259,7 +259,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParams.kt index 1118b2815..7e918eadc 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParams.kt @@ -278,7 +278,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParams.kt index a20062476..ea4c40a0f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParams.kt @@ -270,7 +270,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("spend-limit-reads-2026-09-26") - it) } + .joinToString(","), + ) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParams.kt index fdd4270db..da798b6a6 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParams.kt @@ -12,7 +12,9 @@ import com.anthropic.core.checkRequired import com.anthropic.core.getOrThrow import com.anthropic.core.http.Headers import com.anthropic.core.http.QueryParams +import com.anthropic.core.toImmutable import com.anthropic.errors.AnthropicInvalidDataException +import com.anthropic.models.beta.AnthropicBeta import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator @@ -40,11 +42,15 @@ import kotlin.jvm.optionals.getOrNull */ class SpendLimitSetParams private constructor( + private val betas: List?, private val body: Body, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(): Optional> = Optional.ofNullable(betas) + /** * Limit amount as a non-negative integer decimal string in the minor unit of the organization's * billing currency (cents for USD): "50000" is $500.00. `null` sets an explicit no-limit @@ -121,17 +127,43 @@ private constructor( /** A builder for [SpendLimitSetParams]. */ class Builder internal constructor() { + private var betas: MutableList? = null private var body: Body.Builder = Body.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(spendLimitSetParams: SpendLimitSetParams) = apply { + betas = spendLimitSetParams.betas?.toMutableList() body = spendLimitSetParams.body.toBuilder() additionalHeaders = spendLimitSetParams.additionalHeaders.toBuilder() additionalQueryParams = spendLimitSetParams.additionalQueryParams.toBuilder() } + /** Optional header to specify the beta version(s) you want to use. */ + fun betas(betas: List?) = apply { this.betas = betas?.toMutableList() } + + /** Alias for calling [Builder.betas] with `betas.orElse(null)`. */ + fun betas(betas: Optional>) = betas(betas.getOrNull()) + + /** + * Adds a single [AnthropicBeta] to [betas]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addBeta(beta: AnthropicBeta) = apply { + betas = (betas ?: mutableListOf()).apply { add(beta) } + } + + /** + * Sets [addBeta] to an arbitrary [String]. + * + * You should usually call [addBeta] with a well-typed [AnthropicBeta] constant instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun addBeta(value: String) = addBeta(AnthropicBeta.of(value)) + /** * Sets the entire request body. * @@ -352,6 +384,7 @@ private constructor( */ fun build(): SpendLimitSetParams = SpendLimitSetParams( + betas?.toImmutable(), body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -360,7 +393,17 @@ private constructor( fun _body(): Body = body - override fun _headers(): Headers = additionalHeaders + override fun _headers(): Headers = + Headers.builder() + .apply { + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } + putAll(additionalHeaders) + } + .build() override fun _queryParams(): QueryParams = additionalQueryParams @@ -1080,13 +1123,15 @@ private constructor( } return other is SpendLimitSetParams && + betas == other.betas && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } - override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + override fun hashCode(): Int = + Objects.hash(betas, body, additionalHeaders, additionalQueryParams) override fun toString() = - "SpendLimitSetParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "SpendLimitSetParams{betas=$betas, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParams.kt index 35cb12167..afaff78a3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParams.kt @@ -430,7 +430,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParams.kt index 1479b90a8..59a2a802d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParams.kt @@ -13,6 +13,7 @@ private constructor( private val afterId: String?, private val beforeId: String?, private val includeArchived: Boolean?, + private val includeDefault: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -33,6 +34,9 @@ private constructor( /** Whether to include Workspaces that have been archived in the response */ fun includeArchived(): Optional = Optional.ofNullable(includeArchived) + /** Whether to include the organization's default Workspace in the response */ + fun includeDefault(): Optional = Optional.ofNullable(includeDefault) + /** * Number of items to return per page. * @@ -62,6 +66,7 @@ private constructor( private var afterId: String? = null private var beforeId: String? = null private var includeArchived: Boolean? = null + private var includeDefault: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -71,6 +76,7 @@ private constructor( afterId = workspaceListParams.afterId beforeId = workspaceListParams.beforeId includeArchived = workspaceListParams.includeArchived + includeDefault = workspaceListParams.includeDefault limit = workspaceListParams.limit additionalHeaders = workspaceListParams.additionalHeaders.toBuilder() additionalQueryParams = workspaceListParams.additionalQueryParams.toBuilder() @@ -110,6 +116,22 @@ private constructor( fun includeArchived(includeArchived: Optional) = includeArchived(includeArchived.getOrNull()) + /** Whether to include the organization's default Workspace in the response */ + fun includeDefault(includeDefault: Boolean?) = apply { + this.includeDefault = includeDefault + } + + /** + * Alias for [Builder.includeDefault]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeDefault(includeDefault: Boolean) = includeDefault(includeDefault as Boolean?) + + /** Alias for calling [Builder.includeDefault] with `includeDefault.orElse(null)`. */ + fun includeDefault(includeDefault: Optional) = + includeDefault(includeDefault.getOrNull()) + /** * Number of items to return per page. * @@ -235,6 +257,7 @@ private constructor( afterId, beforeId, includeArchived, + includeDefault, limit, additionalHeaders.build(), additionalQueryParams.build(), @@ -249,6 +272,7 @@ private constructor( afterId?.let { put("after_id", it) } beforeId?.let { put("before_id", it) } includeArchived?.let { put("include_archived", it.toString()) } + includeDefault?.let { put("include_default", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) } @@ -263,6 +287,7 @@ private constructor( afterId == other.afterId && beforeId == other.beforeId && includeArchived == other.includeArchived && + includeDefault == other.includeDefault && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -273,11 +298,12 @@ private constructor( afterId, beforeId, includeArchived, + includeDefault, limit, additionalHeaders, additionalQueryParams, ) override fun toString() = - "WorkspaceListParams{afterId=$afterId, beforeId=$beforeId, includeArchived=$includeArchived, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "WorkspaceListParams{afterId=$afterId, beforeId=$beforeId, includeArchived=$includeArchived, includeDefault=$includeDefault, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParams.kt index e94d2fe6b..f84f77dd3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParams.kt @@ -346,7 +346,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParams.kt index 73b7abf8b..18659dc9c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParams.kt @@ -251,7 +251,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParams.kt index 3ada7b1b9..b19fb2d96 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParams.kt @@ -279,7 +279,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParams.kt index cbcfb4517..ab767f191 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParams.kt @@ -245,7 +245,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParams.kt index 6f6fa560b..1a632617b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParams.kt @@ -325,7 +325,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } putAll(additionalHeaders) } .build() diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAdvisorParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAdvisorParams.kt index 15de282cb..48e3287f4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAdvisorParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsAdvisorParams.kt @@ -34,8 +34,7 @@ private constructor( ) : this(model, type, mutableMapOf()) /** - * A Claude model id. The model must be permitted as an advisor for this agent's model — see the - * sessions/threads/advisor spec. + * A Claude model id. The model must be permitted as an advisor for this agent's model. * * @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). @@ -104,10 +103,7 @@ private constructor( betaManagedAgentsAdvisorParams.additionalProperties.toMutableMap() } - /** - * A Claude model id. The model must be permitted as an advisor for this agent's model — see - * the sessions/threads/advisor spec. - */ + /** A Claude model id. The model must be permitted as an advisor for this agent's model. */ fun model(model: String) = model(JsonField.of(model)) /** 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 index 560a9b317..2dd281ea1 100644 --- 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 @@ -18,7 +18,7 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull -/** Multiagent orchestration configuration. Currently supports the `coordinator` topology. */ +/** Multiagent orchestration configuration. */ class BetaManagedAgentsMultiagentParams @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParams.kt index 500e3c48d..a05b9937b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParams.kt @@ -263,7 +263,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt index 7ab347cd8..545f6ea83 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionCreateParams.kt @@ -669,7 +669,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParams.kt index ce5d106ec..9bb5303e1 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParams.kt @@ -263,7 +263,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt index a2ae57a3f..8bf3fe40f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionListParams.kt @@ -428,7 +428,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParams.kt index c3b83e97c..68861600b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParams.kt @@ -230,7 +230,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParams.kt index 519279104..8ac6a4243 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParams.kt @@ -474,7 +474,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt index f3b35053d..e3d8d2689 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEvent.kt @@ -752,8 +752,8 @@ private constructor( Optional.ofNullable(sessionStatusTerminated) /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun sessionThreadCreated(): Optional = Optional.ofNullable(sessionThreadCreated) @@ -1017,8 +1017,8 @@ private constructor( sessionStatusTerminated.getOrThrow("sessionStatusTerminated") /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun asSessionThreadCreated(): BetaManagedAgentsSessionThreadCreatedEvent = sessionThreadCreated.getOrThrow("sessionThreadCreated") @@ -1599,8 +1599,8 @@ private constructor( ) = BetaManagedAgentsSessionEvent(sessionStatusTerminated = sessionStatusTerminated) /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ @JvmStatic fun ofSessionThreadCreated( @@ -1832,8 +1832,8 @@ private constructor( ): T /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun visitSessionThreadCreated( sessionThreadCreated: BetaManagedAgentsSessionThreadCreatedEvent diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEvent.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEvent.kt index f4941190b..c8a7a2247 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEvent.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEvent.kt @@ -17,8 +17,8 @@ import java.util.Objects import kotlin.jvm.optionals.getOrNull /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream - * so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so clients + * observing the session see child creation. */ class BetaManagedAgentsSessionThreadCreatedEvent @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt index e9ae5b3bd..490de17a5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEvents.kt @@ -786,8 +786,8 @@ private constructor( Optional.ofNullable(sessionStatusTerminated) /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun sessionThreadCreated(): Optional = Optional.ofNullable(sessionThreadCreated) @@ -1073,8 +1073,8 @@ private constructor( sessionStatusTerminated.getOrThrow("sessionStatusTerminated") /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun asSessionThreadCreated(): BetaManagedAgentsSessionThreadCreatedEvent = sessionThreadCreated.getOrThrow("sessionThreadCreated") @@ -1703,8 +1703,8 @@ private constructor( ) = BetaManagedAgentsStreamSessionEvents(sessionStatusTerminated = sessionStatusTerminated) /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ @JvmStatic fun ofSessionThreadCreated( @@ -1981,8 +1981,8 @@ private constructor( ): T /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun visitSessionThreadCreated( sessionThreadCreated: BetaManagedAgentsSessionThreadCreatedEvent diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListParams.kt index 58d8b41e3..235f85d37 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventListParams.kt @@ -397,7 +397,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt index 9107b6f75..5a6c90f03 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventSendParams.kt @@ -438,7 +438,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParams.kt index 8b616f12e..1fed8ce41 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParams.kt @@ -274,7 +274,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParams.kt index bfabcab27..17e67489f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParams.kt @@ -284,7 +284,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParams.kt index 022c93de6..d8f9c5ddc 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParams.kt @@ -285,7 +285,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParams.kt index cfb960a6a..0b6cbc695 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParams.kt @@ -268,7 +268,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParams.kt index bb3bf152d..82c252613 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParams.kt @@ -252,7 +252,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParams.kt index 4ca63e5fd..3f058234b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParams.kt @@ -336,7 +336,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThread.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThread.kt index d0f0fa64c..93a735c82 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThread.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThread.kt @@ -31,7 +31,7 @@ import kotlin.jvm.optionals.getOrNull /** * An execution thread within a `session`. Each session has one primary thread plus zero or more - * child threads spawned by the coordinator. + * child threads. */ class BetaManagedAgentsSessionThread @JsonCreator(mode = JsonCreator.Mode.DISABLED) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt index d5beca49f..17f8cdb82 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEvents.kt @@ -820,8 +820,8 @@ private constructor( Optional.ofNullable(sessionStatusTerminated) /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun sessionThreadCreated(): Optional = Optional.ofNullable(sessionThreadCreated) @@ -1107,8 +1107,8 @@ private constructor( sessionStatusTerminated.getOrThrow("sessionStatusTerminated") /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun asSessionThreadCreated(): BetaManagedAgentsSessionThreadCreatedEvent = sessionThreadCreated.getOrThrow("sessionThreadCreated") @@ -1747,8 +1747,8 @@ private constructor( ) /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ @JvmStatic fun ofSessionThreadCreated( @@ -2031,8 +2031,8 @@ private constructor( ): T /** - * Emitted when a subagent is spawned as a new thread. Written to the parent thread's output - * stream so clients observing the session see child creation. + * Emitted when a child thread is created. Written to the parent thread's output stream so + * clients observing the session see child creation. */ fun visitSessionThreadCreated( sessionThreadCreated: BetaManagedAgentsSessionThreadCreatedEvent diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParams.kt index 0287ad77e..fbfcbbc05 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParams.kt @@ -285,7 +285,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParams.kt index 11de0e86b..ca1cce791 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParams.kt @@ -263,7 +263,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParams.kt index af7fcf80d..146eb7532 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParams.kt @@ -252,7 +252,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParams.kt index 958f8ecd7..944f6bed0 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParams.kt @@ -281,7 +281,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParams.kt index fa63e7e37..3605e64a4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParams.kt @@ -296,7 +296,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillCreateParams.kt index 2e630d657..c18450cd7 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillCreateParams.kt @@ -331,7 +331,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillDeleteParams.kt index 4c7824d11..a29e72db5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillDeleteParams.kt @@ -273,7 +273,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillListParams.kt index a066ff624..9dc07c953 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillListParams.kt @@ -288,7 +288,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParams.kt index 06f93f894..3fd08690a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParams.kt @@ -240,7 +240,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParams.kt index 6d7406e60..9d9bddbc5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParams.kt @@ -319,7 +319,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParams.kt index 99c62cf81..f4c8c2bf2 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParams.kt @@ -307,7 +307,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParams.kt index b57e13059..3d85119f4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParams.kt @@ -274,7 +274,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionListParams.kt index 2e0e5b6f2..5b5d750c3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionListParams.kt @@ -281,7 +281,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParams.kt index 2217630f7..718bdfb0e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParams.kt @@ -276,7 +276,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParams.kt index 5e0343349..45606d140 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParams.kt @@ -274,7 +274,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParams.kt index fbbfcd3b0..7f26973a4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParams.kt @@ -296,7 +296,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelListParams.kt index 817339d91..04bfedbef 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelListParams.kt @@ -276,7 +276,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParams.kt index 6f2f0b612..1571d07b4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParams.kt @@ -238,7 +238,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParams.kt index b8c70bf08..1b6172f34 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParams.kt @@ -274,7 +274,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParams.kt index 996b39ce4..a6adee15a 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParams.kt @@ -315,7 +315,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParams.kt index 65af13180..0a29a911e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParams.kt @@ -299,7 +299,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParams.kt index 83db862ba..b6e19d6cd 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParams.kt @@ -335,7 +335,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParams.kt index 2fa874de6..5f5a3ef9b 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParams.kt @@ -295,7 +295,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParams.kt index a26bc4b2c..04c147a56 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParams.kt @@ -263,7 +263,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("mcp-tunnels-2026-06-22") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParams.kt index 7266894f6..250abcd01 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParams.kt @@ -273,7 +273,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("user-profiles-2026-08-18") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParams.kt index bf77f91d3..89bb45084 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParams.kt @@ -485,7 +485,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("user-profiles-2026-08-18") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParams.kt index 9c0d8d479..f943fe80c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParams.kt @@ -290,7 +290,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("user-profiles-2026-08-18") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParams.kt index a8a5eeec0..7fe73f983 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParams.kt @@ -235,7 +235,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("user-profiles-2026-08-18") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParams.kt index db1b676be..2763e552e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParams.kt @@ -502,7 +502,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("user-profiles-2026-08-18") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParams.kt index 9042a6862..8e57e2d27 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultCreateParams.kt index 44c72a489..f88be7d03 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultCreateParams.kt @@ -331,7 +331,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParams.kt index 103c89db3..af671171f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParams.kt @@ -265,7 +265,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultListParams.kt index 2852ba357..43327dc13 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultListParams.kt @@ -269,7 +269,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParams.kt index 3f47f1000..01ae4a181 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParams.kt @@ -232,7 +232,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParams.kt index 829a228b1..7ebe78e1d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParams.kt @@ -343,7 +343,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParams.kt index 30f15060c..ba19cd978 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParams.kt @@ -290,7 +290,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt index 0b2f1adc5..01d78b4a8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParams.kt @@ -405,7 +405,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParams.kt index a848d02b5..23eb27651 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParams.kt @@ -290,7 +290,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParams.kt index ffb891515..d75d7f2c3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParams.kt @@ -288,7 +288,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParams.kt index ee290c298..094b473a3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParams.kt @@ -293,7 +293,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParams.kt index 009056ef0..85134886f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParams.kt @@ -256,7 +256,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt index 1cf0995ad..b554f71d8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParams.kt @@ -422,7 +422,16 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put( + "anthropic-beta", + it.map { it.toString() } + .let { it + (listOf("managed-agents-2026-04-01") - it) } + .joinToString(","), + ) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/completions/CompletionCreateParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/completions/CompletionCreateParams.kt index c8f019e39..3297ae7cf 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/completions/CompletionCreateParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/completions/CompletionCreateParams.kt @@ -33,6 +33,9 @@ import kotlin.jvm.optionals.getOrNull * [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) * for guidance in migrating from Text Completions to Messages. */ +@Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." +) class CompletionCreateParams private constructor( private val betas: List?, @@ -668,7 +671,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserClickTarget.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserClickTarget.kt new file mode 100644 index 000000000..f481871fc --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserClickTarget.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +/** Where to act: either a viewport coordinate or an element reference. */ +@JsonDeserialize(using = BrowserClickTarget.Deserializer::class) +@JsonSerialize(using = BrowserClickTarget.Serializer::class) +class BrowserClickTarget +private constructor( + private val coordinate: BrowserCoordinateTarget? = null, + private val ref: BrowserRefTarget? = null, + private val _json: JsonValue? = null, +) { + + fun type(): Type = + when { + coordinate != null -> Type.COORDINATE + ref != null -> Type.REF + else -> Type.of(_json?.asObject()?.getOrNull()?.get("type") ?: JsonMissing.of()) + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun coordinate(): Optional = Optional.ofNullable(coordinate) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + */ + fun ref(): Optional = Optional.ofNullable(ref) + + fun isCoordinate(): Boolean = coordinate != null + + fun isRef(): Boolean = ref != null + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun asCoordinate(): BrowserCoordinateTarget = coordinate.getOrThrow("coordinate") + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + */ + fun asRef(): BrowserRefTarget = ref.getOrThrow("ref") + + 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 = browserClickTarget.accept(new BrowserClickTarget.Visitor>() { + * @Override + * public Optional visitCoordinate(BrowserCoordinateTarget coordinate) { + * return Optional.of(coordinate.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 { + coordinate != null -> visitor.visitCoordinate(coordinate) + ref != null -> visitor.visitRef(ref) + 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(): BrowserClickTarget = apply { + if (validated) { + return@apply + } + + when { + coordinate != null -> coordinate.validate() + ref != null -> ref.validate() + else -> throw AnthropicInvalidDataException("Unknown BrowserClickTarget: $_json") + } + 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 = + when { + coordinate != null -> coordinate.validity() + ref != null -> ref.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserClickTarget && coordinate == other.coordinate && ref == other.ref + } + + override fun hashCode(): Int = Objects.hash(coordinate, ref) + + override fun toString(): String = + when { + coordinate != null -> "BrowserClickTarget{coordinate=$coordinate}" + ref != null -> "BrowserClickTarget{ref=$ref}" + _json != null -> "BrowserClickTarget{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BrowserClickTarget") + } + + companion object { + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + @JvmStatic + fun ofCoordinate(coordinate: BrowserCoordinateTarget) = + BrowserClickTarget(coordinate = coordinate) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + @JvmStatic fun ofRef(ref: BrowserRefTarget) = BrowserClickTarget(ref = ref) + + /** + * Returns an immutable instance of [BrowserClickTarget] whose [ofRef] variant is built from + * the given required [ref]. + */ + @JvmStatic fun ofRef(ref: String) = ofRef(BrowserRefTarget.of(ref)) + } + + /** + * An interface that defines how to map each variant of [BrowserClickTarget] to a value of type + * [T]. + */ + interface Visitor { + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun visitCoordinate(coordinate: BrowserCoordinateTarget): T + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun visitRef(ref: BrowserRefTarget): T + + /** + * Maps an unknown variant of [BrowserClickTarget] to a value of type [T]. + * + * An instance of [BrowserClickTarget] 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 BrowserClickTarget: $json") + } + } + + internal class Deserializer : BaseDeserializer(BrowserClickTarget::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BrowserClickTarget { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "coordinate" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserClickTarget(coordinate = it, _json = json) + } ?: BrowserClickTarget(_json = json) + } + "ref" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserClickTarget(ref = it, _json = json) + } ?: BrowserClickTarget(_json = json) + } + } + + return BrowserClickTarget(_json = json) + } + } + + internal class Serializer : BaseSerializer(BrowserClickTarget::class) { + + override fun serialize( + value: BrowserClickTarget, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.coordinate != null -> generator.writeObject(value.coordinate) + value.ref != null -> generator.writeObject(value.ref) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BrowserClickTarget") + } + } + } + + class Type 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 COORDINATE = Type(JsonField.of("coordinate")) + + @JvmField val REF = Type(JsonField.of("ref")) + + @JvmStatic + fun of(value: String): Type = + // Intern known values so `==` works + when (value) { + "coordinate" -> COORDINATE + "ref" -> REF + else -> Type(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Type = + value.asString().getOrNull()?.let { of(it) } ?: Type(value) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + COORDINATE, + REF, + } + + /** + * 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 { + COORDINATE, + REF, + /** 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) { + COORDINATE -> Value.COORDINATE + REF -> Value.REF + 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) { + COORDINATE -> Known.COORDINATE + REF -> Known.REF + 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() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCloseTabInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCloseTabInput.kt new file mode 100644 index 000000000..bef860c64 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCloseTabInput.kt @@ -0,0 +1,183 @@ +package com.anthropic.models.messages + +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 + +/** Close the tab with the given tab_id. */ +class BrowserCloseTabInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * The tab to close. + * + * @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 tabId(): String = tabId.getRequired("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserCloseTabInput]. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserCloseTabInput] with the required [tabId] set to + * the given value. + */ + @JvmStatic fun of(tabId: String) = builder().tabId(tabId).build() + } + + /** A builder for [BrowserCloseTabInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserCloseTabInput: BrowserCloseTabInput) = apply { + tabId = browserCloseTabInput.tabId + additionalProperties = browserCloseTabInput.additionalProperties.toMutableMap() + } + + /** The tab to close. */ + fun tabId(tabId: String) = tabId(JsonField.of(tabId)) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserCloseTabInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserCloseTabInput = + BrowserCloseTabInput(checkRequired("tabId", tabId), 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(): BrowserCloseTabInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserCloseTabInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserCloseTabInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCloseTabToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCloseTabToolUseBlock.kt new file mode 100644 index 000000000..9bc3a9713 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCloseTabToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserCloseTabToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Close the tab with the given tab_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 input(): BrowserCloseTabInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("close_tab") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserCloseTabToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserCloseTabToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("close_tab") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserCloseTabToolUseBlock: BrowserCloseTabToolUseBlock) = apply { + id = browserCloseTabToolUseBlock.id + caller = browserCloseTabToolUseBlock.caller + input = browserCloseTabToolUseBlock.input + name = browserCloseTabToolUseBlock.name + toolsetName = browserCloseTabToolUseBlock.toolsetName + type = browserCloseTabToolUseBlock.type + additionalProperties = browserCloseTabToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Close the tab with the given tab_id. */ + fun input(input: BrowserCloseTabInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserCloseTabInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("close_tab") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserCloseTabToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserCloseTabToolUseBlock = + BrowserCloseTabToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserCloseTabToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("close_tab")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("close_tab")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserCloseTabToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserCloseTabToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCoordinateTarget.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCoordinateTarget.kt new file mode 100644 index 000000000..74d475300 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserCoordinateTarget.kt @@ -0,0 +1,258 @@ +package com.anthropic.models.messages + +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 + +/** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ +class BrowserCoordinateTarget +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val type: JsonValue, + private val x: JsonField, + private val y: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + @JsonProperty("x") @ExcludeMissing x: JsonField = JsonMissing.of(), + @JsonProperty("y") @ExcludeMissing y: JsonField = JsonMissing.of(), + ) : this(type, x, y, mutableMapOf()) + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("coordinate") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Pixels from the left edge of the viewport. + * + * @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 x(): Long = x.getRequired("x") + + /** + * Pixels from the top edge of the viewport. + * + * @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 y(): Long = y.getRequired("y") + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + + @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 [BrowserCoordinateTarget]. + * + * The following fields are required: + * ```java + * .x() + * .y() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserCoordinateTarget]. */ + class Builder internal constructor() { + + private var type: JsonValue = JsonValue.from("coordinate") + private var x: JsonField? = null + private var y: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserCoordinateTarget: BrowserCoordinateTarget) = apply { + type = browserCoordinateTarget.type + x = browserCoordinateTarget.x + y = browserCoordinateTarget.y + additionalProperties = browserCoordinateTarget.additionalProperties.toMutableMap() + } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("coordinate") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = apply { this.type = type } + + /** Pixels from the left edge of the viewport. */ + fun x(x: Long) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [Long] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun x(x: JsonField) = apply { this.x = x } + + /** Pixels from the top edge of the viewport. */ + fun y(y: Long) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Long] value instead. This method + * is primarily for setting the field to an undocumented or not yet supported value. + */ + fun y(y: JsonField) = apply { this.y = y } + + 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 [BrowserCoordinateTarget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .x() + * .y() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserCoordinateTarget = + BrowserCoordinateTarget( + type, + checkRequired("x", x), + checkRequired("y", y), + 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(): BrowserCoordinateTarget = apply { + if (validated) { + return@apply + } + + _type().let { + if (it != JsonValue.from("coordinate")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + x() + y() + 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.let { if (it == JsonValue.from("coordinate")) 1 else 0 } + + (if (x.asKnown().isPresent) 1 else 0) + + (if (y.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserCoordinateTarget && + type == other.type && + x == other.x && + y == other.y && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, x, y, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserCoordinateTarget{type=$type, x=$x, y=$y, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserDoubleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserDoubleClickInput.kt new file mode 100644 index 000000000..679d16bf7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserDoubleClickInput.kt @@ -0,0 +1,291 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Double left-click at a viewport coordinate or on an element by reference. */ +class BrowserDoubleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserDoubleClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserDoubleClickInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BrowserDoubleClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserDoubleClickInput: BrowserDoubleClickInput) = apply { + target = browserDoubleClickInput.target + modifiers = browserDoubleClickInput.modifiers + tabId = browserDoubleClickInput.tabId + additionalProperties = browserDoubleClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BrowserCoordinateTarget) = + target(BrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BrowserRefTarget) = target(BrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserDoubleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserDoubleClickInput = + BrowserDoubleClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BrowserDoubleClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserDoubleClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserDoubleClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserDoubleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserDoubleClickToolUseBlock.kt new file mode 100644 index 000000000..6b08d64ee --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserDoubleClickToolUseBlock.kt @@ -0,0 +1,411 @@ +package com.anthropic.models.messages + +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 + +class BrowserDoubleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Double left-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BrowserDoubleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserDoubleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserDoubleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("double_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserDoubleClickToolUseBlock: BrowserDoubleClickToolUseBlock) = apply { + id = browserDoubleClickToolUseBlock.id + caller = browserDoubleClickToolUseBlock.caller + input = browserDoubleClickToolUseBlock.input + name = browserDoubleClickToolUseBlock.name + toolsetName = browserDoubleClickToolUseBlock.toolsetName + type = browserDoubleClickToolUseBlock.type + additionalProperties = + browserDoubleClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Double left-click at a viewport coordinate or on an element by reference. */ + fun input(input: BrowserDoubleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserDoubleClickInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserDoubleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserDoubleClickToolUseBlock = + BrowserDoubleClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserDoubleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("double_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("double_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserDoubleClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserDoubleClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFileUploadInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFileUploadInput.kt new file mode 100644 index 000000000..e86029613 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFileUploadInput.kt @@ -0,0 +1,359 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Set the value of a file-input element to one or more files. The target must be an element + * reference; at least one of paths or document_ids is required. + */ +class BrowserFileUploadInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val documentIds: JsonField>, + private val paths: JsonField>, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("document_ids") + @ExcludeMissing + documentIds: JsonField> = JsonMissing.of(), + @JsonProperty("paths") @ExcludeMissing paths: JsonField> = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, documentIds, paths, tabId, mutableMapOf()) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + * + * @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 target(): BrowserRefTarget = target.getRequired("target") + + /** + * References to files the harness has staged, for deployments where the browser executor cannot + * read the caller's filesystem. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun documentIds(): Optional> = documentIds.getOptional("document_ids") + + /** + * File paths on the browser executor's filesystem. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paths(): Optional> = paths.getOptional("paths") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [documentIds]. + * + * Unlike [documentIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("document_ids") + @ExcludeMissing + fun _documentIds(): JsonField> = documentIds + + /** + * Returns the raw JSON value of [paths]. + * + * Unlike [paths], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paths") @ExcludeMissing fun _paths(): JsonField> = paths + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserFileUploadInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserFileUploadInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserRefTarget) = builder().target(target).build() + } + + /** A builder for [BrowserFileUploadInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var documentIds: JsonField>? = null + private var paths: JsonField>? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserFileUploadInput: BrowserFileUploadInput) = apply { + target = browserFileUploadInput.target + documentIds = + browserFileUploadInput.documentIds + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + paths = + browserFileUploadInput.paths + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + tabId = browserFileUploadInput.tabId + additionalProperties = browserFileUploadInput.additionalProperties.toMutableMap() + } + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun target(target: BrowserRefTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserRefTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** + * References to files the harness has staged, for deployments where the browser executor + * cannot read the caller's filesystem. + */ + fun documentIds(documentIds: List?) = documentIds(JsonField.ofNullable(documentIds)) + + /** Alias for calling [Builder.documentIds] with `documentIds.orElse(null)`. */ + fun documentIds(documentIds: Optional>) = documentIds(documentIds.getOrNull()) + + /** + * Sets [Builder.documentIds] to an arbitrary JSON value. + * + * You should usually call [Builder.documentIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun documentIds(documentIds: JsonField>) = apply { + this.documentIds = documentIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [documentIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDocumentId(documentId: String) = apply { + documentIds = + (documentIds ?: JsonField.of(mutableListOf())).also { + checkKnown("documentIds", it).add(documentId) + } + } + + /** File paths on the browser executor's filesystem. */ + fun paths(paths: List?) = paths(JsonField.ofNullable(paths)) + + /** Alias for calling [Builder.paths] with `paths.orElse(null)`. */ + fun paths(paths: Optional>) = paths(paths.getOrNull()) + + /** + * Sets [Builder.paths] to an arbitrary JSON value. + * + * You should usually call [Builder.paths] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun paths(paths: JsonField>) = apply { + this.paths = paths.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [paths]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPath(path: String) = apply { + paths = + (paths ?: JsonField.of(mutableListOf())).also { checkKnown("paths", it).add(path) } + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserFileUploadInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserFileUploadInput = + BrowserFileUploadInput( + checkRequired("target", target), + (documentIds ?: JsonMissing.of()).map { it.toImmutable() }, + (paths ?: JsonMissing.of()).map { it.toImmutable() }, + tabId, + 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(): BrowserFileUploadInput = apply { + if (validated) { + return@apply + } + + target().validate() + documentIds() + paths() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (documentIds.asKnown().getOrNull()?.size ?: 0) + + (paths.asKnown().getOrNull()?.size ?: 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserFileUploadInput && + target == other.target && + documentIds == other.documentIds && + paths == other.paths && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, documentIds, paths, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserFileUploadInput{target=$target, documentIds=$documentIds, paths=$paths, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFileUploadToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFileUploadToolUseBlock.kt new file mode 100644 index 000000000..668395882 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFileUploadToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +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 + +class BrowserFileUploadToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Set the value of a file-input element to one or more files. The target must be an element + * reference; at least one of paths or document_ids is required. + * + * @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 input(): BrowserFileUploadInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("file_upload") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserFileUploadToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserFileUploadToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("file_upload") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserFileUploadToolUseBlock: BrowserFileUploadToolUseBlock) = apply { + id = browserFileUploadToolUseBlock.id + caller = browserFileUploadToolUseBlock.caller + input = browserFileUploadToolUseBlock.input + name = browserFileUploadToolUseBlock.name + toolsetName = browserFileUploadToolUseBlock.toolsetName + type = browserFileUploadToolUseBlock.type + additionalProperties = browserFileUploadToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Set the value of a file-input element to one or more files. The target must be an element + * reference; at least one of paths or document_ids is required. + */ + fun input(input: BrowserFileUploadInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserFileUploadInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("file_upload") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserFileUploadToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserFileUploadToolUseBlock = + BrowserFileUploadToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserFileUploadToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("file_upload")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("file_upload")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserFileUploadToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserFileUploadToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFindInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFindInput.kt new file mode 100644 index 000000000..6ec3cfe20 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFindInput.kt @@ -0,0 +1,229 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Find elements matching a natural-language description (e.g. "search bar", "add to cart button") + * and return up to 20 matches with element references. + */ +class BrowserFindInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val query: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("query") @ExcludeMissing query: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(query, tabId, mutableMapOf()) + + /** + * Natural-language description of the element(s) to find. + * + * @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 query(): String = query.getRequired("query") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [query]. + * + * Unlike [query], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("query") @ExcludeMissing fun _query(): JsonField = query + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserFindInput]. + * + * The following fields are required: + * ```java + * .query() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserFindInput] with the required [query] set to the + * given value. + */ + @JvmStatic fun of(query: String) = builder().query(query).build() + } + + /** A builder for [BrowserFindInput]. */ + class Builder internal constructor() { + + private var query: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserFindInput: BrowserFindInput) = apply { + query = browserFindInput.query + tabId = browserFindInput.tabId + additionalProperties = browserFindInput.additionalProperties.toMutableMap() + } + + /** Natural-language description of the element(s) to find. */ + fun query(query: String) = query(JsonField.of(query)) + + /** + * Sets [Builder.query] to an arbitrary JSON value. + * + * You should usually call [Builder.query] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun query(query: JsonField) = apply { this.query = query } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserFindInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .query() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserFindInput = + BrowserFindInput( + checkRequired("query", query), + tabId, + 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(): BrowserFindInput = apply { + if (validated) { + return@apply + } + + query() + tabId() + 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 (query.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserFindInput && + query == other.query && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(query, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserFindInput{query=$query, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFindToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFindToolUseBlock.kt new file mode 100644 index 000000000..3c2ad31c5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFindToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class BrowserFindToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Find elements matching a natural-language description (e.g. "search bar", "add to cart + * button") and return up to 20 matches with element references. + * + * @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 input(): BrowserFindInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("find") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserFindToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserFindToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("find") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserFindToolUseBlock: BrowserFindToolUseBlock) = apply { + id = browserFindToolUseBlock.id + caller = browserFindToolUseBlock.caller + input = browserFindToolUseBlock.input + name = browserFindToolUseBlock.name + toolsetName = browserFindToolUseBlock.toolsetName + type = browserFindToolUseBlock.type + additionalProperties = browserFindToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Find elements matching a natural-language description (e.g. "search bar", "add to cart + * button") and return up to 20 matches with element references. + */ + fun input(input: BrowserFindInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserFindInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("find") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserFindToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserFindToolUseBlock = + BrowserFindToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserFindToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("find")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("find")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserFindToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserFindToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputInput.kt new file mode 100644 index 000000000..d8efe68a1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputInput.kt @@ -0,0 +1,281 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Set the value of a form element (input, textarea, select, checkbox). Use a boolean for + * checkboxes, an option value or text for selects. + */ +class BrowserFormInputInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val value: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, value, tabId, mutableMapOf()) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + * + * @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 target(): BrowserRefTarget = target.getRequired("target") + + /** + * The value to set. + * + * @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 value(): BrowserFormInputValue = value.getRequired("value") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserFormInputInput]. + * + * The following fields are required: + * ```java + * .target() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserFormInputInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var value: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserFormInputInput: BrowserFormInputInput) = apply { + target = browserFormInputInput.target + value = browserFormInputInput.value + tabId = browserFormInputInput.tabId + additionalProperties = browserFormInputInput.additionalProperties.toMutableMap() + } + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun target(target: BrowserRefTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserRefTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** The value to set. */ + fun value(value: BrowserFormInputValue) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [BrowserFormInputValue] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + /** Alias for calling [value] with `BrowserFormInputValue.ofString(string)`. */ + fun value(string: String) = value(BrowserFormInputValue.ofString(string)) + + /** Alias for calling [value] with `BrowserFormInputValue.ofNumber(number)`. */ + fun value(number: Double) = value(BrowserFormInputValue.ofNumber(number)) + + /** Alias for calling [value] with `BrowserFormInputValue.ofBool(bool)`. */ + fun value(bool: Boolean) = value(BrowserFormInputValue.ofBool(bool)) + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserFormInputInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserFormInputInput = + BrowserFormInputInput( + checkRequired("target", target), + checkRequired("value", value), + tabId, + 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(): BrowserFormInputInput = apply { + if (validated) { + return@apply + } + + target().validate() + value().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserFormInputInput && + target == other.target && + value == other.value && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, value, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserFormInputInput{target=$target, value=$value, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputToolUseBlock.kt new file mode 100644 index 000000000..cb73a3f6c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class BrowserFormInputToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Set the value of a form element (input, textarea, select, checkbox). Use a boolean for + * checkboxes, an option value or text for selects. + * + * @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 input(): BrowserFormInputInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("form_input") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserFormInputToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserFormInputToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("form_input") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserFormInputToolUseBlock: BrowserFormInputToolUseBlock) = apply { + id = browserFormInputToolUseBlock.id + caller = browserFormInputToolUseBlock.caller + input = browserFormInputToolUseBlock.input + name = browserFormInputToolUseBlock.name + toolsetName = browserFormInputToolUseBlock.toolsetName + type = browserFormInputToolUseBlock.type + additionalProperties = browserFormInputToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Set the value of a form element (input, textarea, select, checkbox). Use a boolean for + * checkboxes, an option value or text for selects. + */ + fun input(input: BrowserFormInputInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserFormInputInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("form_input") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserFormInputToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserFormInputToolUseBlock = + BrowserFormInputToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserFormInputToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("form_input")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("form_input")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserFormInputToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserFormInputToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputValue.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputValue.kt new file mode 100644 index 000000000..2f98bf1be --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserFormInputValue.kt @@ -0,0 +1,240 @@ +package com.anthropic.models.messages + +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.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 + +@JsonDeserialize(using = BrowserFormInputValue.Deserializer::class) +@JsonSerialize(using = BrowserFormInputValue.Serializer::class) +class BrowserFormInputValue +private constructor( + private val string: String? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, +) { + + fun string(): Optional = Optional.ofNullable(string) + + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + 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 = browserFormInputValue.accept(new BrowserFormInputValue.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) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + 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(): BrowserFormInputValue = apply { + if (validated) { + return@apply + } + + when { + string != null -> {} + number != null -> {} + bool != null -> {} + else -> throw AnthropicInvalidDataException("Unknown BrowserFormInputValue: $_json") + } + 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 = + when { + string != null -> 1 + number != null -> 1 + bool != null -> 1 + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserFormInputValue && + string == other.string && + number == other.number && + bool == other.bool + } + + override fun hashCode(): Int = Objects.hash(string, number, bool) + + override fun toString(): String = + when { + string != null -> "BrowserFormInputValue{string=$string}" + number != null -> "BrowserFormInputValue{number=$number}" + bool != null -> "BrowserFormInputValue{bool=$bool}" + _json != null -> "BrowserFormInputValue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BrowserFormInputValue") + } + + companion object { + + @JvmStatic fun ofString(string: String) = BrowserFormInputValue(string = string) + + @JvmStatic fun ofNumber(number: Double) = BrowserFormInputValue(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = BrowserFormInputValue(bool = bool) + } + + /** + * An interface that defines how to map each variant of [BrowserFormInputValue] to a value of + * type [T]. + */ + interface Visitor { + + fun visitString(string: String): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [BrowserFormInputValue] to a value of type [T]. + * + * An instance of [BrowserFormInputValue] 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 BrowserFormInputValue: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BrowserFormInputValue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BrowserFormInputValue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BrowserFormInputValue(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BrowserFormInputValue(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BrowserFormInputValue(bool = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from object). + 0 -> BrowserFormInputValue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(BrowserFormInputValue::class) { + + override fun serialize( + value: BrowserFormInputValue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BrowserFormInputValue") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserGetPageTextInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserGetPageTextInput.kt new file mode 100644 index 000000000..1c5416e1c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserGetPageTextInput.kt @@ -0,0 +1,170 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return the page's visible text content as plain text, prioritizing article content. Suited to + * articles, documentation, and other text-heavy pages. + */ +class BrowserGetPageTextInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserGetPageTextInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserGetPageTextInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserGetPageTextInput: BrowserGetPageTextInput) = apply { + tabId = browserGetPageTextInput.tabId + additionalProperties = browserGetPageTextInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserGetPageTextInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrowserGetPageTextInput = + BrowserGetPageTextInput(tabId, 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(): BrowserGetPageTextInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserGetPageTextInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserGetPageTextInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserGetPageTextToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserGetPageTextToolUseBlock.kt new file mode 100644 index 000000000..918b27a34 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserGetPageTextToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.messages + +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 + +class BrowserGetPageTextToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Return the page's visible text content as plain text, prioritizing article content. Suited to + * articles, documentation, and other text-heavy pages. + * + * @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 input(): BrowserGetPageTextInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("get_page_text") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserGetPageTextToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserGetPageTextToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("get_page_text") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserGetPageTextToolUseBlock: BrowserGetPageTextToolUseBlock) = apply { + id = browserGetPageTextToolUseBlock.id + caller = browserGetPageTextToolUseBlock.caller + input = browserGetPageTextToolUseBlock.input + name = browserGetPageTextToolUseBlock.name + toolsetName = browserGetPageTextToolUseBlock.toolsetName + type = browserGetPageTextToolUseBlock.type + additionalProperties = + browserGetPageTextToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Return the page's visible text content as plain text, prioritizing article content. + * Suited to articles, documentation, and other text-heavy pages. + */ + fun input(input: BrowserGetPageTextInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserGetPageTextInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("get_page_text") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserGetPageTextToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserGetPageTextToolUseBlock = + BrowserGetPageTextToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserGetPageTextToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("get_page_text")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("get_page_text")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserGetPageTextToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserGetPageTextToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoldKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoldKeyInput.kt new file mode 100644 index 000000000..55b501821 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoldKeyInput.kt @@ -0,0 +1,260 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Hold a key or key chord down for a duration, then release it. Uses the same key names and "+" + * chord syntax as the key action. + */ +class BrowserHoldKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val text: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(duration, text, tabId, mutableMapOf()) + + /** + * Seconds to hold the key down (maximum 30). + * + * @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 duration(): Double = duration.getRequired("duration") + + /** + * The key or chord to hold. + * + * @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 text(): String = text.getRequired("text") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserHoldKeyInput]. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserHoldKeyInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var text: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserHoldKeyInput: BrowserHoldKeyInput) = apply { + duration = browserHoldKeyInput.duration + text = browserHoldKeyInput.text + tabId = browserHoldKeyInput.tabId + additionalProperties = browserHoldKeyInput.additionalProperties.toMutableMap() + } + + /** Seconds to hold the key down (maximum 30). */ + fun duration(duration: Double) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The key or chord to hold. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserHoldKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserHoldKeyInput = + BrowserHoldKeyInput( + checkRequired("duration", duration), + checkRequired("text", text), + tabId, + 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(): BrowserHoldKeyInput = apply { + if (validated) { + return@apply + } + + duration() + text() + tabId() + 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 (duration.asKnown().isPresent) 1 else 0) + + (if (text.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserHoldKeyInput && + duration == other.duration && + text == other.text && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, text, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserHoldKeyInput{duration=$duration, text=$text, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoldKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoldKeyToolUseBlock.kt new file mode 100644 index 000000000..2e5762f4a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoldKeyToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class BrowserHoldKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Hold a key or key chord down for a duration, then release it. Uses the same key names and "+" + * chord syntax as the key action. + * + * @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 input(): BrowserHoldKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserHoldKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserHoldKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("hold_key") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserHoldKeyToolUseBlock: BrowserHoldKeyToolUseBlock) = apply { + id = browserHoldKeyToolUseBlock.id + caller = browserHoldKeyToolUseBlock.caller + input = browserHoldKeyToolUseBlock.input + name = browserHoldKeyToolUseBlock.name + toolsetName = browserHoldKeyToolUseBlock.toolsetName + type = browserHoldKeyToolUseBlock.type + additionalProperties = browserHoldKeyToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Hold a key or key chord down for a duration, then release it. Uses the same key names and + * "+" chord syntax as the key action. + */ + fun input(input: BrowserHoldKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserHoldKeyInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserHoldKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserHoldKeyToolUseBlock = + BrowserHoldKeyToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserHoldKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("hold_key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("hold_key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserHoldKeyToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserHoldKeyToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoverInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoverInput.kt new file mode 100644 index 000000000..e4f1e2fe1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoverInput.kt @@ -0,0 +1,246 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Move the cursor to a coordinate or element without clicking. */ +class BrowserHoverInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BrowserClickTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserHoverInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserHoverInput] with the required [target] set to + * the given value. + */ + @JvmStatic fun of(target: BrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BrowserHoverInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserHoverInput: BrowserHoverInput) = apply { + target = browserHoverInput.target + tabId = browserHoverInput.tabId + additionalProperties = browserHoverInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BrowserCoordinateTarget) = + target(BrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BrowserRefTarget) = target(BrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BrowserRefTarget.builder().ref(ref).build()) + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserHoverInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserHoverInput = + BrowserHoverInput( + checkRequired("target", target), + tabId, + 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(): BrowserHoverInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserHoverInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserHoverInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoverToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoverToolUseBlock.kt new file mode 100644 index 000000000..8c9da9cd3 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserHoverToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserHoverToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Move the cursor to a coordinate or element without clicking. + * + * @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 input(): BrowserHoverInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("hover") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserHoverToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserHoverToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("hover") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserHoverToolUseBlock: BrowserHoverToolUseBlock) = apply { + id = browserHoverToolUseBlock.id + caller = browserHoverToolUseBlock.caller + input = browserHoverToolUseBlock.input + name = browserHoverToolUseBlock.name + toolsetName = browserHoverToolUseBlock.toolsetName + type = browserHoverToolUseBlock.type + additionalProperties = browserHoverToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Move the cursor to a coordinate or element without clicking. */ + fun input(input: BrowserHoverInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserHoverInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("hover") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserHoverToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserHoverToolUseBlock = + BrowserHoverToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserHoverToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("hover")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("hover")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserHoverToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserHoverToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserJavascriptExecInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserJavascriptExecInput.kt new file mode 100644 index 000000000..50371a9c5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserJavascriptExecInput.kt @@ -0,0 +1,230 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Execute JavaScript in the page context and return the value of the last expression. The code runs + * with access to the DOM, `window`, and page variables. Write the expression you want evaluated — + * do NOT use `return`. + */ +class BrowserJavascriptExecInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(text, tabId, mutableMapOf()) + + /** + * JavaScript to execute in the page context. + * + * @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 text(): String = text.getRequired("text") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserJavascriptExecInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserJavascriptExecInput] with the required [text] + * set to the given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BrowserJavascriptExecInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserJavascriptExecInput: BrowserJavascriptExecInput) = apply { + text = browserJavascriptExecInput.text + tabId = browserJavascriptExecInput.tabId + additionalProperties = browserJavascriptExecInput.additionalProperties.toMutableMap() + } + + /** JavaScript to execute in the page context. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserJavascriptExecInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserJavascriptExecInput = + BrowserJavascriptExecInput( + checkRequired("text", text), + tabId, + 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(): BrowserJavascriptExecInput = apply { + if (validated) { + return@apply + } + + text() + tabId() + 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 (text.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserJavascriptExecInput && + text == other.text && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserJavascriptExecInput{text=$text, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserJavascriptExecToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserJavascriptExecToolUseBlock.kt new file mode 100644 index 000000000..d1bdd7515 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserJavascriptExecToolUseBlock.kt @@ -0,0 +1,420 @@ +package com.anthropic.models.messages + +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 + +class BrowserJavascriptExecToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Execute JavaScript in the page context and return the value of the last expression. The code + * runs with access to the DOM, `window`, and page variables. Write the expression you want + * evaluated — do NOT use `return`. + * + * @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 input(): BrowserJavascriptExecInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("javascript_exec") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + @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 + * [BrowserJavascriptExecToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserJavascriptExecToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("javascript_exec") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserJavascriptExecToolUseBlock: BrowserJavascriptExecToolUseBlock) = + apply { + id = browserJavascriptExecToolUseBlock.id + caller = browserJavascriptExecToolUseBlock.caller + input = browserJavascriptExecToolUseBlock.input + name = browserJavascriptExecToolUseBlock.name + toolsetName = browserJavascriptExecToolUseBlock.toolsetName + type = browserJavascriptExecToolUseBlock.type + additionalProperties = + browserJavascriptExecToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Execute JavaScript in the page context and return the value of the last expression. The + * code runs with access to the DOM, `window`, and page variables. Write the expression you + * want evaluated — do NOT use `return`. + */ + fun input(input: BrowserJavascriptExecInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserJavascriptExecInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("javascript_exec") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserJavascriptExecToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserJavascriptExecToolUseBlock = + BrowserJavascriptExecToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserJavascriptExecToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("javascript_exec")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("javascript_exec")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserJavascriptExecToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserJavascriptExecToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserKeyInput.kt new file mode 100644 index 000000000..0c043d7cd --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserKeyInput.kt @@ -0,0 +1,275 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Press a key or key chord. Use "+" to combine modifiers with a key (e.g. "ctrl+a", "cmd+shift+p") + * and space to sequence presses (e.g. "Backspace Backspace Delete"). Common names like "Return", + * "Tab", "Escape", "BackSpace" are supported. + */ +class BrowserKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val repeat: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("repeat") @ExcludeMissing repeat: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(text, repeat, tabId, mutableMapOf()) + + /** + * The key, chord, or space-separated sequence to press. + * + * @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 text(): String = text.getRequired("text") + + /** + * Number of times to repeat. Default 1. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun repeat(): Optional = repeat.getOptional("repeat") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [repeat]. + * + * Unlike [repeat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repeat") @ExcludeMissing fun _repeat(): JsonField = repeat + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserKeyInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserKeyInput] with the required [text] set to the + * given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BrowserKeyInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var repeat: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserKeyInput: BrowserKeyInput) = apply { + text = browserKeyInput.text + repeat = browserKeyInput.repeat + tabId = browserKeyInput.tabId + additionalProperties = browserKeyInput.additionalProperties.toMutableMap() + } + + /** The key, chord, or space-separated sequence to press. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Number of times to repeat. Default 1. */ + fun repeat(repeat: Long?) = repeat(JsonField.ofNullable(repeat)) + + /** + * Alias for [Builder.repeat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun repeat(repeat: Long) = repeat(repeat as Long?) + + /** Alias for calling [Builder.repeat] with `repeat.orElse(null)`. */ + fun repeat(repeat: Optional) = repeat(repeat.getOrNull()) + + /** + * Sets [Builder.repeat] to an arbitrary JSON value. + * + * You should usually call [Builder.repeat] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repeat(repeat: JsonField) = apply { this.repeat = repeat } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserKeyInput = + BrowserKeyInput( + checkRequired("text", text), + repeat, + tabId, + 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(): BrowserKeyInput = apply { + if (validated) { + return@apply + } + + text() + repeat() + tabId() + 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 (text.asKnown().isPresent) 1 else 0) + + (if (repeat.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserKeyInput && + text == other.text && + repeat == other.repeat && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, repeat, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserKeyInput{text=$text, repeat=$repeat, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserKeyToolUseBlock.kt new file mode 100644 index 000000000..77003a762 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserKeyToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class BrowserKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") @ExcludeMissing input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Press a key or key chord. Use "+" to combine modifiers with a key (e.g. "ctrl+a", + * "cmd+shift+p") and space to sequence presses (e.g. "Backspace Backspace Delete"). Common + * names like "Return", "Tab", "Escape", "BackSpace" are supported. + * + * @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 input(): BrowserKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("key") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserKeyToolUseBlock: BrowserKeyToolUseBlock) = apply { + id = browserKeyToolUseBlock.id + caller = browserKeyToolUseBlock.caller + input = browserKeyToolUseBlock.input + name = browserKeyToolUseBlock.name + toolsetName = browserKeyToolUseBlock.toolsetName + type = browserKeyToolUseBlock.type + additionalProperties = browserKeyToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Press a key or key chord. Use "+" to combine modifiers with a key (e.g. "ctrl+a", + * "cmd+shift+p") and space to sequence presses (e.g. "Backspace Backspace Delete"). Common + * names like "Return", "Tab", "Escape", "BackSpace" are supported. + */ + fun input(input: BrowserKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserKeyInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserKeyToolUseBlock = + BrowserKeyToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserKeyToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserKeyToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickDragInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickDragInput.kt new file mode 100644 index 000000000..903b4cc72 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickDragInput.kt @@ -0,0 +1,273 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Press at `from`, drag to `target`, release. Both must be coordinate targets. */ +class BrowserLeftClickDragInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val from: JsonField, + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("from") + @ExcludeMissing + from: JsonField = JsonMissing.of(), + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(from, target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 from(): BrowserCoordinateTarget = from.getRequired("from") + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [from]. + * + * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserLeftClickDragInput]. + * + * The following fields are required: + * ```java + * .from() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserLeftClickDragInput]. */ + class Builder internal constructor() { + + private var from: JsonField? = null + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftClickDragInput: BrowserLeftClickDragInput) = apply { + from = browserLeftClickDragInput.from + target = browserLeftClickDragInput.target + tabId = browserLeftClickDragInput.tabId + additionalProperties = browserLeftClickDragInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun from(from: BrowserCoordinateTarget) = from(JsonField.of(from)) + + /** + * Sets [Builder.from] to an arbitrary JSON value. + * + * You should usually call [Builder.from] with a well-typed [BrowserCoordinateTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun from(from: JsonField) = apply { this.from = from } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserLeftClickDragInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .from() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftClickDragInput = + BrowserLeftClickDragInput( + checkRequired("from", from), + checkRequired("target", target), + tabId, + 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(): BrowserLeftClickDragInput = apply { + if (validated) { + return@apply + } + + from().validate() + target().validate() + tabId() + 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 = + (from.asKnown().getOrNull()?.validity() ?: 0) + + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftClickDragInput && + from == other.from && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(from, target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftClickDragInput{from=$from, target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickDragToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickDragToolUseBlock.kt new file mode 100644 index 000000000..2f4cb9631 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickDragToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +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 + +class BrowserLeftClickDragToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Press at `from`, drag to `target`, release. Both must be coordinate targets. + * + * @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 input(): BrowserLeftClickDragInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + @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 + * [BrowserLeftClickDragToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserLeftClickDragToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click_drag") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftClickDragToolUseBlock: BrowserLeftClickDragToolUseBlock) = + apply { + id = browserLeftClickDragToolUseBlock.id + caller = browserLeftClickDragToolUseBlock.caller + input = browserLeftClickDragToolUseBlock.input + name = browserLeftClickDragToolUseBlock.name + toolsetName = browserLeftClickDragToolUseBlock.toolsetName + type = browserLeftClickDragToolUseBlock.type + additionalProperties = + browserLeftClickDragToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Press at `from`, drag to `target`, release. Both must be coordinate targets. */ + fun input(input: BrowserLeftClickDragInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserLeftClickDragInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserLeftClickDragToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftClickDragToolUseBlock = + BrowserLeftClickDragToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserLeftClickDragToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_click_drag")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click_drag")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftClickDragToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftClickDragToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickInput.kt new file mode 100644 index 000000000..aaa5de219 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickInput.kt @@ -0,0 +1,291 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Left-click at a viewport coordinate or on an element by reference. */ +class BrowserLeftClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserLeftClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserLeftClickInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BrowserLeftClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftClickInput: BrowserLeftClickInput) = apply { + target = browserLeftClickInput.target + modifiers = browserLeftClickInput.modifiers + tabId = browserLeftClickInput.tabId + additionalProperties = browserLeftClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BrowserCoordinateTarget) = + target(BrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BrowserRefTarget) = target(BrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserLeftClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftClickInput = + BrowserLeftClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BrowserLeftClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickToolUseBlock.kt new file mode 100644 index 000000000..b88b34aa8 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftClickToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserLeftClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Left-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BrowserLeftClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserLeftClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserLeftClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftClickToolUseBlock: BrowserLeftClickToolUseBlock) = apply { + id = browserLeftClickToolUseBlock.id + caller = browserLeftClickToolUseBlock.caller + input = browserLeftClickToolUseBlock.input + name = browserLeftClickToolUseBlock.name + toolsetName = browserLeftClickToolUseBlock.toolsetName + type = browserLeftClickToolUseBlock.type + additionalProperties = browserLeftClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Left-click at a viewport coordinate or on an element by reference. */ + fun input(input: BrowserLeftClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserLeftClickInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserLeftClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftClickToolUseBlock = + BrowserLeftClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserLeftClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownInput.kt new file mode 100644 index 000000000..4a0fda5c3 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownInput.kt @@ -0,0 +1,238 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Press and hold the left mouse button at a viewport coordinate. Pair with left_mouse_up to perform + * a custom drag. + */ +class BrowserLeftMouseDownInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserLeftMouseDownInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserLeftMouseDownInput] with the required [target] + * set to the given value. + */ + @JvmStatic fun of(target: BrowserCoordinateTarget) = builder().target(target).build() + } + + /** A builder for [BrowserLeftMouseDownInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftMouseDownInput: BrowserLeftMouseDownInput) = apply { + target = browserLeftMouseDownInput.target + tabId = browserLeftMouseDownInput.tabId + additionalProperties = browserLeftMouseDownInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserLeftMouseDownInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftMouseDownInput = + BrowserLeftMouseDownInput( + checkRequired("target", target), + tabId, + 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(): BrowserLeftMouseDownInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftMouseDownInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftMouseDownInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownToolUseBlock.kt new file mode 100644 index 000000000..ba8b0dd6e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownToolUseBlock.kt @@ -0,0 +1,418 @@ +package com.anthropic.models.messages + +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 + +class BrowserLeftMouseDownToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Press and hold the left mouse button at a viewport coordinate. Pair with left_mouse_up to + * perform a custom drag. + * + * @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 input(): BrowserLeftMouseDownInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + @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 + * [BrowserLeftMouseDownToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserLeftMouseDownToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_down") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftMouseDownToolUseBlock: BrowserLeftMouseDownToolUseBlock) = + apply { + id = browserLeftMouseDownToolUseBlock.id + caller = browserLeftMouseDownToolUseBlock.caller + input = browserLeftMouseDownToolUseBlock.input + name = browserLeftMouseDownToolUseBlock.name + toolsetName = browserLeftMouseDownToolUseBlock.toolsetName + type = browserLeftMouseDownToolUseBlock.type + additionalProperties = + browserLeftMouseDownToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Press and hold the left mouse button at a viewport coordinate. Pair with left_mouse_up to + * perform a custom drag. + */ + fun input(input: BrowserLeftMouseDownInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserLeftMouseDownInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserLeftMouseDownToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftMouseDownToolUseBlock = + BrowserLeftMouseDownToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserLeftMouseDownToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_down")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_down")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftMouseDownToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftMouseDownToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpInput.kt new file mode 100644 index 000000000..d0ed2f7ab --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpInput.kt @@ -0,0 +1,235 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Release the left mouse button at a viewport coordinate. */ +class BrowserLeftMouseUpInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserLeftMouseUpInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserLeftMouseUpInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserCoordinateTarget) = builder().target(target).build() + } + + /** A builder for [BrowserLeftMouseUpInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftMouseUpInput: BrowserLeftMouseUpInput) = apply { + target = browserLeftMouseUpInput.target + tabId = browserLeftMouseUpInput.tabId + additionalProperties = browserLeftMouseUpInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserLeftMouseUpInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftMouseUpInput = + BrowserLeftMouseUpInput( + checkRequired("target", target), + tabId, + 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(): BrowserLeftMouseUpInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftMouseUpInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftMouseUpInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpToolUseBlock.kt new file mode 100644 index 000000000..5431b0ca0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpToolUseBlock.kt @@ -0,0 +1,411 @@ +package com.anthropic.models.messages + +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 + +class BrowserLeftMouseUpToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Release the left mouse button at a viewport coordinate. + * + * @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 input(): BrowserLeftMouseUpInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserLeftMouseUpToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserLeftMouseUpToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_up") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserLeftMouseUpToolUseBlock: BrowserLeftMouseUpToolUseBlock) = apply { + id = browserLeftMouseUpToolUseBlock.id + caller = browserLeftMouseUpToolUseBlock.caller + input = browserLeftMouseUpToolUseBlock.input + name = browserLeftMouseUpToolUseBlock.name + toolsetName = browserLeftMouseUpToolUseBlock.toolsetName + type = browserLeftMouseUpToolUseBlock.type + additionalProperties = + browserLeftMouseUpToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Release the left mouse button at a viewport coordinate. */ + fun input(input: BrowserLeftMouseUpInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserLeftMouseUpInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserLeftMouseUpToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserLeftMouseUpToolUseBlock = + BrowserLeftMouseUpToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserLeftMouseUpToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_up")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_up")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserLeftMouseUpToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserLeftMouseUpToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserListTabsInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserListTabsInput.kt new file mode 100644 index 000000000..d0eb45f08 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserListTabsInput.kt @@ -0,0 +1,121 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** List all open tabs with each tab's tab_id, title, and URL. */ +class BrowserListTabsInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [BrowserListTabsInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserListTabsInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserListTabsInput: BrowserListTabsInput) = apply { + additionalProperties = browserListTabsInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrowserListTabsInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrowserListTabsInput = + BrowserListTabsInput(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(): BrowserListTabsInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserListTabsInput && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BrowserListTabsInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserListTabsToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserListTabsToolUseBlock.kt new file mode 100644 index 000000000..03fbcfee8 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserListTabsToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserListTabsToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * List all open tabs with each tab's tab_id, title, and URL. + * + * @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 input(): BrowserListTabsInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("list_tabs") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserListTabsToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserListTabsToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("list_tabs") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserListTabsToolUseBlock: BrowserListTabsToolUseBlock) = apply { + id = browserListTabsToolUseBlock.id + caller = browserListTabsToolUseBlock.caller + input = browserListTabsToolUseBlock.input + name = browserListTabsToolUseBlock.name + toolsetName = browserListTabsToolUseBlock.toolsetName + type = browserListTabsToolUseBlock.type + additionalProperties = browserListTabsToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** List all open tabs with each tab's tab_id, title, and URL. */ + fun input(input: BrowserListTabsInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserListTabsInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("list_tabs") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserListTabsToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserListTabsToolUseBlock = + BrowserListTabsToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserListTabsToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("list_tabs")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("list_tabs")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserListTabsToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserListTabsToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMiddleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMiddleClickInput.kt new file mode 100644 index 000000000..1456c68bf --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMiddleClickInput.kt @@ -0,0 +1,291 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Middle-click at a viewport coordinate or on an element by reference. */ +class BrowserMiddleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserMiddleClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserMiddleClickInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BrowserMiddleClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserMiddleClickInput: BrowserMiddleClickInput) = apply { + target = browserMiddleClickInput.target + modifiers = browserMiddleClickInput.modifiers + tabId = browserMiddleClickInput.tabId + additionalProperties = browserMiddleClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BrowserCoordinateTarget) = + target(BrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BrowserRefTarget) = target(BrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserMiddleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserMiddleClickInput = + BrowserMiddleClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BrowserMiddleClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserMiddleClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserMiddleClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMiddleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMiddleClickToolUseBlock.kt new file mode 100644 index 000000000..9810ddf50 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMiddleClickToolUseBlock.kt @@ -0,0 +1,411 @@ +package com.anthropic.models.messages + +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 + +class BrowserMiddleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Middle-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BrowserMiddleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserMiddleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserMiddleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("middle_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserMiddleClickToolUseBlock: BrowserMiddleClickToolUseBlock) = apply { + id = browserMiddleClickToolUseBlock.id + caller = browserMiddleClickToolUseBlock.caller + input = browserMiddleClickToolUseBlock.input + name = browserMiddleClickToolUseBlock.name + toolsetName = browserMiddleClickToolUseBlock.toolsetName + type = browserMiddleClickToolUseBlock.type + additionalProperties = + browserMiddleClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Middle-click at a viewport coordinate or on an element by reference. */ + fun input(input: BrowserMiddleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserMiddleClickInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserMiddleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserMiddleClickToolUseBlock = + BrowserMiddleClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserMiddleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("middle_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("middle_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserMiddleClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserMiddleClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMouseMoveInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMouseMoveInput.kt new file mode 100644 index 000000000..71e99f320 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMouseMoveInput.kt @@ -0,0 +1,235 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Move the pointer to a viewport coordinate without clicking. */ +class BrowserMouseMoveInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BrowserCoordinateTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserMouseMoveInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserMouseMoveInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserCoordinateTarget) = builder().target(target).build() + } + + /** A builder for [BrowserMouseMoveInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserMouseMoveInput: BrowserMouseMoveInput) = apply { + target = browserMouseMoveInput.target + tabId = browserMouseMoveInput.tabId + additionalProperties = browserMouseMoveInput.additionalProperties.toMutableMap() + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserMouseMoveInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserMouseMoveInput = + BrowserMouseMoveInput( + checkRequired("target", target), + tabId, + 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(): BrowserMouseMoveInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserMouseMoveInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserMouseMoveInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMouseMoveToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMouseMoveToolUseBlock.kt new file mode 100644 index 000000000..d8c270a2d --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserMouseMoveToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserMouseMoveToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Move the pointer to a viewport coordinate without clicking. + * + * @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 input(): BrowserMouseMoveInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserMouseMoveToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserMouseMoveToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("mouse_move") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserMouseMoveToolUseBlock: BrowserMouseMoveToolUseBlock) = apply { + id = browserMouseMoveToolUseBlock.id + caller = browserMouseMoveToolUseBlock.caller + input = browserMouseMoveToolUseBlock.input + name = browserMouseMoveToolUseBlock.name + toolsetName = browserMouseMoveToolUseBlock.toolsetName + type = browserMouseMoveToolUseBlock.type + additionalProperties = browserMouseMoveToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Move the pointer to a viewport coordinate without clicking. */ + fun input(input: BrowserMouseMoveInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserMouseMoveInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserMouseMoveToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserMouseMoveToolUseBlock = + BrowserMouseMoveToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserMouseMoveToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("mouse_move")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("mouse_move")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserMouseMoveToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserMouseMoveToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNavigateInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNavigateInput.kt new file mode 100644 index 000000000..f3c7e9aa3 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNavigateInput.kt @@ -0,0 +1,229 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Navigate to a URL, or go back/forward/reload in history. The protocol may be omitted (defaults to + * https://). + */ +class BrowserNavigateInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val url: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(url, tabId, mutableMapOf()) + + /** + * The URL to navigate to, or "back" / "forward" / "reload" for history navigation. + * + * @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 url(): String = url.getRequired("url") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserNavigateInput]. + * + * The following fields are required: + * ```java + * .url() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserNavigateInput] with the required [url] set to + * the given value. + */ + @JvmStatic fun of(url: String) = builder().url(url).build() + } + + /** A builder for [BrowserNavigateInput]. */ + class Builder internal constructor() { + + private var url: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserNavigateInput: BrowserNavigateInput) = apply { + url = browserNavigateInput.url + tabId = browserNavigateInput.tabId + additionalProperties = browserNavigateInput.additionalProperties.toMutableMap() + } + + /** The URL to navigate to, or "back" / "forward" / "reload" for history navigation. */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun url(url: JsonField) = apply { this.url = url } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserNavigateInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .url() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserNavigateInput = + BrowserNavigateInput( + checkRequired("url", url), + tabId, + 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(): BrowserNavigateInput = apply { + if (validated) { + return@apply + } + + url() + tabId() + 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 (url.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserNavigateInput && + url == other.url && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(url, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserNavigateInput{url=$url, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNavigateToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNavigateToolUseBlock.kt new file mode 100644 index 000000000..3c63d9ede --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNavigateToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class BrowserNavigateToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Navigate to a URL, or go back/forward/reload in history. The protocol may be omitted + * (defaults to https://). + * + * @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 input(): BrowserNavigateInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("navigate") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserNavigateToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserNavigateToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("navigate") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserNavigateToolUseBlock: BrowserNavigateToolUseBlock) = apply { + id = browserNavigateToolUseBlock.id + caller = browserNavigateToolUseBlock.caller + input = browserNavigateToolUseBlock.input + name = browserNavigateToolUseBlock.name + toolsetName = browserNavigateToolUseBlock.toolsetName + type = browserNavigateToolUseBlock.type + additionalProperties = browserNavigateToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Navigate to a URL, or go back/forward/reload in history. The protocol may be omitted + * (defaults to https://). + */ + fun input(input: BrowserNavigateInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserNavigateInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("navigate") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserNavigateToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserNavigateToolUseBlock = + BrowserNavigateToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserNavigateToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("navigate")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("navigate")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserNavigateToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserNavigateToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNewTabInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNewTabInput.kt new file mode 100644 index 000000000..eb5ddf49f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNewTabInput.kt @@ -0,0 +1,120 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Open a new empty tab and return its tab_id. */ +class BrowserNewTabInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [BrowserNewTabInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserNewTabInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserNewTabInput: BrowserNewTabInput) = apply { + additionalProperties = browserNewTabInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrowserNewTabInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrowserNewTabInput = BrowserNewTabInput(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(): BrowserNewTabInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserNewTabInput && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "BrowserNewTabInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNewTabToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNewTabToolUseBlock.kt new file mode 100644 index 000000000..d972f60ab --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserNewTabToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserNewTabToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Open a new empty tab and return its tab_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 input(): BrowserNewTabInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("new_tab") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserNewTabToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserNewTabToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("new_tab") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserNewTabToolUseBlock: BrowserNewTabToolUseBlock) = apply { + id = browserNewTabToolUseBlock.id + caller = browserNewTabToolUseBlock.caller + input = browserNewTabToolUseBlock.input + name = browserNewTabToolUseBlock.name + toolsetName = browserNewTabToolUseBlock.toolsetName + type = browserNewTabToolUseBlock.type + additionalProperties = browserNewTabToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Open a new empty tab and return its tab_id. */ + fun input(input: BrowserNewTabInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserNewTabInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("new_tab") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserNewTabToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserNewTabToolUseBlock = + BrowserNewTabToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserNewTabToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("new_tab")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("new_tab")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserNewTabToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserNewTabToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadConsoleInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadConsoleInput.kt new file mode 100644 index 000000000..f3129f6ed --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadConsoleInput.kt @@ -0,0 +1,171 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return console output (log entries, errors, warnings) accumulated since the driver attached to + * the tab and since the last read, one line per entry. An empty result does not mean no traffic for + * a tab that predates attach. + */ +class BrowserReadConsoleInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserReadConsoleInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserReadConsoleInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserReadConsoleInput: BrowserReadConsoleInput) = apply { + tabId = browserReadConsoleInput.tabId + additionalProperties = browserReadConsoleInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserReadConsoleInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrowserReadConsoleInput = + BrowserReadConsoleInput(tabId, 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(): BrowserReadConsoleInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserReadConsoleInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserReadConsoleInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadConsoleToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadConsoleToolUseBlock.kt new file mode 100644 index 000000000..2a04a55fe --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadConsoleToolUseBlock.kt @@ -0,0 +1,417 @@ +package com.anthropic.models.messages + +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 + +class BrowserReadConsoleToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Return console output (log entries, errors, warnings) accumulated since the driver attached + * to the tab and since the last read, one line per entry. An empty result does not mean no + * traffic for a tab that predates attach. + * + * @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 input(): BrowserReadConsoleInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("read_console") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserReadConsoleToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserReadConsoleToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("read_console") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserReadConsoleToolUseBlock: BrowserReadConsoleToolUseBlock) = apply { + id = browserReadConsoleToolUseBlock.id + caller = browserReadConsoleToolUseBlock.caller + input = browserReadConsoleToolUseBlock.input + name = browserReadConsoleToolUseBlock.name + toolsetName = browserReadConsoleToolUseBlock.toolsetName + type = browserReadConsoleToolUseBlock.type + additionalProperties = + browserReadConsoleToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Return console output (log entries, errors, warnings) accumulated since the driver + * attached to the tab and since the last read, one line per entry. An empty result does not + * mean no traffic for a tab that predates attach. + */ + fun input(input: BrowserReadConsoleInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserReadConsoleInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("read_console") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserReadConsoleToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserReadConsoleToolUseBlock = + BrowserReadConsoleToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserReadConsoleToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("read_console")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("read_console")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserReadConsoleToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserReadConsoleToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadNetworkInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadNetworkInput.kt new file mode 100644 index 000000000..cd81d71c9 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadNetworkInput.kt @@ -0,0 +1,171 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return the network requests (method, URL, status, MIME type, timing) recorded since the driver + * attached to the tab and since the last read, one line per entry. An empty result does not mean no + * traffic for a tab that predates attach. + */ +class BrowserReadNetworkInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserReadNetworkInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserReadNetworkInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserReadNetworkInput: BrowserReadNetworkInput) = apply { + tabId = browserReadNetworkInput.tabId + additionalProperties = browserReadNetworkInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserReadNetworkInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrowserReadNetworkInput = + BrowserReadNetworkInput(tabId, 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(): BrowserReadNetworkInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserReadNetworkInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserReadNetworkInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadNetworkToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadNetworkToolUseBlock.kt new file mode 100644 index 000000000..8a1a254fb --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadNetworkToolUseBlock.kt @@ -0,0 +1,417 @@ +package com.anthropic.models.messages + +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 + +class BrowserReadNetworkToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Return the network requests (method, URL, status, MIME type, timing) recorded since the + * driver attached to the tab and since the last read, one line per entry. An empty result does + * not mean no traffic for a tab that predates attach. + * + * @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 input(): BrowserReadNetworkInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("read_network") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserReadNetworkToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserReadNetworkToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("read_network") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserReadNetworkToolUseBlock: BrowserReadNetworkToolUseBlock) = apply { + id = browserReadNetworkToolUseBlock.id + caller = browserReadNetworkToolUseBlock.caller + input = browserReadNetworkToolUseBlock.input + name = browserReadNetworkToolUseBlock.name + toolsetName = browserReadNetworkToolUseBlock.toolsetName + type = browserReadNetworkToolUseBlock.type + additionalProperties = + browserReadNetworkToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Return the network requests (method, URL, status, MIME type, timing) recorded since the + * driver attached to the tab and since the last read, one line per entry. An empty result + * does not mean no traffic for a tab that predates attach. + */ + fun input(input: BrowserReadNetworkInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserReadNetworkInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("read_network") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserReadNetworkToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserReadNetworkToolUseBlock = + BrowserReadNetworkToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserReadNetworkToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("read_network")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("read_network")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserReadNetworkToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserReadNetworkToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageFilter.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageFilter.kt new file mode 100644 index 000000000..aff84f38a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageFilter.kt @@ -0,0 +1,152 @@ +package com.anthropic.models.messages + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +class BrowserReadPageFilter 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 ALL = BrowserReadPageFilter(JsonField.of("all")) + + @JvmField val INTERACTIVE = BrowserReadPageFilter(JsonField.of("interactive")) + + @JvmStatic + fun of(value: String): BrowserReadPageFilter = + // Intern known values so `==` works + when (value) { + "all" -> ALL + "interactive" -> INTERACTIVE + else -> BrowserReadPageFilter(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): BrowserReadPageFilter = + value.asString().getOrNull()?.let { of(it) } ?: BrowserReadPageFilter(value) + } + + /** An enum containing [BrowserReadPageFilter]'s known values. */ + enum class Known { + ALL, + INTERACTIVE, + } + + /** + * An enum containing [BrowserReadPageFilter]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BrowserReadPageFilter] 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 { + ALL, + INTERACTIVE, + /** + * An enum member indicating that [BrowserReadPageFilter] 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) { + ALL -> Value.ALL + INTERACTIVE -> Value.INTERACTIVE + 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) { + ALL -> Known.ALL + INTERACTIVE -> Known.INTERACTIVE + else -> throw AnthropicInvalidDataException("Unknown BrowserReadPageFilter: $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(): BrowserReadPageFilter = 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 BrowserReadPageFilter && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageInput.kt new file mode 100644 index 000000000..202907ffb --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageInput.kt @@ -0,0 +1,297 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return a structured accessibility tree of the page (or the subtree rooted at `ref`), with element + * references like [ref_7] that can be used as targets on later actions. Output is capped at 50,000 + * characters — narrow with `ref` or a smaller `depth` when exceeded. + */ +class BrowserReadPageInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val depth: JsonField, + private val filter: JsonField, + private val ref: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("depth") @ExcludeMissing depth: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + filter: JsonField = JsonMissing.of(), + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(depth, filter, ref, tabId, mutableMapOf()) + + /** + * Maximum tree depth. Default 15. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun depth(): Optional = depth.getOptional("depth") + + /** + * Which elements to include. Omitted: every visible element. "interactive": interactive + * elements only. "all": additionally includes off-viewport elements. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun filter(): Optional = filter.getOptional("filter") + + /** + * Element reference to read a subtree from. Omit to read from the page root. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ref(): Optional = ref.getOptional("ref") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [depth]. + * + * Unlike [depth], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("depth") @ExcludeMissing fun _depth(): JsonField = depth + + /** + * Returns the raw JSON value of [filter]. + * + * Unlike [filter], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserReadPageInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserReadPageInput]. */ + class Builder internal constructor() { + + private var depth: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var ref: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserReadPageInput: BrowserReadPageInput) = apply { + depth = browserReadPageInput.depth + filter = browserReadPageInput.filter + ref = browserReadPageInput.ref + tabId = browserReadPageInput.tabId + additionalProperties = browserReadPageInput.additionalProperties.toMutableMap() + } + + /** Maximum tree depth. Default 15. */ + fun depth(depth: Long?) = depth(JsonField.ofNullable(depth)) + + /** + * Alias for [Builder.depth]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun depth(depth: Long) = depth(depth as Long?) + + /** Alias for calling [Builder.depth] with `depth.orElse(null)`. */ + fun depth(depth: Optional) = depth(depth.getOrNull()) + + /** + * Sets [Builder.depth] to an arbitrary JSON value. + * + * You should usually call [Builder.depth] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun depth(depth: JsonField) = apply { this.depth = depth } + + /** + * Which elements to include. Omitted: every visible element. "interactive": interactive + * elements only. "all": additionally includes off-viewport elements. + */ + fun filter(filter: BrowserReadPageFilter?) = filter(JsonField.ofNullable(filter)) + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + + /** + * Sets [Builder.filter] to an arbitrary JSON value. + * + * You should usually call [Builder.filter] with a well-typed [BrowserReadPageFilter] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + + /** Element reference to read a subtree from. Omit to read from the page root. */ + fun ref(ref: String?) = ref(JsonField.ofNullable(ref)) + + /** Alias for calling [Builder.ref] with `ref.orElse(null)`. */ + fun ref(ref: Optional) = ref(ref.getOrNull()) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserReadPageInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrowserReadPageInput = + BrowserReadPageInput(depth, filter, ref, tabId, 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(): BrowserReadPageInput = apply { + if (validated) { + return@apply + } + + depth() + filter().ifPresent { it.validate() } + ref() + tabId() + 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 (depth.asKnown().isPresent) 1 else 0) + + (filter.asKnown().getOrNull()?.validity() ?: 0) + + (if (ref.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserReadPageInput && + depth == other.depth && + filter == other.filter && + ref == other.ref && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(depth, filter, ref, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserReadPageInput{depth=$depth, filter=$filter, ref=$ref, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageToolUseBlock.kt new file mode 100644 index 000000000..b5b099741 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserReadPageToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.messages + +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 + +class BrowserReadPageToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Return a structured accessibility tree of the page (or the subtree rooted at `ref`), with + * element references like [ref_7] that can be used as targets on later actions. Output is + * capped at 50,000 characters — narrow with `ref` or a smaller `depth` when exceeded. + * + * @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 input(): BrowserReadPageInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("read_page") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserReadPageToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserReadPageToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("read_page") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserReadPageToolUseBlock: BrowserReadPageToolUseBlock) = apply { + id = browserReadPageToolUseBlock.id + caller = browserReadPageToolUseBlock.caller + input = browserReadPageToolUseBlock.input + name = browserReadPageToolUseBlock.name + toolsetName = browserReadPageToolUseBlock.toolsetName + type = browserReadPageToolUseBlock.type + additionalProperties = browserReadPageToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Return a structured accessibility tree of the page (or the subtree rooted at `ref`), with + * element references like [ref_7] that can be used as targets on later actions. Output is + * capped at 50,000 characters — narrow with `ref` or a smaller `depth` when exceeded. + */ + fun input(input: BrowserReadPageInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserReadPageInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("read_page") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserReadPageToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserReadPageToolUseBlock = + BrowserReadPageToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserReadPageToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("read_page")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("read_page")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserReadPageToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserReadPageToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRefTarget.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRefTarget.kt new file mode 100644 index 000000000..0381b2484 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRefTarget.kt @@ -0,0 +1,225 @@ +package com.anthropic.models.messages + +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 + +/** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a major + * re-render. + */ +class BrowserRefTarget +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val ref: JsonField, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("ref") @ExcludeMissing ref: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(ref, type, mutableMapOf()) + + /** + * An element reference (e.g. "ref_7") returned by a prior `read_page` or `find` result. + * + * @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 ref(): String = ref.getRequired("ref") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("ref") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * Returns the raw JSON value of [ref]. + * + * Unlike [ref], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ref") @ExcludeMissing fun _ref(): JsonField = ref + + @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 [BrowserRefTarget]. + * + * The following fields are required: + * ```java + * .ref() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserRefTarget] with the required [ref] set to the + * given value. + */ + @JvmStatic fun of(ref: String) = builder().ref(ref).build() + } + + /** A builder for [BrowserRefTarget]. */ + class Builder internal constructor() { + + private var ref: JsonField? = null + private var type: JsonValue = JsonValue.from("ref") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserRefTarget: BrowserRefTarget) = apply { + ref = browserRefTarget.ref + type = browserRefTarget.type + additionalProperties = browserRefTarget.additionalProperties.toMutableMap() + } + + /** An element reference (e.g. "ref_7") returned by a prior `read_page` or `find` result. */ + fun ref(ref: String) = ref(JsonField.of(ref)) + + /** + * Sets [Builder.ref] to an arbitrary JSON value. + * + * You should usually call [Builder.ref] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun ref(ref: JsonField) = apply { this.ref = ref } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("ref") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserRefTarget]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .ref() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserRefTarget = + BrowserRefTarget(checkRequired("ref", ref), 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(): BrowserRefTarget = apply { + if (validated) { + return@apply + } + + ref() + _type().let { + if (it != JsonValue.from("ref")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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 (ref.asKnown().isPresent) 1 else 0) + + type.let { if (it == JsonValue.from("ref")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserRefTarget && + ref == other.ref && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(ref, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserRefTarget{ref=$ref, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRightClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRightClickInput.kt new file mode 100644 index 000000000..06b90163e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRightClickInput.kt @@ -0,0 +1,291 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Right-click at a viewport coordinate or on an element by reference. */ +class BrowserRightClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserRightClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserRightClickInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BrowserRightClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserRightClickInput: BrowserRightClickInput) = apply { + target = browserRightClickInput.target + modifiers = browserRightClickInput.modifiers + tabId = browserRightClickInput.tabId + additionalProperties = browserRightClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BrowserCoordinateTarget) = + target(BrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BrowserRefTarget) = target(BrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserRightClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserRightClickInput = + BrowserRightClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BrowserRightClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserRightClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserRightClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRightClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRightClickToolUseBlock.kt new file mode 100644 index 000000000..586d97258 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserRightClickToolUseBlock.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.messages + +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 + +class BrowserRightClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Right-click at a viewport coordinate or on an element by reference. + * + * @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 input(): BrowserRightClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserRightClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserRightClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("right_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserRightClickToolUseBlock: BrowserRightClickToolUseBlock) = apply { + id = browserRightClickToolUseBlock.id + caller = browserRightClickToolUseBlock.caller + input = browserRightClickToolUseBlock.input + name = browserRightClickToolUseBlock.name + toolsetName = browserRightClickToolUseBlock.toolsetName + type = browserRightClickToolUseBlock.type + additionalProperties = browserRightClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Right-click at a viewport coordinate or on an element by reference. */ + fun input(input: BrowserRightClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserRightClickInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserRightClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserRightClickToolUseBlock = + BrowserRightClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserRightClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("right_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("right_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserRightClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserRightClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScreenshotInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScreenshotInput.kt new file mode 100644 index 000000000..60721e929 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScreenshotInput.kt @@ -0,0 +1,167 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Capture the current browser viewport. */ +class BrowserScreenshotInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserScreenshotInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserScreenshotInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserScreenshotInput: BrowserScreenshotInput) = apply { + tabId = browserScreenshotInput.tabId + additionalProperties = browserScreenshotInput.additionalProperties.toMutableMap() + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserScreenshotInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrowserScreenshotInput = + BrowserScreenshotInput(tabId, 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(): BrowserScreenshotInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserScreenshotInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserScreenshotInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScreenshotToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScreenshotToolUseBlock.kt new file mode 100644 index 000000000..234ba0f7e --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScreenshotToolUseBlock.kt @@ -0,0 +1,410 @@ +package com.anthropic.models.messages + +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 + +class BrowserScreenshotToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Capture the current browser viewport. + * + * @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 input(): BrowserScreenshotInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserScreenshotToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserScreenshotToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("screenshot") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserScreenshotToolUseBlock: BrowserScreenshotToolUseBlock) = apply { + id = browserScreenshotToolUseBlock.id + caller = browserScreenshotToolUseBlock.caller + input = browserScreenshotToolUseBlock.input + name = browserScreenshotToolUseBlock.name + toolsetName = browserScreenshotToolUseBlock.toolsetName + type = browserScreenshotToolUseBlock.type + additionalProperties = browserScreenshotToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Capture the current browser viewport. */ + fun input(input: BrowserScreenshotInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserScreenshotInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserScreenshotToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserScreenshotToolUseBlock = + BrowserScreenshotToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserScreenshotToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("screenshot")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("screenshot")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserScreenshotToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserScreenshotToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollDirection.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollDirection.kt new file mode 100644 index 000000000..4356e0d12 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollDirection.kt @@ -0,0 +1,166 @@ +package com.anthropic.models.messages + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +class BrowserScrollDirection 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 UP = BrowserScrollDirection(JsonField.of("up")) + + @JvmField val DOWN = BrowserScrollDirection(JsonField.of("down")) + + @JvmField val LEFT = BrowserScrollDirection(JsonField.of("left")) + + @JvmField val RIGHT = BrowserScrollDirection(JsonField.of("right")) + + @JvmStatic + fun of(value: String): BrowserScrollDirection = + // Intern known values so `==` works + when (value) { + "up" -> UP + "down" -> DOWN + "left" -> LEFT + "right" -> RIGHT + else -> BrowserScrollDirection(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): BrowserScrollDirection = + value.asString().getOrNull()?.let { of(it) } ?: BrowserScrollDirection(value) + } + + /** An enum containing [BrowserScrollDirection]'s known values. */ + enum class Known { + UP, + DOWN, + LEFT, + RIGHT, + } + + /** + * An enum containing [BrowserScrollDirection]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BrowserScrollDirection] 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 { + UP, + DOWN, + LEFT, + RIGHT, + /** + * An enum member indicating that [BrowserScrollDirection] 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) { + UP -> Value.UP + DOWN -> Value.DOWN + LEFT -> Value.LEFT + RIGHT -> Value.RIGHT + 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) { + UP -> Known.UP + DOWN -> Known.DOWN + LEFT -> Known.LEFT + RIGHT -> Known.RIGHT + else -> throw AnthropicInvalidDataException("Unknown BrowserScrollDirection: $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(): BrowserScrollDirection = 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 BrowserScrollDirection && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollInput.kt new file mode 100644 index 000000000..8ded0b3bc --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollInput.kt @@ -0,0 +1,322 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Scroll at a viewport position. `target` must be a coordinate target. */ +class BrowserScrollInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val scrollDirection: JsonField, + private val target: JsonField, + private val scrollAmount: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("scroll_direction") + @ExcludeMissing + scrollDirection: JsonField = JsonMissing.of(), + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("scroll_amount") + @ExcludeMissing + scrollAmount: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(scrollDirection, target, scrollAmount, tabId, 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 scrollDirection(): BrowserScrollDirection = scrollDirection.getRequired("scroll_direction") + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + * + * @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 target(): BrowserCoordinateTarget = target.getRequired("target") + + /** + * Scroll-wheel notches (1–10). Default 3. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun scrollAmount(): Optional = scrollAmount.getOptional("scroll_amount") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [scrollDirection]. + * + * Unlike [scrollDirection], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_direction") + @ExcludeMissing + fun _scrollDirection(): JsonField = scrollDirection + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [scrollAmount]. + * + * Unlike [scrollAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_amount") + @ExcludeMissing + fun _scrollAmount(): JsonField = scrollAmount + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserScrollInput]. + * + * The following fields are required: + * ```java + * .scrollDirection() + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserScrollInput]. */ + class Builder internal constructor() { + + private var scrollDirection: JsonField? = null + private var target: JsonField? = null + private var scrollAmount: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserScrollInput: BrowserScrollInput) = apply { + scrollDirection = browserScrollInput.scrollDirection + target = browserScrollInput.target + scrollAmount = browserScrollInput.scrollAmount + tabId = browserScrollInput.tabId + additionalProperties = browserScrollInput.additionalProperties.toMutableMap() + } + + fun scrollDirection(scrollDirection: BrowserScrollDirection) = + scrollDirection(JsonField.of(scrollDirection)) + + /** + * Sets [Builder.scrollDirection] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollDirection] with a well-typed + * [BrowserScrollDirection] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun scrollDirection(scrollDirection: JsonField) = apply { + this.scrollDirection = scrollDirection + } + + /** + * A point in the browser viewport, in viewport pixels (the same frame as a full-viewport + * screenshot). + */ + fun target(target: BrowserCoordinateTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserCoordinateTarget] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Scroll-wheel notches (1–10). Default 3. */ + fun scrollAmount(scrollAmount: Long?) = scrollAmount(JsonField.ofNullable(scrollAmount)) + + /** + * Alias for [Builder.scrollAmount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun scrollAmount(scrollAmount: Long) = scrollAmount(scrollAmount as Long?) + + /** Alias for calling [Builder.scrollAmount] with `scrollAmount.orElse(null)`. */ + fun scrollAmount(scrollAmount: Optional) = scrollAmount(scrollAmount.getOrNull()) + + /** + * Sets [Builder.scrollAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scrollAmount(scrollAmount: JsonField) = apply { this.scrollAmount = scrollAmount } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserScrollInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scrollDirection() + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserScrollInput = + BrowserScrollInput( + checkRequired("scrollDirection", scrollDirection), + checkRequired("target", target), + scrollAmount, + tabId, + 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(): BrowserScrollInput = apply { + if (validated) { + return@apply + } + + scrollDirection().validate() + target().validate() + scrollAmount() + tabId() + 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 = + (scrollDirection.asKnown().getOrNull()?.validity() ?: 0) + + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (scrollAmount.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserScrollInput && + scrollDirection == other.scrollDirection && + target == other.target && + scrollAmount == other.scrollAmount && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scrollDirection, target, scrollAmount, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserScrollInput{scrollDirection=$scrollDirection, target=$target, scrollAmount=$scrollAmount, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToInput.kt new file mode 100644 index 000000000..b5cce14ab --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToInput.kt @@ -0,0 +1,235 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Scroll an element into view. */ +class BrowserScrollToInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, tabId, mutableMapOf()) + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` result. + * References are scoped to the tab that produced them and become stale after navigation or a + * major re-render. + * + * @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 target(): BrowserRefTarget = target.getRequired("target") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserScrollToInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserScrollToInput] with the required [target] set to + * the given value. + */ + @JvmStatic fun of(target: BrowserRefTarget) = builder().target(target).build() + } + + /** A builder for [BrowserScrollToInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserScrollToInput: BrowserScrollToInput) = apply { + target = browserScrollToInput.target + tabId = browserScrollToInput.tabId + additionalProperties = browserScrollToInput.additionalProperties.toMutableMap() + } + + /** + * An element on the page, identified by a reference from a prior `read_page` or `find` + * result. References are scoped to the tab that produced them and become stale after + * navigation or a major re-render. + */ + fun target(target: BrowserRefTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserRefTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserScrollToInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserScrollToInput = + BrowserScrollToInput( + checkRequired("target", target), + tabId, + 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(): BrowserScrollToInput = apply { + if (validated) { + return@apply + } + + target().validate() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserScrollToInput && + target == other.target && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(target, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserScrollToInput{target=$target, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToToolUseBlock.kt new file mode 100644 index 000000000..3d1d379ff --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserScrollToToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Scroll an element into view. + * + * @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 input(): BrowserScrollToInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("scroll_to") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserScrollToToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserScrollToToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("scroll_to") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserScrollToToolUseBlock: BrowserScrollToToolUseBlock) = apply { + id = browserScrollToToolUseBlock.id + caller = browserScrollToToolUseBlock.caller + input = browserScrollToToolUseBlock.input + name = browserScrollToToolUseBlock.name + toolsetName = browserScrollToToolUseBlock.toolsetName + type = browserScrollToToolUseBlock.type + additionalProperties = browserScrollToToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Scroll an element into view. */ + fun input(input: BrowserScrollToInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserScrollToInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scroll_to") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserScrollToToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserScrollToToolUseBlock = + BrowserScrollToToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserScrollToToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("scroll_to")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("scroll_to")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserScrollToToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserScrollToToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToolUseBlock.kt new file mode 100644 index 000000000..301bebaf7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserScrollToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserScrollToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Scroll at a viewport position. `target` must be a coordinate target. + * + * @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 input(): BrowserScrollInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserScrollToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserScrollToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("scroll") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserScrollToolUseBlock: BrowserScrollToolUseBlock) = apply { + id = browserScrollToolUseBlock.id + caller = browserScrollToolUseBlock.caller + input = browserScrollToolUseBlock.input + name = browserScrollToolUseBlock.name + toolsetName = browserScrollToolUseBlock.toolsetName + type = browserScrollToolUseBlock.type + additionalProperties = browserScrollToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Scroll at a viewport position. `target` must be a coordinate target. */ + fun input(input: BrowserScrollInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserScrollInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserScrollToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserScrollToolUseBlock = + BrowserScrollToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserScrollToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("scroll")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("scroll")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserScrollToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserScrollToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserSwitchTabInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserSwitchTabInput.kt new file mode 100644 index 000000000..3e8e4f3f7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserSwitchTabInput.kt @@ -0,0 +1,189 @@ +package com.anthropic.models.messages + +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 + +/** + * Make the tab with the given tab_id the active tab — the tab that actions without a tab_id apply + * to. + */ +class BrowserSwitchTabInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of() + ) : this(tabId, mutableMapOf()) + + /** + * The tab to switch to. + * + * @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 tabId(): String = tabId.getRequired("tab_id") + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserSwitchTabInput]. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserSwitchTabInput] with the required [tabId] set to + * the given value. + */ + @JvmStatic fun of(tabId: String) = builder().tabId(tabId).build() + } + + /** A builder for [BrowserSwitchTabInput]. */ + class Builder internal constructor() { + + private var tabId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserSwitchTabInput: BrowserSwitchTabInput) = apply { + tabId = browserSwitchTabInput.tabId + additionalProperties = browserSwitchTabInput.additionalProperties.toMutableMap() + } + + /** The tab to switch to. */ + fun tabId(tabId: String) = tabId(JsonField.of(tabId)) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserSwitchTabInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .tabId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserSwitchTabInput = + BrowserSwitchTabInput( + checkRequired("tabId", tabId), + 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(): BrowserSwitchTabInput = apply { + if (validated) { + return@apply + } + + tabId() + 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 (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserSwitchTabInput && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserSwitchTabInput{tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserSwitchTabToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserSwitchTabToolUseBlock.kt new file mode 100644 index 000000000..3abcb918c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserSwitchTabToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class BrowserSwitchTabToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Make the tab with the given tab_id the active tab — the tab that actions without a tab_id + * apply to. + * + * @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 input(): BrowserSwitchTabInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("switch_tab") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserSwitchTabToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserSwitchTabToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("switch_tab") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserSwitchTabToolUseBlock: BrowserSwitchTabToolUseBlock) = apply { + id = browserSwitchTabToolUseBlock.id + caller = browserSwitchTabToolUseBlock.caller + input = browserSwitchTabToolUseBlock.input + name = browserSwitchTabToolUseBlock.name + toolsetName = browserSwitchTabToolUseBlock.toolsetName + type = browserSwitchTabToolUseBlock.type + additionalProperties = browserSwitchTabToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Make the tab with the given tab_id the active tab — the tab that actions without a tab_id + * apply to. + */ + fun input(input: BrowserSwitchTabInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserSwitchTabInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("switch_tab") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserSwitchTabToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserSwitchTabToolUseBlock = + BrowserSwitchTabToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserSwitchTabToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("switch_tab")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("switch_tab")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserSwitchTabToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserSwitchTabToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserToolUseBlock.kt new file mode 100644 index 000000000..2901a9951 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserToolUseBlock.kt @@ -0,0 +1,1401 @@ +package com.anthropic.models.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.core.getProperty +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = BrowserToolUseBlock.Deserializer::class) +@JsonSerialize(using = BrowserToolUseBlock.Serializer::class) +class BrowserToolUseBlock +private constructor( + private val navigate: BrowserNavigateToolUseBlock? = null, + private val listTabs: BrowserListTabsToolUseBlock? = null, + private val newTab: BrowserNewTabToolUseBlock? = null, + private val switchTab: BrowserSwitchTabToolUseBlock? = null, + private val closeTab: BrowserCloseTabToolUseBlock? = null, + private val readPage: BrowserReadPageToolUseBlock? = null, + private val getPageText: BrowserGetPageTextToolUseBlock? = null, + private val readConsole: BrowserReadConsoleToolUseBlock? = null, + private val readNetwork: BrowserReadNetworkToolUseBlock? = null, + private val find: BrowserFindToolUseBlock? = null, + private val formInput: BrowserFormInputToolUseBlock? = null, + private val fileUpload: BrowserFileUploadToolUseBlock? = null, + private val scrollTo: BrowserScrollToToolUseBlock? = null, + private val screenshot: BrowserScreenshotToolUseBlock? = null, + private val zoom: BrowserZoomToolUseBlock? = null, + private val leftClick: BrowserLeftClickToolUseBlock? = null, + private val rightClick: BrowserRightClickToolUseBlock? = null, + private val middleClick: BrowserMiddleClickToolUseBlock? = null, + private val doubleClick: BrowserDoubleClickToolUseBlock? = null, + private val tripleClick: BrowserTripleClickToolUseBlock? = null, + private val hover: BrowserHoverToolUseBlock? = null, + private val leftClickDrag: BrowserLeftClickDragToolUseBlock? = null, + private val leftMouseDown: BrowserLeftMouseDownToolUseBlock? = null, + private val leftMouseUp: BrowserLeftMouseUpToolUseBlock? = null, + private val mouseMove: BrowserMouseMoveToolUseBlock? = null, + private val scroll: BrowserScrollToolUseBlock? = null, + private val type: BrowserTypeToolUseBlock? = null, + private val key: BrowserKeyToolUseBlock? = null, + private val holdKey: BrowserHoldKeyToolUseBlock? = null, + private val wait: BrowserWaitToolUseBlock? = null, + private val javascriptExec: BrowserJavascriptExecToolUseBlock? = null, + private val _json: JsonValue? = null, +) { + + fun name(): Name = + when { + navigate != null -> Name.NAVIGATE + listTabs != null -> Name.LIST_TABS + newTab != null -> Name.NEW_TAB + switchTab != null -> Name.SWITCH_TAB + closeTab != null -> Name.CLOSE_TAB + readPage != null -> Name.READ_PAGE + getPageText != null -> Name.GET_PAGE_TEXT + readConsole != null -> Name.READ_CONSOLE + readNetwork != null -> Name.READ_NETWORK + find != null -> Name.FIND + formInput != null -> Name.FORM_INPUT + fileUpload != null -> Name.FILE_UPLOAD + scrollTo != null -> Name.SCROLL_TO + screenshot != null -> Name.SCREENSHOT + zoom != null -> Name.ZOOM + leftClick != null -> Name.LEFT_CLICK + rightClick != null -> Name.RIGHT_CLICK + middleClick != null -> Name.MIDDLE_CLICK + doubleClick != null -> Name.DOUBLE_CLICK + tripleClick != null -> Name.TRIPLE_CLICK + hover != null -> Name.HOVER + leftClickDrag != null -> Name.LEFT_CLICK_DRAG + leftMouseDown != null -> Name.LEFT_MOUSE_DOWN + leftMouseUp != null -> Name.LEFT_MOUSE_UP + mouseMove != null -> Name.MOUSE_MOVE + scroll != null -> Name.SCROLL + type != null -> Name.TYPE + key != null -> Name.KEY + holdKey != null -> Name.HOLD_KEY + wait != null -> Name.WAIT + javascriptExec != null -> Name.JAVASCRIPT_EXEC + else -> Name.of(_json?.asObject()?.getOrNull()?.get("name") ?: JsonMissing.of()) + } + + fun id(): String = + when { + navigate != null -> navigate.id() + listTabs != null -> listTabs.id() + newTab != null -> newTab.id() + switchTab != null -> switchTab.id() + closeTab != null -> closeTab.id() + readPage != null -> readPage.id() + getPageText != null -> getPageText.id() + readConsole != null -> readConsole.id() + readNetwork != null -> readNetwork.id() + find != null -> find.id() + formInput != null -> formInput.id() + fileUpload != null -> fileUpload.id() + scrollTo != null -> scrollTo.id() + screenshot != null -> screenshot.id() + zoom != null -> zoom.id() + leftClick != null -> leftClick.id() + rightClick != null -> rightClick.id() + middleClick != null -> middleClick.id() + doubleClick != null -> doubleClick.id() + tripleClick != null -> tripleClick.id() + hover != null -> hover.id() + leftClickDrag != null -> leftClickDrag.id() + leftMouseDown != null -> leftMouseDown.id() + leftMouseUp != null -> leftMouseUp.id() + mouseMove != null -> mouseMove.id() + scroll != null -> scroll.id() + type != null -> type.id() + key != null -> key.id() + holdKey != null -> holdKey.id() + wait != null -> wait.id() + javascriptExec != null -> javascriptExec.id() + else -> _json.getProperty("id").getRequired("id") + } + + fun caller(): ToolUseCaller = + when { + navigate != null -> navigate.caller() + listTabs != null -> listTabs.caller() + newTab != null -> newTab.caller() + switchTab != null -> switchTab.caller() + closeTab != null -> closeTab.caller() + readPage != null -> readPage.caller() + getPageText != null -> getPageText.caller() + readConsole != null -> readConsole.caller() + readNetwork != null -> readNetwork.caller() + find != null -> find.caller() + formInput != null -> formInput.caller() + fileUpload != null -> fileUpload.caller() + scrollTo != null -> scrollTo.caller() + screenshot != null -> screenshot.caller() + zoom != null -> zoom.caller() + leftClick != null -> leftClick.caller() + rightClick != null -> rightClick.caller() + middleClick != null -> middleClick.caller() + doubleClick != null -> doubleClick.caller() + tripleClick != null -> tripleClick.caller() + hover != null -> hover.caller() + leftClickDrag != null -> leftClickDrag.caller() + leftMouseDown != null -> leftMouseDown.caller() + leftMouseUp != null -> leftMouseUp.caller() + mouseMove != null -> mouseMove.caller() + scroll != null -> scroll.caller() + type != null -> type.caller() + key != null -> key.caller() + holdKey != null -> holdKey.caller() + wait != null -> wait.caller() + javascriptExec != null -> javascriptExec.caller() + else -> _json.getProperty("caller").getRequired("caller") + } + + fun navigate(): Optional = Optional.ofNullable(navigate) + + fun listTabs(): Optional = Optional.ofNullable(listTabs) + + fun newTab(): Optional = Optional.ofNullable(newTab) + + fun switchTab(): Optional = Optional.ofNullable(switchTab) + + fun closeTab(): Optional = Optional.ofNullable(closeTab) + + fun readPage(): Optional = Optional.ofNullable(readPage) + + fun getPageText(): Optional = Optional.ofNullable(getPageText) + + fun readConsole(): Optional = Optional.ofNullable(readConsole) + + fun readNetwork(): Optional = Optional.ofNullable(readNetwork) + + fun find(): Optional = Optional.ofNullable(find) + + fun formInput(): Optional = Optional.ofNullable(formInput) + + fun fileUpload(): Optional = Optional.ofNullable(fileUpload) + + fun scrollTo(): Optional = Optional.ofNullable(scrollTo) + + fun screenshot(): Optional = Optional.ofNullable(screenshot) + + fun zoom(): Optional = Optional.ofNullable(zoom) + + fun leftClick(): Optional = Optional.ofNullable(leftClick) + + fun rightClick(): Optional = Optional.ofNullable(rightClick) + + fun middleClick(): Optional = Optional.ofNullable(middleClick) + + fun doubleClick(): Optional = Optional.ofNullable(doubleClick) + + fun tripleClick(): Optional = Optional.ofNullable(tripleClick) + + fun hover(): Optional = Optional.ofNullable(hover) + + fun leftClickDrag(): Optional = + Optional.ofNullable(leftClickDrag) + + fun leftMouseDown(): Optional = + Optional.ofNullable(leftMouseDown) + + fun leftMouseUp(): Optional = Optional.ofNullable(leftMouseUp) + + fun mouseMove(): Optional = Optional.ofNullable(mouseMove) + + fun scroll(): Optional = Optional.ofNullable(scroll) + + fun type(): Optional = Optional.ofNullable(type) + + fun key(): Optional = Optional.ofNullable(key) + + fun holdKey(): Optional = Optional.ofNullable(holdKey) + + fun wait(): Optional = Optional.ofNullable(wait) + + fun javascriptExec(): Optional = + Optional.ofNullable(javascriptExec) + + fun isNavigate(): Boolean = navigate != null + + fun isListTabs(): Boolean = listTabs != null + + fun isNewTab(): Boolean = newTab != null + + fun isSwitchTab(): Boolean = switchTab != null + + fun isCloseTab(): Boolean = closeTab != null + + fun isReadPage(): Boolean = readPage != null + + fun isGetPageText(): Boolean = getPageText != null + + fun isReadConsole(): Boolean = readConsole != null + + fun isReadNetwork(): Boolean = readNetwork != null + + fun isFind(): Boolean = find != null + + fun isFormInput(): Boolean = formInput != null + + fun isFileUpload(): Boolean = fileUpload != null + + fun isScrollTo(): Boolean = scrollTo != null + + fun isScreenshot(): Boolean = screenshot != null + + fun isZoom(): Boolean = zoom != null + + fun isLeftClick(): Boolean = leftClick != null + + fun isRightClick(): Boolean = rightClick != null + + fun isMiddleClick(): Boolean = middleClick != null + + fun isDoubleClick(): Boolean = doubleClick != null + + fun isTripleClick(): Boolean = tripleClick != null + + fun isHover(): Boolean = hover != null + + fun isLeftClickDrag(): Boolean = leftClickDrag != null + + fun isLeftMouseDown(): Boolean = leftMouseDown != null + + fun isLeftMouseUp(): Boolean = leftMouseUp != null + + fun isMouseMove(): Boolean = mouseMove != null + + fun isScroll(): Boolean = scroll != null + + fun isType(): Boolean = type != null + + fun isKey(): Boolean = key != null + + fun isHoldKey(): Boolean = holdKey != null + + fun isWait(): Boolean = wait != null + + fun isJavascriptExec(): Boolean = javascriptExec != null + + fun asNavigate(): BrowserNavigateToolUseBlock = navigate.getOrThrow("navigate") + + fun asListTabs(): BrowserListTabsToolUseBlock = listTabs.getOrThrow("listTabs") + + fun asNewTab(): BrowserNewTabToolUseBlock = newTab.getOrThrow("newTab") + + fun asSwitchTab(): BrowserSwitchTabToolUseBlock = switchTab.getOrThrow("switchTab") + + fun asCloseTab(): BrowserCloseTabToolUseBlock = closeTab.getOrThrow("closeTab") + + fun asReadPage(): BrowserReadPageToolUseBlock = readPage.getOrThrow("readPage") + + fun asGetPageText(): BrowserGetPageTextToolUseBlock = getPageText.getOrThrow("getPageText") + + fun asReadConsole(): BrowserReadConsoleToolUseBlock = readConsole.getOrThrow("readConsole") + + fun asReadNetwork(): BrowserReadNetworkToolUseBlock = readNetwork.getOrThrow("readNetwork") + + fun asFind(): BrowserFindToolUseBlock = find.getOrThrow("find") + + fun asFormInput(): BrowserFormInputToolUseBlock = formInput.getOrThrow("formInput") + + fun asFileUpload(): BrowserFileUploadToolUseBlock = fileUpload.getOrThrow("fileUpload") + + fun asScrollTo(): BrowserScrollToToolUseBlock = scrollTo.getOrThrow("scrollTo") + + fun asScreenshot(): BrowserScreenshotToolUseBlock = screenshot.getOrThrow("screenshot") + + fun asZoom(): BrowserZoomToolUseBlock = zoom.getOrThrow("zoom") + + fun asLeftClick(): BrowserLeftClickToolUseBlock = leftClick.getOrThrow("leftClick") + + fun asRightClick(): BrowserRightClickToolUseBlock = rightClick.getOrThrow("rightClick") + + fun asMiddleClick(): BrowserMiddleClickToolUseBlock = middleClick.getOrThrow("middleClick") + + fun asDoubleClick(): BrowserDoubleClickToolUseBlock = doubleClick.getOrThrow("doubleClick") + + fun asTripleClick(): BrowserTripleClickToolUseBlock = tripleClick.getOrThrow("tripleClick") + + fun asHover(): BrowserHoverToolUseBlock = hover.getOrThrow("hover") + + fun asLeftClickDrag(): BrowserLeftClickDragToolUseBlock = + leftClickDrag.getOrThrow("leftClickDrag") + + fun asLeftMouseDown(): BrowserLeftMouseDownToolUseBlock = + leftMouseDown.getOrThrow("leftMouseDown") + + fun asLeftMouseUp(): BrowserLeftMouseUpToolUseBlock = leftMouseUp.getOrThrow("leftMouseUp") + + fun asMouseMove(): BrowserMouseMoveToolUseBlock = mouseMove.getOrThrow("mouseMove") + + fun asScroll(): BrowserScrollToolUseBlock = scroll.getOrThrow("scroll") + + fun asType(): BrowserTypeToolUseBlock = type.getOrThrow("type") + + fun asKey(): BrowserKeyToolUseBlock = key.getOrThrow("key") + + fun asHoldKey(): BrowserHoldKeyToolUseBlock = holdKey.getOrThrow("holdKey") + + fun asWait(): BrowserWaitToolUseBlock = wait.getOrThrow("wait") + + fun asJavascriptExec(): BrowserJavascriptExecToolUseBlock = + javascriptExec.getOrThrow("javascriptExec") + + 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 = browserToolUseBlock.accept(new BrowserToolUseBlock.Visitor>() { + * @Override + * public Optional visitNavigate(BrowserNavigateToolUseBlock navigate) { + * return Optional.of(navigate.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 { + navigate != null -> visitor.visitNavigate(navigate) + listTabs != null -> visitor.visitListTabs(listTabs) + newTab != null -> visitor.visitNewTab(newTab) + switchTab != null -> visitor.visitSwitchTab(switchTab) + closeTab != null -> visitor.visitCloseTab(closeTab) + readPage != null -> visitor.visitReadPage(readPage) + getPageText != null -> visitor.visitGetPageText(getPageText) + readConsole != null -> visitor.visitReadConsole(readConsole) + readNetwork != null -> visitor.visitReadNetwork(readNetwork) + find != null -> visitor.visitFind(find) + formInput != null -> visitor.visitFormInput(formInput) + fileUpload != null -> visitor.visitFileUpload(fileUpload) + scrollTo != null -> visitor.visitScrollTo(scrollTo) + screenshot != null -> visitor.visitScreenshot(screenshot) + zoom != null -> visitor.visitZoom(zoom) + leftClick != null -> visitor.visitLeftClick(leftClick) + rightClick != null -> visitor.visitRightClick(rightClick) + middleClick != null -> visitor.visitMiddleClick(middleClick) + doubleClick != null -> visitor.visitDoubleClick(doubleClick) + tripleClick != null -> visitor.visitTripleClick(tripleClick) + hover != null -> visitor.visitHover(hover) + leftClickDrag != null -> visitor.visitLeftClickDrag(leftClickDrag) + leftMouseDown != null -> visitor.visitLeftMouseDown(leftMouseDown) + leftMouseUp != null -> visitor.visitLeftMouseUp(leftMouseUp) + mouseMove != null -> visitor.visitMouseMove(mouseMove) + scroll != null -> visitor.visitScroll(scroll) + type != null -> visitor.visitType(type) + key != null -> visitor.visitKey(key) + holdKey != null -> visitor.visitHoldKey(holdKey) + wait != null -> visitor.visitWait(wait) + javascriptExec != null -> visitor.visitJavascriptExec(javascriptExec) + 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(): BrowserToolUseBlock = apply { + if (validated) { + return@apply + } + + when { + navigate != null -> navigate.validate() + listTabs != null -> listTabs.validate() + newTab != null -> newTab.validate() + switchTab != null -> switchTab.validate() + closeTab != null -> closeTab.validate() + readPage != null -> readPage.validate() + getPageText != null -> getPageText.validate() + readConsole != null -> readConsole.validate() + readNetwork != null -> readNetwork.validate() + find != null -> find.validate() + formInput != null -> formInput.validate() + fileUpload != null -> fileUpload.validate() + scrollTo != null -> scrollTo.validate() + screenshot != null -> screenshot.validate() + zoom != null -> zoom.validate() + leftClick != null -> leftClick.validate() + rightClick != null -> rightClick.validate() + middleClick != null -> middleClick.validate() + doubleClick != null -> doubleClick.validate() + tripleClick != null -> tripleClick.validate() + hover != null -> hover.validate() + leftClickDrag != null -> leftClickDrag.validate() + leftMouseDown != null -> leftMouseDown.validate() + leftMouseUp != null -> leftMouseUp.validate() + mouseMove != null -> mouseMove.validate() + scroll != null -> scroll.validate() + type != null -> type.validate() + key != null -> key.validate() + holdKey != null -> holdKey.validate() + wait != null -> wait.validate() + javascriptExec != null -> javascriptExec.validate() + else -> throw AnthropicInvalidDataException("Unknown BrowserToolUseBlock: $_json") + } + 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 = + when { + navigate != null -> navigate.validity() + listTabs != null -> listTabs.validity() + newTab != null -> newTab.validity() + switchTab != null -> switchTab.validity() + closeTab != null -> closeTab.validity() + readPage != null -> readPage.validity() + getPageText != null -> getPageText.validity() + readConsole != null -> readConsole.validity() + readNetwork != null -> readNetwork.validity() + find != null -> find.validity() + formInput != null -> formInput.validity() + fileUpload != null -> fileUpload.validity() + scrollTo != null -> scrollTo.validity() + screenshot != null -> screenshot.validity() + zoom != null -> zoom.validity() + leftClick != null -> leftClick.validity() + rightClick != null -> rightClick.validity() + middleClick != null -> middleClick.validity() + doubleClick != null -> doubleClick.validity() + tripleClick != null -> tripleClick.validity() + hover != null -> hover.validity() + leftClickDrag != null -> leftClickDrag.validity() + leftMouseDown != null -> leftMouseDown.validity() + leftMouseUp != null -> leftMouseUp.validity() + mouseMove != null -> mouseMove.validity() + scroll != null -> scroll.validity() + type != null -> type.validity() + key != null -> key.validity() + holdKey != null -> holdKey.validity() + wait != null -> wait.validity() + javascriptExec != null -> javascriptExec.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserToolUseBlock && + navigate == other.navigate && + listTabs == other.listTabs && + newTab == other.newTab && + switchTab == other.switchTab && + closeTab == other.closeTab && + readPage == other.readPage && + getPageText == other.getPageText && + readConsole == other.readConsole && + readNetwork == other.readNetwork && + find == other.find && + formInput == other.formInput && + fileUpload == other.fileUpload && + scrollTo == other.scrollTo && + screenshot == other.screenshot && + zoom == other.zoom && + leftClick == other.leftClick && + rightClick == other.rightClick && + middleClick == other.middleClick && + doubleClick == other.doubleClick && + tripleClick == other.tripleClick && + hover == other.hover && + leftClickDrag == other.leftClickDrag && + leftMouseDown == other.leftMouseDown && + leftMouseUp == other.leftMouseUp && + mouseMove == other.mouseMove && + scroll == other.scroll && + type == other.type && + key == other.key && + holdKey == other.holdKey && + wait == other.wait && + javascriptExec == other.javascriptExec + } + + override fun hashCode(): Int = + Objects.hash( + navigate, + listTabs, + newTab, + switchTab, + closeTab, + readPage, + getPageText, + readConsole, + readNetwork, + find, + formInput, + fileUpload, + scrollTo, + screenshot, + zoom, + leftClick, + rightClick, + middleClick, + doubleClick, + tripleClick, + hover, + leftClickDrag, + leftMouseDown, + leftMouseUp, + mouseMove, + scroll, + type, + key, + holdKey, + wait, + javascriptExec, + ) + + override fun toString(): String = + when { + navigate != null -> "BrowserToolUseBlock{navigate=$navigate}" + listTabs != null -> "BrowserToolUseBlock{listTabs=$listTabs}" + newTab != null -> "BrowserToolUseBlock{newTab=$newTab}" + switchTab != null -> "BrowserToolUseBlock{switchTab=$switchTab}" + closeTab != null -> "BrowserToolUseBlock{closeTab=$closeTab}" + readPage != null -> "BrowserToolUseBlock{readPage=$readPage}" + getPageText != null -> "BrowserToolUseBlock{getPageText=$getPageText}" + readConsole != null -> "BrowserToolUseBlock{readConsole=$readConsole}" + readNetwork != null -> "BrowserToolUseBlock{readNetwork=$readNetwork}" + find != null -> "BrowserToolUseBlock{find=$find}" + formInput != null -> "BrowserToolUseBlock{formInput=$formInput}" + fileUpload != null -> "BrowserToolUseBlock{fileUpload=$fileUpload}" + scrollTo != null -> "BrowserToolUseBlock{scrollTo=$scrollTo}" + screenshot != null -> "BrowserToolUseBlock{screenshot=$screenshot}" + zoom != null -> "BrowserToolUseBlock{zoom=$zoom}" + leftClick != null -> "BrowserToolUseBlock{leftClick=$leftClick}" + rightClick != null -> "BrowserToolUseBlock{rightClick=$rightClick}" + middleClick != null -> "BrowserToolUseBlock{middleClick=$middleClick}" + doubleClick != null -> "BrowserToolUseBlock{doubleClick=$doubleClick}" + tripleClick != null -> "BrowserToolUseBlock{tripleClick=$tripleClick}" + hover != null -> "BrowserToolUseBlock{hover=$hover}" + leftClickDrag != null -> "BrowserToolUseBlock{leftClickDrag=$leftClickDrag}" + leftMouseDown != null -> "BrowserToolUseBlock{leftMouseDown=$leftMouseDown}" + leftMouseUp != null -> "BrowserToolUseBlock{leftMouseUp=$leftMouseUp}" + mouseMove != null -> "BrowserToolUseBlock{mouseMove=$mouseMove}" + scroll != null -> "BrowserToolUseBlock{scroll=$scroll}" + type != null -> "BrowserToolUseBlock{type=$type}" + key != null -> "BrowserToolUseBlock{key=$key}" + holdKey != null -> "BrowserToolUseBlock{holdKey=$holdKey}" + wait != null -> "BrowserToolUseBlock{wait=$wait}" + javascriptExec != null -> "BrowserToolUseBlock{javascriptExec=$javascriptExec}" + _json != null -> "BrowserToolUseBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BrowserToolUseBlock") + } + + companion object { + + @JvmStatic + fun ofNavigate(navigate: BrowserNavigateToolUseBlock) = + BrowserToolUseBlock(navigate = navigate) + + @JvmStatic + fun ofListTabs(listTabs: BrowserListTabsToolUseBlock) = + BrowserToolUseBlock(listTabs = listTabs) + + @JvmStatic + fun ofNewTab(newTab: BrowserNewTabToolUseBlock) = BrowserToolUseBlock(newTab = newTab) + + @JvmStatic + fun ofSwitchTab(switchTab: BrowserSwitchTabToolUseBlock) = + BrowserToolUseBlock(switchTab = switchTab) + + @JvmStatic + fun ofCloseTab(closeTab: BrowserCloseTabToolUseBlock) = + BrowserToolUseBlock(closeTab = closeTab) + + @JvmStatic + fun ofReadPage(readPage: BrowserReadPageToolUseBlock) = + BrowserToolUseBlock(readPage = readPage) + + @JvmStatic + fun ofGetPageText(getPageText: BrowserGetPageTextToolUseBlock) = + BrowserToolUseBlock(getPageText = getPageText) + + @JvmStatic + fun ofReadConsole(readConsole: BrowserReadConsoleToolUseBlock) = + BrowserToolUseBlock(readConsole = readConsole) + + @JvmStatic + fun ofReadNetwork(readNetwork: BrowserReadNetworkToolUseBlock) = + BrowserToolUseBlock(readNetwork = readNetwork) + + @JvmStatic fun ofFind(find: BrowserFindToolUseBlock) = BrowserToolUseBlock(find = find) + + @JvmStatic + fun ofFormInput(formInput: BrowserFormInputToolUseBlock) = + BrowserToolUseBlock(formInput = formInput) + + @JvmStatic + fun ofFileUpload(fileUpload: BrowserFileUploadToolUseBlock) = + BrowserToolUseBlock(fileUpload = fileUpload) + + @JvmStatic + fun ofScrollTo(scrollTo: BrowserScrollToToolUseBlock) = + BrowserToolUseBlock(scrollTo = scrollTo) + + @JvmStatic + fun ofScreenshot(screenshot: BrowserScreenshotToolUseBlock) = + BrowserToolUseBlock(screenshot = screenshot) + + @JvmStatic fun ofZoom(zoom: BrowserZoomToolUseBlock) = BrowserToolUseBlock(zoom = zoom) + + @JvmStatic + fun ofLeftClick(leftClick: BrowserLeftClickToolUseBlock) = + BrowserToolUseBlock(leftClick = leftClick) + + @JvmStatic + fun ofRightClick(rightClick: BrowserRightClickToolUseBlock) = + BrowserToolUseBlock(rightClick = rightClick) + + @JvmStatic + fun ofMiddleClick(middleClick: BrowserMiddleClickToolUseBlock) = + BrowserToolUseBlock(middleClick = middleClick) + + @JvmStatic + fun ofDoubleClick(doubleClick: BrowserDoubleClickToolUseBlock) = + BrowserToolUseBlock(doubleClick = doubleClick) + + @JvmStatic + fun ofTripleClick(tripleClick: BrowserTripleClickToolUseBlock) = + BrowserToolUseBlock(tripleClick = tripleClick) + + @JvmStatic fun ofHover(hover: BrowserHoverToolUseBlock) = BrowserToolUseBlock(hover = hover) + + @JvmStatic + fun ofLeftClickDrag(leftClickDrag: BrowserLeftClickDragToolUseBlock) = + BrowserToolUseBlock(leftClickDrag = leftClickDrag) + + @JvmStatic + fun ofLeftMouseDown(leftMouseDown: BrowserLeftMouseDownToolUseBlock) = + BrowserToolUseBlock(leftMouseDown = leftMouseDown) + + @JvmStatic + fun ofLeftMouseUp(leftMouseUp: BrowserLeftMouseUpToolUseBlock) = + BrowserToolUseBlock(leftMouseUp = leftMouseUp) + + @JvmStatic + fun ofMouseMove(mouseMove: BrowserMouseMoveToolUseBlock) = + BrowserToolUseBlock(mouseMove = mouseMove) + + @JvmStatic + fun ofScroll(scroll: BrowserScrollToolUseBlock) = BrowserToolUseBlock(scroll = scroll) + + @JvmStatic fun ofType(type: BrowserTypeToolUseBlock) = BrowserToolUseBlock(type = type) + + @JvmStatic fun ofKey(key: BrowserKeyToolUseBlock) = BrowserToolUseBlock(key = key) + + @JvmStatic + fun ofHoldKey(holdKey: BrowserHoldKeyToolUseBlock) = BrowserToolUseBlock(holdKey = holdKey) + + @JvmStatic fun ofWait(wait: BrowserWaitToolUseBlock) = BrowserToolUseBlock(wait = wait) + + @JvmStatic + fun ofJavascriptExec(javascriptExec: BrowserJavascriptExecToolUseBlock) = + BrowserToolUseBlock(javascriptExec = javascriptExec) + } + + /** + * An interface that defines how to map each variant of [BrowserToolUseBlock] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNavigate(navigate: BrowserNavigateToolUseBlock): T + + fun visitListTabs(listTabs: BrowserListTabsToolUseBlock): T + + fun visitNewTab(newTab: BrowserNewTabToolUseBlock): T + + fun visitSwitchTab(switchTab: BrowserSwitchTabToolUseBlock): T + + fun visitCloseTab(closeTab: BrowserCloseTabToolUseBlock): T + + fun visitReadPage(readPage: BrowserReadPageToolUseBlock): T + + fun visitGetPageText(getPageText: BrowserGetPageTextToolUseBlock): T + + fun visitReadConsole(readConsole: BrowserReadConsoleToolUseBlock): T + + fun visitReadNetwork(readNetwork: BrowserReadNetworkToolUseBlock): T + + fun visitFind(find: BrowserFindToolUseBlock): T + + fun visitFormInput(formInput: BrowserFormInputToolUseBlock): T + + fun visitFileUpload(fileUpload: BrowserFileUploadToolUseBlock): T + + fun visitScrollTo(scrollTo: BrowserScrollToToolUseBlock): T + + fun visitScreenshot(screenshot: BrowserScreenshotToolUseBlock): T + + fun visitZoom(zoom: BrowserZoomToolUseBlock): T + + fun visitLeftClick(leftClick: BrowserLeftClickToolUseBlock): T + + fun visitRightClick(rightClick: BrowserRightClickToolUseBlock): T + + fun visitMiddleClick(middleClick: BrowserMiddleClickToolUseBlock): T + + fun visitDoubleClick(doubleClick: BrowserDoubleClickToolUseBlock): T + + fun visitTripleClick(tripleClick: BrowserTripleClickToolUseBlock): T + + fun visitHover(hover: BrowserHoverToolUseBlock): T + + fun visitLeftClickDrag(leftClickDrag: BrowserLeftClickDragToolUseBlock): T + + fun visitLeftMouseDown(leftMouseDown: BrowserLeftMouseDownToolUseBlock): T + + fun visitLeftMouseUp(leftMouseUp: BrowserLeftMouseUpToolUseBlock): T + + fun visitMouseMove(mouseMove: BrowserMouseMoveToolUseBlock): T + + fun visitScroll(scroll: BrowserScrollToolUseBlock): T + + fun visitType(type: BrowserTypeToolUseBlock): T + + fun visitKey(key: BrowserKeyToolUseBlock): T + + fun visitHoldKey(holdKey: BrowserHoldKeyToolUseBlock): T + + fun visitWait(wait: BrowserWaitToolUseBlock): T + + fun visitJavascriptExec(javascriptExec: BrowserJavascriptExecToolUseBlock): T + + /** + * Maps an unknown variant of [BrowserToolUseBlock] to a value of type [T]. + * + * An instance of [BrowserToolUseBlock] 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 BrowserToolUseBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(BrowserToolUseBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BrowserToolUseBlock { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "navigate" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(navigate = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "list_tabs" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(listTabs = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "new_tab" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(newTab = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "switch_tab" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(switchTab = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "close_tab" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(closeTab = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "read_page" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(readPage = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "get_page_text" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(getPageText = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "read_console" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(readConsole = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "read_network" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(readNetwork = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "find" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(find = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "form_input" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(formInput = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "file_upload" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(fileUpload = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "scroll_to" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(scrollTo = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "screenshot" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(screenshot = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "zoom" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(zoom = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "left_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(leftClick = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "right_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(rightClick = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "middle_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(middleClick = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "double_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(doubleClick = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "triple_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(tripleClick = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "hover" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(hover = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "left_click_drag" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(leftClickDrag = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "left_mouse_down" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(leftMouseDown = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "left_mouse_up" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(leftMouseUp = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "mouse_move" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(mouseMove = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + "scroll" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(scroll = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "type" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(type = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "key" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(key = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "hold_key" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(holdKey = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "wait" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + BrowserToolUseBlock(wait = it, _json = json) + } ?: BrowserToolUseBlock(_json = json) + } + "javascript_exec" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { BrowserToolUseBlock(javascriptExec = it, _json = json) } + ?: BrowserToolUseBlock(_json = json) + } + } + + return BrowserToolUseBlock(_json = json) + } + } + + internal class Serializer : BaseSerializer(BrowserToolUseBlock::class) { + + override fun serialize( + value: BrowserToolUseBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.navigate != null -> generator.writeObject(value.navigate) + value.listTabs != null -> generator.writeObject(value.listTabs) + value.newTab != null -> generator.writeObject(value.newTab) + value.switchTab != null -> generator.writeObject(value.switchTab) + value.closeTab != null -> generator.writeObject(value.closeTab) + value.readPage != null -> generator.writeObject(value.readPage) + value.getPageText != null -> generator.writeObject(value.getPageText) + value.readConsole != null -> generator.writeObject(value.readConsole) + value.readNetwork != null -> generator.writeObject(value.readNetwork) + value.find != null -> generator.writeObject(value.find) + value.formInput != null -> generator.writeObject(value.formInput) + value.fileUpload != null -> generator.writeObject(value.fileUpload) + value.scrollTo != null -> generator.writeObject(value.scrollTo) + value.screenshot != null -> generator.writeObject(value.screenshot) + value.zoom != null -> generator.writeObject(value.zoom) + value.leftClick != null -> generator.writeObject(value.leftClick) + value.rightClick != null -> generator.writeObject(value.rightClick) + value.middleClick != null -> generator.writeObject(value.middleClick) + value.doubleClick != null -> generator.writeObject(value.doubleClick) + value.tripleClick != null -> generator.writeObject(value.tripleClick) + value.hover != null -> generator.writeObject(value.hover) + value.leftClickDrag != null -> generator.writeObject(value.leftClickDrag) + value.leftMouseDown != null -> generator.writeObject(value.leftMouseDown) + value.leftMouseUp != null -> generator.writeObject(value.leftMouseUp) + value.mouseMove != null -> generator.writeObject(value.mouseMove) + value.scroll != null -> generator.writeObject(value.scroll) + value.type != null -> generator.writeObject(value.type) + value.key != null -> generator.writeObject(value.key) + value.holdKey != null -> generator.writeObject(value.holdKey) + value.wait != null -> generator.writeObject(value.wait) + value.javascriptExec != null -> generator.writeObject(value.javascriptExec) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BrowserToolUseBlock") + } + } + } + + class Name 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 NAVIGATE = Name(JsonField.of("navigate")) + + @JvmField val LIST_TABS = Name(JsonField.of("list_tabs")) + + @JvmField val NEW_TAB = Name(JsonField.of("new_tab")) + + @JvmField val SWITCH_TAB = Name(JsonField.of("switch_tab")) + + @JvmField val CLOSE_TAB = Name(JsonField.of("close_tab")) + + @JvmField val READ_PAGE = Name(JsonField.of("read_page")) + + @JvmField val GET_PAGE_TEXT = Name(JsonField.of("get_page_text")) + + @JvmField val READ_CONSOLE = Name(JsonField.of("read_console")) + + @JvmField val READ_NETWORK = Name(JsonField.of("read_network")) + + @JvmField val FIND = Name(JsonField.of("find")) + + @JvmField val FORM_INPUT = Name(JsonField.of("form_input")) + + @JvmField val FILE_UPLOAD = Name(JsonField.of("file_upload")) + + @JvmField val SCROLL_TO = Name(JsonField.of("scroll_to")) + + @JvmField val SCREENSHOT = Name(JsonField.of("screenshot")) + + @JvmField val ZOOM = Name(JsonField.of("zoom")) + + @JvmField val LEFT_CLICK = Name(JsonField.of("left_click")) + + @JvmField val RIGHT_CLICK = Name(JsonField.of("right_click")) + + @JvmField val MIDDLE_CLICK = Name(JsonField.of("middle_click")) + + @JvmField val DOUBLE_CLICK = Name(JsonField.of("double_click")) + + @JvmField val TRIPLE_CLICK = Name(JsonField.of("triple_click")) + + @JvmField val HOVER = Name(JsonField.of("hover")) + + @JvmField val LEFT_CLICK_DRAG = Name(JsonField.of("left_click_drag")) + + @JvmField val LEFT_MOUSE_DOWN = Name(JsonField.of("left_mouse_down")) + + @JvmField val LEFT_MOUSE_UP = Name(JsonField.of("left_mouse_up")) + + @JvmField val MOUSE_MOVE = Name(JsonField.of("mouse_move")) + + @JvmField val SCROLL = Name(JsonField.of("scroll")) + + @JvmField val TYPE = Name(JsonField.of("type")) + + @JvmField val KEY = Name(JsonField.of("key")) + + @JvmField val HOLD_KEY = Name(JsonField.of("hold_key")) + + @JvmField val WAIT = Name(JsonField.of("wait")) + + @JvmField val JAVASCRIPT_EXEC = Name(JsonField.of("javascript_exec")) + + @JvmStatic + fun of(value: String): Name = + // Intern known values so `==` works + when (value) { + "navigate" -> NAVIGATE + "list_tabs" -> LIST_TABS + "new_tab" -> NEW_TAB + "switch_tab" -> SWITCH_TAB + "close_tab" -> CLOSE_TAB + "read_page" -> READ_PAGE + "get_page_text" -> GET_PAGE_TEXT + "read_console" -> READ_CONSOLE + "read_network" -> READ_NETWORK + "find" -> FIND + "form_input" -> FORM_INPUT + "file_upload" -> FILE_UPLOAD + "scroll_to" -> SCROLL_TO + "screenshot" -> SCREENSHOT + "zoom" -> ZOOM + "left_click" -> LEFT_CLICK + "right_click" -> RIGHT_CLICK + "middle_click" -> MIDDLE_CLICK + "double_click" -> DOUBLE_CLICK + "triple_click" -> TRIPLE_CLICK + "hover" -> HOVER + "left_click_drag" -> LEFT_CLICK_DRAG + "left_mouse_down" -> LEFT_MOUSE_DOWN + "left_mouse_up" -> LEFT_MOUSE_UP + "mouse_move" -> MOUSE_MOVE + "scroll" -> SCROLL + "type" -> TYPE + "key" -> KEY + "hold_key" -> HOLD_KEY + "wait" -> WAIT + "javascript_exec" -> JAVASCRIPT_EXEC + else -> Name(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Name = + value.asString().getOrNull()?.let { of(it) } ?: Name(value) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + NAVIGATE, + LIST_TABS, + NEW_TAB, + SWITCH_TAB, + CLOSE_TAB, + READ_PAGE, + GET_PAGE_TEXT, + READ_CONSOLE, + READ_NETWORK, + FIND, + FORM_INPUT, + FILE_UPLOAD, + SCROLL_TO, + SCREENSHOT, + ZOOM, + LEFT_CLICK, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + HOVER, + LEFT_CLICK_DRAG, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + MOUSE_MOVE, + SCROLL, + TYPE, + KEY, + HOLD_KEY, + WAIT, + JAVASCRIPT_EXEC, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] 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 { + NAVIGATE, + LIST_TABS, + NEW_TAB, + SWITCH_TAB, + CLOSE_TAB, + READ_PAGE, + GET_PAGE_TEXT, + READ_CONSOLE, + READ_NETWORK, + FIND, + FORM_INPUT, + FILE_UPLOAD, + SCROLL_TO, + SCREENSHOT, + ZOOM, + LEFT_CLICK, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + HOVER, + LEFT_CLICK_DRAG, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + MOUSE_MOVE, + SCROLL, + TYPE, + KEY, + HOLD_KEY, + WAIT, + JAVASCRIPT_EXEC, + /** An enum member indicating that [Name] 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) { + NAVIGATE -> Value.NAVIGATE + LIST_TABS -> Value.LIST_TABS + NEW_TAB -> Value.NEW_TAB + SWITCH_TAB -> Value.SWITCH_TAB + CLOSE_TAB -> Value.CLOSE_TAB + READ_PAGE -> Value.READ_PAGE + GET_PAGE_TEXT -> Value.GET_PAGE_TEXT + READ_CONSOLE -> Value.READ_CONSOLE + READ_NETWORK -> Value.READ_NETWORK + FIND -> Value.FIND + FORM_INPUT -> Value.FORM_INPUT + FILE_UPLOAD -> Value.FILE_UPLOAD + SCROLL_TO -> Value.SCROLL_TO + SCREENSHOT -> Value.SCREENSHOT + ZOOM -> Value.ZOOM + LEFT_CLICK -> Value.LEFT_CLICK + RIGHT_CLICK -> Value.RIGHT_CLICK + MIDDLE_CLICK -> Value.MIDDLE_CLICK + DOUBLE_CLICK -> Value.DOUBLE_CLICK + TRIPLE_CLICK -> Value.TRIPLE_CLICK + HOVER -> Value.HOVER + LEFT_CLICK_DRAG -> Value.LEFT_CLICK_DRAG + LEFT_MOUSE_DOWN -> Value.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Value.LEFT_MOUSE_UP + MOUSE_MOVE -> Value.MOUSE_MOVE + SCROLL -> Value.SCROLL + TYPE -> Value.TYPE + KEY -> Value.KEY + HOLD_KEY -> Value.HOLD_KEY + WAIT -> Value.WAIT + JAVASCRIPT_EXEC -> Value.JAVASCRIPT_EXEC + 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) { + NAVIGATE -> Known.NAVIGATE + LIST_TABS -> Known.LIST_TABS + NEW_TAB -> Known.NEW_TAB + SWITCH_TAB -> Known.SWITCH_TAB + CLOSE_TAB -> Known.CLOSE_TAB + READ_PAGE -> Known.READ_PAGE + GET_PAGE_TEXT -> Known.GET_PAGE_TEXT + READ_CONSOLE -> Known.READ_CONSOLE + READ_NETWORK -> Known.READ_NETWORK + FIND -> Known.FIND + FORM_INPUT -> Known.FORM_INPUT + FILE_UPLOAD -> Known.FILE_UPLOAD + SCROLL_TO -> Known.SCROLL_TO + SCREENSHOT -> Known.SCREENSHOT + ZOOM -> Known.ZOOM + LEFT_CLICK -> Known.LEFT_CLICK + RIGHT_CLICK -> Known.RIGHT_CLICK + MIDDLE_CLICK -> Known.MIDDLE_CLICK + DOUBLE_CLICK -> Known.DOUBLE_CLICK + TRIPLE_CLICK -> Known.TRIPLE_CLICK + HOVER -> Known.HOVER + LEFT_CLICK_DRAG -> Known.LEFT_CLICK_DRAG + LEFT_MOUSE_DOWN -> Known.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Known.LEFT_MOUSE_UP + MOUSE_MOVE -> Known.MOUSE_MOVE + SCROLL -> Known.SCROLL + TYPE -> Known.TYPE + KEY -> Known.KEY + HOLD_KEY -> Known.HOLD_KEY + WAIT -> Known.WAIT + JAVASCRIPT_EXEC -> Known.JAVASCRIPT_EXEC + else -> throw AnthropicInvalidDataException("Unknown Name: $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(): Name = 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 Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTripleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTripleClickInput.kt new file mode 100644 index 000000000..e764c934a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTripleClickInput.kt @@ -0,0 +1,294 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triple left-click at a viewport coordinate or on an element by reference (typically selects a + * line or paragraph). + */ +class BrowserTripleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val target: JsonField, + private val modifiers: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("modifiers") @ExcludeMissing modifiers: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(target, modifiers, tabId, mutableMapOf()) + + /** + * Where to act: either a viewport coordinate or an element reference. + * + * @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 target(): BrowserClickTarget = target.getRequired("target") + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun modifiers(): Optional = modifiers.getOptional("modifiers") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("target") @ExcludeMissing fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [modifiers]. + * + * Unlike [modifiers], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("modifiers") @ExcludeMissing fun _modifiers(): JsonField = modifiers + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserTripleClickInput]. + * + * The following fields are required: + * ```java + * .target() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserTripleClickInput] with the required [target] set + * to the given value. + */ + @JvmStatic fun of(target: BrowserClickTarget) = builder().target(target).build() + } + + /** A builder for [BrowserTripleClickInput]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var modifiers: JsonField = JsonMissing.of() + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserTripleClickInput: BrowserTripleClickInput) = apply { + target = browserTripleClickInput.target + modifiers = browserTripleClickInput.modifiers + tabId = browserTripleClickInput.tabId + additionalProperties = browserTripleClickInput.additionalProperties.toMutableMap() + } + + /** Where to act: either a viewport coordinate or an element reference. */ + fun target(target: BrowserClickTarget) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [BrowserClickTarget] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Alias for calling [target] with `BrowserClickTarget.ofCoordinate(coordinate)`. */ + fun target(coordinate: BrowserCoordinateTarget) = + target(BrowserClickTarget.ofCoordinate(coordinate)) + + /** Alias for calling [target] with `BrowserClickTarget.ofRef(ref)`. */ + fun target(ref: BrowserRefTarget) = target(BrowserClickTarget.ofRef(ref)) + + /** + * Alias for calling [target] with the following: + * ```java + * BrowserRefTarget.builder() + * .ref(ref) + * .build() + * ``` + */ + fun refTarget(ref: String) = target(BrowserRefTarget.builder().ref(ref).build()) + + /** + * Optional modifier key chord to hold for the duration of this action (e.g. "shift", + * "ctrl+shift", "cmd+alt"). + */ + fun modifiers(modifiers: String?) = modifiers(JsonField.ofNullable(modifiers)) + + /** Alias for calling [Builder.modifiers] with `modifiers.orElse(null)`. */ + fun modifiers(modifiers: Optional) = modifiers(modifiers.getOrNull()) + + /** + * Sets [Builder.modifiers] to an arbitrary JSON value. + * + * You should usually call [Builder.modifiers] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun modifiers(modifiers: JsonField) = apply { this.modifiers = modifiers } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserTripleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .target() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserTripleClickInput = + BrowserTripleClickInput( + checkRequired("target", target), + modifiers, + tabId, + 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(): BrowserTripleClickInput = apply { + if (validated) { + return@apply + } + + target().validate() + modifiers() + tabId() + 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 = + (target.asKnown().getOrNull()?.validity() ?: 0) + + (if (modifiers.asKnown().isPresent) 1 else 0) + + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserTripleClickInput && + target == other.target && + modifiers == other.modifiers && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(target, modifiers, tabId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserTripleClickInput{target=$target, modifiers=$modifiers, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTripleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTripleClickToolUseBlock.kt new file mode 100644 index 000000000..2b918ffa5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTripleClickToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.messages + +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 + +class BrowserTripleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Triple left-click at a viewport coordinate or on an element by reference (typically selects a + * line or paragraph). + * + * @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 input(): BrowserTripleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [BrowserTripleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserTripleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("triple_click") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserTripleClickToolUseBlock: BrowserTripleClickToolUseBlock) = apply { + id = browserTripleClickToolUseBlock.id + caller = browserTripleClickToolUseBlock.caller + input = browserTripleClickToolUseBlock.input + name = browserTripleClickToolUseBlock.name + toolsetName = browserTripleClickToolUseBlock.toolsetName + type = browserTripleClickToolUseBlock.type + additionalProperties = + browserTripleClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Triple left-click at a viewport coordinate or on an element by reference (typically + * selects a line or paragraph). + */ + fun input(input: BrowserTripleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserTripleClickInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserTripleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserTripleClickToolUseBlock = + BrowserTripleClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserTripleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("triple_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("triple_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserTripleClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserTripleClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTypeInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTypeInput.kt new file mode 100644 index 000000000..2948dcfbb --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTypeInput.kt @@ -0,0 +1,226 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Type a literal string at the current focus. */ +class BrowserTypeInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(text, tabId, mutableMapOf()) + + /** + * The text to 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 text(): String = text.getRequired("text") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserTypeInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserTypeInput] with the required [text] set to the + * given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [BrowserTypeInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserTypeInput: BrowserTypeInput) = apply { + text = browserTypeInput.text + tabId = browserTypeInput.tabId + additionalProperties = browserTypeInput.additionalProperties.toMutableMap() + } + + /** The text to type. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserTypeInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserTypeInput = + BrowserTypeInput( + checkRequired("text", text), + tabId, + 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(): BrowserTypeInput = apply { + if (validated) { + return@apply + } + + text() + tabId() + 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 (text.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserTypeInput && + text == other.text && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserTypeInput{text=$text, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTypeToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTypeToolUseBlock.kt new file mode 100644 index 000000000..2daefd66a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserTypeToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserTypeToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Type a literal string at the current focus. + * + * @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 input(): BrowserTypeInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("type") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserTypeToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserTypeToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("type") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserTypeToolUseBlock: BrowserTypeToolUseBlock) = apply { + id = browserTypeToolUseBlock.id + caller = browserTypeToolUseBlock.caller + input = browserTypeToolUseBlock.input + name = browserTypeToolUseBlock.name + toolsetName = browserTypeToolUseBlock.toolsetName + type = browserTypeToolUseBlock.type + additionalProperties = browserTypeToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Type a literal string at the current focus. */ + fun input(input: BrowserTypeInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserTypeInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("type") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserTypeToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserTypeToolUseBlock = + BrowserTypeToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserTypeToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("type")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("type")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserTypeToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserTypeToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserWaitInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserWaitInput.kt new file mode 100644 index 000000000..3843ed8dc --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserWaitInput.kt @@ -0,0 +1,226 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Pause for the given duration. */ +class BrowserWaitInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(duration, tabId, mutableMapOf()) + + /** + * Seconds to wait (maximum 30). + * + * @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 duration(): Double = duration.getRequired("duration") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserWaitInput]. + * + * The following fields are required: + * ```java + * .duration() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserWaitInput] with the required [duration] set to + * the given value. + */ + @JvmStatic fun of(duration: Double) = builder().duration(duration).build() + } + + /** A builder for [BrowserWaitInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserWaitInput: BrowserWaitInput) = apply { + duration = browserWaitInput.duration + tabId = browserWaitInput.tabId + additionalProperties = browserWaitInput.additionalProperties.toMutableMap() + } + + /** Seconds to wait (maximum 30). */ + fun duration(duration: Double) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserWaitInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserWaitInput = + BrowserWaitInput( + checkRequired("duration", duration), + tabId, + 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(): BrowserWaitInput = apply { + if (validated) { + return@apply + } + + duration() + tabId() + 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 (duration.asKnown().isPresent) 1 else 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserWaitInput && + duration == other.duration && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserWaitInput{duration=$duration, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserWaitToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserWaitToolUseBlock.kt new file mode 100644 index 000000000..15dab2c76 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserWaitToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class BrowserWaitToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Pause for the given duration. + * + * @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 input(): BrowserWaitInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("wait") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserWaitToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserWaitToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("wait") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserWaitToolUseBlock: BrowserWaitToolUseBlock) = apply { + id = browserWaitToolUseBlock.id + caller = browserWaitToolUseBlock.caller + input = browserWaitToolUseBlock.input + name = browserWaitToolUseBlock.name + toolsetName = browserWaitToolUseBlock.toolsetName + type = browserWaitToolUseBlock.type + additionalProperties = browserWaitToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Pause for the given duration. */ + fun input(input: BrowserWaitInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserWaitInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("wait") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserWaitToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserWaitToolUseBlock = + BrowserWaitToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserWaitToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("wait")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("wait")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserWaitToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserWaitToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserZoomInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserZoomInput.kt new file mode 100644 index 000000000..3a6375875 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserZoomInput.kt @@ -0,0 +1,248 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Return a cropped screenshot of the given viewport region, scaled up for closer inspection — + * useful for small icons, buttons, or text. Coordinates are in the same viewport-pixel space as a + * full screenshot. + */ +class BrowserZoomInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val region: JsonField>, + private val tabId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("region") @ExcludeMissing region: JsonField> = JsonMissing.of(), + @JsonProperty("tab_id") @ExcludeMissing tabId: JsonField = JsonMissing.of(), + ) : this(region, tabId, mutableMapOf()) + + /** + * [x0, y0, x1, y1] in viewport pixels. + * + * @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 region(): List = region.getRequired("region") + + /** + * Tab to act on. Defaults to the active tab when omitted. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tabId(): Optional = tabId.getOptional("tab_id") + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField> = region + + /** + * Returns the raw JSON value of [tabId]. + * + * Unlike [tabId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tab_id") @ExcludeMissing fun _tabId(): JsonField = tabId + + @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 [BrowserZoomInput]. + * + * The following fields are required: + * ```java + * .region() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [BrowserZoomInput] with the required [region] set to the + * given value. + */ + @JvmStatic fun of(region: List) = builder().region(region).build() + } + + /** A builder for [BrowserZoomInput]. */ + class Builder internal constructor() { + + private var region: JsonField>? = null + private var tabId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserZoomInput: BrowserZoomInput) = apply { + region = + browserZoomInput.region.map { it.toMutableList() }.takeUnless { it.isMissing() } + tabId = browserZoomInput.tabId + additionalProperties = browserZoomInput.additionalProperties.toMutableMap() + } + + /** [x0, y0, x1, y1] in viewport pixels. */ + fun region(region: List) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun region(region: JsonField>) = apply { + this.region = region.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.region]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegion(region: Long) = apply { + this.region = + (this.region ?: JsonField.of(mutableListOf())).also { + checkKnown("region", it).add(region) + } + } + + /** Tab to act on. Defaults to the active tab when omitted. */ + fun tabId(tabId: String?) = tabId(JsonField.ofNullable(tabId)) + + /** Alias for calling [Builder.tabId] with `tabId.orElse(null)`. */ + fun tabId(tabId: Optional) = tabId(tabId.getOrNull()) + + /** + * Sets [Builder.tabId] to an arbitrary JSON value. + * + * You should usually call [Builder.tabId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tabId(tabId: JsonField) = apply { this.tabId = tabId } + + 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 [BrowserZoomInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .region() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserZoomInput = + BrowserZoomInput( + checkRequired("region", region).map { it.toImmutable() }, + tabId, + 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(): BrowserZoomInput = apply { + if (validated) { + return@apply + } + + region() + tabId() + 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 = + (region.asKnown().getOrNull()?.size ?: 0) + (if (tabId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserZoomInput && + region == other.region && + tabId == other.tabId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(region, tabId, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserZoomInput{region=$region, tabId=$tabId, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserZoomToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserZoomToolUseBlock.kt new file mode 100644 index 000000000..832e97daa --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/BrowserZoomToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.messages + +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 + +class BrowserZoomToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Return a cropped screenshot of the given viewport region, scaled up for closer inspection — + * useful for small icons, buttons, or text. Coordinates are in the same viewport-pixel space as + * a full screenshot. + * + * @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 input(): BrowserZoomInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("browser") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [BrowserZoomToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrowserZoomToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("zoom") + private var toolsetName: JsonValue = JsonValue.from("browser") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(browserZoomToolUseBlock: BrowserZoomToolUseBlock) = apply { + id = browserZoomToolUseBlock.id + caller = browserZoomToolUseBlock.caller + input = browserZoomToolUseBlock.input + name = browserZoomToolUseBlock.name + toolsetName = browserZoomToolUseBlock.toolsetName + type = browserZoomToolUseBlock.type + additionalProperties = browserZoomToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Return a cropped screenshot of the given viewport region, scaled up for closer inspection + * — useful for small icons, buttons, or text. Coordinates are in the same viewport-pixel + * space as a full screenshot. + */ + fun input(input: BrowserZoomInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [BrowserZoomInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("browser") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [BrowserZoomToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BrowserZoomToolUseBlock = + BrowserZoomToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): BrowserZoomToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("zoom")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("browser")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("zoom")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("browser")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrowserZoomToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrowserZoomToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerCursorPositionInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerCursorPositionInput.kt new file mode 100644 index 000000000..972ea5b24 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerCursorPositionInput.kt @@ -0,0 +1,125 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Get the current (x, y) pixel coordinate of the cursor. */ +class ComputerCursorPositionInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [ComputerCursorPositionInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerCursorPositionInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerCursorPositionInput: ComputerCursorPositionInput) = apply { + additionalProperties = computerCursorPositionInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComputerCursorPositionInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerCursorPositionInput = + ComputerCursorPositionInput(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(): ComputerCursorPositionInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerCursorPositionInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerCursorPositionInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerCursorPositionToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerCursorPositionToolUseBlock.kt new file mode 100644 index 000000000..a58c0b11b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerCursorPositionToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +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 + +class ComputerCursorPositionToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Get the current (x, y) pixel coordinate of the cursor. + * + * @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 input(): ComputerCursorPositionInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("cursor_position") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + @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 + * [ComputerCursorPositionToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerCursorPositionToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("cursor_position") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerCursorPositionToolUseBlock: ComputerCursorPositionToolUseBlock) = + apply { + id = computerCursorPositionToolUseBlock.id + caller = computerCursorPositionToolUseBlock.caller + input = computerCursorPositionToolUseBlock.input + name = computerCursorPositionToolUseBlock.name + toolsetName = computerCursorPositionToolUseBlock.toolsetName + type = computerCursorPositionToolUseBlock.type + additionalProperties = + computerCursorPositionToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Get the current (x, y) pixel coordinate of the cursor. */ + fun input(input: ComputerCursorPositionInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerCursorPositionInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("cursor_position") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerCursorPositionToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerCursorPositionToolUseBlock = + ComputerCursorPositionToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerCursorPositionToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("cursor_position")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("cursor_position")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerCursorPositionToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerCursorPositionToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerDoubleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerDoubleClickInput.kt new file mode 100644 index 000000000..13a93c531 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerDoubleClickInput.kt @@ -0,0 +1,239 @@ +package com.anthropic.models.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Double-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ +class ComputerDoubleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerDoubleClickInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerDoubleClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerDoubleClickInput: ComputerDoubleClickInput) = apply { + coordinate = + computerDoubleClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = computerDoubleClickInput.text + additionalProperties = computerDoubleClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerDoubleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerDoubleClickInput = + ComputerDoubleClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): ComputerDoubleClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerDoubleClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerDoubleClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerDoubleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerDoubleClickToolUseBlock.kt new file mode 100644 index 000000000..75abeec7c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerDoubleClickToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.messages + +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 + +class ComputerDoubleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Double-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + * + * @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 input(): ComputerDoubleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerDoubleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerDoubleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("double_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerDoubleClickToolUseBlock: ComputerDoubleClickToolUseBlock) = + apply { + id = computerDoubleClickToolUseBlock.id + caller = computerDoubleClickToolUseBlock.caller + input = computerDoubleClickToolUseBlock.input + name = computerDoubleClickToolUseBlock.name + toolsetName = computerDoubleClickToolUseBlock.toolsetName + type = computerDoubleClickToolUseBlock.type + additionalProperties = + computerDoubleClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Double-click the left mouse button at the specified (x, y) pixel coordinate, or the + * current cursor position if `coordinate` is omitted. + */ + fun input(input: ComputerDoubleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerDoubleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("double_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerDoubleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerDoubleClickToolUseBlock = + ComputerDoubleClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerDoubleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("double_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("double_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerDoubleClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerDoubleClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerHoldKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerHoldKeyInput.kt new file mode 100644 index 000000000..98ccff7cd --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerHoldKeyInput.kt @@ -0,0 +1,219 @@ +package com.anthropic.models.messages + +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 + +/** + * Hold down a key or key-combination for a specified duration. Uses the same key syntax as `key`. + */ +class ComputerHoldKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(duration, text, mutableMapOf()) + + /** + * Duration to hold the key, in seconds. + * + * @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 duration(): Long = duration.getRequired("duration") + + /** + * The key or key-combination to hold. + * + * @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 text(): String = text.getRequired("text") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerHoldKeyInput]. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerHoldKeyInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var text: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerHoldKeyInput: ComputerHoldKeyInput) = apply { + duration = computerHoldKeyInput.duration + text = computerHoldKeyInput.text + additionalProperties = computerHoldKeyInput.additionalProperties.toMutableMap() + } + + /** Duration to hold the key, in seconds. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The key or key-combination to hold. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerHoldKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerHoldKeyInput = + ComputerHoldKeyInput( + checkRequired("duration", duration), + checkRequired("text", text), + 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(): ComputerHoldKeyInput = apply { + if (validated) { + return@apply + } + + duration() + text() + 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 (duration.asKnown().isPresent) 1 else 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerHoldKeyInput && + duration == other.duration && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerHoldKeyInput{duration=$duration, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerHoldKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerHoldKeyToolUseBlock.kt new file mode 100644 index 000000000..6905e1e54 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerHoldKeyToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class ComputerHoldKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Hold down a key or key-combination for a specified duration. Uses the same key syntax as + * `key`. + * + * @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 input(): ComputerHoldKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [ComputerHoldKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerHoldKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("hold_key") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerHoldKeyToolUseBlock: ComputerHoldKeyToolUseBlock) = apply { + id = computerHoldKeyToolUseBlock.id + caller = computerHoldKeyToolUseBlock.caller + input = computerHoldKeyToolUseBlock.input + name = computerHoldKeyToolUseBlock.name + toolsetName = computerHoldKeyToolUseBlock.toolsetName + type = computerHoldKeyToolUseBlock.type + additionalProperties = computerHoldKeyToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Hold down a key or key-combination for a specified duration. Uses the same key syntax as + * `key`. + */ + fun input(input: ComputerHoldKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerHoldKeyInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("hold_key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerHoldKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerHoldKeyToolUseBlock = + ComputerHoldKeyToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerHoldKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("hold_key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("hold_key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerHoldKeyToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerHoldKeyToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerKeyInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerKeyInput.kt new file mode 100644 index 000000000..594077760 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerKeyInput.kt @@ -0,0 +1,238 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Press a key or key-combination on the keyboard. Use "+" to combine modifiers with a key (e.g. + * "ctrl+s", "alt+Tab", "ctrl+shift+Escape"). Key names are case-insensitive; common names like + * "Return", "Tab", "Escape", "Up", "Down", "Left", "Right", "Home", "End", "Page_Up", "Page_Down", + * "Delete", "BackSpace" are supported. + */ +class ComputerKeyInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val repeat: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + @JsonProperty("repeat") @ExcludeMissing repeat: JsonField = JsonMissing.of(), + ) : this(text, repeat, mutableMapOf()) + + /** + * The key or key-combination to press. + * + * @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 text(): String = text.getRequired("text") + + /** + * Number of times to repeat the key press. Default is 1. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun repeat(): Optional = repeat.getOptional("repeat") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + /** + * Returns the raw JSON value of [repeat]. + * + * Unlike [repeat], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("repeat") @ExcludeMissing fun _repeat(): JsonField = repeat + + @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 [ComputerKeyInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [ComputerKeyInput] with the required [text] set to the + * given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [ComputerKeyInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var repeat: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerKeyInput: ComputerKeyInput) = apply { + text = computerKeyInput.text + repeat = computerKeyInput.repeat + additionalProperties = computerKeyInput.additionalProperties.toMutableMap() + } + + /** The key or key-combination to press. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + /** Number of times to repeat the key press. Default is 1. */ + fun repeat(repeat: Long?) = repeat(JsonField.ofNullable(repeat)) + + /** + * Alias for [Builder.repeat]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun repeat(repeat: Long) = repeat(repeat as Long?) + + /** Alias for calling [Builder.repeat] with `repeat.orElse(null)`. */ + fun repeat(repeat: Optional) = repeat(repeat.getOrNull()) + + /** + * Sets [Builder.repeat] to an arbitrary JSON value. + * + * You should usually call [Builder.repeat] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun repeat(repeat: JsonField) = apply { this.repeat = repeat } + + 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 [ComputerKeyInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerKeyInput = + ComputerKeyInput( + checkRequired("text", text), + repeat, + 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(): ComputerKeyInput = apply { + if (validated) { + return@apply + } + + text() + repeat() + 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 (text.asKnown().isPresent) 1 else 0) + (if (repeat.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerKeyInput && + text == other.text && + repeat == other.repeat && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, repeat, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerKeyInput{text=$text, repeat=$repeat, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerKeyToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerKeyToolUseBlock.kt new file mode 100644 index 000000000..65cbf0ad2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerKeyToolUseBlock.kt @@ -0,0 +1,417 @@ +package com.anthropic.models.messages + +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 + +class ComputerKeyToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Press a key or key-combination on the keyboard. Use "+" to combine modifiers with a key (e.g. + * "ctrl+s", "alt+Tab", "ctrl+shift+Escape"). Key names are case-insensitive; common names like + * "Return", "Tab", "Escape", "Up", "Down", "Left", "Right", "Home", "End", "Page_Up", + * "Page_Down", "Delete", "BackSpace" are supported. + * + * @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 input(): ComputerKeyInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("key") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [ComputerKeyToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerKeyToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("key") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerKeyToolUseBlock: ComputerKeyToolUseBlock) = apply { + id = computerKeyToolUseBlock.id + caller = computerKeyToolUseBlock.caller + input = computerKeyToolUseBlock.input + name = computerKeyToolUseBlock.name + toolsetName = computerKeyToolUseBlock.toolsetName + type = computerKeyToolUseBlock.type + additionalProperties = computerKeyToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Press a key or key-combination on the keyboard. Use "+" to combine modifiers with a key + * (e.g. "ctrl+s", "alt+Tab", "ctrl+shift+Escape"). Key names are case-insensitive; common + * names like "Return", "Tab", "Escape", "Up", "Down", "Left", "Right", "Home", "End", + * "Page_Up", "Page_Down", "Delete", "BackSpace" are supported. + */ + fun input(input: ComputerKeyInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerKeyInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("key") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerKeyToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerKeyToolUseBlock = + ComputerKeyToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerKeyToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("key")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("key")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerKeyToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerKeyToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickDragInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickDragInput.kt new file mode 100644 index 000000000..ec769879d --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickDragInput.kt @@ -0,0 +1,310 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Click and drag the cursor from `start_coordinate` to `coordinate`. */ +class ComputerLeftClickDragInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val startCoordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("start_coordinate") + @ExcludeMissing + startCoordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, startCoordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @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 coordinate(): List = coordinate.getRequired("coordinate") + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @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 startCoordinate(): List = startCoordinate.getRequired("start_coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [startCoordinate]. + * + * Unlike [startCoordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_coordinate") + @ExcludeMissing + fun _startCoordinate(): JsonField> = startCoordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerLeftClickDragInput]. + * + * The following fields are required: + * ```java + * .coordinate() + * .startCoordinate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftClickDragInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var startCoordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftClickDragInput: ComputerLeftClickDragInput) = apply { + coordinate = + computerLeftClickDragInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + startCoordinate = + computerLeftClickDragInput.startCoordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = computerLeftClickDragInput.text + additionalProperties = computerLeftClickDragInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List) = coordinate(JsonField.of(coordinate)) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun startCoordinate(startCoordinate: List) = + startCoordinate(JsonField.of(startCoordinate)) + + /** + * Sets [Builder.startCoordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.startCoordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startCoordinate(startCoordinate: JsonField>) = apply { + this.startCoordinate = startCoordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.startCoordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addStartCoordinate(startCoordinate: Long) = apply { + this.startCoordinate = + (this.startCoordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("startCoordinate", it).add(startCoordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerLeftClickDragInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .coordinate() + * .startCoordinate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerLeftClickDragInput = + ComputerLeftClickDragInput( + checkRequired("coordinate", coordinate).map { it.toImmutable() }, + checkRequired("startCoordinate", startCoordinate).map { it.toImmutable() }, + text, + 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(): ComputerLeftClickDragInput = apply { + if (validated) { + return@apply + } + + coordinate() + startCoordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + + (startCoordinate.asKnown().getOrNull()?.size ?: 0) + + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftClickDragInput && + coordinate == other.coordinate && + startCoordinate == other.startCoordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(coordinate, startCoordinate, text, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerLeftClickDragInput{coordinate=$coordinate, startCoordinate=$startCoordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickDragToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickDragToolUseBlock.kt new file mode 100644 index 000000000..934b2f94b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickDragToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +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 + +class ComputerLeftClickDragToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Click and drag the cursor from `start_coordinate` to `coordinate`. + * + * @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 input(): ComputerLeftClickDragInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + @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 + * [ComputerLeftClickDragToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftClickDragToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click_drag") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftClickDragToolUseBlock: ComputerLeftClickDragToolUseBlock) = + apply { + id = computerLeftClickDragToolUseBlock.id + caller = computerLeftClickDragToolUseBlock.caller + input = computerLeftClickDragToolUseBlock.input + name = computerLeftClickDragToolUseBlock.name + toolsetName = computerLeftClickDragToolUseBlock.toolsetName + type = computerLeftClickDragToolUseBlock.type + additionalProperties = + computerLeftClickDragToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Click and drag the cursor from `start_coordinate` to `coordinate`. */ + fun input(input: ComputerLeftClickDragInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerLeftClickDragInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click_drag") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerLeftClickDragToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerLeftClickDragToolUseBlock = + ComputerLeftClickDragToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerLeftClickDragToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_click_drag")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click_drag")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftClickDragToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerLeftClickDragToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickInput.kt new file mode 100644 index 000000000..505b6bc75 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickInput.kt @@ -0,0 +1,239 @@ +package com.anthropic.models.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Click the left mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + */ +class ComputerLeftClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerLeftClickInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftClickInput: ComputerLeftClickInput) = apply { + coordinate = + computerLeftClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = computerLeftClickInput.text + additionalProperties = computerLeftClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerLeftClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerLeftClickInput = + ComputerLeftClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): ComputerLeftClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerLeftClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickToolUseBlock.kt new file mode 100644 index 000000000..f815212e5 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftClickToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +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 + +class ComputerLeftClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Click the left mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + * + * @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 input(): ComputerLeftClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerLeftClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftClickToolUseBlock: ComputerLeftClickToolUseBlock) = apply { + id = computerLeftClickToolUseBlock.id + caller = computerLeftClickToolUseBlock.caller + input = computerLeftClickToolUseBlock.input + name = computerLeftClickToolUseBlock.name + toolsetName = computerLeftClickToolUseBlock.toolsetName + type = computerLeftClickToolUseBlock.type + additionalProperties = computerLeftClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ + fun input(input: ComputerLeftClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerLeftClickInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerLeftClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerLeftClickToolUseBlock = + ComputerLeftClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerLeftClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerLeftClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownInput.kt new file mode 100644 index 000000000..19c2cc06a --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownInput.kt @@ -0,0 +1,125 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Press and hold the left mouse button at the current cursor position. */ +class ComputerLeftMouseDownInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [ComputerLeftMouseDownInput]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftMouseDownInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftMouseDownInput: ComputerLeftMouseDownInput) = apply { + additionalProperties = computerLeftMouseDownInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComputerLeftMouseDownInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerLeftMouseDownInput = + ComputerLeftMouseDownInput(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(): ComputerLeftMouseDownInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftMouseDownInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerLeftMouseDownInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownToolUseBlock.kt new file mode 100644 index 000000000..a25be5ead --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +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 + +class ComputerLeftMouseDownToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Press and hold the left mouse button at the current cursor position. + * + * @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 input(): ComputerLeftMouseDownInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") + @ExcludeMissing + fun _input(): JsonField = input + + @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 + * [ComputerLeftMouseDownToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftMouseDownToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_down") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftMouseDownToolUseBlock: ComputerLeftMouseDownToolUseBlock) = + apply { + id = computerLeftMouseDownToolUseBlock.id + caller = computerLeftMouseDownToolUseBlock.caller + input = computerLeftMouseDownToolUseBlock.input + name = computerLeftMouseDownToolUseBlock.name + toolsetName = computerLeftMouseDownToolUseBlock.toolsetName + type = computerLeftMouseDownToolUseBlock.type + additionalProperties = + computerLeftMouseDownToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Press and hold the left mouse button at the current cursor position. */ + fun input(input: ComputerLeftMouseDownInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerLeftMouseDownInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_down") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerLeftMouseDownToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerLeftMouseDownToolUseBlock = + ComputerLeftMouseDownToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerLeftMouseDownToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_down")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_down")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftMouseDownToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerLeftMouseDownToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpInput.kt new file mode 100644 index 000000000..ea0748a47 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpInput.kt @@ -0,0 +1,122 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Release the left mouse button. */ +class ComputerLeftMouseUpInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [ComputerLeftMouseUpInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftMouseUpInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftMouseUpInput: ComputerLeftMouseUpInput) = apply { + additionalProperties = computerLeftMouseUpInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComputerLeftMouseUpInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerLeftMouseUpInput = + ComputerLeftMouseUpInput(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(): ComputerLeftMouseUpInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftMouseUpInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ComputerLeftMouseUpInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpToolUseBlock.kt new file mode 100644 index 000000000..94564d7c1 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpToolUseBlock.kt @@ -0,0 +1,412 @@ +package com.anthropic.models.messages + +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 + +class ComputerLeftMouseUpToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Release the left mouse button. + * + * @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 input(): ComputerLeftMouseUpInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerLeftMouseUpToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerLeftMouseUpToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("left_mouse_up") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerLeftMouseUpToolUseBlock: ComputerLeftMouseUpToolUseBlock) = + apply { + id = computerLeftMouseUpToolUseBlock.id + caller = computerLeftMouseUpToolUseBlock.caller + input = computerLeftMouseUpToolUseBlock.input + name = computerLeftMouseUpToolUseBlock.name + toolsetName = computerLeftMouseUpToolUseBlock.toolsetName + type = computerLeftMouseUpToolUseBlock.type + additionalProperties = + computerLeftMouseUpToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Release the left mouse button. */ + fun input(input: ComputerLeftMouseUpInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerLeftMouseUpInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("left_mouse_up") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerLeftMouseUpToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerLeftMouseUpToolUseBlock = + ComputerLeftMouseUpToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerLeftMouseUpToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("left_mouse_up")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("left_mouse_up")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerLeftMouseUpToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerLeftMouseUpToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMiddleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMiddleClickInput.kt new file mode 100644 index 000000000..9a777b0a8 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMiddleClickInput.kt @@ -0,0 +1,239 @@ +package com.anthropic.models.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Click the middle mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + */ +class ComputerMiddleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerMiddleClickInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerMiddleClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerMiddleClickInput: ComputerMiddleClickInput) = apply { + coordinate = + computerMiddleClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = computerMiddleClickInput.text + additionalProperties = computerMiddleClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerMiddleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerMiddleClickInput = + ComputerMiddleClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): ComputerMiddleClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerMiddleClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerMiddleClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMiddleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMiddleClickToolUseBlock.kt new file mode 100644 index 000000000..a03f09618 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMiddleClickToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.messages + +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 + +class ComputerMiddleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Click the middle mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + * + * @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 input(): ComputerMiddleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerMiddleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerMiddleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("middle_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerMiddleClickToolUseBlock: ComputerMiddleClickToolUseBlock) = + apply { + id = computerMiddleClickToolUseBlock.id + caller = computerMiddleClickToolUseBlock.caller + input = computerMiddleClickToolUseBlock.input + name = computerMiddleClickToolUseBlock.name + toolsetName = computerMiddleClickToolUseBlock.toolsetName + type = computerMiddleClickToolUseBlock.type + additionalProperties = + computerMiddleClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Click the middle mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ + fun input(input: ComputerMiddleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerMiddleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("middle_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerMiddleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerMiddleClickToolUseBlock = + ComputerMiddleClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerMiddleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("middle_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("middle_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerMiddleClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerMiddleClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMouseMoveInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMouseMoveInput.kt new file mode 100644 index 000000000..34aae91f0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMouseMoveInput.kt @@ -0,0 +1,214 @@ +package com.anthropic.models.messages + +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 + +/** + * Move the cursor to a specified (x, y) pixel coordinate. Use this ONLY to hover without clicking; + * otherwise use a click action directly. + */ +class ComputerMouseMoveInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of() + ) : this(coordinate, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @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 coordinate(): List = coordinate.getRequired("coordinate") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + @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 [ComputerMouseMoveInput]. + * + * The following fields are required: + * ```java + * .coordinate() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [ComputerMouseMoveInput] with the required [coordinate] + * set to the given value. + */ + @JvmStatic fun of(coordinate: List) = builder().coordinate(coordinate).build() + } + + /** A builder for [ComputerMouseMoveInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerMouseMoveInput: ComputerMouseMoveInput) = apply { + coordinate = + computerMouseMoveInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + additionalProperties = computerMouseMoveInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List) = coordinate(JsonField.of(coordinate)) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + 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 [ComputerMouseMoveInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .coordinate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerMouseMoveInput = + ComputerMouseMoveInput( + checkRequired("coordinate", coordinate).map { it.toImmutable() }, + 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(): ComputerMouseMoveInput = apply { + if (validated) { + return@apply + } + + coordinate() + 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 = (coordinate.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerMouseMoveInput && + coordinate == other.coordinate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerMouseMoveInput{coordinate=$coordinate, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMouseMoveToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMouseMoveToolUseBlock.kt new file mode 100644 index 000000000..49d2ec1dd --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerMouseMoveToolUseBlock.kt @@ -0,0 +1,414 @@ +package com.anthropic.models.messages + +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 + +class ComputerMouseMoveToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Move the cursor to a specified (x, y) pixel coordinate. Use this ONLY to hover without + * clicking; otherwise use a click action directly. + * + * @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 input(): ComputerMouseMoveInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerMouseMoveToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerMouseMoveToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("mouse_move") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerMouseMoveToolUseBlock: ComputerMouseMoveToolUseBlock) = apply { + id = computerMouseMoveToolUseBlock.id + caller = computerMouseMoveToolUseBlock.caller + input = computerMouseMoveToolUseBlock.input + name = computerMouseMoveToolUseBlock.name + toolsetName = computerMouseMoveToolUseBlock.toolsetName + type = computerMouseMoveToolUseBlock.type + additionalProperties = computerMouseMoveToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Move the cursor to a specified (x, y) pixel coordinate. Use this ONLY to hover without + * clicking; otherwise use a click action directly. + */ + fun input(input: ComputerMouseMoveInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerMouseMoveInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("mouse_move") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerMouseMoveToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerMouseMoveToolUseBlock = + ComputerMouseMoveToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerMouseMoveToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("mouse_move")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("mouse_move")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerMouseMoveToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerMouseMoveToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerRightClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerRightClickInput.kt new file mode 100644 index 000000000..c704a0d7f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerRightClickInput.kt @@ -0,0 +1,239 @@ +package com.anthropic.models.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Click the right mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + */ +class ComputerRightClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerRightClickInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerRightClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerRightClickInput: ComputerRightClickInput) = apply { + coordinate = + computerRightClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = computerRightClickInput.text + additionalProperties = computerRightClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerRightClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerRightClickInput = + ComputerRightClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): ComputerRightClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerRightClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerRightClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerRightClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerRightClickToolUseBlock.kt new file mode 100644 index 000000000..57742ac57 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerRightClickToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.messages + +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 + +class ComputerRightClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Click the right mouse button at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. + * + * @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 input(): ComputerRightClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerRightClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerRightClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("right_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerRightClickToolUseBlock: ComputerRightClickToolUseBlock) = apply { + id = computerRightClickToolUseBlock.id + caller = computerRightClickToolUseBlock.caller + input = computerRightClickToolUseBlock.input + name = computerRightClickToolUseBlock.name + toolsetName = computerRightClickToolUseBlock.toolsetName + type = computerRightClickToolUseBlock.type + additionalProperties = + computerRightClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Click the right mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ + fun input(input: ComputerRightClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerRightClickInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("right_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerRightClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerRightClickToolUseBlock = + ComputerRightClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerRightClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("right_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("right_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerRightClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerRightClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScreenshotInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScreenshotInput.kt new file mode 100644 index 000000000..82948f8d7 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScreenshotInput.kt @@ -0,0 +1,122 @@ +package com.anthropic.models.messages + +import com.anthropic.core.ExcludeMissing +import com.anthropic.core.JsonValue +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import java.util.Collections +import java.util.Objects + +/** Take a screenshot of the screen. */ +class ComputerScreenshotInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [ComputerScreenshotInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerScreenshotInput]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerScreenshotInput: ComputerScreenshotInput) = apply { + additionalProperties = computerScreenshotInput.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComputerScreenshotInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerScreenshotInput = + ComputerScreenshotInput(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(): ComputerScreenshotInput = apply { + if (validated) { + return@apply + } + + 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerScreenshotInput && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "ComputerScreenshotInput{additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScreenshotToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScreenshotToolUseBlock.kt new file mode 100644 index 000000000..d8bfd4a71 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScreenshotToolUseBlock.kt @@ -0,0 +1,411 @@ +package com.anthropic.models.messages + +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 + +class ComputerScreenshotToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Take a screenshot of the screen. + * + * @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 input(): ComputerScreenshotInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerScreenshotToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerScreenshotToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("screenshot") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerScreenshotToolUseBlock: ComputerScreenshotToolUseBlock) = apply { + id = computerScreenshotToolUseBlock.id + caller = computerScreenshotToolUseBlock.caller + input = computerScreenshotToolUseBlock.input + name = computerScreenshotToolUseBlock.name + toolsetName = computerScreenshotToolUseBlock.toolsetName + type = computerScreenshotToolUseBlock.type + additionalProperties = + computerScreenshotToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Take a screenshot of the screen. */ + fun input(input: ComputerScreenshotInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerScreenshotInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("screenshot") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerScreenshotToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerScreenshotToolUseBlock = + ComputerScreenshotToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerScreenshotToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("screenshot")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("screenshot")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerScreenshotToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerScreenshotToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollDirection.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollDirection.kt new file mode 100644 index 000000000..a8423332b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollDirection.kt @@ -0,0 +1,166 @@ +package com.anthropic.models.messages + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +class ComputerScrollDirection 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 UP = ComputerScrollDirection(JsonField.of("up")) + + @JvmField val DOWN = ComputerScrollDirection(JsonField.of("down")) + + @JvmField val LEFT = ComputerScrollDirection(JsonField.of("left")) + + @JvmField val RIGHT = ComputerScrollDirection(JsonField.of("right")) + + @JvmStatic + fun of(value: String): ComputerScrollDirection = + // Intern known values so `==` works + when (value) { + "up" -> UP + "down" -> DOWN + "left" -> LEFT + "right" -> RIGHT + else -> ComputerScrollDirection(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): ComputerScrollDirection = + value.asString().getOrNull()?.let { of(it) } ?: ComputerScrollDirection(value) + } + + /** An enum containing [ComputerScrollDirection]'s known values. */ + enum class Known { + UP, + DOWN, + LEFT, + RIGHT, + } + + /** + * An enum containing [ComputerScrollDirection]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ComputerScrollDirection] 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 { + UP, + DOWN, + LEFT, + RIGHT, + /** + * An enum member indicating that [ComputerScrollDirection] 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) { + UP -> Value.UP + DOWN -> Value.DOWN + LEFT -> Value.LEFT + RIGHT -> Value.RIGHT + 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) { + UP -> Known.UP + DOWN -> Known.DOWN + LEFT -> Known.LEFT + RIGHT -> Known.RIGHT + else -> throw AnthropicInvalidDataException("Unknown ComputerScrollDirection: $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(): ComputerScrollDirection = 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 ComputerScrollDirection && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollInput.kt new file mode 100644 index 000000000..d8cd69f9c --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollInput.kt @@ -0,0 +1,337 @@ +package com.anthropic.models.messages + +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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Scroll the screen at the specified (x, y) pixel coordinate, or the current cursor position if + * `coordinate` is omitted. Do NOT use PageUp/PageDown to scroll. + */ +class ComputerScrollInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val scrollAmount: JsonField, + private val scrollDirection: JsonField, + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("scroll_amount") + @ExcludeMissing + scrollAmount: JsonField = JsonMissing.of(), + @JsonProperty("scroll_direction") + @ExcludeMissing + scrollDirection: JsonField = JsonMissing.of(), + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(scrollAmount, scrollDirection, coordinate, text, mutableMapOf()) + + /** + * Number of 'clicks' of the scroll wheel. + * + * @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 scrollAmount(): Long = scrollAmount.getRequired("scroll_amount") + + /** + * @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 scrollDirection(): ComputerScrollDirection = scrollDirection.getRequired("scroll_direction") + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [scrollAmount]. + * + * Unlike [scrollAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_amount") + @ExcludeMissing + fun _scrollAmount(): JsonField = scrollAmount + + /** + * Returns the raw JSON value of [scrollDirection]. + * + * Unlike [scrollDirection], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scroll_direction") + @ExcludeMissing + fun _scrollDirection(): JsonField = scrollDirection + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerScrollInput]. + * + * The following fields are required: + * ```java + * .scrollAmount() + * .scrollDirection() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerScrollInput]. */ + class Builder internal constructor() { + + private var scrollAmount: JsonField? = null + private var scrollDirection: JsonField? = null + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerScrollInput: ComputerScrollInput) = apply { + scrollAmount = computerScrollInput.scrollAmount + scrollDirection = computerScrollInput.scrollDirection + coordinate = + computerScrollInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = computerScrollInput.text + additionalProperties = computerScrollInput.additionalProperties.toMutableMap() + } + + /** Number of 'clicks' of the scroll wheel. */ + fun scrollAmount(scrollAmount: Long) = scrollAmount(JsonField.of(scrollAmount)) + + /** + * Sets [Builder.scrollAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scrollAmount(scrollAmount: JsonField) = apply { this.scrollAmount = scrollAmount } + + fun scrollDirection(scrollDirection: ComputerScrollDirection) = + scrollDirection(JsonField.of(scrollDirection)) + + /** + * Sets [Builder.scrollDirection] to an arbitrary JSON value. + * + * You should usually call [Builder.scrollDirection] with a well-typed + * [ComputerScrollDirection] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun scrollDirection(scrollDirection: JsonField) = apply { + this.scrollDirection = scrollDirection + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerScrollInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .scrollAmount() + * .scrollDirection() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerScrollInput = + ComputerScrollInput( + checkRequired("scrollAmount", scrollAmount), + checkRequired("scrollDirection", scrollDirection), + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): ComputerScrollInput = apply { + if (validated) { + return@apply + } + + scrollAmount() + scrollDirection().validate() + coordinate() + text() + 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 (scrollAmount.asKnown().isPresent) 1 else 0) + + (scrollDirection.asKnown().getOrNull()?.validity() ?: 0) + + (coordinate.asKnown().getOrNull()?.size ?: 0) + + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerScrollInput && + scrollAmount == other.scrollAmount && + scrollDirection == other.scrollDirection && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(scrollAmount, scrollDirection, coordinate, text, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerScrollInput{scrollAmount=$scrollAmount, scrollDirection=$scrollDirection, coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollToolUseBlock.kt new file mode 100644 index 000000000..4c0531277 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerScrollToolUseBlock.kt @@ -0,0 +1,413 @@ +package com.anthropic.models.messages + +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 + +class ComputerScrollToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Scroll the screen at the specified (x, y) pixel coordinate, or the current cursor position if + * `coordinate` is omitted. Do NOT use PageUp/PageDown to scroll. + * + * @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 input(): ComputerScrollInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [ComputerScrollToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerScrollToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("scroll") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerScrollToolUseBlock: ComputerScrollToolUseBlock) = apply { + id = computerScrollToolUseBlock.id + caller = computerScrollToolUseBlock.caller + input = computerScrollToolUseBlock.input + name = computerScrollToolUseBlock.name + toolsetName = computerScrollToolUseBlock.toolsetName + type = computerScrollToolUseBlock.type + additionalProperties = computerScrollToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Scroll the screen at the specified (x, y) pixel coordinate, or the current cursor + * position if `coordinate` is omitted. Do NOT use PageUp/PageDown to scroll. + */ + fun input(input: ComputerScrollInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerScrollInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("scroll") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerScrollToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerScrollToolUseBlock = + ComputerScrollToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerScrollToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("scroll")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("scroll")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerScrollToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerScrollToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerToolUseBlock.kt new file mode 100644 index 000000000..63abd39cf --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerToolUseBlock.kt @@ -0,0 +1,920 @@ +package com.anthropic.models.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.core.getProperty +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = ComputerToolUseBlock.Deserializer::class) +@JsonSerialize(using = ComputerToolUseBlock.Serializer::class) +class ComputerToolUseBlock +private constructor( + private val key: ComputerKeyToolUseBlock? = null, + private val holdKey: ComputerHoldKeyToolUseBlock? = null, + private val type: ComputerTypeToolUseBlock? = null, + private val cursorPosition: ComputerCursorPositionToolUseBlock? = null, + private val mouseMove: ComputerMouseMoveToolUseBlock? = null, + private val leftMouseDown: ComputerLeftMouseDownToolUseBlock? = null, + private val leftMouseUp: ComputerLeftMouseUpToolUseBlock? = null, + private val leftClick: ComputerLeftClickToolUseBlock? = null, + private val leftClickDrag: ComputerLeftClickDragToolUseBlock? = null, + private val rightClick: ComputerRightClickToolUseBlock? = null, + private val middleClick: ComputerMiddleClickToolUseBlock? = null, + private val doubleClick: ComputerDoubleClickToolUseBlock? = null, + private val tripleClick: ComputerTripleClickToolUseBlock? = null, + private val scroll: ComputerScrollToolUseBlock? = null, + private val wait: ComputerWaitToolUseBlock? = null, + private val screenshot: ComputerScreenshotToolUseBlock? = null, + private val zoom: ComputerZoomToolUseBlock? = null, + private val _json: JsonValue? = null, +) { + + fun name(): Name = + when { + key != null -> Name.KEY + holdKey != null -> Name.HOLD_KEY + type != null -> Name.TYPE + cursorPosition != null -> Name.CURSOR_POSITION + mouseMove != null -> Name.MOUSE_MOVE + leftMouseDown != null -> Name.LEFT_MOUSE_DOWN + leftMouseUp != null -> Name.LEFT_MOUSE_UP + leftClick != null -> Name.LEFT_CLICK + leftClickDrag != null -> Name.LEFT_CLICK_DRAG + rightClick != null -> Name.RIGHT_CLICK + middleClick != null -> Name.MIDDLE_CLICK + doubleClick != null -> Name.DOUBLE_CLICK + tripleClick != null -> Name.TRIPLE_CLICK + scroll != null -> Name.SCROLL + wait != null -> Name.WAIT + screenshot != null -> Name.SCREENSHOT + zoom != null -> Name.ZOOM + else -> Name.of(_json?.asObject()?.getOrNull()?.get("name") ?: JsonMissing.of()) + } + + fun id(): String = + when { + key != null -> key.id() + holdKey != null -> holdKey.id() + type != null -> type.id() + cursorPosition != null -> cursorPosition.id() + mouseMove != null -> mouseMove.id() + leftMouseDown != null -> leftMouseDown.id() + leftMouseUp != null -> leftMouseUp.id() + leftClick != null -> leftClick.id() + leftClickDrag != null -> leftClickDrag.id() + rightClick != null -> rightClick.id() + middleClick != null -> middleClick.id() + doubleClick != null -> doubleClick.id() + tripleClick != null -> tripleClick.id() + scroll != null -> scroll.id() + wait != null -> wait.id() + screenshot != null -> screenshot.id() + zoom != null -> zoom.id() + else -> _json.getProperty("id").getRequired("id") + } + + fun caller(): ToolUseCaller = + when { + key != null -> key.caller() + holdKey != null -> holdKey.caller() + type != null -> type.caller() + cursorPosition != null -> cursorPosition.caller() + mouseMove != null -> mouseMove.caller() + leftMouseDown != null -> leftMouseDown.caller() + leftMouseUp != null -> leftMouseUp.caller() + leftClick != null -> leftClick.caller() + leftClickDrag != null -> leftClickDrag.caller() + rightClick != null -> rightClick.caller() + middleClick != null -> middleClick.caller() + doubleClick != null -> doubleClick.caller() + tripleClick != null -> tripleClick.caller() + scroll != null -> scroll.caller() + wait != null -> wait.caller() + screenshot != null -> screenshot.caller() + zoom != null -> zoom.caller() + else -> _json.getProperty("caller").getRequired("caller") + } + + fun key(): Optional = Optional.ofNullable(key) + + fun holdKey(): Optional = Optional.ofNullable(holdKey) + + fun type(): Optional = Optional.ofNullable(type) + + fun cursorPosition(): Optional = + Optional.ofNullable(cursorPosition) + + fun mouseMove(): Optional = Optional.ofNullable(mouseMove) + + fun leftMouseDown(): Optional = + Optional.ofNullable(leftMouseDown) + + fun leftMouseUp(): Optional = Optional.ofNullable(leftMouseUp) + + fun leftClick(): Optional = Optional.ofNullable(leftClick) + + fun leftClickDrag(): Optional = + Optional.ofNullable(leftClickDrag) + + fun rightClick(): Optional = Optional.ofNullable(rightClick) + + fun middleClick(): Optional = Optional.ofNullable(middleClick) + + fun doubleClick(): Optional = Optional.ofNullable(doubleClick) + + fun tripleClick(): Optional = Optional.ofNullable(tripleClick) + + fun scroll(): Optional = Optional.ofNullable(scroll) + + fun wait(): Optional = Optional.ofNullable(wait) + + fun screenshot(): Optional = Optional.ofNullable(screenshot) + + fun zoom(): Optional = Optional.ofNullable(zoom) + + fun isKey(): Boolean = key != null + + fun isHoldKey(): Boolean = holdKey != null + + fun isType(): Boolean = type != null + + fun isCursorPosition(): Boolean = cursorPosition != null + + fun isMouseMove(): Boolean = mouseMove != null + + fun isLeftMouseDown(): Boolean = leftMouseDown != null + + fun isLeftMouseUp(): Boolean = leftMouseUp != null + + fun isLeftClick(): Boolean = leftClick != null + + fun isLeftClickDrag(): Boolean = leftClickDrag != null + + fun isRightClick(): Boolean = rightClick != null + + fun isMiddleClick(): Boolean = middleClick != null + + fun isDoubleClick(): Boolean = doubleClick != null + + fun isTripleClick(): Boolean = tripleClick != null + + fun isScroll(): Boolean = scroll != null + + fun isWait(): Boolean = wait != null + + fun isScreenshot(): Boolean = screenshot != null + + fun isZoom(): Boolean = zoom != null + + fun asKey(): ComputerKeyToolUseBlock = key.getOrThrow("key") + + fun asHoldKey(): ComputerHoldKeyToolUseBlock = holdKey.getOrThrow("holdKey") + + fun asType(): ComputerTypeToolUseBlock = type.getOrThrow("type") + + fun asCursorPosition(): ComputerCursorPositionToolUseBlock = + cursorPosition.getOrThrow("cursorPosition") + + fun asMouseMove(): ComputerMouseMoveToolUseBlock = mouseMove.getOrThrow("mouseMove") + + fun asLeftMouseDown(): ComputerLeftMouseDownToolUseBlock = + leftMouseDown.getOrThrow("leftMouseDown") + + fun asLeftMouseUp(): ComputerLeftMouseUpToolUseBlock = leftMouseUp.getOrThrow("leftMouseUp") + + fun asLeftClick(): ComputerLeftClickToolUseBlock = leftClick.getOrThrow("leftClick") + + fun asLeftClickDrag(): ComputerLeftClickDragToolUseBlock = + leftClickDrag.getOrThrow("leftClickDrag") + + fun asRightClick(): ComputerRightClickToolUseBlock = rightClick.getOrThrow("rightClick") + + fun asMiddleClick(): ComputerMiddleClickToolUseBlock = middleClick.getOrThrow("middleClick") + + fun asDoubleClick(): ComputerDoubleClickToolUseBlock = doubleClick.getOrThrow("doubleClick") + + fun asTripleClick(): ComputerTripleClickToolUseBlock = tripleClick.getOrThrow("tripleClick") + + fun asScroll(): ComputerScrollToolUseBlock = scroll.getOrThrow("scroll") + + fun asWait(): ComputerWaitToolUseBlock = wait.getOrThrow("wait") + + fun asScreenshot(): ComputerScreenshotToolUseBlock = screenshot.getOrThrow("screenshot") + + fun asZoom(): ComputerZoomToolUseBlock = zoom.getOrThrow("zoom") + + 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 = computerToolUseBlock.accept(new ComputerToolUseBlock.Visitor>() { + * @Override + * public Optional visitKey(ComputerKeyToolUseBlock key) { + * return Optional.of(key.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 { + key != null -> visitor.visitKey(key) + holdKey != null -> visitor.visitHoldKey(holdKey) + type != null -> visitor.visitType(type) + cursorPosition != null -> visitor.visitCursorPosition(cursorPosition) + mouseMove != null -> visitor.visitMouseMove(mouseMove) + leftMouseDown != null -> visitor.visitLeftMouseDown(leftMouseDown) + leftMouseUp != null -> visitor.visitLeftMouseUp(leftMouseUp) + leftClick != null -> visitor.visitLeftClick(leftClick) + leftClickDrag != null -> visitor.visitLeftClickDrag(leftClickDrag) + rightClick != null -> visitor.visitRightClick(rightClick) + middleClick != null -> visitor.visitMiddleClick(middleClick) + doubleClick != null -> visitor.visitDoubleClick(doubleClick) + tripleClick != null -> visitor.visitTripleClick(tripleClick) + scroll != null -> visitor.visitScroll(scroll) + wait != null -> visitor.visitWait(wait) + screenshot != null -> visitor.visitScreenshot(screenshot) + zoom != null -> visitor.visitZoom(zoom) + 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(): ComputerToolUseBlock = apply { + if (validated) { + return@apply + } + + when { + key != null -> key.validate() + holdKey != null -> holdKey.validate() + type != null -> type.validate() + cursorPosition != null -> cursorPosition.validate() + mouseMove != null -> mouseMove.validate() + leftMouseDown != null -> leftMouseDown.validate() + leftMouseUp != null -> leftMouseUp.validate() + leftClick != null -> leftClick.validate() + leftClickDrag != null -> leftClickDrag.validate() + rightClick != null -> rightClick.validate() + middleClick != null -> middleClick.validate() + doubleClick != null -> doubleClick.validate() + tripleClick != null -> tripleClick.validate() + scroll != null -> scroll.validate() + wait != null -> wait.validate() + screenshot != null -> screenshot.validate() + zoom != null -> zoom.validate() + else -> throw AnthropicInvalidDataException("Unknown ComputerToolUseBlock: $_json") + } + 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 = + when { + key != null -> key.validity() + holdKey != null -> holdKey.validity() + type != null -> type.validity() + cursorPosition != null -> cursorPosition.validity() + mouseMove != null -> mouseMove.validity() + leftMouseDown != null -> leftMouseDown.validity() + leftMouseUp != null -> leftMouseUp.validity() + leftClick != null -> leftClick.validity() + leftClickDrag != null -> leftClickDrag.validity() + rightClick != null -> rightClick.validity() + middleClick != null -> middleClick.validity() + doubleClick != null -> doubleClick.validity() + tripleClick != null -> tripleClick.validity() + scroll != null -> scroll.validity() + wait != null -> wait.validity() + screenshot != null -> screenshot.validity() + zoom != null -> zoom.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerToolUseBlock && + key == other.key && + holdKey == other.holdKey && + type == other.type && + cursorPosition == other.cursorPosition && + mouseMove == other.mouseMove && + leftMouseDown == other.leftMouseDown && + leftMouseUp == other.leftMouseUp && + leftClick == other.leftClick && + leftClickDrag == other.leftClickDrag && + rightClick == other.rightClick && + middleClick == other.middleClick && + doubleClick == other.doubleClick && + tripleClick == other.tripleClick && + scroll == other.scroll && + wait == other.wait && + screenshot == other.screenshot && + zoom == other.zoom + } + + override fun hashCode(): Int = + Objects.hash( + key, + holdKey, + type, + cursorPosition, + mouseMove, + leftMouseDown, + leftMouseUp, + leftClick, + leftClickDrag, + rightClick, + middleClick, + doubleClick, + tripleClick, + scroll, + wait, + screenshot, + zoom, + ) + + override fun toString(): String = + when { + key != null -> "ComputerToolUseBlock{key=$key}" + holdKey != null -> "ComputerToolUseBlock{holdKey=$holdKey}" + type != null -> "ComputerToolUseBlock{type=$type}" + cursorPosition != null -> "ComputerToolUseBlock{cursorPosition=$cursorPosition}" + mouseMove != null -> "ComputerToolUseBlock{mouseMove=$mouseMove}" + leftMouseDown != null -> "ComputerToolUseBlock{leftMouseDown=$leftMouseDown}" + leftMouseUp != null -> "ComputerToolUseBlock{leftMouseUp=$leftMouseUp}" + leftClick != null -> "ComputerToolUseBlock{leftClick=$leftClick}" + leftClickDrag != null -> "ComputerToolUseBlock{leftClickDrag=$leftClickDrag}" + rightClick != null -> "ComputerToolUseBlock{rightClick=$rightClick}" + middleClick != null -> "ComputerToolUseBlock{middleClick=$middleClick}" + doubleClick != null -> "ComputerToolUseBlock{doubleClick=$doubleClick}" + tripleClick != null -> "ComputerToolUseBlock{tripleClick=$tripleClick}" + scroll != null -> "ComputerToolUseBlock{scroll=$scroll}" + wait != null -> "ComputerToolUseBlock{wait=$wait}" + screenshot != null -> "ComputerToolUseBlock{screenshot=$screenshot}" + zoom != null -> "ComputerToolUseBlock{zoom=$zoom}" + _json != null -> "ComputerToolUseBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ComputerToolUseBlock") + } + + companion object { + + @JvmStatic fun ofKey(key: ComputerKeyToolUseBlock) = ComputerToolUseBlock(key = key) + + @JvmStatic + fun ofHoldKey(holdKey: ComputerHoldKeyToolUseBlock) = + ComputerToolUseBlock(holdKey = holdKey) + + @JvmStatic fun ofType(type: ComputerTypeToolUseBlock) = ComputerToolUseBlock(type = type) + + @JvmStatic + fun ofCursorPosition(cursorPosition: ComputerCursorPositionToolUseBlock) = + ComputerToolUseBlock(cursorPosition = cursorPosition) + + @JvmStatic + fun ofMouseMove(mouseMove: ComputerMouseMoveToolUseBlock) = + ComputerToolUseBlock(mouseMove = mouseMove) + + @JvmStatic + fun ofLeftMouseDown(leftMouseDown: ComputerLeftMouseDownToolUseBlock) = + ComputerToolUseBlock(leftMouseDown = leftMouseDown) + + @JvmStatic + fun ofLeftMouseUp(leftMouseUp: ComputerLeftMouseUpToolUseBlock) = + ComputerToolUseBlock(leftMouseUp = leftMouseUp) + + @JvmStatic + fun ofLeftClick(leftClick: ComputerLeftClickToolUseBlock) = + ComputerToolUseBlock(leftClick = leftClick) + + @JvmStatic + fun ofLeftClickDrag(leftClickDrag: ComputerLeftClickDragToolUseBlock) = + ComputerToolUseBlock(leftClickDrag = leftClickDrag) + + @JvmStatic + fun ofRightClick(rightClick: ComputerRightClickToolUseBlock) = + ComputerToolUseBlock(rightClick = rightClick) + + @JvmStatic + fun ofMiddleClick(middleClick: ComputerMiddleClickToolUseBlock) = + ComputerToolUseBlock(middleClick = middleClick) + + @JvmStatic + fun ofDoubleClick(doubleClick: ComputerDoubleClickToolUseBlock) = + ComputerToolUseBlock(doubleClick = doubleClick) + + @JvmStatic + fun ofTripleClick(tripleClick: ComputerTripleClickToolUseBlock) = + ComputerToolUseBlock(tripleClick = tripleClick) + + @JvmStatic + fun ofScroll(scroll: ComputerScrollToolUseBlock) = ComputerToolUseBlock(scroll = scroll) + + @JvmStatic fun ofWait(wait: ComputerWaitToolUseBlock) = ComputerToolUseBlock(wait = wait) + + @JvmStatic + fun ofScreenshot(screenshot: ComputerScreenshotToolUseBlock) = + ComputerToolUseBlock(screenshot = screenshot) + + @JvmStatic fun ofZoom(zoom: ComputerZoomToolUseBlock) = ComputerToolUseBlock(zoom = zoom) + } + + /** + * An interface that defines how to map each variant of [ComputerToolUseBlock] to a value of + * type [T]. + */ + interface Visitor { + + fun visitKey(key: ComputerKeyToolUseBlock): T + + fun visitHoldKey(holdKey: ComputerHoldKeyToolUseBlock): T + + fun visitType(type: ComputerTypeToolUseBlock): T + + fun visitCursorPosition(cursorPosition: ComputerCursorPositionToolUseBlock): T + + fun visitMouseMove(mouseMove: ComputerMouseMoveToolUseBlock): T + + fun visitLeftMouseDown(leftMouseDown: ComputerLeftMouseDownToolUseBlock): T + + fun visitLeftMouseUp(leftMouseUp: ComputerLeftMouseUpToolUseBlock): T + + fun visitLeftClick(leftClick: ComputerLeftClickToolUseBlock): T + + fun visitLeftClickDrag(leftClickDrag: ComputerLeftClickDragToolUseBlock): T + + fun visitRightClick(rightClick: ComputerRightClickToolUseBlock): T + + fun visitMiddleClick(middleClick: ComputerMiddleClickToolUseBlock): T + + fun visitDoubleClick(doubleClick: ComputerDoubleClickToolUseBlock): T + + fun visitTripleClick(tripleClick: ComputerTripleClickToolUseBlock): T + + fun visitScroll(scroll: ComputerScrollToolUseBlock): T + + fun visitWait(wait: ComputerWaitToolUseBlock): T + + fun visitScreenshot(screenshot: ComputerScreenshotToolUseBlock): T + + fun visitZoom(zoom: ComputerZoomToolUseBlock): T + + /** + * Maps an unknown variant of [ComputerToolUseBlock] to a value of type [T]. + * + * An instance of [ComputerToolUseBlock] 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 ComputerToolUseBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ComputerToolUseBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ComputerToolUseBlock { + val json = JsonValue.fromJsonNode(node) + val name = json.asObject().getOrNull()?.get("name")?.asString()?.getOrNull() + + when (name) { + "key" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ComputerToolUseBlock(key = it, _json = json) + } ?: ComputerToolUseBlock(_json = json) + } + "hold_key" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(holdKey = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "type" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ComputerToolUseBlock(type = it, _json = json) + } ?: ComputerToolUseBlock(_json = json) + } + "cursor_position" -> { + return tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { ComputerToolUseBlock(cursorPosition = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "mouse_move" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(mouseMove = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "left_mouse_down" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(leftMouseDown = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "left_mouse_up" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(leftMouseUp = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "left_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(leftClick = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "left_click_drag" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(leftClickDrag = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "right_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(rightClick = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "middle_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(middleClick = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "double_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(doubleClick = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "triple_click" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(tripleClick = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "scroll" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ComputerToolUseBlock(scroll = it, _json = json) + } ?: ComputerToolUseBlock(_json = json) + } + "wait" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ComputerToolUseBlock(wait = it, _json = json) + } ?: ComputerToolUseBlock(_json = json) + } + "screenshot" -> { + return tryDeserialize(node, jacksonTypeRef()) + ?.let { ComputerToolUseBlock(screenshot = it, _json = json) } + ?: ComputerToolUseBlock(_json = json) + } + "zoom" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ComputerToolUseBlock(zoom = it, _json = json) + } ?: ComputerToolUseBlock(_json = json) + } + } + + return ComputerToolUseBlock(_json = json) + } + } + + internal class Serializer : BaseSerializer(ComputerToolUseBlock::class) { + + override fun serialize( + value: ComputerToolUseBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.key != null -> generator.writeObject(value.key) + value.holdKey != null -> generator.writeObject(value.holdKey) + value.type != null -> generator.writeObject(value.type) + value.cursorPosition != null -> generator.writeObject(value.cursorPosition) + value.mouseMove != null -> generator.writeObject(value.mouseMove) + value.leftMouseDown != null -> generator.writeObject(value.leftMouseDown) + value.leftMouseUp != null -> generator.writeObject(value.leftMouseUp) + value.leftClick != null -> generator.writeObject(value.leftClick) + value.leftClickDrag != null -> generator.writeObject(value.leftClickDrag) + value.rightClick != null -> generator.writeObject(value.rightClick) + value.middleClick != null -> generator.writeObject(value.middleClick) + value.doubleClick != null -> generator.writeObject(value.doubleClick) + value.tripleClick != null -> generator.writeObject(value.tripleClick) + value.scroll != null -> generator.writeObject(value.scroll) + value.wait != null -> generator.writeObject(value.wait) + value.screenshot != null -> generator.writeObject(value.screenshot) + value.zoom != null -> generator.writeObject(value.zoom) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ComputerToolUseBlock") + } + } + } + + class Name 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 KEY = Name(JsonField.of("key")) + + @JvmField val HOLD_KEY = Name(JsonField.of("hold_key")) + + @JvmField val TYPE = Name(JsonField.of("type")) + + @JvmField val CURSOR_POSITION = Name(JsonField.of("cursor_position")) + + @JvmField val MOUSE_MOVE = Name(JsonField.of("mouse_move")) + + @JvmField val LEFT_MOUSE_DOWN = Name(JsonField.of("left_mouse_down")) + + @JvmField val LEFT_MOUSE_UP = Name(JsonField.of("left_mouse_up")) + + @JvmField val LEFT_CLICK = Name(JsonField.of("left_click")) + + @JvmField val LEFT_CLICK_DRAG = Name(JsonField.of("left_click_drag")) + + @JvmField val RIGHT_CLICK = Name(JsonField.of("right_click")) + + @JvmField val MIDDLE_CLICK = Name(JsonField.of("middle_click")) + + @JvmField val DOUBLE_CLICK = Name(JsonField.of("double_click")) + + @JvmField val TRIPLE_CLICK = Name(JsonField.of("triple_click")) + + @JvmField val SCROLL = Name(JsonField.of("scroll")) + + @JvmField val WAIT = Name(JsonField.of("wait")) + + @JvmField val SCREENSHOT = Name(JsonField.of("screenshot")) + + @JvmField val ZOOM = Name(JsonField.of("zoom")) + + @JvmStatic + fun of(value: String): Name = + // Intern known values so `==` works + when (value) { + "key" -> KEY + "hold_key" -> HOLD_KEY + "type" -> TYPE + "cursor_position" -> CURSOR_POSITION + "mouse_move" -> MOUSE_MOVE + "left_mouse_down" -> LEFT_MOUSE_DOWN + "left_mouse_up" -> LEFT_MOUSE_UP + "left_click" -> LEFT_CLICK + "left_click_drag" -> LEFT_CLICK_DRAG + "right_click" -> RIGHT_CLICK + "middle_click" -> MIDDLE_CLICK + "double_click" -> DOUBLE_CLICK + "triple_click" -> TRIPLE_CLICK + "scroll" -> SCROLL + "wait" -> WAIT + "screenshot" -> SCREENSHOT + "zoom" -> ZOOM + else -> Name(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Name = + value.asString().getOrNull()?.let { of(it) } ?: Name(value) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + KEY, + HOLD_KEY, + TYPE, + CURSOR_POSITION, + MOUSE_MOVE, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + LEFT_CLICK, + LEFT_CLICK_DRAG, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + SCROLL, + WAIT, + SCREENSHOT, + ZOOM, + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] 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 { + KEY, + HOLD_KEY, + TYPE, + CURSOR_POSITION, + MOUSE_MOVE, + LEFT_MOUSE_DOWN, + LEFT_MOUSE_UP, + LEFT_CLICK, + LEFT_CLICK_DRAG, + RIGHT_CLICK, + MIDDLE_CLICK, + DOUBLE_CLICK, + TRIPLE_CLICK, + SCROLL, + WAIT, + SCREENSHOT, + ZOOM, + /** An enum member indicating that [Name] 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) { + KEY -> Value.KEY + HOLD_KEY -> Value.HOLD_KEY + TYPE -> Value.TYPE + CURSOR_POSITION -> Value.CURSOR_POSITION + MOUSE_MOVE -> Value.MOUSE_MOVE + LEFT_MOUSE_DOWN -> Value.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Value.LEFT_MOUSE_UP + LEFT_CLICK -> Value.LEFT_CLICK + LEFT_CLICK_DRAG -> Value.LEFT_CLICK_DRAG + RIGHT_CLICK -> Value.RIGHT_CLICK + MIDDLE_CLICK -> Value.MIDDLE_CLICK + DOUBLE_CLICK -> Value.DOUBLE_CLICK + TRIPLE_CLICK -> Value.TRIPLE_CLICK + SCROLL -> Value.SCROLL + WAIT -> Value.WAIT + SCREENSHOT -> Value.SCREENSHOT + ZOOM -> Value.ZOOM + 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) { + KEY -> Known.KEY + HOLD_KEY -> Known.HOLD_KEY + TYPE -> Known.TYPE + CURSOR_POSITION -> Known.CURSOR_POSITION + MOUSE_MOVE -> Known.MOUSE_MOVE + LEFT_MOUSE_DOWN -> Known.LEFT_MOUSE_DOWN + LEFT_MOUSE_UP -> Known.LEFT_MOUSE_UP + LEFT_CLICK -> Known.LEFT_CLICK + LEFT_CLICK_DRAG -> Known.LEFT_CLICK_DRAG + RIGHT_CLICK -> Known.RIGHT_CLICK + MIDDLE_CLICK -> Known.MIDDLE_CLICK + DOUBLE_CLICK -> Known.DOUBLE_CLICK + TRIPLE_CLICK -> Known.TRIPLE_CLICK + SCROLL -> Known.SCROLL + WAIT -> Known.WAIT + SCREENSHOT -> Known.SCREENSHOT + ZOOM -> Known.ZOOM + else -> throw AnthropicInvalidDataException("Unknown Name: $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(): Name = 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 Name && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTripleClickInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTripleClickInput.kt new file mode 100644 index 000000000..e63d01c28 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTripleClickInput.kt @@ -0,0 +1,239 @@ +package com.anthropic.models.messages + +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.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 java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Triple-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + */ +class ComputerTripleClickInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val coordinate: JsonField>, + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("coordinate") + @ExcludeMissing + coordinate: JsonField> = JsonMissing.of(), + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of(), + ) : this(coordinate, text, mutableMapOf()) + + /** + * (x, y): x pixels from the left edge, y pixels from the top edge. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun coordinate(): Optional> = coordinate.getOptional("coordinate") + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun text(): Optional = text.getOptional("text") + + /** + * Returns the raw JSON value of [coordinate]. + * + * Unlike [coordinate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("coordinate") + @ExcludeMissing + fun _coordinate(): JsonField> = coordinate + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerTripleClickInput]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerTripleClickInput]. */ + class Builder internal constructor() { + + private var coordinate: JsonField>? = null + private var text: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerTripleClickInput: ComputerTripleClickInput) = apply { + coordinate = + computerTripleClickInput.coordinate + .map { it.toMutableList() } + .takeUnless { it.isMissing() } + text = computerTripleClickInput.text + additionalProperties = computerTripleClickInput.additionalProperties.toMutableMap() + } + + /** (x, y): x pixels from the left edge, y pixels from the top edge. */ + fun coordinate(coordinate: List?) = coordinate(JsonField.ofNullable(coordinate)) + + /** Alias for calling [Builder.coordinate] with `coordinate.orElse(null)`. */ + fun coordinate(coordinate: Optional>) = coordinate(coordinate.getOrNull()) + + /** + * Sets [Builder.coordinate] to an arbitrary JSON value. + * + * You should usually call [Builder.coordinate] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun coordinate(coordinate: JsonField>) = apply { + this.coordinate = coordinate.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.coordinate]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCoordinate(coordinate: Long) = apply { + this.coordinate = + (this.coordinate ?: JsonField.of(mutableListOf())).also { + checkKnown("coordinate", it).add(coordinate) + } + } + + /** + * Optional key combination to hold down during this action (e.g. "ctrl", "shift", + * "ctrl+shift"). + */ + fun text(text: String?) = text(JsonField.ofNullable(text)) + + /** Alias for calling [Builder.text] with `text.orElse(null)`. */ + fun text(text: Optional) = text(text.getOrNull()) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerTripleClickInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ComputerTripleClickInput = + ComputerTripleClickInput( + (coordinate ?: JsonMissing.of()).map { it.toImmutable() }, + text, + 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(): ComputerTripleClickInput = apply { + if (validated) { + return@apply + } + + coordinate() + text() + 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 = + (coordinate.asKnown().getOrNull()?.size ?: 0) + (if (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerTripleClickInput && + coordinate == other.coordinate && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(coordinate, text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerTripleClickInput{coordinate=$coordinate, text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTripleClickToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTripleClickToolUseBlock.kt new file mode 100644 index 000000000..c6b454bcb --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTripleClickToolUseBlock.kt @@ -0,0 +1,416 @@ +package com.anthropic.models.messages + +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 + +class ComputerTripleClickToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Triple-click the left mouse button at the specified (x, y) pixel coordinate, or the current + * cursor position if `coordinate` is omitted. + * + * @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 input(): ComputerTripleClickInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 + * [ComputerTripleClickToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerTripleClickToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("triple_click") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerTripleClickToolUseBlock: ComputerTripleClickToolUseBlock) = + apply { + id = computerTripleClickToolUseBlock.id + caller = computerTripleClickToolUseBlock.caller + input = computerTripleClickToolUseBlock.input + name = computerTripleClickToolUseBlock.name + toolsetName = computerTripleClickToolUseBlock.toolsetName + type = computerTripleClickToolUseBlock.type + additionalProperties = + computerTripleClickToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Triple-click the left mouse button at the specified (x, y) pixel coordinate, or the + * current cursor position if `coordinate` is omitted. + */ + fun input(input: ComputerTripleClickInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerTripleClickInput] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("triple_click") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerTripleClickToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerTripleClickToolUseBlock = + ComputerTripleClickToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerTripleClickToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("triple_click")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("triple_click")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerTripleClickToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerTripleClickToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTypeInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTypeInput.kt new file mode 100644 index 000000000..0914ec8fa --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTypeInput.kt @@ -0,0 +1,183 @@ +package com.anthropic.models.messages + +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 + +/** Type a string of text on the keyboard. */ +class ComputerTypeInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val text: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("text") @ExcludeMissing text: JsonField = JsonMissing.of() + ) : this(text, mutableMapOf()) + + /** + * The text to 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 text(): String = text.getRequired("text") + + /** + * Returns the raw JSON value of [text]. + * + * Unlike [text], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("text") @ExcludeMissing fun _text(): JsonField = text + + @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 [ComputerTypeInput]. + * + * The following fields are required: + * ```java + * .text() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [ComputerTypeInput] with the required [text] set to the + * given value. + */ + @JvmStatic fun of(text: String) = builder().text(text).build() + } + + /** A builder for [ComputerTypeInput]. */ + class Builder internal constructor() { + + private var text: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerTypeInput: ComputerTypeInput) = apply { + text = computerTypeInput.text + additionalProperties = computerTypeInput.additionalProperties.toMutableMap() + } + + /** The text to type. */ + fun text(text: String) = text(JsonField.of(text)) + + /** + * Sets [Builder.text] to an arbitrary JSON value. + * + * You should usually call [Builder.text] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun text(text: JsonField) = apply { this.text = text } + + 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 [ComputerTypeInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .text() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerTypeInput = + ComputerTypeInput(checkRequired("text", text), 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(): ComputerTypeInput = apply { + if (validated) { + return@apply + } + + text() + 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 (text.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerTypeInput && + text == other.text && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(text, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerTypeInput{text=$text, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTypeToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTypeToolUseBlock.kt new file mode 100644 index 000000000..cbc20276f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerTypeToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class ComputerTypeToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Type a string of text on the keyboard. + * + * @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 input(): ComputerTypeInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("type") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [ComputerTypeToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerTypeToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("type") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerTypeToolUseBlock: ComputerTypeToolUseBlock) = apply { + id = computerTypeToolUseBlock.id + caller = computerTypeToolUseBlock.caller + input = computerTypeToolUseBlock.input + name = computerTypeToolUseBlock.name + toolsetName = computerTypeToolUseBlock.toolsetName + type = computerTypeToolUseBlock.type + additionalProperties = computerTypeToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Type a string of text on the keyboard. */ + fun input(input: ComputerTypeInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerTypeInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("type") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerTypeToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerTypeToolUseBlock = + ComputerTypeToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerTypeToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("type")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("type")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerTypeToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerTypeToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerWaitInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerWaitInput.kt new file mode 100644 index 000000000..1f7949cca --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerWaitInput.kt @@ -0,0 +1,186 @@ +package com.anthropic.models.messages + +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 + +/** Wait for a specified duration. */ +class ComputerWaitInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val duration: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("duration") @ExcludeMissing duration: JsonField = JsonMissing.of() + ) : this(duration, mutableMapOf()) + + /** + * Duration to wait, in seconds. + * + * @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 duration(): Long = duration.getRequired("duration") + + /** + * Returns the raw JSON value of [duration]. + * + * Unlike [duration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + @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 [ComputerWaitInput]. + * + * The following fields are required: + * ```java + * .duration() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [ComputerWaitInput] with the required [duration] set to + * the given value. + */ + @JvmStatic fun of(duration: Long) = builder().duration(duration).build() + } + + /** A builder for [ComputerWaitInput]. */ + class Builder internal constructor() { + + private var duration: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerWaitInput: ComputerWaitInput) = apply { + duration = computerWaitInput.duration + additionalProperties = computerWaitInput.additionalProperties.toMutableMap() + } + + /** Duration to wait, in seconds. */ + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** + * Sets [Builder.duration] to an arbitrary JSON value. + * + * You should usually call [Builder.duration] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + 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 [ComputerWaitInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .duration() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerWaitInput = + ComputerWaitInput( + checkRequired("duration", duration), + 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(): ComputerWaitInput = apply { + if (validated) { + return@apply + } + + duration() + 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 (duration.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerWaitInput && + duration == other.duration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(duration, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerWaitInput{duration=$duration, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerWaitToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerWaitToolUseBlock.kt new file mode 100644 index 000000000..39c215de0 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerWaitToolUseBlock.kt @@ -0,0 +1,409 @@ +package com.anthropic.models.messages + +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 + +class ComputerWaitToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Wait for a specified duration. + * + * @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 input(): ComputerWaitInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("wait") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [ComputerWaitToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerWaitToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("wait") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerWaitToolUseBlock: ComputerWaitToolUseBlock) = apply { + id = computerWaitToolUseBlock.id + caller = computerWaitToolUseBlock.caller + input = computerWaitToolUseBlock.input + name = computerWaitToolUseBlock.name + toolsetName = computerWaitToolUseBlock.toolsetName + type = computerWaitToolUseBlock.type + additionalProperties = computerWaitToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** Wait for a specified duration. */ + fun input(input: ComputerWaitInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerWaitInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("wait") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerWaitToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerWaitToolUseBlock = + ComputerWaitToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerWaitToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("wait")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("wait")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerWaitToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerWaitToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerZoomInput.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerZoomInput.kt new file mode 100644 index 000000000..2ec5e4c5b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerZoomInput.kt @@ -0,0 +1,209 @@ +package com.anthropic.models.messages + +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 + +/** + * Take a screenshot of a rectangular region. Region coordinates are in the full-screenshot space + * (not physical display pixels). The crop is scaled up to fill the image budget so fine details + * become legible. + */ +class ComputerZoomInput +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val region: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("region") @ExcludeMissing region: JsonField> = JsonMissing.of() + ) : this(region, mutableMapOf()) + + /** + * (x0, y0, x1, y1): The region to capture. + * + * @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 region(): List = region.getRequired("region") + + /** + * Returns the raw JSON value of [region]. + * + * Unlike [region], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("region") @ExcludeMissing fun _region(): JsonField> = region + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ComputerZoomInput]. + * + * The following fields are required: + * ```java + * .region() + * ``` + */ + @JvmStatic fun builder() = Builder() + + /** + * Returns an immutable instance of [ComputerZoomInput] with the required [region] set to + * the given value. + */ + @JvmStatic fun of(region: List) = builder().region(region).build() + } + + /** A builder for [ComputerZoomInput]. */ + class Builder internal constructor() { + + private var region: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerZoomInput: ComputerZoomInput) = apply { + region = + computerZoomInput.region.map { it.toMutableList() }.takeUnless { it.isMissing() } + additionalProperties = computerZoomInput.additionalProperties.toMutableMap() + } + + /** (x0, y0, x1, y1): The region to capture. */ + fun region(region: List) = region(JsonField.of(region)) + + /** + * Sets [Builder.region] to an arbitrary JSON value. + * + * You should usually call [Builder.region] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun region(region: JsonField>) = apply { + this.region = region.map { it.toMutableList() } + } + + /** + * Adds a single [Long] to [Builder.region]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRegion(region: Long) = apply { + this.region = + (this.region ?: JsonField.of(mutableListOf())).also { + checkKnown("region", it).add(region) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ComputerZoomInput]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .region() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerZoomInput = + ComputerZoomInput( + checkRequired("region", region).map { it.toImmutable() }, + 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(): ComputerZoomInput = apply { + if (validated) { + return@apply + } + + region() + 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 = (region.asKnown().getOrNull()?.size ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerZoomInput && + region == other.region && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(region, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerZoomInput{region=$region, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerZoomToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerZoomToolUseBlock.kt new file mode 100644 index 000000000..db286bae3 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ComputerZoomToolUseBlock.kt @@ -0,0 +1,415 @@ +package com.anthropic.models.messages + +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 + +class ComputerZoomToolUseBlock +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val caller: JsonField, + private val input: JsonField, + private val name: JsonValue, + private val toolsetName: JsonValue, + private val type: JsonValue, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("caller") @ExcludeMissing caller: JsonField = JsonMissing.of(), + @JsonProperty("input") + @ExcludeMissing + input: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonValue = JsonMissing.of(), + @JsonProperty("toolset_name") @ExcludeMissing toolsetName: JsonValue = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), + ) : this(id, caller, input, name, toolsetName, 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 id(): String = id.getRequired("id") + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + * + * @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 caller(): ToolUseCaller = caller.getRequired("caller") + + /** + * Take a screenshot of a rectangular region. Region coordinates are in the full-screenshot + * space (not physical display pixels). The crop is scaled up to fill the image budget so fine + * details become legible. + * + * @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 input(): ComputerZoomInput = input.getRequired("input") + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonValue = name + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("computer") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("toolset_name") @ExcludeMissing fun _toolsetName(): JsonValue = toolsetName + + /** + * Expected to always return the following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonValue = type + + /** + * 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 [caller]. + * + * Unlike [caller], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("caller") @ExcludeMissing fun _caller(): JsonField = caller + + /** + * Returns the raw JSON value of [input]. + * + * Unlike [input], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("input") @ExcludeMissing fun _input(): JsonField = input + + @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 [ComputerZoomToolUseBlock]. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ComputerZoomToolUseBlock]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var caller: JsonField? = null + private var input: JsonField? = null + private var name: JsonValue = JsonValue.from("zoom") + private var toolsetName: JsonValue = JsonValue.from("computer") + private var type: JsonValue = JsonValue.from("tool_use") + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(computerZoomToolUseBlock: ComputerZoomToolUseBlock) = apply { + id = computerZoomToolUseBlock.id + caller = computerZoomToolUseBlock.caller + input = computerZoomToolUseBlock.input + name = computerZoomToolUseBlock.name + toolsetName = computerZoomToolUseBlock.toolsetName + type = computerZoomToolUseBlock.type + additionalProperties = computerZoomToolUseBlock.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 } + + /** + * Which party invoked the tool call: the model directly, or a server tool on its behalf. + */ + fun caller(caller: ToolUseCaller) = caller(JsonField.of(caller)) + + /** + * Sets [Builder.caller] to an arbitrary JSON value. + * + * You should usually call [Builder.caller] with a well-typed [ToolUseCaller] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun caller(caller: JsonField) = apply { this.caller = caller } + + /** Alias for calling [caller] with `ToolUseCaller.ofDirect(direct)`. */ + fun caller(direct: DirectCaller) = caller(ToolUseCaller.ofDirect(direct)) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)`. + */ + fun caller(codeExecution20250825: ServerToolCaller) = + caller(ToolUseCaller.ofCodeExecution20250825(codeExecution20250825)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20250825Caller(toolId: String) = + caller(ServerToolCaller.builder().toolId(toolId).build()) + + /** + * Alias for calling [caller] with + * `ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)`. + */ + fun caller(codeExecution20260120: ServerToolCaller20260120) = + caller(ToolUseCaller.ofCodeExecution20260120(codeExecution20260120)) + + /** + * Alias for calling [caller] with the following: + * ```java + * ServerToolCaller20260120.builder() + * .toolId(toolId) + * .build() + * ``` + */ + fun codeExecution20260120Caller(toolId: String) = + caller(ServerToolCaller20260120.builder().toolId(toolId).build()) + + /** + * Take a screenshot of a rectangular region. Region coordinates are in the full-screenshot + * space (not physical display pixels). The crop is scaled up to fill the image budget so + * fine details become legible. + */ + fun input(input: ComputerZoomInput) = input(JsonField.of(input)) + + /** + * Sets [Builder.input] to an arbitrary JSON value. + * + * You should usually call [Builder.input] with a well-typed [ComputerZoomInput] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun input(input: JsonField) = apply { this.input = input } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("zoom") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonValue) = apply { this.name = name } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("computer") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun toolsetName(toolsetName: JsonValue) = apply { this.toolsetName = toolsetName } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("tool_use") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonValue) = 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 [ComputerZoomToolUseBlock]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .caller() + * .input() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ComputerZoomToolUseBlock = + ComputerZoomToolUseBlock( + checkRequired("id", id), + checkRequired("caller", caller), + checkRequired("input", input), + name, + toolsetName, + 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(): ComputerZoomToolUseBlock = apply { + if (validated) { + return@apply + } + + id() + caller().validate() + input().validate() + _name().let { + if (it != JsonValue.from("zoom")) { + throw AnthropicInvalidDataException("'name' is invalid, received $it") + } + } + _toolsetName().let { + if (it != JsonValue.from("computer")) { + throw AnthropicInvalidDataException("'toolsetName' is invalid, received $it") + } + } + _type().let { + if (it != JsonValue.from("tool_use")) { + throw AnthropicInvalidDataException("'type' is invalid, received $it") + } + } + 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) + + (caller.asKnown().getOrNull()?.validity() ?: 0) + + (input.asKnown().getOrNull()?.validity() ?: 0) + + name.let { if (it == JsonValue.from("zoom")) 1 else 0 } + + toolsetName.let { if (it == JsonValue.from("computer")) 1 else 0 } + + type.let { if (it == JsonValue.from("tool_use")) 1 else 0 } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ComputerZoomToolUseBlock && + id == other.id && + caller == other.caller && + input == other.input && + name == other.name && + toolsetName == other.toolsetName && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(id, caller, input, name, toolsetName, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ComputerZoomToolUseBlock{id=$id, caller=$caller, input=$input, name=$name, toolsetName=$toolsetName, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/Model.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/Model.kt index ec7dc81b4..167e18419 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/Model.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/Model.kt @@ -25,6 +25,9 @@ class Model private constructor(private val value: JsonField) : Enum { companion object { + /** Fastest model for high-volume, real-time tasks */ + @JvmField val CLAUDE_HAIKU_5_5 = Model(JsonField.of("claude-haiku-5-5")) + /** Efficient model for coding and agents */ @JvmField val CLAUDE_SONNET_5_5 = Model(JsonField.of("claude-sonnet-5-5")) @@ -104,6 +107,7 @@ class Model private constructor(private val value: JsonField) : Enum { fun of(value: String): Model = // Intern known values so `==` works when (value) { + "claude-haiku-5-5" -> CLAUDE_HAIKU_5_5 "claude-sonnet-5-5" -> CLAUDE_SONNET_5_5 "claude-fable-5-1" -> CLAUDE_FABLE_5_1 "claude-opus-5-5" -> CLAUDE_OPUS_5_5 @@ -134,6 +138,8 @@ class Model private constructor(private val value: JsonField) : Enum { /** An enum containing [Model]'s known values. */ enum class Known { + /** Fastest model for high-volume, real-time tasks */ + CLAUDE_HAIKU_5_5, /** Efficient model for coding and agents */ CLAUDE_SONNET_5_5, /** @@ -199,6 +205,8 @@ class Model private constructor(private val value: JsonField) : Enum { * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + /** Fastest model for high-volume, real-time tasks */ + CLAUDE_HAIKU_5_5, /** Efficient model for coding and agents */ CLAUDE_SONNET_5_5, /** @@ -265,6 +273,7 @@ class Model private constructor(private val value: JsonField) : Enum { */ fun value(): Value = when (this) { + CLAUDE_HAIKU_5_5 -> Value.CLAUDE_HAIKU_5_5 CLAUDE_SONNET_5_5 -> Value.CLAUDE_SONNET_5_5 CLAUDE_FABLE_5_1 -> Value.CLAUDE_FABLE_5_1 CLAUDE_OPUS_5_5 -> Value.CLAUDE_OPUS_5_5 @@ -297,6 +306,7 @@ class Model private constructor(private val value: JsonField) : Enum { */ fun known(): Known = when (this) { + CLAUDE_HAIKU_5_5 -> Known.CLAUDE_HAIKU_5_5 CLAUDE_SONNET_5_5 -> Known.CLAUDE_SONNET_5_5 CLAUDE_FABLE_5_1 -> Known.CLAUDE_FABLE_5_1 CLAUDE_OPUS_5_5 -> Known.CLAUDE_OPUS_5_5 diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ToolUseCaller.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ToolUseCaller.kt new file mode 100644 index 000000000..2bd9da27b --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ToolUseCaller.kt @@ -0,0 +1,448 @@ +package com.anthropic.models.messages + +import com.anthropic.core.BaseDeserializer +import com.anthropic.core.BaseSerializer +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.core.JsonMissing +import com.anthropic.core.JsonValue +import com.anthropic.core.getOrThrow +import com.anthropic.core.getProperty +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +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 +import kotlin.jvm.optionals.getOrNull + +/** Which party invoked the tool call: the model directly, or a server tool on its behalf. */ +@JsonDeserialize(using = ToolUseCaller.Deserializer::class) +@JsonSerialize(using = ToolUseCaller.Serializer::class) +class ToolUseCaller +private constructor( + private val direct: DirectCaller? = null, + private val codeExecution20250825: ServerToolCaller? = null, + private val codeExecution20260120: ServerToolCaller20260120? = null, + private val _json: JsonValue? = null, +) { + + fun type(): Type = + when { + direct != null -> Type.DIRECT + codeExecution20250825 != null -> Type.CODE_EXECUTION_20250825 + codeExecution20260120 != null -> Type.CODE_EXECUTION_20260120 + else -> Type.of(_json?.asObject()?.getOrNull()?.get("type") ?: JsonMissing.of()) + } + + fun toolId(): Optional = + when { + direct != null -> Optional.empty() + codeExecution20250825 != null -> Optional.of(codeExecution20250825.toolId()) + codeExecution20260120 != null -> Optional.of(codeExecution20260120.toolId()) + else -> _json.getProperty("tool_id").asKnown() + } + + /** Tool invocation directly from the model. */ + fun direct(): Optional = Optional.ofNullable(direct) + + /** Tool invocation generated by a server-side tool. */ + fun codeExecution20250825(): Optional = + Optional.ofNullable(codeExecution20250825) + + fun codeExecution20260120(): Optional = + Optional.ofNullable(codeExecution20260120) + + fun isDirect(): Boolean = direct != null + + fun isCodeExecution20250825(): Boolean = codeExecution20250825 != null + + fun isCodeExecution20260120(): Boolean = codeExecution20260120 != null + + /** Tool invocation directly from the model. */ + fun asDirect(): DirectCaller = direct.getOrThrow("direct") + + /** Tool invocation generated by a server-side tool. */ + fun asCodeExecution20250825(): ServerToolCaller = + codeExecution20250825.getOrThrow("codeExecution20250825") + + fun asCodeExecution20260120(): ServerToolCaller20260120 = + codeExecution20260120.getOrThrow("codeExecution20260120") + + 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 = toolUseCaller.accept(new ToolUseCaller.Visitor>() { + * @Override + * public Optional visitDirect(DirectCaller direct) { + * return Optional.of(direct.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 { + direct != null -> visitor.visitDirect(direct) + codeExecution20250825 != null -> + visitor.visitCodeExecution20250825(codeExecution20250825) + codeExecution20260120 != null -> + visitor.visitCodeExecution20260120(codeExecution20260120) + 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(): ToolUseCaller = apply { + if (validated) { + return@apply + } + + when { + direct != null -> direct.validate() + codeExecution20250825 != null -> codeExecution20250825.validate() + codeExecution20260120 != null -> codeExecution20260120.validate() + else -> throw AnthropicInvalidDataException("Unknown ToolUseCaller: $_json") + } + 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 = + when { + direct != null -> direct.validity() + codeExecution20250825 != null -> codeExecution20250825.validity() + codeExecution20260120 != null -> codeExecution20260120.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolUseCaller && + direct == other.direct && + codeExecution20250825 == other.codeExecution20250825 && + codeExecution20260120 == other.codeExecution20260120 + } + + override fun hashCode(): Int = + Objects.hash(direct, codeExecution20250825, codeExecution20260120) + + override fun toString(): String = + when { + direct != null -> "ToolUseCaller{direct=$direct}" + codeExecution20250825 != null -> + "ToolUseCaller{codeExecution20250825=$codeExecution20250825}" + codeExecution20260120 != null -> + "ToolUseCaller{codeExecution20260120=$codeExecution20260120}" + _json != null -> "ToolUseCaller{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolUseCaller") + } + + companion object { + + /** Tool invocation directly from the model. */ + @JvmStatic fun ofDirect(direct: DirectCaller) = ToolUseCaller(direct = direct) + + /** Tool invocation generated by a server-side tool. */ + @JvmStatic + fun ofCodeExecution20250825(codeExecution20250825: ServerToolCaller) = + ToolUseCaller(codeExecution20250825 = codeExecution20250825) + + /** + * Returns an immutable instance of [ToolUseCaller] whose [ofCodeExecution20250825] variant + * is built from the given required [toolId]. + */ + @JvmStatic + fun ofCodeExecution20250825(toolId: String) = + ofCodeExecution20250825(ServerToolCaller.of(toolId)) + + @JvmStatic + fun ofCodeExecution20260120(codeExecution20260120: ServerToolCaller20260120) = + ToolUseCaller(codeExecution20260120 = codeExecution20260120) + + /** + * Returns an immutable instance of [ToolUseCaller] whose [ofCodeExecution20260120] variant + * is built from the given required [toolId]. + */ + @JvmStatic + fun ofCodeExecution20260120(toolId: String) = + ofCodeExecution20260120(ServerToolCaller20260120.of(toolId)) + } + + /** + * An interface that defines how to map each variant of [ToolUseCaller] to a value of type [T]. + */ + interface Visitor { + + /** Tool invocation directly from the model. */ + fun visitDirect(direct: DirectCaller): T + + /** Tool invocation generated by a server-side tool. */ + fun visitCodeExecution20250825(codeExecution20250825: ServerToolCaller): T + + fun visitCodeExecution20260120(codeExecution20260120: ServerToolCaller20260120): T + + /** + * Maps an unknown variant of [ToolUseCaller] to a value of type [T]. + * + * An instance of [ToolUseCaller] 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 ToolUseCaller: $json") + } + } + + internal class Deserializer : BaseDeserializer(ToolUseCaller::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolUseCaller { + val json = JsonValue.fromJsonNode(node) + val type = json.asObject().getOrNull()?.get("type")?.asString()?.getOrNull() + + when (type) { + "direct" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ToolUseCaller(direct = it, _json = json) + } ?: ToolUseCaller(_json = json) + } + "code_execution_20250825" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ToolUseCaller(codeExecution20250825 = it, _json = json) + } ?: ToolUseCaller(_json = json) + } + "code_execution_20260120" -> { + return tryDeserialize(node, jacksonTypeRef())?.let { + ToolUseCaller(codeExecution20260120 = it, _json = json) + } ?: ToolUseCaller(_json = json) + } + } + + return ToolUseCaller(_json = json) + } + } + + internal class Serializer : BaseSerializer(ToolUseCaller::class) { + + override fun serialize( + value: ToolUseCaller, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.direct != null -> generator.writeObject(value.direct) + value.codeExecution20250825 != null -> + generator.writeObject(value.codeExecution20250825) + value.codeExecution20260120 != null -> + generator.writeObject(value.codeExecution20260120) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolUseCaller") + } + } + } + + class Type 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 DIRECT = Type(JsonField.of("direct")) + + @JvmField val CODE_EXECUTION_20250825 = Type(JsonField.of("code_execution_20250825")) + + @JvmField val CODE_EXECUTION_20260120 = Type(JsonField.of("code_execution_20260120")) + + @JvmStatic + fun of(value: String): Type = + // Intern known values so `==` works + when (value) { + "direct" -> DIRECT + "code_execution_20250825" -> CODE_EXECUTION_20250825 + "code_execution_20260120" -> CODE_EXECUTION_20260120 + else -> Type(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Type = + value.asString().getOrNull()?.let { of(it) } ?: Type(value) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + DIRECT, + CODE_EXECUTION_20250825, + CODE_EXECUTION_20260120, + } + + /** + * 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 { + DIRECT, + CODE_EXECUTION_20250825, + CODE_EXECUTION_20260120, + /** 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) { + DIRECT -> Value.DIRECT + CODE_EXECUTION_20250825 -> Value.CODE_EXECUTION_20250825 + CODE_EXECUTION_20260120 -> Value.CODE_EXECUTION_20260120 + 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) { + DIRECT -> Known.DIRECT + CODE_EXECUTION_20250825 -> Known.CODE_EXECUTION_20250825 + CODE_EXECUTION_20260120 -> Known.CODE_EXECUTION_20260120 + 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() + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ToolsetToolUseBlock.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ToolsetToolUseBlock.kt new file mode 100644 index 000000000..b3a9cf90f --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/messages/ToolsetToolUseBlock.kt @@ -0,0 +1,243 @@ +package com.anthropic.models.messages + +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.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 + +@JsonDeserialize(using = ToolsetToolUseBlock.Deserializer::class) +@JsonSerialize(using = ToolsetToolUseBlock.Serializer::class) +class ToolsetToolUseBlock +private constructor( + private val browser: BrowserToolUseBlock? = null, + private val computer: ComputerToolUseBlock? = null, + private val toolUseBlock: ToolUseBlock? = null, + private val _json: JsonValue? = null, +) { + + fun browser(): Optional = Optional.ofNullable(browser) + + fun computer(): Optional = Optional.ofNullable(computer) + + fun toolUseBlock(): Optional = Optional.ofNullable(toolUseBlock) + + fun isBrowser(): Boolean = browser != null + + fun isComputer(): Boolean = computer != null + + fun isToolUseBlock(): Boolean = toolUseBlock != null + + fun asBrowser(): BrowserToolUseBlock = browser.getOrThrow("browser") + + fun asComputer(): ComputerToolUseBlock = computer.getOrThrow("computer") + + fun asToolUseBlock(): ToolUseBlock = toolUseBlock.getOrThrow("toolUseBlock") + + 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 = toolsetToolUseBlock.accept(new ToolsetToolUseBlock.Visitor>() { + * @Override + * public Optional visitBrowser(BrowserToolUseBlock browser) { + * return Optional.of(browser.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 { + browser != null -> visitor.visitBrowser(browser) + computer != null -> visitor.visitComputer(computer) + toolUseBlock != null -> visitor.visitToolUseBlock(toolUseBlock) + 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(): ToolsetToolUseBlock = apply { + if (validated) { + return@apply + } + + when { + browser != null -> browser.validate() + computer != null -> computer.validate() + toolUseBlock != null -> toolUseBlock.validate() + else -> throw AnthropicInvalidDataException("Unknown ToolsetToolUseBlock: $_json") + } + 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 = + when { + browser != null -> browser.validity() + computer != null -> computer.validity() + toolUseBlock != null -> toolUseBlock.validity() + else -> 0 + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ToolsetToolUseBlock && + browser == other.browser && + computer == other.computer && + toolUseBlock == other.toolUseBlock + } + + override fun hashCode(): Int = Objects.hash(browser, computer, toolUseBlock) + + override fun toString(): String = + when { + browser != null -> "ToolsetToolUseBlock{browser=$browser}" + computer != null -> "ToolsetToolUseBlock{computer=$computer}" + toolUseBlock != null -> "ToolsetToolUseBlock{toolUseBlock=$toolUseBlock}" + _json != null -> "ToolsetToolUseBlock{_unknown=$_json}" + else -> throw IllegalStateException("Invalid ToolsetToolUseBlock") + } + + companion object { + + @JvmStatic + fun ofBrowser(browser: BrowserToolUseBlock) = ToolsetToolUseBlock(browser = browser) + + @JvmStatic + fun ofComputer(computer: ComputerToolUseBlock) = ToolsetToolUseBlock(computer = computer) + + @JvmStatic + fun ofToolUseBlock(toolUseBlock: ToolUseBlock) = + ToolsetToolUseBlock(toolUseBlock = toolUseBlock) + } + + /** + * An interface that defines how to map each variant of [ToolsetToolUseBlock] to a value of type + * [T]. + */ + interface Visitor { + + fun visitBrowser(browser: BrowserToolUseBlock): T + + fun visitComputer(computer: ComputerToolUseBlock): T + + fun visitToolUseBlock(toolUseBlock: ToolUseBlock): T + + /** + * Maps an unknown variant of [ToolsetToolUseBlock] to a value of type [T]. + * + * An instance of [ToolsetToolUseBlock] 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 ToolsetToolUseBlock: $json") + } + } + + internal class Deserializer : + BaseDeserializer(ToolsetToolUseBlock::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): ToolsetToolUseBlock { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + ToolsetToolUseBlock(browser = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ToolsetToolUseBlock(computer = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + ToolsetToolUseBlock(toolUseBlock = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> ToolsetToolUseBlock(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(ToolsetToolUseBlock::class) { + + override fun serialize( + value: ToolsetToolUseBlock, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.browser != null -> generator.writeObject(value.browser) + value.computer != null -> generator.writeObject(value.computer) + value.toolUseBlock != null -> generator.writeObject(value.toolUseBlock) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid ToolsetToolUseBlock") + } + } + } +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelCapabilities.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelCapabilities.kt index 1ce6a8c72..3bab0cf7d 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelCapabilities.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelCapabilities.kt @@ -25,6 +25,7 @@ private constructor( private val effort: JsonField, private val imageInput: JsonField, private val pdfInput: JsonField, + private val serverTools: JsonField, private val structuredOutputs: JsonField, private val thinking: JsonField, private val additionalProperties: MutableMap, @@ -53,6 +54,9 @@ private constructor( @JsonProperty("pdf_input") @ExcludeMissing pdfInput: JsonField = JsonMissing.of(), + @JsonProperty("server_tools") + @ExcludeMissing + serverTools: JsonField = JsonMissing.of(), @JsonProperty("structured_outputs") @ExcludeMissing structuredOutputs: JsonField = JsonMissing.of(), @@ -67,6 +71,7 @@ private constructor( effort, imageInput, pdfInput, + serverTools, structuredOutputs, thinking, mutableMapOf(), @@ -89,7 +94,9 @@ private constructor( fun citations(): CapabilitySupport = citations.getRequired("citations") /** - * Whether the model supports code execution tools. + * Whether code that the model runs in the code execution tool can call the request's other + * tools, as in programmatic tool calling and dynamic filtering for web search and web fetch. + * Support for the code execution tool itself is in `server_tools.code_execution`. * * @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). @@ -129,6 +136,16 @@ private constructor( */ fun pdfInput(): CapabilitySupport = pdfInput.getRequired("pdf_input") + /** + * Whether this model supports the web search and code execution server tools. `supported` is + * true when the model supports at least one of the tools. A supported tool can still be + * rejected for your organization, for example when an admin has turned web search off. + * + * @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 serverTools(): ServerToolsCapability = serverTools.getRequired("server_tools") + /** * Whether the model supports structured output / JSON mode / strict tool schemas. * @@ -205,6 +222,15 @@ private constructor( @ExcludeMissing fun _pdfInput(): JsonField = pdfInput + /** + * Returns the raw JSON value of [serverTools]. + * + * Unlike [serverTools], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("server_tools") + @ExcludeMissing + fun _serverTools(): JsonField = serverTools + /** * Returns the raw JSON value of [structuredOutputs]. * @@ -250,6 +276,7 @@ private constructor( * .effort() * .imageInput() * .pdfInput() + * .serverTools() * .structuredOutputs() * .thinking() * ``` @@ -267,6 +294,7 @@ private constructor( private var effort: JsonField? = null private var imageInput: JsonField? = null private var pdfInput: JsonField? = null + private var serverTools: JsonField? = null private var structuredOutputs: JsonField? = null private var thinking: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -280,6 +308,7 @@ private constructor( effort = modelCapabilities.effort imageInput = modelCapabilities.imageInput pdfInput = modelCapabilities.pdfInput + serverTools = modelCapabilities.serverTools structuredOutputs = modelCapabilities.structuredOutputs thinking = modelCapabilities.thinking additionalProperties = modelCapabilities.additionalProperties.toMutableMap() @@ -311,7 +340,11 @@ private constructor( this.citations = citations } - /** Whether the model supports code execution tools. */ + /** + * Whether code that the model runs in the code execution tool can call the request's other + * tools, as in programmatic tool calling and dynamic filtering for web search and web + * fetch. Support for the code execution tool itself is in `server_tools.code_execution`. + */ fun codeExecution(codeExecution: CapabilitySupport) = codeExecution(JsonField.of(codeExecution)) @@ -379,6 +412,24 @@ private constructor( */ fun pdfInput(pdfInput: JsonField) = apply { this.pdfInput = pdfInput } + /** + * Whether this model supports the web search and code execution server tools. `supported` + * is true when the model supports at least one of the tools. A supported tool can still be + * rejected for your organization, for example when an admin has turned web search off. + */ + fun serverTools(serverTools: ServerToolsCapability) = serverTools(JsonField.of(serverTools)) + + /** + * Sets [Builder.serverTools] to an arbitrary JSON value. + * + * You should usually call [Builder.serverTools] with a well-typed [ServerToolsCapability] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serverTools(serverTools: JsonField) = apply { + this.serverTools = serverTools + } + /** Whether the model supports structured output / JSON mode / strict tool schemas. */ fun structuredOutputs(structuredOutputs: CapabilitySupport) = structuredOutputs(JsonField.of(structuredOutputs)) @@ -439,6 +490,7 @@ private constructor( * .effort() * .imageInput() * .pdfInput() + * .serverTools() * .structuredOutputs() * .thinking() * ``` @@ -454,6 +506,7 @@ private constructor( checkRequired("effort", effort), checkRequired("imageInput", imageInput), checkRequired("pdfInput", pdfInput), + checkRequired("serverTools", serverTools), checkRequired("structuredOutputs", structuredOutputs), checkRequired("thinking", thinking), additionalProperties.toMutableMap(), @@ -482,6 +535,7 @@ private constructor( effort().validate() imageInput().validate() pdfInput().validate() + serverTools().validate() structuredOutputs().validate() thinking().validate() validated = true @@ -509,6 +563,7 @@ private constructor( (effort.asKnown().getOrNull()?.validity() ?: 0) + (imageInput.asKnown().getOrNull()?.validity() ?: 0) + (pdfInput.asKnown().getOrNull()?.validity() ?: 0) + + (serverTools.asKnown().getOrNull()?.validity() ?: 0) + (structuredOutputs.asKnown().getOrNull()?.validity() ?: 0) + (thinking.asKnown().getOrNull()?.validity() ?: 0) @@ -525,6 +580,7 @@ private constructor( effort == other.effort && imageInput == other.imageInput && pdfInput == other.pdfInput && + serverTools == other.serverTools && structuredOutputs == other.structuredOutputs && thinking == other.thinking && additionalProperties == other.additionalProperties @@ -539,6 +595,7 @@ private constructor( effort, imageInput, pdfInput, + serverTools, structuredOutputs, thinking, additionalProperties, @@ -548,5 +605,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ModelCapabilities{batch=$batch, citations=$citations, codeExecution=$codeExecution, contextManagement=$contextManagement, effort=$effort, imageInput=$imageInput, pdfInput=$pdfInput, structuredOutputs=$structuredOutputs, thinking=$thinking, additionalProperties=$additionalProperties}" + "ModelCapabilities{batch=$batch, citations=$citations, codeExecution=$codeExecution, contextManagement=$contextManagement, effort=$effort, imageInput=$imageInput, pdfInput=$pdfInput, serverTools=$serverTools, structuredOutputs=$structuredOutputs, thinking=$thinking, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelInfo.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelInfo.kt index abfe1f5d2..811975d38 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelInfo.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelInfo.kt @@ -1,5 +1,6 @@ package com.anthropic.models.models +import com.anthropic.core.Enum import com.anthropic.core.ExcludeMissing import com.anthropic.core.JsonField import com.anthropic.core.JsonMissing @@ -22,9 +23,13 @@ private constructor( private val id: JsonField, private val capabilities: JsonField, private val createdAt: JsonField, + private val deprecatedAt: JsonField, private val displayName: JsonField, + private val lifecycle: JsonField, + private val line: JsonField, private val maxInputTokens: JsonField, private val maxTokens: JsonField, + private val retiresAt: JsonField, private val type: JsonValue, private val additionalProperties: MutableMap, ) { @@ -38,21 +43,35 @@ private constructor( @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), + @JsonProperty("deprecated_at") + @ExcludeMissing + deprecatedAt: JsonField = JsonMissing.of(), @JsonProperty("display_name") @ExcludeMissing displayName: JsonField = JsonMissing.of(), + @JsonProperty("lifecycle") + @ExcludeMissing + lifecycle: JsonField = JsonMissing.of(), + @JsonProperty("line") @ExcludeMissing line: JsonField = JsonMissing.of(), @JsonProperty("max_input_tokens") @ExcludeMissing maxInputTokens: JsonField = JsonMissing.of(), @JsonProperty("max_tokens") @ExcludeMissing maxTokens: JsonField = JsonMissing.of(), + @JsonProperty("retires_at") + @ExcludeMissing + retiresAt: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonValue = JsonMissing.of(), ) : this( id, capabilities, createdAt, + deprecatedAt, displayName, + lifecycle, + line, maxInputTokens, maxTokens, + retiresAt, type, mutableMapOf(), ) @@ -83,6 +102,15 @@ private constructor( */ fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + /** + * RFC 3339 datetime string representing the time of the model's most recent deprecation. + * Populated for `deprecated` and `retired` models; `null` while the model is `active`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deprecatedAt(): Optional = deprecatedAt.getOptional("deprecated_at") + /** * A human-readable name for the model. * @@ -91,6 +119,30 @@ private constructor( */ fun displayName(): String = displayName.getRequired("display_name") + /** + * The model's current lifecycle stage. + * - `active`: The model is available for use, open to new adopters, and not scheduled for + * retirement. + * - `deprecated`: The model remains callable for organizations with existing access, but is + * headed for retirement and closed to new adopters. + * - `retired`: The model is no longer available for use; inference requests naming it fail. It + * remains in the catalogue as the historical record of its retirement. + * + * @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 lifecycle(): Lifecycle = lifecycle.getRequired("lifecycle") + + /** + * The model line this model belongs to, such as `opus` for both Claude Opus 4.5 and Claude Opus + * 4.6. More lines may be added. `null` when the model belongs to no line; do not infer a line + * from the `id`. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun line(): Optional = line.getOptional("line") + /** * Maximum input context window size in tokens for this model. * @@ -107,6 +159,17 @@ private constructor( */ fun maxTokens(): Optional = maxTokens.getOptional("max_tokens") + /** + * RFC 3339 datetime string representing the model's currently scheduled retirement date. The + * schedule can be revised until retirement occurs; `null` while the model is `active` or while + * no retirement is scheduled. A past date on a `deprecated` model means retirement is overdue, + * not that it has occurred: `lifecycle` is the retirement signal. + * + * @throws AnthropicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun retiresAt(): Optional = retiresAt.getOptional("retires_at") + /** * Object type. * @@ -147,6 +210,15 @@ private constructor( @ExcludeMissing fun _createdAt(): JsonField = createdAt + /** + * Returns the raw JSON value of [deprecatedAt]. + * + * Unlike [deprecatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("deprecated_at") + @ExcludeMissing + fun _deprecatedAt(): JsonField = deprecatedAt + /** * Returns the raw JSON value of [displayName]. * @@ -156,6 +228,20 @@ private constructor( @ExcludeMissing fun _displayName(): JsonField = displayName + /** + * Returns the raw JSON value of [lifecycle]. + * + * Unlike [lifecycle], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("lifecycle") @ExcludeMissing fun _lifecycle(): JsonField = lifecycle + + /** + * Returns the raw JSON value of [line]. + * + * Unlike [line], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("line") @ExcludeMissing fun _line(): JsonField = line + /** * Returns the raw JSON value of [maxInputTokens]. * @@ -172,6 +258,15 @@ private constructor( */ @JsonProperty("max_tokens") @ExcludeMissing fun _maxTokens(): JsonField = maxTokens + /** + * Returns the raw JSON value of [retiresAt]. + * + * Unlike [retiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("retires_at") + @ExcludeMissing + fun _retiresAt(): JsonField = retiresAt + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -194,9 +289,13 @@ private constructor( * .id() * .capabilities() * .createdAt() + * .deprecatedAt() * .displayName() + * .lifecycle() + * .line() * .maxInputTokens() * .maxTokens() + * .retiresAt() * ``` */ @JvmStatic fun builder() = Builder() @@ -208,9 +307,13 @@ private constructor( private var id: JsonField? = null private var capabilities: JsonField? = null private var createdAt: JsonField? = null + private var deprecatedAt: JsonField? = null private var displayName: JsonField? = null + private var lifecycle: JsonField? = null + private var line: JsonField? = null private var maxInputTokens: JsonField? = null private var maxTokens: JsonField? = null + private var retiresAt: JsonField? = null private var type: JsonValue = JsonValue.from("model") private var additionalProperties: MutableMap = mutableMapOf() @@ -219,9 +322,13 @@ private constructor( id = modelInfo.id capabilities = modelInfo.capabilities createdAt = modelInfo.createdAt + deprecatedAt = modelInfo.deprecatedAt displayName = modelInfo.displayName + lifecycle = modelInfo.lifecycle + line = modelInfo.line maxInputTokens = modelInfo.maxInputTokens maxTokens = modelInfo.maxTokens + retiresAt = modelInfo.retiresAt type = modelInfo.type additionalProperties = modelInfo.additionalProperties.toMutableMap() } @@ -274,6 +381,28 @@ private constructor( */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + /** + * RFC 3339 datetime string representing the time of the model's most recent deprecation. + * Populated for `deprecated` and `retired` models; `null` while the model is `active`. + */ + fun deprecatedAt(deprecatedAt: OffsetDateTime?) = + deprecatedAt(JsonField.ofNullable(deprecatedAt)) + + /** Alias for calling [Builder.deprecatedAt] with `deprecatedAt.orElse(null)`. */ + fun deprecatedAt(deprecatedAt: Optional) = + deprecatedAt(deprecatedAt.getOrNull()) + + /** + * Sets [Builder.deprecatedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.deprecatedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deprecatedAt(deprecatedAt: JsonField) = apply { + this.deprecatedAt = deprecatedAt + } + /** A human-readable name for the model. */ fun displayName(displayName: String) = displayName(JsonField.of(displayName)) @@ -286,6 +415,44 @@ private constructor( */ fun displayName(displayName: JsonField) = apply { this.displayName = displayName } + /** + * The model's current lifecycle stage. + * - `active`: The model is available for use, open to new adopters, and not scheduled for + * retirement. + * - `deprecated`: The model remains callable for organizations with existing access, but is + * headed for retirement and closed to new adopters. + * - `retired`: The model is no longer available for use; inference requests naming it fail. + * It remains in the catalogue as the historical record of its retirement. + */ + fun lifecycle(lifecycle: Lifecycle) = lifecycle(JsonField.of(lifecycle)) + + /** + * Sets [Builder.lifecycle] to an arbitrary JSON value. + * + * You should usually call [Builder.lifecycle] with a well-typed [Lifecycle] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun lifecycle(lifecycle: JsonField) = apply { this.lifecycle = lifecycle } + + /** + * The model line this model belongs to, such as `opus` for both Claude Opus 4.5 and Claude + * Opus 4.6. More lines may be added. `null` when the model belongs to no line; do not infer + * a line from the `id`. + */ + fun line(line: ModelLine?) = line(JsonField.ofNullable(line)) + + /** Alias for calling [Builder.line] with `line.orElse(null)`. */ + fun line(line: Optional) = line(line.getOrNull()) + + /** + * Sets [Builder.line] to an arbitrary JSON value. + * + * You should usually call [Builder.line] with a well-typed [ModelLine] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun line(line: JsonField) = apply { this.line = line } + /** Maximum input context window size in tokens for this model. */ fun maxInputTokens(maxInputTokens: Long?) = maxInputTokens(JsonField.ofNullable(maxInputTokens)) @@ -333,6 +500,26 @@ private constructor( */ fun maxTokens(maxTokens: JsonField) = apply { this.maxTokens = maxTokens } + /** + * RFC 3339 datetime string representing the model's currently scheduled retirement date. + * The schedule can be revised until retirement occurs; `null` while the model is `active` + * or while no retirement is scheduled. A past date on a `deprecated` model means retirement + * is overdue, not that it has occurred: `lifecycle` is the retirement signal. + */ + fun retiresAt(retiresAt: OffsetDateTime?) = retiresAt(JsonField.ofNullable(retiresAt)) + + /** Alias for calling [Builder.retiresAt] with `retiresAt.orElse(null)`. */ + fun retiresAt(retiresAt: Optional) = retiresAt(retiresAt.getOrNull()) + + /** + * Sets [Builder.retiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.retiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun retiresAt(retiresAt: JsonField) = apply { this.retiresAt = retiresAt } + /** * Sets the field to an arbitrary JSON value. * @@ -376,9 +563,13 @@ private constructor( * .id() * .capabilities() * .createdAt() + * .deprecatedAt() * .displayName() + * .lifecycle() + * .line() * .maxInputTokens() * .maxTokens() + * .retiresAt() * ``` * * @throws IllegalStateException if any required field is unset. @@ -388,9 +579,13 @@ private constructor( checkRequired("id", id), checkRequired("capabilities", capabilities), checkRequired("createdAt", createdAt), + checkRequired("deprecatedAt", deprecatedAt), checkRequired("displayName", displayName), + checkRequired("lifecycle", lifecycle), + checkRequired("line", line), checkRequired("maxInputTokens", maxInputTokens), checkRequired("maxTokens", maxTokens), + checkRequired("retiresAt", retiresAt), type, additionalProperties.toMutableMap(), ) @@ -414,9 +609,13 @@ private constructor( id() capabilities().ifPresent { it.validate() } createdAt() + deprecatedAt() displayName() + lifecycle().validate() + line().ifPresent { it.validate() } maxInputTokens() maxTokens() + retiresAt() _type().let { if (it != JsonValue.from("model")) { throw AnthropicInvalidDataException("'type' is invalid, received $it") @@ -443,11 +642,181 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (capabilities.asKnown().getOrNull()?.validity() ?: 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (deprecatedAt.asKnown().isPresent) 1 else 0) + (if (displayName.asKnown().isPresent) 1 else 0) + + (lifecycle.asKnown().getOrNull()?.validity() ?: 0) + + (line.asKnown().getOrNull()?.validity() ?: 0) + (if (maxInputTokens.asKnown().isPresent) 1 else 0) + (if (maxTokens.asKnown().isPresent) 1 else 0) + + (if (retiresAt.asKnown().isPresent) 1 else 0) + type.let { if (it == JsonValue.from("model")) 1 else 0 } + /** + * The model's current lifecycle stage. + * - `active`: The model is available for use, open to new adopters, and not scheduled for + * retirement. + * - `deprecated`: The model remains callable for organizations with existing access, but is + * headed for retirement and closed to new adopters. + * - `retired`: The model is no longer available for use; inference requests naming it fail. It + * remains in the catalogue as the historical record of its retirement. + */ + class Lifecycle 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 ACTIVE = Lifecycle(JsonField.of("active")) + + @JvmField val DEPRECATED = Lifecycle(JsonField.of("deprecated")) + + @JvmField val RETIRED = Lifecycle(JsonField.of("retired")) + + @JvmStatic + fun of(value: String): Lifecycle = + // Intern known values so `==` works + when (value) { + "active" -> ACTIVE + "deprecated" -> DEPRECATED + "retired" -> RETIRED + else -> Lifecycle(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Lifecycle = + value.asString().getOrNull()?.let { of(it) } ?: Lifecycle(value) + } + + /** An enum containing [Lifecycle]'s known values. */ + enum class Known { + ACTIVE, + DEPRECATED, + RETIRED, + } + + /** + * An enum containing [Lifecycle]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Lifecycle] 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 { + ACTIVE, + DEPRECATED, + RETIRED, + /** + * An enum member indicating that [Lifecycle] 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) { + ACTIVE -> Value.ACTIVE + DEPRECATED -> Value.DEPRECATED + RETIRED -> Value.RETIRED + 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) { + ACTIVE -> Known.ACTIVE + DEPRECATED -> Known.DEPRECATED + RETIRED -> Known.RETIRED + else -> throw AnthropicInvalidDataException("Unknown Lifecycle: $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(): Lifecycle = 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 Lifecycle && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -457,9 +826,13 @@ private constructor( id == other.id && capabilities == other.capabilities && createdAt == other.createdAt && + deprecatedAt == other.deprecatedAt && displayName == other.displayName && + lifecycle == other.lifecycle && + line == other.line && maxInputTokens == other.maxInputTokens && maxTokens == other.maxTokens && + retiresAt == other.retiresAt && type == other.type && additionalProperties == other.additionalProperties } @@ -469,9 +842,13 @@ private constructor( id, capabilities, createdAt, + deprecatedAt, displayName, + lifecycle, + line, maxInputTokens, maxTokens, + retiresAt, type, additionalProperties, ) @@ -480,5 +857,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ModelInfo{id=$id, capabilities=$capabilities, createdAt=$createdAt, displayName=$displayName, maxInputTokens=$maxInputTokens, maxTokens=$maxTokens, type=$type, additionalProperties=$additionalProperties}" + "ModelInfo{id=$id, capabilities=$capabilities, createdAt=$createdAt, deprecatedAt=$deprecatedAt, displayName=$displayName, lifecycle=$lifecycle, line=$line, maxInputTokens=$maxInputTokens, maxTokens=$maxTokens, retiresAt=$retiresAt, type=$type, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelLine.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelLine.kt new file mode 100644 index 000000000..58a102846 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelLine.kt @@ -0,0 +1,171 @@ +package com.anthropic.models.models + +import com.anthropic.core.Enum +import com.anthropic.core.JsonField +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator +import kotlin.jvm.optionals.getOrNull + +/** A Claude model line, such as `opus` or `sonnet`. More lines may be added as new values. */ +class ModelLine 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 HAIKU = ModelLine(JsonField.of("haiku")) + + @JvmField val SONNET = ModelLine(JsonField.of("sonnet")) + + @JvmField val OPUS = ModelLine(JsonField.of("opus")) + + @JvmField val FABLE = ModelLine(JsonField.of("fable")) + + @JvmField val MYTHOS = ModelLine(JsonField.of("mythos")) + + @JvmStatic + fun of(value: String): ModelLine = + // Intern known values so `==` works + when (value) { + "haiku" -> HAIKU + "sonnet" -> SONNET + "opus" -> OPUS + "fable" -> FABLE + "mythos" -> MYTHOS + else -> ModelLine(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): ModelLine = + value.asString().getOrNull()?.let { of(it) } ?: ModelLine(value) + } + + /** An enum containing [ModelLine]'s known values. */ + enum class Known { + HAIKU, + SONNET, + OPUS, + FABLE, + MYTHOS, + } + + /** + * An enum containing [ModelLine]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ModelLine] 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 { + HAIKU, + SONNET, + OPUS, + FABLE, + MYTHOS, + /** An enum member indicating that [ModelLine] 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) { + HAIKU -> Value.HAIKU + SONNET -> Value.SONNET + OPUS -> Value.OPUS + FABLE -> Value.FABLE + MYTHOS -> Value.MYTHOS + 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) { + HAIKU -> Known.HAIKU + SONNET -> Known.SONNET + OPUS -> Known.OPUS + FABLE -> Known.FABLE + MYTHOS -> Known.MYTHOS + else -> throw AnthropicInvalidDataException("Unknown ModelLine: $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(): ModelLine = 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 ModelLine && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelListParams.kt index 04cb96e46..a58c7ecf4 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelListParams.kt @@ -1,10 +1,14 @@ package com.anthropic.models.models +import com.anthropic.core.Enum +import com.anthropic.core.JsonField import com.anthropic.core.Params import com.anthropic.core.http.Headers import com.anthropic.core.http.QueryParams import com.anthropic.core.toImmutable +import com.anthropic.errors.AnthropicInvalidDataException import com.anthropic.models.beta.AnthropicBeta +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -19,6 +23,7 @@ class ModelListParams private constructor( private val afterId: String?, private val beforeId: String?, + private val lifecycle: List?, private val limit: Long?, private val betas: List?, private val workspaceId: String?, @@ -38,6 +43,13 @@ private constructor( */ fun beforeId(): Optional = Optional.ofNullable(beforeId) + /** + * Filter the list to models in any of the given lifecycle stages (`active`, `deprecated`, or + * `retired`). Up to 3 values. When omitted, the list contains the `active` and `deprecated` + * models; `retired` models appear only when `retired` is requested explicitly. + */ + fun lifecycle(): Optional> = Optional.ofNullable(lifecycle) + /** * Number of items to return per page. * @@ -81,6 +93,7 @@ private constructor( private var afterId: String? = null private var beforeId: String? = null + private var lifecycle: MutableList? = null private var limit: Long? = null private var betas: MutableList? = null private var workspaceId: String? = null @@ -91,6 +104,7 @@ private constructor( internal fun from(modelListParams: ModelListParams) = apply { afterId = modelListParams.afterId beforeId = modelListParams.beforeId + lifecycle = modelListParams.lifecycle?.toMutableList() limit = modelListParams.limit betas = modelListParams.betas?.toMutableList() workspaceId = modelListParams.workspaceId @@ -116,6 +130,27 @@ private constructor( /** Alias for calling [Builder.beforeId] with `beforeId.orElse(null)`. */ fun beforeId(beforeId: Optional) = beforeId(beforeId.getOrNull()) + /** + * Filter the list to models in any of the given lifecycle stages (`active`, `deprecated`, + * or `retired`). Up to 3 values. When omitted, the list contains the `active` and + * `deprecated` models; `retired` models appear only when `retired` is requested explicitly. + */ + fun lifecycle(lifecycle: List?) = apply { + this.lifecycle = lifecycle?.toMutableList() + } + + /** Alias for calling [Builder.lifecycle] with `lifecycle.orElse(null)`. */ + fun lifecycle(lifecycle: Optional>) = lifecycle(lifecycle.getOrNull()) + + /** + * Adds a single [Lifecycle] to [Builder.lifecycle]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLifecycle(lifecycle: Lifecycle) = apply { + this.lifecycle = (this.lifecycle ?: mutableListOf()).apply { add(lifecycle) } + } + /** * Number of items to return per page. * @@ -288,6 +323,7 @@ private constructor( ModelListParams( afterId, beforeId, + lifecycle?.toImmutable(), limit, betas?.toImmutable(), workspaceId, @@ -299,7 +335,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } @@ -310,11 +350,169 @@ private constructor( .apply { afterId?.let { put("after_id", it) } beforeId?.let { put("before_id", it) } + lifecycle?.forEach { put("lifecycle[]", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) } .build() + class Lifecycle 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 ACTIVE = Lifecycle(JsonField.of("active")) + + @JvmField val DEPRECATED = Lifecycle(JsonField.of("deprecated")) + + @JvmField val RETIRED = Lifecycle(JsonField.of("retired")) + + @JvmStatic + fun of(value: String): Lifecycle = + // Intern known values so `==` works + when (value) { + "active" -> ACTIVE + "deprecated" -> DEPRECATED + "retired" -> RETIRED + else -> Lifecycle(JsonField.of(value)) + } + + @JsonCreator + @JvmStatic + fun of(value: JsonField): Lifecycle = + value.asString().getOrNull()?.let { of(it) } ?: Lifecycle(value) + } + + /** An enum containing [Lifecycle]'s known values. */ + enum class Known { + ACTIVE, + DEPRECATED, + RETIRED, + } + + /** + * An enum containing [Lifecycle]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Lifecycle] 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 { + ACTIVE, + DEPRECATED, + RETIRED, + /** + * An enum member indicating that [Lifecycle] 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) { + ACTIVE -> Value.ACTIVE + DEPRECATED -> Value.DEPRECATED + RETIRED -> Value.RETIRED + 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) { + ACTIVE -> Known.ACTIVE + DEPRECATED -> Known.DEPRECATED + RETIRED -> Known.RETIRED + else -> throw AnthropicInvalidDataException("Unknown Lifecycle: $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(): Lifecycle = 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 Lifecycle && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -323,6 +521,7 @@ private constructor( return other is ModelListParams && afterId == other.afterId && beforeId == other.beforeId && + lifecycle == other.lifecycle && limit == other.limit && betas == other.betas && workspaceId == other.workspaceId && @@ -334,6 +533,7 @@ private constructor( Objects.hash( afterId, beforeId, + lifecycle, limit, betas, workspaceId, @@ -342,5 +542,5 @@ private constructor( ) override fun toString() = - "ModelListParams{afterId=$afterId, beforeId=$beforeId, limit=$limit, betas=$betas, workspaceId=$workspaceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ModelListParams{afterId=$afterId, beforeId=$beforeId, lifecycle=$lifecycle, limit=$limit, betas=$betas, workspaceId=$workspaceId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelRetrieveParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelRetrieveParams.kt index 2909a607d..de78d5b9e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelRetrieveParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ModelRetrieveParams.kt @@ -252,7 +252,11 @@ private constructor( override fun _headers(): Headers = Headers.builder() .apply { - betas?.forEach { put("anthropic-beta", it.toString()) } + betas?.let { + if (it.isNotEmpty()) { + put("anthropic-beta", it.joinToString(",")) + } + } workspaceId?.let { put("anthropic-workspace-id", it) } putAll(additionalHeaders) } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ServerToolsCapability.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ServerToolsCapability.kt new file mode 100644 index 000000000..0db1e0ec2 --- /dev/null +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ServerToolsCapability.kt @@ -0,0 +1,281 @@ +package com.anthropic.models.models + +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 + +/** Web search and code execution tool support, with one entry per tool. */ +class ServerToolsCapability +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val codeExecution: JsonField, + private val supported: JsonField, + private val webSearch: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code_execution") + @ExcludeMissing + codeExecution: JsonField = JsonMissing.of(), + @JsonProperty("supported") @ExcludeMissing supported: JsonField = JsonMissing.of(), + @JsonProperty("web_search") + @ExcludeMissing + webSearch: JsonField = JsonMissing.of(), + ) : this(codeExecution, supported, webSearch, mutableMapOf()) + + /** + * Whether the model supports the code execution tool: true when the model supports at least one + * version of the tool, not necessarily every 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 codeExecution(): CapabilitySupport = codeExecution.getRequired("code_execution") + + /** + * Whether this capability is supported by the model. + * + * @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 supported(): Boolean = supported.getRequired("supported") + + /** + * Whether the model supports the web search tool: true when the model supports at least one + * version of the tool, not necessarily every 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 webSearch(): CapabilitySupport = webSearch.getRequired("web_search") + + /** + * Returns the raw JSON value of [codeExecution]. + * + * Unlike [codeExecution], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code_execution") + @ExcludeMissing + fun _codeExecution(): JsonField = codeExecution + + /** + * Returns the raw JSON value of [supported]. + * + * Unlike [supported], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("supported") @ExcludeMissing fun _supported(): JsonField = supported + + /** + * Returns the raw JSON value of [webSearch]. + * + * Unlike [webSearch], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("web_search") + @ExcludeMissing + fun _webSearch(): JsonField = webSearch + + @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 [ServerToolsCapability]. + * + * The following fields are required: + * ```java + * .codeExecution() + * .supported() + * .webSearch() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ServerToolsCapability]. */ + class Builder internal constructor() { + + private var codeExecution: JsonField? = null + private var supported: JsonField? = null + private var webSearch: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(serverToolsCapability: ServerToolsCapability) = apply { + codeExecution = serverToolsCapability.codeExecution + supported = serverToolsCapability.supported + webSearch = serverToolsCapability.webSearch + additionalProperties = serverToolsCapability.additionalProperties.toMutableMap() + } + + /** + * Whether the model supports the code execution tool: true when the model supports at least + * one version of the tool, not necessarily every version. + */ + fun codeExecution(codeExecution: CapabilitySupport) = + codeExecution(JsonField.of(codeExecution)) + + /** + * Sets [Builder.codeExecution] to an arbitrary JSON value. + * + * You should usually call [Builder.codeExecution] with a well-typed [CapabilitySupport] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun codeExecution(codeExecution: JsonField) = apply { + this.codeExecution = codeExecution + } + + /** Whether this capability is supported by the model. */ + fun supported(supported: Boolean) = supported(JsonField.of(supported)) + + /** + * Sets [Builder.supported] to an arbitrary JSON value. + * + * You should usually call [Builder.supported] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun supported(supported: JsonField) = apply { this.supported = supported } + + /** + * Whether the model supports the web search tool: true when the model supports at least one + * version of the tool, not necessarily every version. + */ + fun webSearch(webSearch: CapabilitySupport) = webSearch(JsonField.of(webSearch)) + + /** + * Sets [Builder.webSearch] to an arbitrary JSON value. + * + * You should usually call [Builder.webSearch] with a well-typed [CapabilitySupport] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webSearch(webSearch: JsonField) = apply { + this.webSearch = webSearch + } + + 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 [ServerToolsCapability]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .codeExecution() + * .supported() + * .webSearch() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ServerToolsCapability = + ServerToolsCapability( + checkRequired("codeExecution", codeExecution), + checkRequired("supported", supported), + checkRequired("webSearch", webSearch), + 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(): ServerToolsCapability = apply { + if (validated) { + return@apply + } + + codeExecution().validate() + supported() + webSearch().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 = + (codeExecution.asKnown().getOrNull()?.validity() ?: 0) + + (if (supported.asKnown().isPresent) 1 else 0) + + (webSearch.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ServerToolsCapability && + codeExecution == other.codeExecution && + supported == other.supported && + webSearch == other.webSearch && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(codeExecution, supported, webSearch, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ServerToolsCapability{codeExecution=$codeExecution, supported=$supported, webSearch=$webSearch, additionalProperties=$additionalProperties}" +} diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ThinkingTypes.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ThinkingTypes.kt index 9243a8501..31375fa2e 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ThinkingTypes.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/models/ThinkingTypes.kt @@ -14,11 +14,15 @@ import java.util.Collections import java.util.Objects import kotlin.jvm.optionals.getOrNull -/** Supported thinking type configurations. */ +/** + * Which `thinking.type` values the model accepts on requests. Read each key on its own: for + * example, `enabled` can be false while `disabled` is true. + */ class ThinkingTypes @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val adaptive: JsonField, + private val disabled: JsonField, private val enabled: JsonField, private val additionalProperties: MutableMap, ) { @@ -28,13 +32,17 @@ private constructor( @JsonProperty("adaptive") @ExcludeMissing adaptive: JsonField = JsonMissing.of(), + @JsonProperty("disabled") + @ExcludeMissing + disabled: JsonField = JsonMissing.of(), @JsonProperty("enabled") @ExcludeMissing enabled: JsonField = JsonMissing.of(), - ) : this(adaptive, enabled, mutableMapOf()) + ) : this(adaptive, disabled, enabled, mutableMapOf()) /** - * Whether the model supports thinking with type 'adaptive' (auto). + * Whether the model accepts thinking with type 'adaptive' (the model decides whether and how + * much to think). * * @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). @@ -42,7 +50,18 @@ private constructor( fun adaptive(): CapabilitySupport = adaptive.getRequired("adaptive") /** - * Whether the model supports thinking with type 'enabled'. + * Whether the model accepts thinking with type 'disabled' (thinking turned off). False exactly + * when a request that sends it gets a 400 from this model. True on a model that does not + * support thinking. + * + * @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 disabled(): CapabilitySupport = disabled.getRequired("disabled") + + /** + * Whether the model accepts thinking with type 'enabled' (extended thinking with a caller-set + * `budget_tokens`). * * @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). @@ -58,6 +77,15 @@ private constructor( @ExcludeMissing fun _adaptive(): JsonField = adaptive + /** + * Returns the raw JSON value of [disabled]. + * + * Unlike [disabled], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disabled") + @ExcludeMissing + fun _disabled(): JsonField = disabled + /** * Returns the raw JSON value of [enabled]. * @@ -85,6 +113,7 @@ private constructor( * The following fields are required: * ```java * .adaptive() + * .disabled() * .enabled() * ``` */ @@ -95,17 +124,22 @@ private constructor( class Builder internal constructor() { private var adaptive: JsonField? = null + private var disabled: JsonField? = null private var enabled: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(thinkingTypes: ThinkingTypes) = apply { adaptive = thinkingTypes.adaptive + disabled = thinkingTypes.disabled enabled = thinkingTypes.enabled additionalProperties = thinkingTypes.additionalProperties.toMutableMap() } - /** Whether the model supports thinking with type 'adaptive' (auto). */ + /** + * Whether the model accepts thinking with type 'adaptive' (the model decides whether and + * how much to think). + */ fun adaptive(adaptive: CapabilitySupport) = adaptive(JsonField.of(adaptive)) /** @@ -117,7 +151,26 @@ private constructor( */ fun adaptive(adaptive: JsonField) = apply { this.adaptive = adaptive } - /** Whether the model supports thinking with type 'enabled'. */ + /** + * Whether the model accepts thinking with type 'disabled' (thinking turned off). False + * exactly when a request that sends it gets a 400 from this model. True on a model that + * does not support thinking. + */ + fun disabled(disabled: CapabilitySupport) = disabled(JsonField.of(disabled)) + + /** + * Sets [Builder.disabled] to an arbitrary JSON value. + * + * You should usually call [Builder.disabled] with a well-typed [CapabilitySupport] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun disabled(disabled: JsonField) = apply { this.disabled = disabled } + + /** + * Whether the model accepts thinking with type 'enabled' (extended thinking with a + * caller-set `budget_tokens`). + */ fun enabled(enabled: CapabilitySupport) = enabled(JsonField.of(enabled)) /** @@ -156,6 +209,7 @@ private constructor( * The following fields are required: * ```java * .adaptive() + * .disabled() * .enabled() * ``` * @@ -164,6 +218,7 @@ private constructor( fun build(): ThinkingTypes = ThinkingTypes( checkRequired("adaptive", adaptive), + checkRequired("disabled", disabled), checkRequired("enabled", enabled), additionalProperties.toMutableMap(), ) @@ -185,6 +240,7 @@ private constructor( } adaptive().validate() + disabled().validate() enabled().validate() validated = true } @@ -205,6 +261,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (adaptive.asKnown().getOrNull()?.validity() ?: 0) + + (disabled.asKnown().getOrNull()?.validity() ?: 0) + (enabled.asKnown().getOrNull()?.validity() ?: 0) override fun equals(other: Any?): Boolean { @@ -214,14 +271,17 @@ private constructor( return other is ThinkingTypes && adaptive == other.adaptive && + disabled == other.disabled && enabled == other.enabled && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(adaptive, enabled, additionalProperties) } + private val hashCode: Int by lazy { + Objects.hash(adaptive, disabled, enabled, additionalProperties) + } override fun hashCode(): Int = hashCode override fun toString() = - "ThinkingTypes{adaptive=$adaptive, enabled=$enabled, additionalProperties=$additionalProperties}" + "ThinkingTypes{adaptive=$adaptive, disabled=$disabled, enabled=$enabled, additionalProperties=$additionalProperties}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/federation/rules/FederationRule.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/federation/rules/FederationRule.kt index f5298cd56..d603c05f6 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/federation/rules/FederationRule.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/federation/rules/FederationRule.kt @@ -223,8 +223,8 @@ private constructor( fun oauthScope(): String = oauthScope.getRequired("oauth_scope") /** - * Identity that tokens minted via this rule act as. Currently always a `service_account` - * target. + * What this rule targets. Check `type` before reading the other fields. Tokens minted via a + * rule whose target `type` is `service_account` act as that service account. * * @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). @@ -683,8 +683,8 @@ private constructor( fun oauthScope(oauthScope: JsonField) = apply { this.oauthScope = oauthScope } /** - * Identity that tokens minted via this rule act as. Currently always a `service_account` - * target. + * What this rule targets. Check `type` before reading the other fields. Tokens minted via a + * rule whose target `type` is `service_account` act as that service account. */ fun target(target: ServiceAccountTarget) = target(JsonField.of(target)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/ratelimits/RateLimitListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/ratelimits/RateLimitListParams.kt index 0d9cb330c..486cc78b9 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/ratelimits/RateLimitListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/ratelimits/RateLimitListParams.kt @@ -15,8 +15,8 @@ import kotlin.jvm.optionals.getOrNull * List Messages API rate limits for your organization. * * Each entry corresponds to one rate-limit group (either a model family or an API-surface category - * such as the Files API or Message Batches) and contains the set of limiter values that apply to - * it. + * such as the Message Batches API or the web search tool) and contains the set of limiter values + * that apply to it. * * When `limit` is omitted, every matching entry is returned in a single page; when `limit` * truncates the result, follow `next_page` to fetch the remaining entries. diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParams.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParams.kt index 74b3374dc..184d8cd23 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParams.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParams.kt @@ -13,6 +13,7 @@ private constructor( private val afterId: String?, private val beforeId: String?, private val includeArchived: Boolean?, + private val includeDefault: Boolean?, private val limit: Long?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -33,6 +34,9 @@ private constructor( /** Whether to include Workspaces that have been archived in the response */ fun includeArchived(): Optional = Optional.ofNullable(includeArchived) + /** Whether to include the organization's default Workspace in the response */ + fun includeDefault(): Optional = Optional.ofNullable(includeDefault) + /** * Number of items to return per page. * @@ -62,6 +66,7 @@ private constructor( private var afterId: String? = null private var beforeId: String? = null private var includeArchived: Boolean? = null + private var includeDefault: Boolean? = null private var limit: Long? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -71,6 +76,7 @@ private constructor( afterId = workspaceListParams.afterId beforeId = workspaceListParams.beforeId includeArchived = workspaceListParams.includeArchived + includeDefault = workspaceListParams.includeDefault limit = workspaceListParams.limit additionalHeaders = workspaceListParams.additionalHeaders.toBuilder() additionalQueryParams = workspaceListParams.additionalQueryParams.toBuilder() @@ -110,6 +116,22 @@ private constructor( fun includeArchived(includeArchived: Optional) = includeArchived(includeArchived.getOrNull()) + /** Whether to include the organization's default Workspace in the response */ + fun includeDefault(includeDefault: Boolean?) = apply { + this.includeDefault = includeDefault + } + + /** + * Alias for [Builder.includeDefault]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun includeDefault(includeDefault: Boolean) = includeDefault(includeDefault as Boolean?) + + /** Alias for calling [Builder.includeDefault] with `includeDefault.orElse(null)`. */ + fun includeDefault(includeDefault: Optional) = + includeDefault(includeDefault.getOrNull()) + /** * Number of items to return per page. * @@ -235,6 +257,7 @@ private constructor( afterId, beforeId, includeArchived, + includeDefault, limit, additionalHeaders.build(), additionalQueryParams.build(), @@ -249,6 +272,7 @@ private constructor( afterId?.let { put("after_id", it) } beforeId?.let { put("before_id", it) } includeArchived?.let { put("include_archived", it.toString()) } + includeDefault?.let { put("include_default", it.toString()) } limit?.let { put("limit", it.toString()) } putAll(additionalQueryParams) } @@ -263,6 +287,7 @@ private constructor( afterId == other.afterId && beforeId == other.beforeId && includeArchived == other.includeArchived && + includeDefault == other.includeDefault && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -273,11 +298,12 @@ private constructor( afterId, beforeId, includeArchived, + includeDefault, limit, additionalHeaders, additionalQueryParams, ) override fun toString() = - "WorkspaceListParams{afterId=$afterId, beforeId=$beforeId, includeArchived=$includeArchived, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "WorkspaceListParams{afterId=$afterId, beforeId=$beforeId, includeArchived=$includeArchived, includeDefault=$includeDefault, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsync.kt index 563765358..5116f14f3 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsync.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsync.kt @@ -35,10 +35,16 @@ interface CompletionServiceAsync { * [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) * for guidance in migrating from Text Completions to Messages. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun create(params: CompletionCreateParams): CompletableFuture = create(params, RequestOptions.none()) /** @see create */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun create( params: CompletionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -54,10 +60,16 @@ interface CompletionServiceAsync { * [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) * for guidance in migrating from Text Completions to Messages. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun createStreaming(params: CompletionCreateParams): AsyncStreamResponse = createStreaming(params, RequestOptions.none()) /** @see createStreaming */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun createStreaming( params: CompletionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -82,10 +94,16 @@ interface CompletionServiceAsync { * Returns a raw HTTP response for `post /v1/complete`, but is otherwise the same as * [CompletionServiceAsync.create]. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun create(params: CompletionCreateParams): CompletableFuture> = create(params, RequestOptions.none()) /** @see create */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun create( params: CompletionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -95,6 +113,9 @@ interface CompletionServiceAsync { * Returns a raw HTTP response for `post /v1/complete`, but is otherwise the same as * [CompletionServiceAsync.createStreaming]. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun createStreaming( params: CompletionCreateParams @@ -102,6 +123,9 @@ interface CompletionServiceAsync { createStreaming(params, RequestOptions.none()) /** @see createStreaming */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun createStreaming( params: CompletionCreateParams, diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsyncImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsyncImpl.kt index 4922011b1..522634ff5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsyncImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/CompletionServiceAsyncImpl.kt @@ -37,6 +37,9 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: override fun withOptions(modifier: Consumer): CompletionServiceAsync = CompletionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -44,6 +47,9 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: // post /v1/complete withRawResponse().create(params, requestOptions).thenApply { it.parse() } + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun createStreaming( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -70,6 +76,9 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -108,6 +117,9 @@ class CompletionServiceAsyncImpl internal constructor(private val clientOptions: private val createStreamingHandler: Handler> = sseHandler(clientOptions.jsonMapper).mapJson() + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun createStreaming( params: CompletionCreateParams, requestOptions: RequestOptions, diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/RateLimitServiceAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/RateLimitServiceAsync.kt index 6ce0ca3bb..f7d78a494 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/RateLimitServiceAsync.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/RateLimitServiceAsync.kt @@ -26,8 +26,8 @@ interface RateLimitServiceAsync { * List Messages API rate limits for your organization. * * Each entry corresponds to one rate-limit group (either a model family or an API-surface - * category such as the Files API or Message Batches) and contains the set of limiter values - * that apply to it. + * category such as the Message Batches API or the web search tool) and contains the set of + * limiter values that apply to it. * * When `limit` is omitted, every matching entry is returned in a single page; when `limit` * truncates the result, follow `next_page` to fetch the remaining entries. diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncImpl.kt index 1a037ed5f..80f5a7a3c 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncImpl.kt @@ -155,6 +155,7 @@ class SpendLimitServiceAsyncImpl internal constructor(private val clientOptions: .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "organizations", "spend_limits") .putQueryParam("beta", "true") + .replaceHeaders("anthropic-beta", "spend-limit-reads-2026-09-26") .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/analytics/SummaryServiceAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/analytics/SummaryServiceAsync.kt index ed28a717e..e249427f2 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/analytics/SummaryServiceAsync.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/beta/organization/analytics/SummaryServiceAsync.kt @@ -27,13 +27,12 @@ interface SummaryServiceAsync { * * Returns one entry per day from `starting_date` (inclusive) to `ending_date` (exclusive) in * `data`, the same `data` / `next_page` envelope as the other analytics list endpoints; the - * series is currently returned in full, so `next_page` is always null (`summaries` is a - * deprecated alias of `data`). Data is typically available with a 1-day lag and may be revised - * by a few percent over the following days: when `ending_date` is omitted it defaults to the - * most recent available day + 1, so the last entry covers the most recent available day. The - * series can be scoped to an RBAC group via `filter[]=rbac_group_id:{id}`. Available to - * organizations on a Claude Enterprise plan. Requires an API key with the `read:analytics` - * scope. + * series is currently returned in full, so `next_page` is always null. Data is typically + * available with a 1-day lag and may be revised by a few percent over the following days: when + * `ending_date` is omitted it defaults to the most recent available day + 1, so the last entry + * covers the most recent available day. The series can be scoped to an RBAC group via + * `filter[]=rbac_group_id:{id}`. Available to organizations on a Claude Enterprise plan. + * Requires an API key with the `read:analytics` scope. */ fun list(params: SummaryListParams): CompletableFuture = list(params, RequestOptions.none()) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/organization/RateLimitServiceAsync.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/organization/RateLimitServiceAsync.kt index 1bf854101..8ee86b2d5 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/organization/RateLimitServiceAsync.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/async/organization/RateLimitServiceAsync.kt @@ -26,8 +26,8 @@ interface RateLimitServiceAsync { * List Messages API rate limits for your organization. * * Each entry corresponds to one rate-limit group (either a model family or an API-surface - * category such as the Files API or Message Batches) and contains the set of limiter values - * that apply to it. + * category such as the Message Batches API or the web search tool) and contains the set of + * limiter values that apply to it. * * When `limit` is omitted, every matching entry is returned in a single page; when `limit` * truncates the result, follow `next_page` to fetch the remaining entries. diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionService.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionService.kt index 485310ea1..984ca84d8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionService.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionService.kt @@ -33,9 +33,15 @@ interface CompletionService { * [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) * for guidance in migrating from Text Completions to Messages. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun create(params: CompletionCreateParams): Completion = create(params, RequestOptions.none()) /** @see create */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) fun create( params: CompletionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -51,11 +57,17 @@ interface CompletionService { * [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages) * for guidance in migrating from Text Completions to Messages. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun createStreaming(params: CompletionCreateParams): StreamResponse = createStreaming(params, RequestOptions.none()) /** @see createStreaming */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun createStreaming( params: CompletionCreateParams, @@ -78,11 +90,17 @@ interface CompletionService { * Returns a raw HTTP response for `post /v1/complete`, but is otherwise the same as * [CompletionService.create]. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun create(params: CompletionCreateParams): HttpResponseFor = create(params, RequestOptions.none()) /** @see create */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun create( params: CompletionCreateParams, @@ -93,6 +111,9 @@ interface CompletionService { * Returns a raw HTTP response for `post /v1/complete`, but is otherwise the same as * [CompletionService.createStreaming]. */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun createStreaming( params: CompletionCreateParams @@ -100,6 +121,9 @@ interface CompletionService { createStreaming(params, RequestOptions.none()) /** @see createStreaming */ + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) @MustBeClosed fun createStreaming( params: CompletionCreateParams, diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionServiceImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionServiceImpl.kt index 512ebe1ea..33c57c0b8 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionServiceImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/CompletionServiceImpl.kt @@ -34,6 +34,9 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie override fun withOptions(modifier: Consumer): CompletionService = CompletionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -41,6 +44,9 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie // post /v1/complete withRawResponse().create(params, requestOptions).parse() + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun createStreaming( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -64,6 +70,9 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun create( params: CompletionCreateParams, requestOptions: RequestOptions, @@ -99,6 +108,9 @@ class CompletionServiceImpl internal constructor(private val clientOptions: Clie private val createStreamingHandler: Handler> = sseHandler(clientOptions.jsonMapper).mapJson() + @Deprecated( + "Use the [Messages API](https://platform.claude.com/docs/en/api/messages/create) instead." + ) override fun createStreaming( params: CompletionCreateParams, requestOptions: RequestOptions, diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/RateLimitService.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/RateLimitService.kt index 496103100..387fe06c7 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/RateLimitService.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/RateLimitService.kt @@ -26,8 +26,8 @@ interface RateLimitService { * List Messages API rate limits for your organization. * * Each entry corresponds to one rate-limit group (either a model family or an API-surface - * category such as the Files API or Message Batches) and contains the set of limiter values - * that apply to it. + * category such as the Message Batches API or the web search tool) and contains the set of + * limiter values that apply to it. * * When `limit` is omitted, every matching entry is returned in a single page; when `limit` * truncates the result, follow `next_page` to fetch the remaining entries. diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceImpl.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceImpl.kt index 079e3385d..0c838ce7f 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceImpl.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceImpl.kt @@ -145,6 +145,7 @@ class SpendLimitServiceImpl internal constructor(private val clientOptions: Clie .baseUrl(clientOptions.baseUrl()) .addPathSegments("v1", "organizations", "spend_limits") .putQueryParam("beta", "true") + .replaceHeaders("anthropic-beta", "spend-limit-reads-2026-09-26") .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/analytics/SummaryService.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/analytics/SummaryService.kt index a86de3cfb..bf92623ca 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/analytics/SummaryService.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/beta/organization/analytics/SummaryService.kt @@ -27,13 +27,12 @@ interface SummaryService { * * Returns one entry per day from `starting_date` (inclusive) to `ending_date` (exclusive) in * `data`, the same `data` / `next_page` envelope as the other analytics list endpoints; the - * series is currently returned in full, so `next_page` is always null (`summaries` is a - * deprecated alias of `data`). Data is typically available with a 1-day lag and may be revised - * by a few percent over the following days: when `ending_date` is omitted it defaults to the - * most recent available day + 1, so the last entry covers the most recent available day. The - * series can be scoped to an RBAC group via `filter[]=rbac_group_id:{id}`. Available to - * organizations on a Claude Enterprise plan. Requires an API key with the `read:analytics` - * scope. + * series is currently returned in full, so `next_page` is always null. Data is typically + * available with a 1-day lag and may be revised by a few percent over the following days: when + * `ending_date` is omitted it defaults to the most recent available day + 1, so the last entry + * covers the most recent available day. The series can be scoped to an RBAC group via + * `filter[]=rbac_group_id:{id}`. Available to organizations on a Claude Enterprise plan. + * Requires an API key with the `read:analytics` scope. */ fun list(params: SummaryListParams): SummaryListPage = list(params, RequestOptions.none()) diff --git a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/organization/RateLimitService.kt b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/organization/RateLimitService.kt index 1505841e7..5450e27ce 100644 --- a/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/organization/RateLimitService.kt +++ b/anthropic-java-core/src/main/kotlin/com/anthropic/services/blocking/organization/RateLimitService.kt @@ -26,8 +26,8 @@ interface RateLimitService { * List Messages API rate limits for your organization. * * Each entry corresponds to one rate-limit group (either a model family or an API-surface - * category such as the Files API or Message Batches) and contains the set of limiter values - * that apply to it. + * category such as the Message Batches API or the web search tool) and contains the set of + * limiter values that apply to it. * * When `limit` is omitted, every matching entry is returned in a single page; when `limit` * truncates the result, follow `next_page` to fetch the remaining entries. diff --git a/anthropic-java-core/src/main/resources/META-INF/proguard/anthropic-java-core.pro b/anthropic-java-core/src/main/resources/META-INF/proguard/anthropic-java-core.pro index b4b8090b1..6ae4417cb 100644 --- a/anthropic-java-core/src/main/resources/META-INF/proguard/anthropic-java-core.pro +++ b/anthropic-java-core/src/main/resources/META-INF/proguard/anthropic-java-core.pro @@ -1,32 +1,57 @@ -# Jackson uses reflection and depends heavily on runtime attributes. --keepattributes Exceptions,InnerClasses,Signature,Deprecated,*Annotation* +# Jackson, and the Kotlin reflection it uses on our classes, read these attributes at runtime. +-keepattributes RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,AnnotationDefault,Signature,InnerClasses,EnclosingMethod -# Jackson uses Kotlin reflection utilities, which themselves use reflection to access things. --keep class kotlin.reflect.** { *; } +# Jackson reads the default arguments of our constructors from `@Metadata`, which is what makes an absent property missing +# instead of null. Shrinkers strip the annotation from every class unless the annotation class itself is kept. -keep class kotlin.Metadata { *; } -# Jackson uses reflection to access enum members (e.g. via `java.lang.Class.getEnumConstants()`). --keepclassmembers class com.fasterxml.jackson.** extends java.lang.Enum { - ; - public static **[] values(); - public static ** valueOf(java.lang.String); -} +# ProGuard, unlike R8, does not see that Kotlin reflection loads these through `java.util.ServiceLoader`. +-keep interface kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader +-keep class * implements kotlin.reflect.jvm.internal.impl.builtins.BuiltInsLoader { public protected *; } +-keep interface kotlin.reflect.jvm.internal.impl.resolve.ExternalOverridabilityCondition +-keep class * implements kotlin.reflect.jvm.internal.impl.resolve.ExternalOverridabilityCondition { public protected *; } +-keep interface kotlin.reflect.jvm.internal.impl.km.internal.extensions.MetadataExtensions +-keep class * implements kotlin.reflect.jvm.internal.impl.km.internal.extensions.MetadataExtensions { public protected *; } -# Jackson uses reflection to access annotation members. --keepclassmembers @interface com.fasterxml.jackson.annotation.** { - *; +# `java.lang.Class.getEnumConstants()`, which Jackson calls, finds `values()` reflectively. So do `java.util.EnumMap` and +# `java.lang.Enum.valueOf(...)`, which ProGuard, unlike R8, does not see. +-keepclassmembers enum com.fasterxml.jackson.**, kotlin.reflect.jvm.internal.**, com.anthropic.** { + public static **[] values(); } -# Jackson uses reified type information to serialize and deserialize our classes (via `TypeReference`). --keep class com.fasterxml.jackson.core.type.TypeReference { *; } --keep class * extends com.fasterxml.jackson.core.type.TypeReference { *; } +# Jackson reads the type argument of a `TypeReference` subclass from its generic signature. R8 drops the signature of a +# class that no rule matches, and the signature of a subclass is unreadable without the one of `TypeReference` itself. +-keep,allowshrinking,allowobfuscation class com.fasterxml.jackson.core.type.TypeReference +-keep,allowshrinking,allowobfuscation class * extends com.fasterxml.jackson.core.type.TypeReference -# Jackson uses reflection to access our class serializers and deserializers. --keep @com.fasterxml.jackson.databind.annotation.JsonSerialize class com.anthropic.** { *; } --keep @com.fasterxml.jackson.databind.annotation.JsonDeserialize class com.anthropic.** { *; } +# Only annotations refer to these, so to a shrinker they look unused. Jackson instantiates the classes reflectively. +-keep,allowobfuscation @interface com.anthropic.core.ExcludeMissing +-keep,allowobfuscation class com.anthropic.core.JsonField$IsMissing { (); } +-keepclassmembers class com.fasterxml.jackson.databind.ser.std.NullSerializer { (); } -# Jackson uses reflection to serialize and deserialize our classes based on their constructors and annotated members. --keepclassmembers class com.anthropic.** { - (...); +# Jackson calls the annotated members of our classes reflectively. Their names are free to change because the annotations +# hold the names of the JSON properties, except for enum constants, which Jackson matches to their fields by name. +-keepclassmembers,allowobfuscation class com.anthropic.** { @com.fasterxml.jackson.annotation.* *; -} \ No newline at end of file +} +-keepclassmembers enum com.anthropic.** { + @com.fasterxml.jackson.annotation.* ; +} + +# Jackson may be all that instantiates one of our classes (e.g. a response). R8 treats a class as instantiated, and keeps +# its annotations, only if a rule keeps the class itself, so `-keepclassmembers` is not enough. The `-if`, which also matches +# a constructor with annotated parameters, leaves unused classes removable (in R8; to ProGuard the condition holds +# whenever the class exists). The constructors include the synthetic one that Kotlin reflection calls to apply default +# arguments. +-if class com.anthropic.** { @com.fasterxml.jackson.annotation.* (...); } +-keep,allowobfuscation class com.anthropic.<1> { (...); } + +# Likewise for our classes with a deserializer or serializer, and for those, which only the annotations refer to. +-if @com.fasterxml.jackson.databind.annotation.JsonDeserialize class com.anthropic.** +-keep,allowobfuscation class com.anthropic.<1> +-if @com.fasterxml.jackson.databind.annotation.JsonSerialize class com.anthropic.** +-keep,allowobfuscation class com.anthropic.<1> +-if class com.anthropic.** extends com.fasterxml.jackson.databind.JsonDeserializer +-keep,allowobfuscation class com.anthropic.<1> { (); } +-if class com.anthropic.** extends com.fasterxml.jackson.databind.JsonSerializer +-keep,allowobfuscation class com.anthropic.<1> { (); } \ No newline at end of file diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/core/http/HttpRequestTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/core/http/HttpRequestTest.kt index 433edddfe..7058269e0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/core/http/HttpRequestTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/core/http/HttpRequestTest.kt @@ -5,6 +5,7 @@ import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource +import org.junit.jupiter.params.provider.ValueSource internal class HttpRequestTest { @@ -206,4 +207,17 @@ internal class HttpRequestTest { assertThat(actualUrl).isEqualTo(testCase.expectedUrl) } + + @ParameterizedTest + @ValueSource(strings = [".", ".."]) + fun addPathSegment_dotSegment_throws(segment: String) { + val builder = HttpRequest.builder() + + assertThat(runCatching { builder.addPathSegment(segment) }.exceptionOrNull()) + .isInstanceOf(IllegalStateException::class.java) + .hasMessageContaining("dot-segment") + assertThat(runCatching { builder.addPathSegments("cards", segment) }.exceptionOrNull()) + .isInstanceOf(IllegalStateException::class.java) + .hasMessageContaining("dot-segment") + } } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentArchiveParamsTest.kt index 2afce82c3..a42527165 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentArchiveParamsTest.kt @@ -39,7 +39,11 @@ internal class AgentArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentCreateParamsTest.kt index 637a7e1eb..fe6fe76da 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentCreateParamsTest.kt @@ -157,7 +157,11 @@ internal class AgentCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListPageResponseTest.kt index b3a50cbe2..0f53cea8a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListPageResponseTest.kt @@ -66,7 +66,7 @@ internal class AgentListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -161,7 +161,7 @@ internal class AgentListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -259,7 +259,7 @@ internal class AgentListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListParamsTest.kt index e0291d961..412fe7e0b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentListParamsTest.kt @@ -40,7 +40,11 @@ internal class AgentListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParamsTest.kt index d409726a9..b86321140 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentRetrieveParamsTest.kt @@ -42,7 +42,11 @@ internal class AgentRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentUpdateParamsTest.kt index 4b04a3ae1..eb31dddaf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/AgentUpdateParamsTest.kt @@ -189,7 +189,11 @@ internal class AgentUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentTest.kt index f32004fbc..dd513ee41 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentTest.kt @@ -60,7 +60,7 @@ internal class BetaManagedAgentsAgentTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -152,7 +152,7 @@ internal class BetaManagedAgentsAgentTest { ), BetaManagedAgentsAgent.Skill.ofCustom( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -247,7 +247,7 @@ internal class BetaManagedAgentsAgentTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigParamsTest.kt index f80c832a1..33a9f9a78 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigParamsTest.kt @@ -339,6 +339,13 @@ internal class BetaManagedAgentsAgentToolConfigParamsTest { ) ) .type(BetaManagedAgentsWebFetchToolConfigParams.Type.WEB_FETCH) + .urlSources( + BetaManagedAgentsWebFetchUrlSourcesParams.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .userInput(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .build() + ) .build() val betaManagedAgentsAgentToolConfigParams = @@ -370,6 +377,13 @@ internal class BetaManagedAgentsAgentToolConfigParamsTest { ) ) .type(BetaManagedAgentsWebFetchToolConfigParams.Type.WEB_FETCH) + .urlSources( + BetaManagedAgentsWebFetchUrlSourcesParams.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .userInput(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .build() + ) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigTest.kt index 9bf5a4c6c..bec401adc 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsAgentToolConfigTest.kt @@ -317,6 +317,13 @@ internal class BetaManagedAgentsAgentToolConfigTest { BetaManagedAgentsAlwaysAllowPolicy.Type.ALWAYS_ALLOW ) ) + .urlSources( + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + ) .addAllowedDomain("string") .addBlockedDomain("string") .maxContentTokens(0) @@ -346,6 +353,17 @@ internal class BetaManagedAgentsAgentToolConfigTest { BetaManagedAgentsAlwaysAllowPolicy.Type.ALWAYS_ALLOW ) ) + .urlSources( + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + .serverToolResults( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + ) .addAllowedDomain("string") .addBlockedDomain("string") .maxContentTokens(0) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillParamsTest.kt index bb9006403..238ef5986 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillParamsTest.kt @@ -11,13 +11,13 @@ internal class BetaManagedAgentsCustomSkillParamsTest { fun create() { val betaManagedAgentsCustomSkillParams = BetaManagedAgentsCustomSkillParams.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkillParams.Type.CUSTOM) .version("2") .build() assertThat(betaManagedAgentsCustomSkillParams.skillId()) - .isEqualTo("skill_011CZkZFNu9hAbo3jZPRgTlx") + .isEqualTo("skill_011CZkZFNu9hAbo3jZPRgTmx") assertThat(betaManagedAgentsCustomSkillParams.type()) .isEqualTo(BetaManagedAgentsCustomSkillParams.Type.CUSTOM) assertThat(betaManagedAgentsCustomSkillParams.version()).contains("2") @@ -28,7 +28,7 @@ internal class BetaManagedAgentsCustomSkillParamsTest { val jsonMapper = jsonMapper() val betaManagedAgentsCustomSkillParams = BetaManagedAgentsCustomSkillParams.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkillParams.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillTest.kt index ee3442386..8ddc5dec2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsCustomSkillTest.kt @@ -11,13 +11,13 @@ internal class BetaManagedAgentsCustomSkillTest { fun create() { val betaManagedAgentsCustomSkill = BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() assertThat(betaManagedAgentsCustomSkill.skillId()) - .isEqualTo("skill_011CZkZFNu9hAbo3jZPRgTlx") + .isEqualTo("skill_011CZkZFNu9hAbo3jZPRgTmx") assertThat(betaManagedAgentsCustomSkill.type()) .isEqualTo(BetaManagedAgentsCustomSkill.Type.CUSTOM) assertThat(betaManagedAgentsCustomSkill.version()).isEqualTo("2") @@ -28,7 +28,7 @@ internal class BetaManagedAgentsCustomSkillTest { val jsonMapper = jsonMapper() val betaManagedAgentsCustomSkill = BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsSkillParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsSkillParamsTest.kt index 64aeb9659..782d16244 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsSkillParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsSkillParamsTest.kt @@ -52,7 +52,7 @@ internal class BetaManagedAgentsSkillParamsTest { fun ofCustom() { val custom = BetaManagedAgentsCustomSkillParams.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkillParams.Type.CUSTOM) .version("2") .build() @@ -69,7 +69,7 @@ internal class BetaManagedAgentsSkillParamsTest { val betaManagedAgentsSkillParams = BetaManagedAgentsSkillParams.ofCustom( BetaManagedAgentsCustomSkillParams.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkillParams.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParamsTest.kt index c8a532acc..dd6197079 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigParamsTest.kt @@ -22,6 +22,13 @@ internal class BetaManagedAgentsWebFetchToolConfigParamsTest { ) ) .type(BetaManagedAgentsWebFetchToolConfigParams.Type.WEB_FETCH) + .urlSources( + BetaManagedAgentsWebFetchUrlSourcesParams.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .userInput(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .build() + ) .build() assertThat(betaManagedAgentsWebFetchToolConfigParams.allowedDomains().getOrNull()) @@ -38,6 +45,14 @@ internal class BetaManagedAgentsWebFetchToolConfigParamsTest { ) assertThat(betaManagedAgentsWebFetchToolConfigParams.type()) .contains(BetaManagedAgentsWebFetchToolConfigParams.Type.WEB_FETCH) + assertThat(betaManagedAgentsWebFetchToolConfigParams.urlSources()) + .contains( + BetaManagedAgentsWebFetchUrlSourcesParams.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .userInput(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .build() + ) } @Test @@ -73,6 +88,13 @@ internal class BetaManagedAgentsWebFetchToolConfigParamsTest { ) ) .type(BetaManagedAgentsWebFetchToolConfigParams.Type.WEB_FETCH) + .urlSources( + BetaManagedAgentsWebFetchUrlSourcesParams.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .userInput(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .build() + ) .build() val roundtrippedBetaManagedAgentsWebFetchToolConfigParams = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigTest.kt index 3db3ce8ac..10e26ff1a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchToolConfigTest.kt @@ -18,6 +18,13 @@ internal class BetaManagedAgentsWebFetchToolConfigTest { BetaManagedAgentsAlwaysAllowPolicy.Type.ALWAYS_ALLOW ) ) + .urlSources( + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + ) .addAllowedDomain("string") .addBlockedDomain("string") .maxContentTokens(0) @@ -30,6 +37,14 @@ internal class BetaManagedAgentsWebFetchToolConfigTest { BetaManagedAgentsAlwaysAllowPolicy.Type.ALWAYS_ALLOW ) ) + assertThat(betaManagedAgentsWebFetchToolConfig.urlSources()) + .contains( + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + ) assertThat(betaManagedAgentsWebFetchToolConfig.allowedDomains().getOrNull()) .containsExactly("string") assertThat(betaManagedAgentsWebFetchToolConfig.blockedDomains().getOrNull()) @@ -47,6 +62,13 @@ internal class BetaManagedAgentsWebFetchToolConfigTest { BetaManagedAgentsAlwaysAllowPolicy.Type.ALWAYS_ALLOW ) ) + .urlSources( + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + ) .build() val betaManagedAgentsWebFetchToolConfig = @@ -73,6 +95,13 @@ internal class BetaManagedAgentsWebFetchToolConfigTest { BetaManagedAgentsAlwaysAllowPolicy.Type.ALWAYS_ALLOW ) ) + .urlSources( + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + ) .addAllowedDomain("string") .addBlockedDomain("string") .maxContentTokens(0) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceAllTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceAllTest.kt new file mode 100644 index 000000000..d23410a61 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceAllTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWebFetchUrlSourceAllTest { + + @Test + fun create() { + val betaManagedAgentsWebFetchUrlSourceAll = + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceAll = + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceAll = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceAll), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceAll) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceAll) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceExceptTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceExceptTest.kt new file mode 100644 index 000000000..8a780df5d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceExceptTest.kt @@ -0,0 +1,38 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWebFetchUrlSourceExceptTest { + + @Test + fun create() { + val betaManagedAgentsWebFetchUrlSourceExcept = + BetaManagedAgentsWebFetchUrlSourceExcept.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + + assertThat(betaManagedAgentsWebFetchUrlSourceExcept.tools()) + .containsExactly(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceExcept = + BetaManagedAgentsWebFetchUrlSourceExcept.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceExcept = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceExcept), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceExcept) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceExcept) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceNoneTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceNoneTest.kt new file mode 100644 index 000000000..5f055a7b4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceNoneTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWebFetchUrlSourceNoneTest { + + @Test + fun create() { + val betaManagedAgentsWebFetchUrlSourceNone = + BetaManagedAgentsWebFetchUrlSourceNone.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceNone = + BetaManagedAgentsWebFetchUrlSourceNone.builder().build() + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceNone = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceNone), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceNone) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceNone) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceOnlyTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceOnlyTest.kt new file mode 100644 index 000000000..e385d9937 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceOnlyTest.kt @@ -0,0 +1,38 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWebFetchUrlSourceOnlyTest { + + @Test + fun create() { + val betaManagedAgentsWebFetchUrlSourceOnly = + BetaManagedAgentsWebFetchUrlSourceOnly.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + + assertThat(betaManagedAgentsWebFetchUrlSourceOnly.tools()) + .containsExactly(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceOnly = + BetaManagedAgentsWebFetchUrlSourceOnly.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceOnly = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceOnly), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceOnly) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceOnly) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterParamsTest.kt new file mode 100644 index 000000000..f25266fd7 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterParamsTest.kt @@ -0,0 +1,114 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsWebFetchUrlSourceToolFilterParamsTest { + + @Test + fun ofShorthand() { + val shorthand = BetaManagedAgentsWebFetchUrlSourceShorthand.ALL + + val betaManagedAgentsWebFetchUrlSourceToolFilterParams = + BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand(shorthand) + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilterParams.shorthand()) + .contains(shorthand) + assertThat( + betaManagedAgentsWebFetchUrlSourceToolFilterParams + .betaManagedAgentsWebFetchUrlSourceToolFilter() + ) + .isEmpty + } + + @Test + fun ofShorthandRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceToolFilterParams = + BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand( + BetaManagedAgentsWebFetchUrlSourceShorthand.ALL + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilterParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceToolFilterParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilterParams) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceToolFilterParams) + } + + @Test + fun ofBetaManagedAgentsWebFetchUrlSourceToolFilter() { + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + + val betaManagedAgentsWebFetchUrlSourceToolFilterParams = + BetaManagedAgentsWebFetchUrlSourceToolFilterParams + .ofBetaManagedAgentsWebFetchUrlSourceToolFilter( + betaManagedAgentsWebFetchUrlSourceToolFilter + ) + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilterParams.shorthand()).isEmpty + assertThat( + betaManagedAgentsWebFetchUrlSourceToolFilterParams + .betaManagedAgentsWebFetchUrlSourceToolFilter() + ) + .contains(betaManagedAgentsWebFetchUrlSourceToolFilter) + } + + @Test + fun ofBetaManagedAgentsWebFetchUrlSourceToolFilterRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceToolFilterParams = + BetaManagedAgentsWebFetchUrlSourceToolFilterParams + .ofBetaManagedAgentsWebFetchUrlSourceToolFilter( + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilterParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceToolFilterParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilterParams) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceToolFilterParams) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsWebFetchUrlSourceToolFilterParams = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsWebFetchUrlSourceToolFilterParams.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterTest.kt new file mode 100644 index 000000000..15ad5c9d0 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolFilterTest.kt @@ -0,0 +1,200 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsWebFetchUrlSourceToolFilterTest { + + @Test + fun ofAll() { + val all = BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll(all) + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.all()).contains(all) + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.none()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.only()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.except()).isEmpty + } + + @Test + fun ofAllRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceToolFilter), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceToolFilter) + } + + @Test + fun ofNone() { + val none = BetaManagedAgentsWebFetchUrlSourceNone.builder().build() + + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofNone(none) + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.all()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.none()).contains(none) + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.only()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.except()).isEmpty + } + + @Test + fun ofNoneRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofNone( + BetaManagedAgentsWebFetchUrlSourceNone.builder().build() + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceToolFilter), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceToolFilter) + } + + @Test + fun ofOnly() { + val only = + BetaManagedAgentsWebFetchUrlSourceOnly.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofOnly(only) + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.all()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.none()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.only()).contains(only) + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.except()).isEmpty + } + + @Test + fun ofOnlyRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofOnly( + BetaManagedAgentsWebFetchUrlSourceOnly.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceToolFilter), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceToolFilter) + } + + @Test + fun ofExcept() { + val except = + BetaManagedAgentsWebFetchUrlSourceExcept.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofExcept(except) + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.all()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.none()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.only()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.except()).contains(except) + } + + @Test + fun ofExceptRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceToolFilter = + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofExcept( + BetaManagedAgentsWebFetchUrlSourceExcept.builder() + .addTool(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + .build() + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceToolFilter), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceToolFilter) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceToolFilter) + } + + @Test + fun unknownVariantCommonProperties() { + val betaManagedAgentsWebFetchUrlSourceToolFilter = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf( + "type" to "unknown_variant", + "tools" to listOf(mapOf("name" to "x", "type" to "tool_reference")), + ) + ), + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsWebFetchUrlSourceToolFilter.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.tools().getOrNull()) + .containsExactly(BetaManagedAgentsWebFetchUrlSourceToolReference.of("x")) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsWebFetchUrlSourceToolFilter = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsWebFetchUrlSourceToolFilter.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(betaManagedAgentsWebFetchUrlSourceToolFilter.tools()).isEmpty + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolReferenceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolReferenceTest.kt new file mode 100644 index 000000000..a1db5674e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceToolReferenceTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWebFetchUrlSourceToolReferenceTest { + + @Test + fun create() { + val betaManagedAgentsWebFetchUrlSourceToolReference = + BetaManagedAgentsWebFetchUrlSourceToolReference.of("x") + + assertThat(betaManagedAgentsWebFetchUrlSourceToolReference.name()).isEqualTo("x") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceToolReference = + BetaManagedAgentsWebFetchUrlSourceToolReference.of("x") + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceToolReference = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceToolReference), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceToolReference) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceToolReference) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputParamsTest.kt new file mode 100644 index 000000000..551a5089e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputParamsTest.kt @@ -0,0 +1,114 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsWebFetchUrlSourceUserInputParamsTest { + + @Test + fun ofShorthand() { + val shorthand = BetaManagedAgentsWebFetchUrlSourceShorthand.ALL + + val betaManagedAgentsWebFetchUrlSourceUserInputParams = + BetaManagedAgentsWebFetchUrlSourceUserInputParams.ofShorthand(shorthand) + + assertThat(betaManagedAgentsWebFetchUrlSourceUserInputParams.shorthand()) + .contains(shorthand) + assertThat( + betaManagedAgentsWebFetchUrlSourceUserInputParams + .betaManagedAgentsWebFetchUrlSourceUserInput() + ) + .isEmpty + } + + @Test + fun ofShorthandRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceUserInputParams = + BetaManagedAgentsWebFetchUrlSourceUserInputParams.ofShorthand( + BetaManagedAgentsWebFetchUrlSourceShorthand.ALL + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInputParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceUserInputParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInputParams) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceUserInputParams) + } + + @Test + fun ofBetaManagedAgentsWebFetchUrlSourceUserInput() { + val betaManagedAgentsWebFetchUrlSourceUserInput = + BetaManagedAgentsWebFetchUrlSourceUserInput.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + + val betaManagedAgentsWebFetchUrlSourceUserInputParams = + BetaManagedAgentsWebFetchUrlSourceUserInputParams + .ofBetaManagedAgentsWebFetchUrlSourceUserInput( + betaManagedAgentsWebFetchUrlSourceUserInput + ) + + assertThat(betaManagedAgentsWebFetchUrlSourceUserInputParams.shorthand()).isEmpty + assertThat( + betaManagedAgentsWebFetchUrlSourceUserInputParams + .betaManagedAgentsWebFetchUrlSourceUserInput() + ) + .contains(betaManagedAgentsWebFetchUrlSourceUserInput) + } + + @Test + fun ofBetaManagedAgentsWebFetchUrlSourceUserInputRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceUserInputParams = + BetaManagedAgentsWebFetchUrlSourceUserInputParams + .ofBetaManagedAgentsWebFetchUrlSourceUserInput( + BetaManagedAgentsWebFetchUrlSourceUserInput.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInputParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceUserInputParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInputParams) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceUserInputParams) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsWebFetchUrlSourceUserInputParams = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsWebFetchUrlSourceUserInputParams.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputTest.kt new file mode 100644 index 000000000..390b1c70a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourceUserInputTest.kt @@ -0,0 +1,97 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaManagedAgentsWebFetchUrlSourceUserInputTest { + + @Test + fun ofAll() { + val all = BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + + val betaManagedAgentsWebFetchUrlSourceUserInput = + BetaManagedAgentsWebFetchUrlSourceUserInput.ofAll(all) + + assertThat(betaManagedAgentsWebFetchUrlSourceUserInput.all()).contains(all) + assertThat(betaManagedAgentsWebFetchUrlSourceUserInput.none()).isEmpty + } + + @Test + fun ofAllRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceUserInput = + BetaManagedAgentsWebFetchUrlSourceUserInput.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceUserInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInput) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceUserInput) + } + + @Test + fun ofNone() { + val none = BetaManagedAgentsWebFetchUrlSourceNone.builder().build() + + val betaManagedAgentsWebFetchUrlSourceUserInput = + BetaManagedAgentsWebFetchUrlSourceUserInput.ofNone(none) + + assertThat(betaManagedAgentsWebFetchUrlSourceUserInput.all()).isEmpty + assertThat(betaManagedAgentsWebFetchUrlSourceUserInput.none()).contains(none) + } + + @Test + fun ofNoneRoundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourceUserInput = + BetaManagedAgentsWebFetchUrlSourceUserInput.ofNone( + BetaManagedAgentsWebFetchUrlSourceNone.builder().build() + ) + + val roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourceUserInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourceUserInput) + .isEqualTo(betaManagedAgentsWebFetchUrlSourceUserInput) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaManagedAgentsWebFetchUrlSourceUserInput = + jsonMapper() + .convertValue( + testCase.value, + jacksonTypeRef(), + ) + + val e = + assertThrows { + betaManagedAgentsWebFetchUrlSourceUserInput.validate() + } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesParamsTest.kt new file mode 100644 index 000000000..becff3f73 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesParamsTest.kt @@ -0,0 +1,58 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWebFetchUrlSourcesParamsTest { + + @Test + fun create() { + val betaManagedAgentsWebFetchUrlSourcesParams = + BetaManagedAgentsWebFetchUrlSourcesParams.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .userInput(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .build() + + assertThat(betaManagedAgentsWebFetchUrlSourcesParams.clientToolResults()) + .contains( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand( + BetaManagedAgentsWebFetchUrlSourceShorthand.ALL + ) + ) + assertThat(betaManagedAgentsWebFetchUrlSourcesParams.serverToolResults()) + .contains( + BetaManagedAgentsWebFetchUrlSourceToolFilterParams.ofShorthand( + BetaManagedAgentsWebFetchUrlSourceShorthand.ALL + ) + ) + assertThat(betaManagedAgentsWebFetchUrlSourcesParams.userInput()) + .contains( + BetaManagedAgentsWebFetchUrlSourceUserInputParams.ofShorthand( + BetaManagedAgentsWebFetchUrlSourceShorthand.ALL + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSourcesParams = + BetaManagedAgentsWebFetchUrlSourcesParams.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .userInput(BetaManagedAgentsWebFetchUrlSourceShorthand.ALL) + .build() + + val roundtrippedBetaManagedAgentsWebFetchUrlSourcesParams = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSourcesParams), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSourcesParams) + .isEqualTo(betaManagedAgentsWebFetchUrlSourcesParams) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesTest.kt new file mode 100644 index 000000000..e974a75ac --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/BetaManagedAgentsWebFetchUrlSourcesTest.kt @@ -0,0 +1,58 @@ +package com.anthropic.models.beta.agents + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaManagedAgentsWebFetchUrlSourcesTest { + + @Test + fun create() { + val betaManagedAgentsWebFetchUrlSources = + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + + assertThat(betaManagedAgentsWebFetchUrlSources.clientToolResults()) + .contains( + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + ) + assertThat(betaManagedAgentsWebFetchUrlSources.serverToolResults()) + .contains( + BetaManagedAgentsWebFetchUrlSourceToolFilter.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + ) + assertThat(betaManagedAgentsWebFetchUrlSources.userInput()) + .contains( + BetaManagedAgentsWebFetchUrlSourceUserInput.ofAll( + BetaManagedAgentsWebFetchUrlSourceAll.builder().build() + ) + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaManagedAgentsWebFetchUrlSources = + BetaManagedAgentsWebFetchUrlSources.builder() + .clientToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .serverToolResults(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .userInput(BetaManagedAgentsWebFetchUrlSourceAll.builder().build()) + .build() + + val roundtrippedBetaManagedAgentsWebFetchUrlSources = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaManagedAgentsWebFetchUrlSources), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaManagedAgentsWebFetchUrlSources) + .isEqualTo(betaManagedAgentsWebFetchUrlSources) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListPageResponseTest.kt index b980f53c5..00bab20da 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListPageResponseTest.kt @@ -79,7 +79,7 @@ internal class VersionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -174,7 +174,7 @@ internal class VersionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -272,7 +272,7 @@ internal class VersionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListParamsTest.kt index 5764729c1..5b8b5b5e7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/agents/versions/VersionListParamsTest.kt @@ -44,7 +44,11 @@ internal class VersionListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParamsTest.kt index 669c4e499..4a080f7cf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunListParamsTest.kt @@ -48,7 +48,11 @@ internal class DeploymentRunListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParamsTest.kt index 0c1e2ffeb..78d2354ce 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deploymentruns/DeploymentRunRetrieveParamsTest.kt @@ -40,7 +40,11 @@ internal class DeploymentRunRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParamsTest.kt index 06a2bb7bc..f96b69cb1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentArchiveParamsTest.kt @@ -40,7 +40,11 @@ internal class DeploymentArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParamsTest.kt index fb2a1b18e..c424e2ed9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentCreateParamsTest.kt @@ -126,7 +126,11 @@ internal class DeploymentCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListParamsTest.kt index 2ed96cd79..c12ced420 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentListParamsTest.kt @@ -44,7 +44,11 @@ internal class DeploymentListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParamsTest.kt index f9b27e0f6..1a70d1ebb 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentPauseParamsTest.kt @@ -40,7 +40,11 @@ internal class DeploymentPauseParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParamsTest.kt index aa319324b..5f90f2141 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRetrieveParamsTest.kt @@ -40,7 +40,11 @@ internal class DeploymentRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParamsTest.kt index fd6b958d3..e14dd337e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentRunParamsTest.kt @@ -40,7 +40,11 @@ internal class DeploymentRunParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParamsTest.kt index 3c3b0df3f..3077d1073 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUnpauseParamsTest.kt @@ -40,7 +40,11 @@ internal class DeploymentUnpauseParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParamsTest.kt index 9563fa1b6..12d3471cb 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/deployments/DeploymentUpdateParamsTest.kt @@ -138,7 +138,11 @@ internal class DeploymentUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParamsTest.kt index a64b7c01c..7cd8df418 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamArchiveParamsTest.kt @@ -39,7 +39,11 @@ internal class DreamArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "dreaming-2026-04-21") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCancelParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCancelParamsTest.kt index 33f9401c0..4d5f6ea66 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCancelParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCancelParamsTest.kt @@ -39,7 +39,11 @@ internal class DreamCancelParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "dreaming-2026-04-21") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCreateParamsTest.kt index 21a63df23..6a46a2b62 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamCreateParamsTest.kt @@ -40,7 +40,11 @@ internal class DreamCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "dreaming-2026-04-21") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamListParamsTest.kt index 946685996..7d4ed5aa8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamListParamsTest.kt @@ -42,7 +42,11 @@ internal class DreamListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "dreaming-2026-04-21") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParamsTest.kt index f1689321a..f57630ed1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/dreams/DreamRetrieveParamsTest.kt @@ -39,7 +39,11 @@ internal class DreamRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "dreaming-2026-04-21") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParamsTest.kt index 7f6a309a0..dd34df6d1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentArchiveParamsTest.kt @@ -40,7 +40,11 @@ internal class EnvironmentArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParamsTest.kt index 2f4c397e8..a95e1b316 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentCreateParamsTest.kt @@ -91,7 +91,11 @@ internal class EnvironmentCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParamsTest.kt index 653c847db..f9ef0c5f2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentDeleteParamsTest.kt @@ -40,7 +40,11 @@ internal class EnvironmentDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentListParamsTest.kt index 7e1848bf4..3ba67687c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentListParamsTest.kt @@ -35,7 +35,11 @@ internal class EnvironmentListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParamsTest.kt index ab6289b95..4c8e58b57 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentRetrieveParamsTest.kt @@ -42,7 +42,11 @@ internal class EnvironmentRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParamsTest.kt index e3aa81fac..11dcf362e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/EnvironmentUpdateParamsTest.kt @@ -103,7 +103,11 @@ internal class EnvironmentUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkAckParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkAckParamsTest.kt index 4693a3e35..168974da6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkAckParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkAckParamsTest.kt @@ -43,7 +43,13 @@ internal class WorkAckParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParamsTest.kt index e5da89a58..398dc8488 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkHeartbeatParamsTest.kt @@ -48,7 +48,13 @@ internal class WorkHeartbeatParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkListParamsTest.kt index 3cd3af98c..7ddabe450 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkListParamsTest.kt @@ -41,7 +41,13 @@ internal class WorkListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkPollParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkPollParamsTest.kt index f78775d60..1286a105c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkPollParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkPollParamsTest.kt @@ -44,7 +44,11 @@ internal class WorkPollParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("Anthropic-Worker-ID", "Anthropic-Worker-ID") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParamsTest.kt index 9f69ea6cc..6bc875e41 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkRetrieveParamsTest.kt @@ -46,7 +46,11 @@ internal class WorkRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParamsTest.kt index 01611a7cd..7d60999d7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStatsParamsTest.kt @@ -39,7 +39,11 @@ internal class WorkStatsParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStopParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStopParamsTest.kt index 2c15100a9..e27f607d7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStopParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkStopParamsTest.kt @@ -53,7 +53,11 @@ internal class WorkStopParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParamsTest.kt index d9b7ccbe0..828861893 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/environments/work/WorkUpdateParamsTest.kt @@ -68,7 +68,11 @@ internal class WorkUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDeleteParamsTest.kt index 44803275c..0963a8421 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDeleteParamsTest.kt @@ -39,7 +39,7 @@ internal class FileDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDownloadParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDownloadParamsTest.kt index 193eabaff..fdeee0de1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDownloadParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileDownloadParamsTest.kt @@ -39,7 +39,7 @@ internal class FileDownloadParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileListParamsTest.kt index 4a3dcc19b..2f3c98b79 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileListParamsTest.kt @@ -37,7 +37,7 @@ internal class FileListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParamsTest.kt index b074117c8..6ffd029b7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileRetrieveMetadataParamsTest.kt @@ -39,7 +39,7 @@ internal class FileRetrieveMetadataParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileUploadParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileUploadParamsTest.kt index cc4f4042c..f228db81e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileUploadParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/files/FileUploadParamsTest.kt @@ -34,7 +34,7 @@ internal class FileUploadParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParamsTest.kt index 630bc0136..821736507 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreArchiveParamsTest.kt @@ -39,7 +39,11 @@ internal class MemoryStoreArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParamsTest.kt index dbfdd66a3..e8ff8d57c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreCreateParamsTest.kt @@ -43,7 +43,11 @@ internal class MemoryStoreCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParamsTest.kt index 70a63e7b7..545643e47 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreDeleteParamsTest.kt @@ -39,7 +39,11 @@ internal class MemoryStoreDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListPageResponseTest.kt index 1b0d14eb6..0a4d22403 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListPageResponseTest.kt @@ -1,6 +1,5 @@ package com.anthropic.models.beta.memorystores -import com.anthropic.core.JsonValue import com.anthropic.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.OffsetDateTime @@ -16,41 +15,34 @@ internal class MemoryStoreListPageResponseTest { MemoryStoreListPageResponse.builder() .addData( BetaManagedAgentsMemoryStore.builder() - .id("id") - .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - BetaManagedAgentsMemoryStore.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") + .id("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .archivedAt(null) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .description("Per-user preferences and project context.") + .metadata(BetaManagedAgentsMemoryStore.Metadata.builder().build()) + .name("User Preferences") .type(BetaManagedAgentsMemoryStore.Type.MEMORY_STORE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) - .nextPage("next_page") + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() assertThat(memoryStoreListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsMemoryStore.builder() - .id("id") - .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - BetaManagedAgentsMemoryStore.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") + .id("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .archivedAt(null) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .description("Per-user preferences and project context.") + .metadata(BetaManagedAgentsMemoryStore.Metadata.builder().build()) + .name("User Preferences") .type(BetaManagedAgentsMemoryStore.Type.MEMORY_STORE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) - assertThat(memoryStoreListPageResponse.nextPage()).contains("next_page") + assertThat(memoryStoreListPageResponse.nextPage()) + .contains("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") } @Test @@ -62,18 +54,14 @@ internal class MemoryStoreListPageResponseTest { .toBuilder() .addData( BetaManagedAgentsMemoryStore.builder() - .id("id") - .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - BetaManagedAgentsMemoryStore.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") + .id("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .archivedAt(null) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .description("Per-user preferences and project context.") + .metadata(BetaManagedAgentsMemoryStore.Metadata.builder().build()) + .name("User Preferences") .type(BetaManagedAgentsMemoryStore.Type.MEMORY_STORE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) .build() @@ -81,18 +69,14 @@ internal class MemoryStoreListPageResponseTest { assertThat(memoryStoreListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsMemoryStore.builder() - .id("id") - .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - BetaManagedAgentsMemoryStore.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") + .id("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .archivedAt(null) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .description("Per-user preferences and project context.") + .metadata(BetaManagedAgentsMemoryStore.Metadata.builder().build()) + .name("User Preferences") .type(BetaManagedAgentsMemoryStore.Type.MEMORY_STORE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) } @@ -104,21 +88,17 @@ internal class MemoryStoreListPageResponseTest { MemoryStoreListPageResponse.builder() .addData( BetaManagedAgentsMemoryStore.builder() - .id("id") - .archivedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .description("description") - .metadata( - BetaManagedAgentsMemoryStore.Metadata.builder() - .putAdditionalProperty("foo", JsonValue.from("string")) - .build() - ) - .name("name") + .id("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .archivedAt(null) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .description("Per-user preferences and project context.") + .metadata(BetaManagedAgentsMemoryStore.Metadata.builder().build()) + .name("User Preferences") .type(BetaManagedAgentsMemoryStore.Type.MEMORY_STORE) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) - .nextPage("next_page") + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() val roundtrippedMemoryStoreListPageResponse = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParamsTest.kt index bdf73b360..509f59604 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreListParamsTest.kt @@ -40,7 +40,11 @@ internal class MemoryStoreListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParamsTest.kt index 967e18dbb..65b8c2c3f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreRetrieveParamsTest.kt @@ -39,7 +39,11 @@ internal class MemoryStoreRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParamsTest.kt index 893970003..e5223545d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/MemoryStoreUpdateParamsTest.kt @@ -54,7 +54,11 @@ internal class MemoryStoreUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParamsTest.kt index 630324277..34347420d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryCreateParamsTest.kt @@ -51,7 +51,11 @@ internal class MemoryCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParamsTest.kt index 37d5c7945..45eb5af36 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryDeleteParamsTest.kt @@ -49,7 +49,11 @@ internal class MemoryDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListPageResponseTest.kt index 5e6645479..f15c6ec88 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListPageResponseTest.kt @@ -15,39 +15,43 @@ internal class MemoryListPageResponseTest { MemoryListPageResponse.builder() .addData( BetaManagedAgentsMemory.builder() - .id("id") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryStoreId("memory_store_id") - .memoryVersionId("memory_version_id") - .path("path") + .id("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .memoryVersionId("memver_011CZkZBJq5dWxk9fVLNcPht") + .path("/preferences/formatting.md") .type(BetaManagedAgentsMemory.Type.MEMORY) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .content("content") + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .content(null) .build() ) - .nextPage("next_page") + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() assertThat(memoryListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsMemoryListItem.ofMemory( BetaManagedAgentsMemory.builder() - .id("id") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryStoreId("memory_store_id") - .memoryVersionId("memory_version_id") - .path("path") + .id("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .memoryVersionId("memver_011CZkZBJq5dWxk9fVLNcPht") + .path("/preferences/formatting.md") .type(BetaManagedAgentsMemory.Type.MEMORY) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .content("content") + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .content(null) .build() ) ) - assertThat(memoryListPageResponse.nextPage()).contains("next_page") + assertThat(memoryListPageResponse.nextPage()).contains("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") } @Test @@ -60,16 +64,18 @@ internal class MemoryListPageResponseTest { .addData( BetaManagedAgentsMemoryListItem.ofMemory( BetaManagedAgentsMemory.builder() - .id("id") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryStoreId("memory_store_id") - .memoryVersionId("memory_version_id") - .path("path") + .id("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .memoryVersionId("memver_011CZkZBJq5dWxk9fVLNcPht") + .path("/preferences/formatting.md") .type(BetaManagedAgentsMemory.Type.MEMORY) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .content("content") + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .content(null) .build() ) ) @@ -79,16 +85,18 @@ internal class MemoryListPageResponseTest { .containsExactly( BetaManagedAgentsMemoryListItem.ofMemory( BetaManagedAgentsMemory.builder() - .id("id") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryStoreId("memory_store_id") - .memoryVersionId("memory_version_id") - .path("path") + .id("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .memoryVersionId("memver_011CZkZBJq5dWxk9fVLNcPht") + .path("/preferences/formatting.md") .type(BetaManagedAgentsMemory.Type.MEMORY) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .content("content") + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .content(null) .build() ) ) @@ -101,19 +109,21 @@ internal class MemoryListPageResponseTest { MemoryListPageResponse.builder() .addData( BetaManagedAgentsMemory.builder() - .id("id") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryStoreId("memory_store_id") - .memoryVersionId("memory_version_id") - .path("path") + .id("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") + .memoryVersionId("memver_011CZkZBJq5dWxk9fVLNcPht") + .path("/preferences/formatting.md") .type(BetaManagedAgentsMemory.Type.MEMORY) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .content("content") + .updatedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .content(null) .build() ) - .nextPage("next_page") + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() val roundtrippedMemoryListPageResponse = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParamsTest.kt index 2faf3e809..0662afa5a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryListParamsTest.kt @@ -50,7 +50,11 @@ internal class MemoryListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParamsTest.kt index 4fe0b80b1..d207422bf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryRetrieveParamsTest.kt @@ -49,7 +49,11 @@ internal class MemoryRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParamsTest.kt index 4120572b0..521edae8b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memories/MemoryUpdateParamsTest.kt @@ -65,7 +65,11 @@ internal class MemoryUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListPageResponseTest.kt index a386a913d..349892512 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListPageResponseTest.kt @@ -15,43 +15,48 @@ internal class MemoryVersionListPageResponseTest { MemoryVersionListPageResponse.builder() .addData( BetaManagedAgentsMemoryVersion.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryId("memory_id") - .memoryStoreId("memory_store_id") + .id("memver_011CZkZBJq5dWxk9fVLNcPht") + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryId("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") .operation(BetaManagedAgentsMemoryVersionOperation.CREATED) .type(BetaManagedAgentsMemoryVersion.Type.MEMORY_VERSION) - .content("content") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .sessionCreatedBy("x") - .path("path") - .redactedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .content(null) + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .sessionCreatedBy("sesn_011CZkZAtmR3yMPDzynEDxu7") + .path("/preferences/formatting.md") + .redactedAt(null) .sessionRedactedBy("x") .build() ) - .nextPage("next_page") + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() assertThat(memoryVersionListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsMemoryVersion.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryId("memory_id") - .memoryStoreId("memory_store_id") + .id("memver_011CZkZBJq5dWxk9fVLNcPht") + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryId("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") .operation(BetaManagedAgentsMemoryVersionOperation.CREATED) .type(BetaManagedAgentsMemoryVersion.Type.MEMORY_VERSION) - .content("content") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .sessionCreatedBy("x") - .path("path") - .redactedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .content(null) + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .sessionCreatedBy("sesn_011CZkZAtmR3yMPDzynEDxu7") + .path("/preferences/formatting.md") + .redactedAt(null) .sessionRedactedBy("x") .build() ) - assertThat(memoryVersionListPageResponse.nextPage()).contains("next_page") + assertThat(memoryVersionListPageResponse.nextPage()) + .contains("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") } @Test @@ -63,18 +68,20 @@ internal class MemoryVersionListPageResponseTest { .toBuilder() .addData( BetaManagedAgentsMemoryVersion.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryId("memory_id") - .memoryStoreId("memory_store_id") + .id("memver_011CZkZBJq5dWxk9fVLNcPht") + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryId("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") .operation(BetaManagedAgentsMemoryVersionOperation.CREATED) .type(BetaManagedAgentsMemoryVersion.Type.MEMORY_VERSION) - .content("content") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .sessionCreatedBy("x") - .path("path") - .redactedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .content(null) + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .sessionCreatedBy("sesn_011CZkZAtmR3yMPDzynEDxu7") + .path("/preferences/formatting.md") + .redactedAt(null) .sessionRedactedBy("x") .build() ) @@ -83,18 +90,20 @@ internal class MemoryVersionListPageResponseTest { assertThat(memoryVersionListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsMemoryVersion.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryId("memory_id") - .memoryStoreId("memory_store_id") + .id("memver_011CZkZBJq5dWxk9fVLNcPht") + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryId("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") .operation(BetaManagedAgentsMemoryVersionOperation.CREATED) .type(BetaManagedAgentsMemoryVersion.Type.MEMORY_VERSION) - .content("content") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .sessionCreatedBy("x") - .path("path") - .redactedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .content(null) + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .sessionCreatedBy("sesn_011CZkZAtmR3yMPDzynEDxu7") + .path("/preferences/formatting.md") + .redactedAt(null) .sessionRedactedBy("x") .build() ) @@ -107,22 +116,24 @@ internal class MemoryVersionListPageResponseTest { MemoryVersionListPageResponse.builder() .addData( BetaManagedAgentsMemoryVersion.builder() - .id("id") - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .memoryId("memory_id") - .memoryStoreId("memory_store_id") + .id("memver_011CZkZBJq5dWxk9fVLNcPht") + .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .memoryId("mem_011CZkZ9X2dpNyB6YbtxvB6e") + .memoryStoreId("memstore_01Wf3kQ8tZxB2mVr7HcJ4aNd") .operation(BetaManagedAgentsMemoryVersionOperation.CREATED) .type(BetaManagedAgentsMemoryVersion.Type.MEMORY_VERSION) - .content("content") - .contentSha256("content_sha256") - .contentSizeBytes(0) - .sessionCreatedBy("x") - .path("path") - .redactedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .content(null) + .contentSha256( + "ba7936d94c84d948a2232088f78228f175df6a8353b2d5bc9228eee5794a0024" + ) + .contentSizeBytes(28) + .sessionCreatedBy("sesn_011CZkZAtmR3yMPDzynEDxu7") + .path("/preferences/formatting.md") + .redactedAt(null) .sessionRedactedBy("x") .build() ) - .nextPage("next_page") + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() val roundtrippedMemoryVersionListPageResponse = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParamsTest.kt index 1e7f7b608..c4303e2cb 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionListParamsTest.kt @@ -62,7 +62,11 @@ internal class MemoryVersionListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParamsTest.kt index 44b1c1e3f..674ca4cff 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRedactParamsTest.kt @@ -46,7 +46,11 @@ internal class MemoryVersionRedactParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParamsTest.kt index 7007a4307..7818195a9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/memorystores/memoryversions/MemoryVersionRetrieveParamsTest.kt @@ -50,7 +50,11 @@ internal class MemoryVersionRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "agent-memory-2026-07-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorMessageIterationUsageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorMessageIterationUsageTest.kt index 40d3583ee..1111db66f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorMessageIterationUsageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorMessageIterationUsageTest.kt @@ -21,7 +21,7 @@ internal class BetaAdvisorMessageIterationUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() @@ -35,7 +35,7 @@ internal class BetaAdvisorMessageIterationUsageTest { assertThat(betaAdvisorMessageIterationUsage.cacheCreationInputTokens()).isEqualTo(0L) assertThat(betaAdvisorMessageIterationUsage.cacheReadInputTokens()).isEqualTo(0L) assertThat(betaAdvisorMessageIterationUsage.inputTokens()).isEqualTo(0L) - assertThat(betaAdvisorMessageIterationUsage.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(betaAdvisorMessageIterationUsage.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) assertThat(betaAdvisorMessageIterationUsage.outputTokens()).isEqualTo(0L) } @@ -53,7 +53,7 @@ internal class BetaAdvisorMessageIterationUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorTool20260301Test.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorTool20260301Test.kt index 3271ea569..81960590e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorTool20260301Test.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaAdvisorTool20260301Test.kt @@ -13,7 +13,7 @@ internal class BetaAdvisorTool20260301Test { fun create() { val betaAdvisorTool20260301 = BetaAdvisorTool20260301.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .addAllowedCaller(BetaAdvisorTool20260301.AllowedCaller.DIRECT) .cacheControl( BetaCacheControlEphemeral.builder() @@ -31,7 +31,7 @@ internal class BetaAdvisorTool20260301Test { .strict(true) .build() - assertThat(betaAdvisorTool20260301.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(betaAdvisorTool20260301.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) assertThat(betaAdvisorTool20260301.allowedCallers().getOrNull()) .containsExactly(BetaAdvisorTool20260301.AllowedCaller.DIRECT) assertThat(betaAdvisorTool20260301.cacheControl()) @@ -54,7 +54,7 @@ internal class BetaAdvisorTool20260301Test { @Test fun addToUnsetListsOnToBuilder() { - val baseBetaAdvisorTool20260301 = BetaAdvisorTool20260301.of(Model.CLAUDE_SONNET_5_5) + val baseBetaAdvisorTool20260301 = BetaAdvisorTool20260301.of(Model.CLAUDE_HAIKU_5_5) val betaAdvisorTool20260301 = baseBetaAdvisorTool20260301 @@ -71,7 +71,7 @@ internal class BetaAdvisorTool20260301Test { val jsonMapper = jsonMapper() val betaAdvisorTool20260301 = BetaAdvisorTool20260301.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .addAllowedCaller(BetaAdvisorTool20260301.AllowedCaller.DIRECT) .cacheControl( BetaCacheControlEphemeral.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserClickTargetTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserClickTargetTest.kt new file mode 100644 index 000000000..8e445ce05 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserClickTargetTest.kt @@ -0,0 +1,83 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaBrowserClickTargetTest { + + @Test + fun ofCoordinate() { + val coordinate = BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + + val betaBrowserClickTarget = BetaBrowserClickTarget.ofCoordinate(coordinate) + + assertThat(betaBrowserClickTarget.coordinate()).contains(coordinate) + assertThat(betaBrowserClickTarget.ref()).isEmpty + } + + @Test + fun ofCoordinateRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserClickTarget = + BetaBrowserClickTarget.ofCoordinate( + BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + + val roundtrippedBetaBrowserClickTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserClickTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserClickTarget).isEqualTo(betaBrowserClickTarget) + } + + @Test + fun ofRef() { + val ref = BetaBrowserRefTarget.of("ref") + + val betaBrowserClickTarget = BetaBrowserClickTarget.ofRef(ref) + + assertThat(betaBrowserClickTarget.coordinate()).isEmpty + assertThat(betaBrowserClickTarget.ref()).contains(ref) + } + + @Test + fun ofRefRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserClickTarget = BetaBrowserClickTarget.ofRef(BetaBrowserRefTarget.of("ref")) + + val roundtrippedBetaBrowserClickTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserClickTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserClickTarget).isEqualTo(betaBrowserClickTarget) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaBrowserClickTarget = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { betaBrowserClickTarget.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabInputTest.kt new file mode 100644 index 000000000..94bdd8a16 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserCloseTabInputTest { + + @Test + fun create() { + val betaBrowserCloseTabInput = BetaBrowserCloseTabInput.of("tab_id") + + assertThat(betaBrowserCloseTabInput.tabId()).isEqualTo("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserCloseTabInput = BetaBrowserCloseTabInput.of("tab_id") + + val roundtrippedBetaBrowserCloseTabInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserCloseTabInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserCloseTabInput).isEqualTo(betaBrowserCloseTabInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabToolUseBlockTest.kt new file mode 100644 index 000000000..ea608cca1 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCloseTabToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserCloseTabToolUseBlockTest { + + @Test + fun create() { + val betaBrowserCloseTabToolUseBlock = + BetaBrowserCloseTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserCloseTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserCloseTabToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserCloseTabToolUseBlock.input()) + .isEqualTo(BetaBrowserCloseTabInput.of("tab_id")) + assertThat(betaBrowserCloseTabToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserCloseTabToolUseBlock = + BetaBrowserCloseTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserCloseTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserCloseTabToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserCloseTabToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserCloseTabToolUseBlock) + .isEqualTo(betaBrowserCloseTabToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCoordinateTargetTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCoordinateTargetTest.kt new file mode 100644 index 000000000..69e3db168 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserCoordinateTargetTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserCoordinateTargetTest { + + @Test + fun create() { + val betaBrowserCoordinateTarget = BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + + assertThat(betaBrowserCoordinateTarget.x()).isEqualTo(0L) + assertThat(betaBrowserCoordinateTarget.y()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserCoordinateTarget = BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + + val roundtrippedBetaBrowserCoordinateTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserCoordinateTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserCoordinateTarget).isEqualTo(betaBrowserCoordinateTarget) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickInputTest.kt new file mode 100644 index 000000000..88b4c0307 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserDoubleClickInputTest { + + @Test + fun create() { + val betaBrowserDoubleClickInput = + BetaBrowserDoubleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(betaBrowserDoubleClickInput.target()) + .isEqualTo( + BetaBrowserClickTarget.ofCoordinate( + BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(betaBrowserDoubleClickInput.modifiers()).contains("modifiers") + assertThat(betaBrowserDoubleClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserDoubleClickInput = + BetaBrowserDoubleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserDoubleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserDoubleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserDoubleClickInput).isEqualTo(betaBrowserDoubleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickToolUseBlockTest.kt new file mode 100644 index 000000000..f55c54e94 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserDoubleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserDoubleClickToolUseBlockTest { + + @Test + fun create() { + val betaBrowserDoubleClickToolUseBlock = + BetaBrowserDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserDoubleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserDoubleClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserDoubleClickToolUseBlock.input()) + .isEqualTo( + BetaBrowserDoubleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserDoubleClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserDoubleClickToolUseBlock = + BetaBrowserDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserDoubleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserDoubleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserDoubleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserDoubleClickToolUseBlock) + .isEqualTo(betaBrowserDoubleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadInputTest.kt new file mode 100644 index 000000000..2b271170a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadInputTest.kt @@ -0,0 +1,62 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserFileUploadInputTest { + + @Test + fun create() { + val betaBrowserFileUploadInput = + BetaBrowserFileUploadInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + + assertThat(betaBrowserFileUploadInput.target()).isEqualTo(BetaBrowserRefTarget.of("ref")) + assertThat(betaBrowserFileUploadInput.documentIds().getOrNull()).containsExactly("string") + assertThat(betaBrowserFileUploadInput.paths().getOrNull()).containsExactly("string") + assertThat(betaBrowserFileUploadInput.tabId()).contains("tab_id") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaBrowserFileUploadInput = + BetaBrowserFileUploadInput.of(BetaBrowserRefTarget.of("ref")) + + val betaBrowserFileUploadInput = + baseBetaBrowserFileUploadInput + .toBuilder() + .addDocumentId("string") + .addPath("string") + .build() + + assertThat(betaBrowserFileUploadInput.documentIds().getOrNull()).containsExactly("string") + assertThat(betaBrowserFileUploadInput.paths().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFileUploadInput = + BetaBrowserFileUploadInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserFileUploadInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFileUploadInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFileUploadInput).isEqualTo(betaBrowserFileUploadInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadToolUseBlockTest.kt new file mode 100644 index 000000000..299963cb3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFileUploadToolUseBlockTest.kt @@ -0,0 +1,66 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserFileUploadToolUseBlockTest { + + @Test + fun create() { + val betaBrowserFileUploadToolUseBlock = + BetaBrowserFileUploadToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFileUploadInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserFileUploadToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserFileUploadToolUseBlock.input()) + .isEqualTo( + BetaBrowserFileUploadInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserFileUploadToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFileUploadToolUseBlock = + BetaBrowserFileUploadToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFileUploadInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserFileUploadToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFileUploadToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFileUploadToolUseBlock) + .isEqualTo(betaBrowserFileUploadToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindInputTest.kt new file mode 100644 index 000000000..273f3ac90 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserFindInputTest { + + @Test + fun create() { + val betaBrowserFindInput = + BetaBrowserFindInput.builder().query("query").tabId("tab_id").build() + + assertThat(betaBrowserFindInput.query()).isEqualTo("query") + assertThat(betaBrowserFindInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFindInput = + BetaBrowserFindInput.builder().query("query").tabId("tab_id").build() + + val roundtrippedBetaBrowserFindInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFindInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFindInput).isEqualTo(betaBrowserFindInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindToolUseBlockTest.kt new file mode 100644 index 000000000..29b7fd4fe --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFindToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserFindToolUseBlockTest { + + @Test + fun create() { + val betaBrowserFindToolUseBlock = + BetaBrowserFindToolUseBlock.builder() + .id("id") + .input(BetaBrowserFindInput.builder().query("query").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserFindToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserFindToolUseBlock.input()) + .isEqualTo(BetaBrowserFindInput.builder().query("query").tabId("tab_id").build()) + assertThat(betaBrowserFindToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFindToolUseBlock = + BetaBrowserFindToolUseBlock.builder() + .id("id") + .input(BetaBrowserFindInput.builder().query("query").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserFindToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFindToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFindToolUseBlock).isEqualTo(betaBrowserFindToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputInputTest.kt new file mode 100644 index 000000000..3f04cb865 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputInputTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserFormInputInputTest { + + @Test + fun create() { + val betaBrowserFormInputInput = + BetaBrowserFormInputInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + + assertThat(betaBrowserFormInputInput.target()).isEqualTo(BetaBrowserRefTarget.of("ref")) + assertThat(betaBrowserFormInputInput.value()) + .isEqualTo(BetaBrowserFormInputValue.ofString("string")) + assertThat(betaBrowserFormInputInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFormInputInput = + BetaBrowserFormInputInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserFormInputInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFormInputInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFormInputInput).isEqualTo(betaBrowserFormInputInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputToolUseBlockTest.kt new file mode 100644 index 000000000..357cbb0ac --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserFormInputToolUseBlockTest { + + @Test + fun create() { + val betaBrowserFormInputToolUseBlock = + BetaBrowserFormInputToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFormInputInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserFormInputToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserFormInputToolUseBlock.input()) + .isEqualTo( + BetaBrowserFormInputInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserFormInputToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFormInputToolUseBlock = + BetaBrowserFormInputToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFormInputInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserFormInputToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFormInputToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFormInputToolUseBlock) + .isEqualTo(betaBrowserFormInputToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputValueTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputValueTest.kt new file mode 100644 index 000000000..4791716ea --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserFormInputValueTest.kt @@ -0,0 +1,104 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaBrowserFormInputValueTest { + + @Test + fun ofString() { + val string = "string" + + val betaBrowserFormInputValue = BetaBrowserFormInputValue.ofString(string) + + assertThat(betaBrowserFormInputValue.string()).contains(string) + assertThat(betaBrowserFormInputValue.number()).isEmpty + assertThat(betaBrowserFormInputValue.bool()).isEmpty + } + + @Test + fun ofStringRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFormInputValue = BetaBrowserFormInputValue.ofString("string") + + val roundtrippedBetaBrowserFormInputValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFormInputValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFormInputValue).isEqualTo(betaBrowserFormInputValue) + } + + @Test + fun ofNumber() { + val number = 0.0 + + val betaBrowserFormInputValue = BetaBrowserFormInputValue.ofNumber(number) + + assertThat(betaBrowserFormInputValue.string()).isEmpty + assertThat(betaBrowserFormInputValue.number()).contains(number) + assertThat(betaBrowserFormInputValue.bool()).isEmpty + } + + @Test + fun ofNumberRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFormInputValue = BetaBrowserFormInputValue.ofNumber(0.0) + + val roundtrippedBetaBrowserFormInputValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFormInputValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFormInputValue).isEqualTo(betaBrowserFormInputValue) + } + + @Test + fun ofBool() { + val bool = true + + val betaBrowserFormInputValue = BetaBrowserFormInputValue.ofBool(bool) + + assertThat(betaBrowserFormInputValue.string()).isEmpty + assertThat(betaBrowserFormInputValue.number()).isEmpty + assertThat(betaBrowserFormInputValue.bool()).contains(bool) + } + + @Test + fun ofBoolRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserFormInputValue = BetaBrowserFormInputValue.ofBool(true) + + val roundtrippedBetaBrowserFormInputValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserFormInputValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserFormInputValue).isEqualTo(betaBrowserFormInputValue) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + OBJECT(JsonValue.from(mapOf("invalid" to "object"))), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaBrowserFormInputValue = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { betaBrowserFormInputValue.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextInputTest.kt new file mode 100644 index 000000000..61b6a83ad --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextInputTest.kt @@ -0,0 +1,32 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserGetPageTextInputTest { + + @Test + fun create() { + val betaBrowserGetPageTextInput = + BetaBrowserGetPageTextInput.builder().tabId("tab_id").build() + + assertThat(betaBrowserGetPageTextInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserGetPageTextInput = + BetaBrowserGetPageTextInput.builder().tabId("tab_id").build() + + val roundtrippedBetaBrowserGetPageTextInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserGetPageTextInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserGetPageTextInput).isEqualTo(betaBrowserGetPageTextInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextToolUseBlockTest.kt new file mode 100644 index 000000000..917c614ed --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserGetPageTextToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserGetPageTextToolUseBlockTest { + + @Test + fun create() { + val betaBrowserGetPageTextToolUseBlock = + BetaBrowserGetPageTextToolUseBlock.builder() + .id("id") + .input(BetaBrowserGetPageTextInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserGetPageTextToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserGetPageTextToolUseBlock.input()) + .isEqualTo(BetaBrowserGetPageTextInput.builder().tabId("tab_id").build()) + assertThat(betaBrowserGetPageTextToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserGetPageTextToolUseBlock = + BetaBrowserGetPageTextToolUseBlock.builder() + .id("id") + .input(BetaBrowserGetPageTextInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserGetPageTextToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserGetPageTextToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserGetPageTextToolUseBlock) + .isEqualTo(betaBrowserGetPageTextToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyInputTest.kt new file mode 100644 index 000000000..b0a871623 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyInputTest.kt @@ -0,0 +1,34 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserHoldKeyInputTest { + + @Test + fun create() { + val betaBrowserHoldKeyInput = + BetaBrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + + assertThat(betaBrowserHoldKeyInput.duration()).isEqualTo(0.0) + assertThat(betaBrowserHoldKeyInput.text()).isEqualTo("text") + assertThat(betaBrowserHoldKeyInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserHoldKeyInput = + BetaBrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + + val roundtrippedBetaBrowserHoldKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserHoldKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserHoldKeyInput).isEqualTo(betaBrowserHoldKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyToolUseBlockTest.kt new file mode 100644 index 000000000..d8bc0fa0a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoldKeyToolUseBlockTest.kt @@ -0,0 +1,59 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserHoldKeyToolUseBlockTest { + + @Test + fun create() { + val betaBrowserHoldKeyToolUseBlock = + BetaBrowserHoldKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoldKeyInput.builder() + .duration(0.0) + .text("text") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserHoldKeyToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserHoldKeyToolUseBlock.input()) + .isEqualTo( + BetaBrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + ) + assertThat(betaBrowserHoldKeyToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserHoldKeyToolUseBlock = + BetaBrowserHoldKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoldKeyInput.builder() + .duration(0.0) + .text("text") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserHoldKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserHoldKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserHoldKeyToolUseBlock) + .isEqualTo(betaBrowserHoldKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverInputTest.kt new file mode 100644 index 000000000..eb2841f59 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverInputTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserHoverInputTest { + + @Test + fun create() { + val betaBrowserHoverInput = + BetaBrowserHoverInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(betaBrowserHoverInput.target()) + .isEqualTo( + BetaBrowserClickTarget.ofCoordinate( + BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(betaBrowserHoverInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserHoverInput = + BetaBrowserHoverInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserHoverInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserHoverInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserHoverInput).isEqualTo(betaBrowserHoverInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverToolUseBlockTest.kt new file mode 100644 index 000000000..376fa3582 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserHoverToolUseBlockTest.kt @@ -0,0 +1,59 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserHoverToolUseBlockTest { + + @Test + fun create() { + val betaBrowserHoverToolUseBlock = + BetaBrowserHoverToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoverInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserHoverToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserHoverToolUseBlock.input()) + .isEqualTo( + BetaBrowserHoverInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserHoverToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserHoverToolUseBlock = + BetaBrowserHoverToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoverInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserHoverToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserHoverToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserHoverToolUseBlock).isEqualTo(betaBrowserHoverToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecInputTest.kt new file mode 100644 index 000000000..24b29b0bf --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecInputTest.kt @@ -0,0 +1,34 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserJavascriptExecInputTest { + + @Test + fun create() { + val betaBrowserJavascriptExecInput = + BetaBrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + + assertThat(betaBrowserJavascriptExecInput.text()).isEqualTo("text") + assertThat(betaBrowserJavascriptExecInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserJavascriptExecInput = + BetaBrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + + val roundtrippedBetaBrowserJavascriptExecInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserJavascriptExecInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserJavascriptExecInput) + .isEqualTo(betaBrowserJavascriptExecInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecToolUseBlockTest.kt new file mode 100644 index 000000000..55f9a7f51 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserJavascriptExecToolUseBlockTest.kt @@ -0,0 +1,51 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserJavascriptExecToolUseBlockTest { + + @Test + fun create() { + val betaBrowserJavascriptExecToolUseBlock = + BetaBrowserJavascriptExecToolUseBlock.builder() + .id("id") + .input( + BetaBrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserJavascriptExecToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserJavascriptExecToolUseBlock.input()) + .isEqualTo( + BetaBrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + ) + assertThat(betaBrowserJavascriptExecToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserJavascriptExecToolUseBlock = + BetaBrowserJavascriptExecToolUseBlock.builder() + .id("id") + .input( + BetaBrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserJavascriptExecToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserJavascriptExecToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserJavascriptExecToolUseBlock) + .isEqualTo(betaBrowserJavascriptExecToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyInputTest.kt new file mode 100644 index 000000000..18927b449 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyInputTest.kt @@ -0,0 +1,34 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserKeyInputTest { + + @Test + fun create() { + val betaBrowserKeyInput = + BetaBrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + + assertThat(betaBrowserKeyInput.text()).isEqualTo("text") + assertThat(betaBrowserKeyInput.repeat()).contains(1L) + assertThat(betaBrowserKeyInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserKeyInput = + BetaBrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + + val roundtrippedBetaBrowserKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserKeyInput).isEqualTo(betaBrowserKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyToolUseBlockTest.kt new file mode 100644 index 000000000..dbb103a1c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserKeyToolUseBlockTest.kt @@ -0,0 +1,50 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserKeyToolUseBlockTest { + + @Test + fun create() { + val betaBrowserKeyToolUseBlock = + BetaBrowserKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserKeyToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserKeyToolUseBlock.input()) + .isEqualTo( + BetaBrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + ) + assertThat(betaBrowserKeyToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserKeyToolUseBlock = + BetaBrowserKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserKeyToolUseBlock).isEqualTo(betaBrowserKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragInputTest.kt new file mode 100644 index 000000000..cd5b57af1 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragInputTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftClickDragInputTest { + + @Test + fun create() { + val betaBrowserLeftClickDragInput = + BetaBrowserLeftClickDragInput.builder() + .from(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(betaBrowserLeftClickDragInput.from()) + .isEqualTo(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(betaBrowserLeftClickDragInput.target()) + .isEqualTo(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(betaBrowserLeftClickDragInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftClickDragInput = + BetaBrowserLeftClickDragInput.builder() + .from(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserLeftClickDragInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftClickDragInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftClickDragInput) + .isEqualTo(betaBrowserLeftClickDragInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragToolUseBlockTest.kt new file mode 100644 index 000000000..d69e00b3b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickDragToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftClickDragToolUseBlockTest { + + @Test + fun create() { + val betaBrowserLeftClickDragToolUseBlock = + BetaBrowserLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickDragInput.builder() + .from(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserLeftClickDragToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserLeftClickDragToolUseBlock.input()) + .isEqualTo( + BetaBrowserLeftClickDragInput.builder() + .from(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserLeftClickDragToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftClickDragToolUseBlock = + BetaBrowserLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickDragInput.builder() + .from(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserLeftClickDragToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftClickDragToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftClickDragToolUseBlock) + .isEqualTo(betaBrowserLeftClickDragToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickInputTest.kt new file mode 100644 index 000000000..85b540991 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftClickInputTest { + + @Test + fun create() { + val betaBrowserLeftClickInput = + BetaBrowserLeftClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(betaBrowserLeftClickInput.target()) + .isEqualTo( + BetaBrowserClickTarget.ofCoordinate( + BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(betaBrowserLeftClickInput.modifiers()).contains("modifiers") + assertThat(betaBrowserLeftClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftClickInput = + BetaBrowserLeftClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserLeftClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftClickInput).isEqualTo(betaBrowserLeftClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickToolUseBlockTest.kt new file mode 100644 index 000000000..de485532a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftClickToolUseBlockTest { + + @Test + fun create() { + val betaBrowserLeftClickToolUseBlock = + BetaBrowserLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserLeftClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserLeftClickToolUseBlock.input()) + .isEqualTo( + BetaBrowserLeftClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserLeftClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftClickToolUseBlock = + BetaBrowserLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserLeftClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftClickToolUseBlock) + .isEqualTo(betaBrowserLeftClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownInputTest.kt new file mode 100644 index 000000000..a34a9845a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownInputTest.kt @@ -0,0 +1,41 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftMouseDownInputTest { + + @Test + fun create() { + val betaBrowserLeftMouseDownInput = + BetaBrowserLeftMouseDownInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(betaBrowserLeftMouseDownInput.target()) + .isEqualTo(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(betaBrowserLeftMouseDownInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftMouseDownInput = + BetaBrowserLeftMouseDownInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserLeftMouseDownInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftMouseDownInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftMouseDownInput) + .isEqualTo(betaBrowserLeftMouseDownInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownToolUseBlockTest.kt new file mode 100644 index 000000000..6ddbb4019 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseDownToolUseBlockTest.kt @@ -0,0 +1,60 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftMouseDownToolUseBlockTest { + + @Test + fun create() { + val betaBrowserLeftMouseDownToolUseBlock = + BetaBrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseDownInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserLeftMouseDownToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserLeftMouseDownToolUseBlock.input()) + .isEqualTo( + BetaBrowserLeftMouseDownInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserLeftMouseDownToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftMouseDownToolUseBlock = + BetaBrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseDownInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserLeftMouseDownToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftMouseDownToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftMouseDownToolUseBlock) + .isEqualTo(betaBrowserLeftMouseDownToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpInputTest.kt new file mode 100644 index 000000000..3bfe534e2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpInputTest.kt @@ -0,0 +1,40 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftMouseUpInputTest { + + @Test + fun create() { + val betaBrowserLeftMouseUpInput = + BetaBrowserLeftMouseUpInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(betaBrowserLeftMouseUpInput.target()) + .isEqualTo(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(betaBrowserLeftMouseUpInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftMouseUpInput = + BetaBrowserLeftMouseUpInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserLeftMouseUpInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftMouseUpInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftMouseUpInput).isEqualTo(betaBrowserLeftMouseUpInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpToolUseBlockTest.kt new file mode 100644 index 000000000..c96999805 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserLeftMouseUpToolUseBlockTest.kt @@ -0,0 +1,60 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserLeftMouseUpToolUseBlockTest { + + @Test + fun create() { + val betaBrowserLeftMouseUpToolUseBlock = + BetaBrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseUpInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserLeftMouseUpToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserLeftMouseUpToolUseBlock.input()) + .isEqualTo( + BetaBrowserLeftMouseUpInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserLeftMouseUpToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserLeftMouseUpToolUseBlock = + BetaBrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseUpInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserLeftMouseUpToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserLeftMouseUpToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserLeftMouseUpToolUseBlock) + .isEqualTo(betaBrowserLeftMouseUpToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsInputTest.kt new file mode 100644 index 000000000..e242bc957 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserListTabsInputTest { + + @Test + fun create() { + val betaBrowserListTabsInput = BetaBrowserListTabsInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserListTabsInput = BetaBrowserListTabsInput.builder().build() + + val roundtrippedBetaBrowserListTabsInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserListTabsInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserListTabsInput).isEqualTo(betaBrowserListTabsInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsToolUseBlockTest.kt new file mode 100644 index 000000000..16d232712 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserListTabsToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserListTabsToolUseBlockTest { + + @Test + fun create() { + val betaBrowserListTabsToolUseBlock = + BetaBrowserListTabsToolUseBlock.builder() + .id("id") + .input(BetaBrowserListTabsInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserListTabsToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserListTabsToolUseBlock.input()) + .isEqualTo(BetaBrowserListTabsInput.builder().build()) + assertThat(betaBrowserListTabsToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserListTabsToolUseBlock = + BetaBrowserListTabsToolUseBlock.builder() + .id("id") + .input(BetaBrowserListTabsInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserListTabsToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserListTabsToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserListTabsToolUseBlock) + .isEqualTo(betaBrowserListTabsToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickInputTest.kt new file mode 100644 index 000000000..12043479b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserMiddleClickInputTest { + + @Test + fun create() { + val betaBrowserMiddleClickInput = + BetaBrowserMiddleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(betaBrowserMiddleClickInput.target()) + .isEqualTo( + BetaBrowserClickTarget.ofCoordinate( + BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(betaBrowserMiddleClickInput.modifiers()).contains("modifiers") + assertThat(betaBrowserMiddleClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserMiddleClickInput = + BetaBrowserMiddleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserMiddleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserMiddleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserMiddleClickInput).isEqualTo(betaBrowserMiddleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickToolUseBlockTest.kt new file mode 100644 index 000000000..d86c9797d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMiddleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserMiddleClickToolUseBlockTest { + + @Test + fun create() { + val betaBrowserMiddleClickToolUseBlock = + BetaBrowserMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMiddleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserMiddleClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserMiddleClickToolUseBlock.input()) + .isEqualTo( + BetaBrowserMiddleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserMiddleClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserMiddleClickToolUseBlock = + BetaBrowserMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMiddleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserMiddleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserMiddleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserMiddleClickToolUseBlock) + .isEqualTo(betaBrowserMiddleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveInputTest.kt new file mode 100644 index 000000000..05ebf329d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveInputTest.kt @@ -0,0 +1,40 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserMouseMoveInputTest { + + @Test + fun create() { + val betaBrowserMouseMoveInput = + BetaBrowserMouseMoveInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(betaBrowserMouseMoveInput.target()) + .isEqualTo(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(betaBrowserMouseMoveInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserMouseMoveInput = + BetaBrowserMouseMoveInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserMouseMoveInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserMouseMoveInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserMouseMoveInput).isEqualTo(betaBrowserMouseMoveInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveToolUseBlockTest.kt new file mode 100644 index 000000000..f7c62756f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserMouseMoveToolUseBlockTest.kt @@ -0,0 +1,60 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserMouseMoveToolUseBlockTest { + + @Test + fun create() { + val betaBrowserMouseMoveToolUseBlock = + BetaBrowserMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMouseMoveInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserMouseMoveToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserMouseMoveToolUseBlock.input()) + .isEqualTo( + BetaBrowserMouseMoveInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserMouseMoveToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserMouseMoveToolUseBlock = + BetaBrowserMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMouseMoveInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserMouseMoveToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserMouseMoveToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserMouseMoveToolUseBlock) + .isEqualTo(betaBrowserMouseMoveToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateInputTest.kt new file mode 100644 index 000000000..1e44a728c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserNavigateInputTest { + + @Test + fun create() { + val betaBrowserNavigateInput = + BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build() + + assertThat(betaBrowserNavigateInput.url()).isEqualTo("url") + assertThat(betaBrowserNavigateInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserNavigateInput = + BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build() + + val roundtrippedBetaBrowserNavigateInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserNavigateInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserNavigateInput).isEqualTo(betaBrowserNavigateInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateToolUseBlockTest.kt new file mode 100644 index 000000000..c452b151e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNavigateToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserNavigateToolUseBlockTest { + + @Test + fun create() { + val betaBrowserNavigateToolUseBlock = + BetaBrowserNavigateToolUseBlock.builder() + .id("id") + .input(BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserNavigateToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserNavigateToolUseBlock.input()) + .isEqualTo(BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + assertThat(betaBrowserNavigateToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserNavigateToolUseBlock = + BetaBrowserNavigateToolUseBlock.builder() + .id("id") + .input(BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserNavigateToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserNavigateToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserNavigateToolUseBlock) + .isEqualTo(betaBrowserNavigateToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabInputTest.kt new file mode 100644 index 000000000..bdf9219e3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserNewTabInputTest { + + @Test + fun create() { + val betaBrowserNewTabInput = BetaBrowserNewTabInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserNewTabInput = BetaBrowserNewTabInput.builder().build() + + val roundtrippedBetaBrowserNewTabInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserNewTabInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserNewTabInput).isEqualTo(betaBrowserNewTabInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabToolUseBlockTest.kt new file mode 100644 index 000000000..ad23b3844 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserNewTabToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserNewTabToolUseBlockTest { + + @Test + fun create() { + val betaBrowserNewTabToolUseBlock = + BetaBrowserNewTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserNewTabInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserNewTabToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserNewTabToolUseBlock.input()) + .isEqualTo(BetaBrowserNewTabInput.builder().build()) + assertThat(betaBrowserNewTabToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserNewTabToolUseBlock = + BetaBrowserNewTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserNewTabInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserNewTabToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserNewTabToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserNewTabToolUseBlock) + .isEqualTo(betaBrowserNewTabToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleInputTest.kt new file mode 100644 index 000000000..9e3cd6ed3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleInputTest.kt @@ -0,0 +1,32 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserReadConsoleInputTest { + + @Test + fun create() { + val betaBrowserReadConsoleInput = + BetaBrowserReadConsoleInput.builder().tabId("tab_id").build() + + assertThat(betaBrowserReadConsoleInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserReadConsoleInput = + BetaBrowserReadConsoleInput.builder().tabId("tab_id").build() + + val roundtrippedBetaBrowserReadConsoleInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserReadConsoleInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserReadConsoleInput).isEqualTo(betaBrowserReadConsoleInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleToolUseBlockTest.kt new file mode 100644 index 000000000..ebc18a4a5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadConsoleToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserReadConsoleToolUseBlockTest { + + @Test + fun create() { + val betaBrowserReadConsoleToolUseBlock = + BetaBrowserReadConsoleToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadConsoleInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserReadConsoleToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserReadConsoleToolUseBlock.input()) + .isEqualTo(BetaBrowserReadConsoleInput.builder().tabId("tab_id").build()) + assertThat(betaBrowserReadConsoleToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserReadConsoleToolUseBlock = + BetaBrowserReadConsoleToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadConsoleInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserReadConsoleToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserReadConsoleToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserReadConsoleToolUseBlock) + .isEqualTo(betaBrowserReadConsoleToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkInputTest.kt new file mode 100644 index 000000000..ceadbf9a2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkInputTest.kt @@ -0,0 +1,32 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserReadNetworkInputTest { + + @Test + fun create() { + val betaBrowserReadNetworkInput = + BetaBrowserReadNetworkInput.builder().tabId("tab_id").build() + + assertThat(betaBrowserReadNetworkInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserReadNetworkInput = + BetaBrowserReadNetworkInput.builder().tabId("tab_id").build() + + val roundtrippedBetaBrowserReadNetworkInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserReadNetworkInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserReadNetworkInput).isEqualTo(betaBrowserReadNetworkInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkToolUseBlockTest.kt new file mode 100644 index 000000000..5438d9806 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadNetworkToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserReadNetworkToolUseBlockTest { + + @Test + fun create() { + val betaBrowserReadNetworkToolUseBlock = + BetaBrowserReadNetworkToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadNetworkInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserReadNetworkToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserReadNetworkToolUseBlock.input()) + .isEqualTo(BetaBrowserReadNetworkInput.builder().tabId("tab_id").build()) + assertThat(betaBrowserReadNetworkToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserReadNetworkToolUseBlock = + BetaBrowserReadNetworkToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadNetworkInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserReadNetworkToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserReadNetworkToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserReadNetworkToolUseBlock) + .isEqualTo(betaBrowserReadNetworkToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageInputTest.kt new file mode 100644 index 000000000..245ffa02c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageInputTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserReadPageInputTest { + + @Test + fun create() { + val betaBrowserReadPageInput = + BetaBrowserReadPageInput.builder() + .depth(1L) + .filter(BetaBrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + + assertThat(betaBrowserReadPageInput.depth()).contains(1L) + assertThat(betaBrowserReadPageInput.filter()).contains(BetaBrowserReadPageFilter.ALL) + assertThat(betaBrowserReadPageInput.ref()).contains("ref") + assertThat(betaBrowserReadPageInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserReadPageInput = + BetaBrowserReadPageInput.builder() + .depth(1L) + .filter(BetaBrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserReadPageInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserReadPageInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserReadPageInput).isEqualTo(betaBrowserReadPageInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageToolUseBlockTest.kt new file mode 100644 index 000000000..da3b94d61 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserReadPageToolUseBlockTest.kt @@ -0,0 +1,66 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserReadPageToolUseBlockTest { + + @Test + fun create() { + val betaBrowserReadPageToolUseBlock = + BetaBrowserReadPageToolUseBlock.builder() + .id("id") + .input( + BetaBrowserReadPageInput.builder() + .depth(1L) + .filter(BetaBrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserReadPageToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserReadPageToolUseBlock.input()) + .isEqualTo( + BetaBrowserReadPageInput.builder() + .depth(1L) + .filter(BetaBrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserReadPageToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserReadPageToolUseBlock = + BetaBrowserReadPageToolUseBlock.builder() + .id("id") + .input( + BetaBrowserReadPageInput.builder() + .depth(1L) + .filter(BetaBrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserReadPageToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserReadPageToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserReadPageToolUseBlock) + .isEqualTo(betaBrowserReadPageToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRefTargetTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRefTargetTest.kt new file mode 100644 index 000000000..311d22a88 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRefTargetTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserRefTargetTest { + + @Test + fun create() { + val betaBrowserRefTarget = BetaBrowserRefTarget.of("ref") + + assertThat(betaBrowserRefTarget.ref()).isEqualTo("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserRefTarget = BetaBrowserRefTarget.of("ref") + + val roundtrippedBetaBrowserRefTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserRefTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserRefTarget).isEqualTo(betaBrowserRefTarget) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickInputTest.kt new file mode 100644 index 000000000..210374eb3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserRightClickInputTest { + + @Test + fun create() { + val betaBrowserRightClickInput = + BetaBrowserRightClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(betaBrowserRightClickInput.target()) + .isEqualTo( + BetaBrowserClickTarget.ofCoordinate( + BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(betaBrowserRightClickInput.modifiers()).contains("modifiers") + assertThat(betaBrowserRightClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserRightClickInput = + BetaBrowserRightClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserRightClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserRightClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserRightClickInput).isEqualTo(betaBrowserRightClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickToolUseBlockTest.kt new file mode 100644 index 000000000..da8d863d3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserRightClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserRightClickToolUseBlockTest { + + @Test + fun create() { + val betaBrowserRightClickToolUseBlock = + BetaBrowserRightClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserRightClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserRightClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserRightClickToolUseBlock.input()) + .isEqualTo( + BetaBrowserRightClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserRightClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserRightClickToolUseBlock = + BetaBrowserRightClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserRightClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserRightClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserRightClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserRightClickToolUseBlock) + .isEqualTo(betaBrowserRightClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotInputTest.kt new file mode 100644 index 000000000..4873e2e04 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotInputTest.kt @@ -0,0 +1,32 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserScreenshotInputTest { + + @Test + fun create() { + val betaBrowserScreenshotInput = + BetaBrowserScreenshotInput.builder().tabId("tab_id").build() + + assertThat(betaBrowserScreenshotInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserScreenshotInput = + BetaBrowserScreenshotInput.builder().tabId("tab_id").build() + + val roundtrippedBetaBrowserScreenshotInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserScreenshotInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserScreenshotInput).isEqualTo(betaBrowserScreenshotInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotToolUseBlockTest.kt new file mode 100644 index 000000000..555634591 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScreenshotToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserScreenshotToolUseBlockTest { + + @Test + fun create() { + val betaBrowserScreenshotToolUseBlock = + BetaBrowserScreenshotToolUseBlock.builder() + .id("id") + .input(BetaBrowserScreenshotInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserScreenshotToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserScreenshotToolUseBlock.input()) + .isEqualTo(BetaBrowserScreenshotInput.builder().tabId("tab_id").build()) + assertThat(betaBrowserScreenshotToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserScreenshotToolUseBlock = + BetaBrowserScreenshotToolUseBlock.builder() + .id("id") + .input(BetaBrowserScreenshotInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserScreenshotToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserScreenshotToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserScreenshotToolUseBlock) + .isEqualTo(betaBrowserScreenshotToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollInputTest.kt new file mode 100644 index 000000000..7f7c923a4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserScrollInputTest { + + @Test + fun create() { + val betaBrowserScrollInput = + BetaBrowserScrollInput.builder() + .scrollDirection(BetaBrowserScrollDirection.UP) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + + assertThat(betaBrowserScrollInput.scrollDirection()) + .isEqualTo(BetaBrowserScrollDirection.UP) + assertThat(betaBrowserScrollInput.target()) + .isEqualTo(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(betaBrowserScrollInput.scrollAmount()).contains(1L) + assertThat(betaBrowserScrollInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserScrollInput = + BetaBrowserScrollInput.builder() + .scrollDirection(BetaBrowserScrollDirection.UP) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserScrollInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserScrollInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserScrollInput).isEqualTo(betaBrowserScrollInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToInputTest.kt new file mode 100644 index 000000000..7d7b92a99 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToInputTest.kt @@ -0,0 +1,39 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserScrollToInputTest { + + @Test + fun create() { + val betaBrowserScrollToInput = + BetaBrowserScrollToInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + + assertThat(betaBrowserScrollToInput.target()).isEqualTo(BetaBrowserRefTarget.of("ref")) + assertThat(betaBrowserScrollToInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserScrollToInput = + BetaBrowserScrollToInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserScrollToInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserScrollToInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserScrollToInput).isEqualTo(betaBrowserScrollToInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToToolUseBlockTest.kt new file mode 100644 index 000000000..33923be0f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToToolUseBlockTest.kt @@ -0,0 +1,60 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserScrollToToolUseBlockTest { + + @Test + fun create() { + val betaBrowserScrollToToolUseBlock = + BetaBrowserScrollToToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollToInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserScrollToToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserScrollToToolUseBlock.input()) + .isEqualTo( + BetaBrowserScrollToInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserScrollToToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserScrollToToolUseBlock = + BetaBrowserScrollToToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollToInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserScrollToToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserScrollToToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserScrollToToolUseBlock) + .isEqualTo(betaBrowserScrollToToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToolUseBlockTest.kt new file mode 100644 index 000000000..e887f83c4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserScrollToolUseBlockTest.kt @@ -0,0 +1,66 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserScrollToolUseBlockTest { + + @Test + fun create() { + val betaBrowserScrollToolUseBlock = + BetaBrowserScrollToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollInput.builder() + .scrollDirection(BetaBrowserScrollDirection.UP) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserScrollToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserScrollToolUseBlock.input()) + .isEqualTo( + BetaBrowserScrollInput.builder() + .scrollDirection(BetaBrowserScrollDirection.UP) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserScrollToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserScrollToolUseBlock = + BetaBrowserScrollToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollInput.builder() + .scrollDirection(BetaBrowserScrollDirection.UP) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserScrollToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserScrollToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserScrollToolUseBlock) + .isEqualTo(betaBrowserScrollToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabInputTest.kt new file mode 100644 index 000000000..b9af04fc0 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserSwitchTabInputTest { + + @Test + fun create() { + val betaBrowserSwitchTabInput = BetaBrowserSwitchTabInput.of("tab_id") + + assertThat(betaBrowserSwitchTabInput.tabId()).isEqualTo("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserSwitchTabInput = BetaBrowserSwitchTabInput.of("tab_id") + + val roundtrippedBetaBrowserSwitchTabInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserSwitchTabInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserSwitchTabInput).isEqualTo(betaBrowserSwitchTabInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabToolUseBlockTest.kt new file mode 100644 index 000000000..d27daad58 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserSwitchTabToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserSwitchTabToolUseBlockTest { + + @Test + fun create() { + val betaBrowserSwitchTabToolUseBlock = + BetaBrowserSwitchTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserSwitchTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserSwitchTabToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserSwitchTabToolUseBlock.input()) + .isEqualTo(BetaBrowserSwitchTabInput.of("tab_id")) + assertThat(betaBrowserSwitchTabToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserSwitchTabToolUseBlock = + BetaBrowserSwitchTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserSwitchTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserSwitchTabToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserSwitchTabToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserSwitchTabToolUseBlock) + .isEqualTo(betaBrowserSwitchTabToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserToolUseBlockTest.kt new file mode 100644 index 000000000..333d40515 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserToolUseBlockTest.kt @@ -0,0 +1,2295 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaBrowserToolUseBlockTest { + + @Test + fun ofNavigate() { + val navigate = + BetaBrowserNavigateToolUseBlock.builder() + .id("id") + .input(BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofNavigate(navigate) + + assertThat(betaBrowserToolUseBlock.navigate()).contains(navigate) + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofNavigateRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofNavigate( + BetaBrowserNavigateToolUseBlock.builder() + .id("id") + .input(BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofListTabs() { + val listTabs = + BetaBrowserListTabsToolUseBlock.builder() + .id("id") + .input(BetaBrowserListTabsInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofListTabs(listTabs) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).contains(listTabs) + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofListTabsRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofListTabs( + BetaBrowserListTabsToolUseBlock.builder() + .id("id") + .input(BetaBrowserListTabsInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofNewTab() { + val newTab = + BetaBrowserNewTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserNewTabInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofNewTab(newTab) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).contains(newTab) + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofNewTabRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofNewTab( + BetaBrowserNewTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserNewTabInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofSwitchTab() { + val switchTab = + BetaBrowserSwitchTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserSwitchTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofSwitchTab(switchTab) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).contains(switchTab) + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofSwitchTabRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofSwitchTab( + BetaBrowserSwitchTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserSwitchTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofCloseTab() { + val closeTab = + BetaBrowserCloseTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserCloseTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofCloseTab(closeTab) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).contains(closeTab) + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofCloseTabRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofCloseTab( + BetaBrowserCloseTabToolUseBlock.builder() + .id("id") + .input(BetaBrowserCloseTabInput.of("tab_id")) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofReadPage() { + val readPage = + BetaBrowserReadPageToolUseBlock.builder() + .id("id") + .input( + BetaBrowserReadPageInput.builder() + .depth(1L) + .filter(BetaBrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofReadPage(readPage) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).contains(readPage) + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofReadPageRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofReadPage( + BetaBrowserReadPageToolUseBlock.builder() + .id("id") + .input( + BetaBrowserReadPageInput.builder() + .depth(1L) + .filter(BetaBrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofGetPageText() { + val getPageText = + BetaBrowserGetPageTextToolUseBlock.builder() + .id("id") + .input(BetaBrowserGetPageTextInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofGetPageText(getPageText) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).contains(getPageText) + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofGetPageTextRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofGetPageText( + BetaBrowserGetPageTextToolUseBlock.builder() + .id("id") + .input(BetaBrowserGetPageTextInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofReadConsole() { + val readConsole = + BetaBrowserReadConsoleToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadConsoleInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofReadConsole(readConsole) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).contains(readConsole) + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofReadConsoleRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofReadConsole( + BetaBrowserReadConsoleToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadConsoleInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofReadNetwork() { + val readNetwork = + BetaBrowserReadNetworkToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadNetworkInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofReadNetwork(readNetwork) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).contains(readNetwork) + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofReadNetworkRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofReadNetwork( + BetaBrowserReadNetworkToolUseBlock.builder() + .id("id") + .input(BetaBrowserReadNetworkInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofFind() { + val find = + BetaBrowserFindToolUseBlock.builder() + .id("id") + .input(BetaBrowserFindInput.builder().query("query").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofFind(find) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).contains(find) + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofFindRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofFind( + BetaBrowserFindToolUseBlock.builder() + .id("id") + .input(BetaBrowserFindInput.builder().query("query").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofFormInput() { + val formInput = + BetaBrowserFormInputToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFormInputInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofFormInput(formInput) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).contains(formInput) + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofFormInputRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofFormInput( + BetaBrowserFormInputToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFormInputInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofFileUpload() { + val fileUpload = + BetaBrowserFileUploadToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFileUploadInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofFileUpload(fileUpload) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).contains(fileUpload) + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofFileUploadRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofFileUpload( + BetaBrowserFileUploadToolUseBlock.builder() + .id("id") + .input( + BetaBrowserFileUploadInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofScrollTo() { + val scrollTo = + BetaBrowserScrollToToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollToInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofScrollTo(scrollTo) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).contains(scrollTo) + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofScrollToRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofScrollTo( + BetaBrowserScrollToToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollToInput.builder() + .target(BetaBrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofScreenshot() { + val screenshot = + BetaBrowserScreenshotToolUseBlock.builder() + .id("id") + .input(BetaBrowserScreenshotInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofScreenshot(screenshot) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).contains(screenshot) + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofScreenshotRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofScreenshot( + BetaBrowserScreenshotToolUseBlock.builder() + .id("id") + .input(BetaBrowserScreenshotInput.builder().tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofZoom() { + val zoom = + BetaBrowserZoomToolUseBlock.builder() + .id("id") + .input( + BetaBrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofZoom(zoom) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).contains(zoom) + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofZoomRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofZoom( + BetaBrowserZoomToolUseBlock.builder() + .id("id") + .input( + BetaBrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofLeftClick() { + val leftClick = + BetaBrowserLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofLeftClick(leftClick) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).contains(leftClick) + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofLeftClick( + BetaBrowserLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofRightClick() { + val rightClick = + BetaBrowserRightClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserRightClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofRightClick(rightClick) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).contains(rightClick) + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofRightClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofRightClick( + BetaBrowserRightClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserRightClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofMiddleClick() { + val middleClick = + BetaBrowserMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMiddleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofMiddleClick(middleClick) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).contains(middleClick) + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofMiddleClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofMiddleClick( + BetaBrowserMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMiddleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofDoubleClick() { + val doubleClick = + BetaBrowserDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserDoubleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofDoubleClick(doubleClick) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).contains(doubleClick) + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofDoubleClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofDoubleClick( + BetaBrowserDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserDoubleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofTripleClick() { + val tripleClick = + BetaBrowserTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserTripleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofTripleClick(tripleClick) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).contains(tripleClick) + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofTripleClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofTripleClick( + BetaBrowserTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserTripleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofHover() { + val hover = + BetaBrowserHoverToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoverInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofHover(hover) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).contains(hover) + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofHoverRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofHover( + BetaBrowserHoverToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoverInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofLeftClickDrag() { + val leftClickDrag = + BetaBrowserLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickDragInput.builder() + .from(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofLeftClickDrag(leftClickDrag) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).contains(leftClickDrag) + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftClickDragRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofLeftClickDrag( + BetaBrowserLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftClickDragInput.builder() + .from(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofLeftMouseDown() { + val leftMouseDown = + BetaBrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseDownInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofLeftMouseDown(leftMouseDown) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).contains(leftMouseDown) + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftMouseDownRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofLeftMouseDown( + BetaBrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseDownInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofLeftMouseUp() { + val leftMouseUp = + BetaBrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseUpInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofLeftMouseUp(leftMouseUp) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).contains(leftMouseUp) + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftMouseUpRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofLeftMouseUp( + BetaBrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .input( + BetaBrowserLeftMouseUpInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofMouseMove() { + val mouseMove = + BetaBrowserMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMouseMoveInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofMouseMove(mouseMove) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).contains(mouseMove) + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofMouseMoveRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofMouseMove( + BetaBrowserMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaBrowserMouseMoveInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofScroll() { + val scroll = + BetaBrowserScrollToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollInput.builder() + .scrollDirection(BetaBrowserScrollDirection.UP) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofScroll(scroll) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).contains(scroll) + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofScrollRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofScroll( + BetaBrowserScrollToolUseBlock.builder() + .id("id") + .input( + BetaBrowserScrollInput.builder() + .scrollDirection(BetaBrowserScrollDirection.UP) + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofType() { + val type = + BetaBrowserTypeToolUseBlock.builder() + .id("id") + .input(BetaBrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofType(type) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).contains(type) + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofTypeRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofType( + BetaBrowserTypeToolUseBlock.builder() + .id("id") + .input(BetaBrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofKey() { + val key = + BetaBrowserKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofKey(key) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).contains(key) + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofKeyRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofKey( + BetaBrowserKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserKeyInput.builder() + .text("text") + .repeat(1L) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofHoldKey() { + val holdKey = + BetaBrowserHoldKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoldKeyInput.builder() + .duration(0.0) + .text("text") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofHoldKey(holdKey) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).contains(holdKey) + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofHoldKeyRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofHoldKey( + BetaBrowserHoldKeyToolUseBlock.builder() + .id("id") + .input( + BetaBrowserHoldKeyInput.builder() + .duration(0.0) + .text("text") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofWait() { + val wait = + BetaBrowserWaitToolUseBlock.builder() + .id("id") + .input(BetaBrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofWait(wait) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).contains(wait) + assertThat(betaBrowserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofWaitRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofWait( + BetaBrowserWaitToolUseBlock.builder() + .id("id") + .input(BetaBrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun ofJavascriptExec() { + val javascriptExec = + BetaBrowserJavascriptExecToolUseBlock.builder() + .id("id") + .input( + BetaBrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaBrowserToolUseBlock = BetaBrowserToolUseBlock.ofJavascriptExec(javascriptExec) + + assertThat(betaBrowserToolUseBlock.navigate()).isEmpty + assertThat(betaBrowserToolUseBlock.listTabs()).isEmpty + assertThat(betaBrowserToolUseBlock.newTab()).isEmpty + assertThat(betaBrowserToolUseBlock.switchTab()).isEmpty + assertThat(betaBrowserToolUseBlock.closeTab()).isEmpty + assertThat(betaBrowserToolUseBlock.readPage()).isEmpty + assertThat(betaBrowserToolUseBlock.getPageText()).isEmpty + assertThat(betaBrowserToolUseBlock.readConsole()).isEmpty + assertThat(betaBrowserToolUseBlock.readNetwork()).isEmpty + assertThat(betaBrowserToolUseBlock.find()).isEmpty + assertThat(betaBrowserToolUseBlock.formInput()).isEmpty + assertThat(betaBrowserToolUseBlock.fileUpload()).isEmpty + assertThat(betaBrowserToolUseBlock.scrollTo()).isEmpty + assertThat(betaBrowserToolUseBlock.screenshot()).isEmpty + assertThat(betaBrowserToolUseBlock.zoom()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClick()).isEmpty + assertThat(betaBrowserToolUseBlock.rightClick()).isEmpty + assertThat(betaBrowserToolUseBlock.middleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.doubleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.tripleClick()).isEmpty + assertThat(betaBrowserToolUseBlock.hover()).isEmpty + assertThat(betaBrowserToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaBrowserToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaBrowserToolUseBlock.mouseMove()).isEmpty + assertThat(betaBrowserToolUseBlock.scroll()).isEmpty + assertThat(betaBrowserToolUseBlock.type()).isEmpty + assertThat(betaBrowserToolUseBlock.key()).isEmpty + assertThat(betaBrowserToolUseBlock.holdKey()).isEmpty + assertThat(betaBrowserToolUseBlock.wait()).isEmpty + assertThat(betaBrowserToolUseBlock.javascriptExec()).contains(javascriptExec) + } + + @Test + fun ofJavascriptExecRoundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserToolUseBlock = + BetaBrowserToolUseBlock.ofJavascriptExec( + BetaBrowserJavascriptExecToolUseBlock.builder() + .id("id") + .input( + BetaBrowserJavascriptExecInput.builder() + .text("text") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserToolUseBlock).isEqualTo(betaBrowserToolUseBlock) + } + + @Test + fun unknownVariantCommonProperties() { + val betaBrowserToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf( + "name" to "unknown_variant", + "id" to "id", + "caller" to mapOf("type" to "direct"), + ) + ), + jacksonTypeRef(), + ) + + val e = assertThrows { betaBrowserToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(betaBrowserToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + + val mismatchedBetaBrowserToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from(mapOf("name" to "unknown_variant", "id" to listOf("invalid"))), + jacksonTypeRef(), + ) + + assertThrows { mismatchedBetaBrowserToolUseBlock.id() } + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaBrowserToolUseBlock = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { betaBrowserToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThrows { betaBrowserToolUseBlock.id() } + assertThat(betaBrowserToolUseBlock.caller()).isEmpty + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickInputTest.kt new file mode 100644 index 000000000..15e8c6f0e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserTripleClickInputTest { + + @Test + fun create() { + val betaBrowserTripleClickInput = + BetaBrowserTripleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(betaBrowserTripleClickInput.target()) + .isEqualTo( + BetaBrowserClickTarget.ofCoordinate( + BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(betaBrowserTripleClickInput.modifiers()).contains("modifiers") + assertThat(betaBrowserTripleClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserTripleClickInput = + BetaBrowserTripleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBetaBrowserTripleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserTripleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserTripleClickInput).isEqualTo(betaBrowserTripleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickToolUseBlockTest.kt new file mode 100644 index 000000000..854df8651 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTripleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserTripleClickToolUseBlockTest { + + @Test + fun create() { + val betaBrowserTripleClickToolUseBlock = + BetaBrowserTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserTripleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserTripleClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserTripleClickToolUseBlock.input()) + .isEqualTo( + BetaBrowserTripleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserTripleClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserTripleClickToolUseBlock = + BetaBrowserTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaBrowserTripleClickInput.builder() + .target(BetaBrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserTripleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserTripleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserTripleClickToolUseBlock) + .isEqualTo(betaBrowserTripleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeInputTest.kt new file mode 100644 index 000000000..d7f98096c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserTypeInputTest { + + @Test + fun create() { + val betaBrowserTypeInput = + BetaBrowserTypeInput.builder().text("text").tabId("tab_id").build() + + assertThat(betaBrowserTypeInput.text()).isEqualTo("text") + assertThat(betaBrowserTypeInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserTypeInput = + BetaBrowserTypeInput.builder().text("text").tabId("tab_id").build() + + val roundtrippedBetaBrowserTypeInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserTypeInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserTypeInput).isEqualTo(betaBrowserTypeInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeToolUseBlockTest.kt new file mode 100644 index 000000000..cea1c1240 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserTypeToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserTypeToolUseBlockTest { + + @Test + fun create() { + val betaBrowserTypeToolUseBlock = + BetaBrowserTypeToolUseBlock.builder() + .id("id") + .input(BetaBrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserTypeToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserTypeToolUseBlock.input()) + .isEqualTo(BetaBrowserTypeInput.builder().text("text").tabId("tab_id").build()) + assertThat(betaBrowserTypeToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserTypeToolUseBlock = + BetaBrowserTypeToolUseBlock.builder() + .id("id") + .input(BetaBrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserTypeToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserTypeToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserTypeToolUseBlock).isEqualTo(betaBrowserTypeToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitInputTest.kt new file mode 100644 index 000000000..54b82932a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserWaitInputTest { + + @Test + fun create() { + val betaBrowserWaitInput = + BetaBrowserWaitInput.builder().duration(0.0).tabId("tab_id").build() + + assertThat(betaBrowserWaitInput.duration()).isEqualTo(0.0) + assertThat(betaBrowserWaitInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserWaitInput = + BetaBrowserWaitInput.builder().duration(0.0).tabId("tab_id").build() + + val roundtrippedBetaBrowserWaitInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserWaitInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserWaitInput).isEqualTo(betaBrowserWaitInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitToolUseBlockTest.kt new file mode 100644 index 000000000..8b2397455 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserWaitToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserWaitToolUseBlockTest { + + @Test + fun create() { + val betaBrowserWaitToolUseBlock = + BetaBrowserWaitToolUseBlock.builder() + .id("id") + .input(BetaBrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserWaitToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserWaitToolUseBlock.input()) + .isEqualTo(BetaBrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + assertThat(betaBrowserWaitToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserWaitToolUseBlock = + BetaBrowserWaitToolUseBlock.builder() + .id("id") + .input(BetaBrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserWaitToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserWaitToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserWaitToolUseBlock).isEqualTo(betaBrowserWaitToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomInputTest.kt new file mode 100644 index 000000000..16e81b544 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserZoomInputTest { + + @Test + fun create() { + val betaBrowserZoomInput = + BetaBrowserZoomInput.builder().region(listOf(0L, 0L, 0L, 0L)).tabId("tab_id").build() + + assertThat(betaBrowserZoomInput.region()).containsExactly(0L, 0L, 0L, 0L) + assertThat(betaBrowserZoomInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserZoomInput = + BetaBrowserZoomInput.builder().region(listOf(0L, 0L, 0L, 0L)).tabId("tab_id").build() + + val roundtrippedBetaBrowserZoomInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserZoomInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserZoomInput).isEqualTo(betaBrowserZoomInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomToolUseBlockTest.kt new file mode 100644 index 000000000..0ab32cfcc --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaBrowserZoomToolUseBlockTest.kt @@ -0,0 +1,59 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaBrowserZoomToolUseBlockTest { + + @Test + fun create() { + val betaBrowserZoomToolUseBlock = + BetaBrowserZoomToolUseBlock.builder() + .id("id") + .input( + BetaBrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaBrowserZoomToolUseBlock.id()).isEqualTo("id") + assertThat(betaBrowserZoomToolUseBlock.input()) + .isEqualTo( + BetaBrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + assertThat(betaBrowserZoomToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaBrowserZoomToolUseBlock = + BetaBrowserZoomToolUseBlock.builder() + .id("id") + .input( + BetaBrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaBrowserZoomToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaBrowserZoomToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaBrowserZoomToolUseBlock).isEqualTo(betaBrowserZoomToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionInputTest.kt new file mode 100644 index 000000000..583433f04 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionInputTest.kt @@ -0,0 +1,29 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerCursorPositionInputTest { + + @Test + fun create() { + val betaComputerCursorPositionInput = BetaComputerCursorPositionInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerCursorPositionInput = BetaComputerCursorPositionInput.builder().build() + + val roundtrippedBetaComputerCursorPositionInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerCursorPositionInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerCursorPositionInput) + .isEqualTo(betaComputerCursorPositionInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionToolUseBlockTest.kt new file mode 100644 index 000000000..8b3838add --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerCursorPositionToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerCursorPositionToolUseBlockTest { + + @Test + fun create() { + val betaComputerCursorPositionToolUseBlock = + BetaComputerCursorPositionToolUseBlock.builder() + .id("id") + .input(BetaComputerCursorPositionInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerCursorPositionToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerCursorPositionToolUseBlock.input()) + .isEqualTo(BetaComputerCursorPositionInput.builder().build()) + assertThat(betaComputerCursorPositionToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerCursorPositionToolUseBlock = + BetaComputerCursorPositionToolUseBlock.builder() + .id("id") + .input(BetaComputerCursorPositionInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerCursorPositionToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerCursorPositionToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerCursorPositionToolUseBlock) + .isEqualTo(betaComputerCursorPositionToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickInputTest.kt new file mode 100644 index 000000000..206f713ee --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerDoubleClickInputTest { + + @Test + fun create() { + val betaComputerDoubleClickInput = + BetaComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(betaComputerDoubleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(betaComputerDoubleClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaComputerDoubleClickInput = BetaComputerDoubleClickInput.builder().build() + + val betaComputerDoubleClickInput = + baseBetaComputerDoubleClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(betaComputerDoubleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerDoubleClickInput = + BetaComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedBetaComputerDoubleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerDoubleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerDoubleClickInput).isEqualTo(betaComputerDoubleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickToolUseBlockTest.kt new file mode 100644 index 000000000..0eef446aa --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerDoubleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerDoubleClickToolUseBlockTest { + + @Test + fun create() { + val betaComputerDoubleClickToolUseBlock = + BetaComputerDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerDoubleClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerDoubleClickToolUseBlock.input()) + .isEqualTo( + BetaComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + assertThat(betaComputerDoubleClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerDoubleClickToolUseBlock = + BetaComputerDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerDoubleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerDoubleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerDoubleClickToolUseBlock) + .isEqualTo(betaComputerDoubleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyInputTest.kt new file mode 100644 index 000000000..e0db750c1 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerHoldKeyInputTest { + + @Test + fun create() { + val betaComputerHoldKeyInput = + BetaComputerHoldKeyInput.builder().duration(300L).text("text").build() + + assertThat(betaComputerHoldKeyInput.duration()).isEqualTo(300L) + assertThat(betaComputerHoldKeyInput.text()).isEqualTo("text") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerHoldKeyInput = + BetaComputerHoldKeyInput.builder().duration(300L).text("text").build() + + val roundtrippedBetaComputerHoldKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerHoldKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerHoldKeyInput).isEqualTo(betaComputerHoldKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyToolUseBlockTest.kt new file mode 100644 index 000000000..200360cc2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerHoldKeyToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerHoldKeyToolUseBlockTest { + + @Test + fun create() { + val betaComputerHoldKeyToolUseBlock = + BetaComputerHoldKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerHoldKeyToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerHoldKeyToolUseBlock.input()) + .isEqualTo(BetaComputerHoldKeyInput.builder().duration(300L).text("text").build()) + assertThat(betaComputerHoldKeyToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerHoldKeyToolUseBlock = + BetaComputerHoldKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerHoldKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerHoldKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerHoldKeyToolUseBlock) + .isEqualTo(betaComputerHoldKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyInputTest.kt new file mode 100644 index 000000000..4a68adabf --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyInputTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerKeyInputTest { + + @Test + fun create() { + val betaComputerKeyInput = BetaComputerKeyInput.builder().text("text").repeat(1L).build() + + assertThat(betaComputerKeyInput.text()).isEqualTo("text") + assertThat(betaComputerKeyInput.repeat()).contains(1L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerKeyInput = BetaComputerKeyInput.builder().text("text").repeat(1L).build() + + val roundtrippedBetaComputerKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerKeyInput).isEqualTo(betaComputerKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyToolUseBlockTest.kt new file mode 100644 index 000000000..fb6ce2868 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerKeyToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerKeyToolUseBlockTest { + + @Test + fun create() { + val betaComputerKeyToolUseBlock = + BetaComputerKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerKeyInput.builder().text("text").repeat(1L).build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerKeyToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerKeyToolUseBlock.input()) + .isEqualTo(BetaComputerKeyInput.builder().text("text").repeat(1L).build()) + assertThat(betaComputerKeyToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerKeyToolUseBlock = + BetaComputerKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerKeyInput.builder().text("text").repeat(1L).build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerKeyToolUseBlock).isEqualTo(betaComputerKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragInputTest.kt new file mode 100644 index 000000000..eab2e430b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftClickDragInputTest { + + @Test + fun create() { + val betaComputerLeftClickDragInput = + BetaComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + + assertThat(betaComputerLeftClickDragInput.coordinate()).containsExactly(0L, 0L) + assertThat(betaComputerLeftClickDragInput.startCoordinate()).containsExactly(0L, 0L) + assertThat(betaComputerLeftClickDragInput.text()).contains("text") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftClickDragInput = + BetaComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + + val roundtrippedBetaComputerLeftClickDragInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftClickDragInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftClickDragInput) + .isEqualTo(betaComputerLeftClickDragInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragToolUseBlockTest.kt new file mode 100644 index 000000000..8ee77ae6c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickDragToolUseBlockTest.kt @@ -0,0 +1,69 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftClickDragToolUseBlockTest { + + @Test + fun create() { + val betaComputerLeftClickDragToolUseBlock = + BetaComputerLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerLeftClickDragToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerLeftClickDragToolUseBlock.input()) + .isEqualTo( + BetaComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + assertThat(betaComputerLeftClickDragToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftClickDragToolUseBlock = + BetaComputerLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerLeftClickDragToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftClickDragToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftClickDragToolUseBlock) + .isEqualTo(betaComputerLeftClickDragToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickInputTest.kt new file mode 100644 index 000000000..fad5fbb75 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftClickInputTest { + + @Test + fun create() { + val betaComputerLeftClickInput = + BetaComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(betaComputerLeftClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(betaComputerLeftClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaComputerLeftClickInput = BetaComputerLeftClickInput.builder().build() + + val betaComputerLeftClickInput = + baseBetaComputerLeftClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(betaComputerLeftClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftClickInput = + BetaComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedBetaComputerLeftClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftClickInput).isEqualTo(betaComputerLeftClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickToolUseBlockTest.kt new file mode 100644 index 000000000..7f8a44d9d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftClickToolUseBlockTest { + + @Test + fun create() { + val betaComputerLeftClickToolUseBlock = + BetaComputerLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerLeftClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerLeftClickToolUseBlock.input()) + .isEqualTo( + BetaComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + assertThat(betaComputerLeftClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftClickToolUseBlock = + BetaComputerLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerLeftClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftClickToolUseBlock) + .isEqualTo(betaComputerLeftClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownInputTest.kt new file mode 100644 index 000000000..069c840bc --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownInputTest.kt @@ -0,0 +1,29 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftMouseDownInputTest { + + @Test + fun create() { + val betaComputerLeftMouseDownInput = BetaComputerLeftMouseDownInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftMouseDownInput = BetaComputerLeftMouseDownInput.builder().build() + + val roundtrippedBetaComputerLeftMouseDownInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftMouseDownInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftMouseDownInput) + .isEqualTo(betaComputerLeftMouseDownInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownToolUseBlockTest.kt new file mode 100644 index 000000000..77b3ba2e4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseDownToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftMouseDownToolUseBlockTest { + + @Test + fun create() { + val betaComputerLeftMouseDownToolUseBlock = + BetaComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseDownInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerLeftMouseDownToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerLeftMouseDownToolUseBlock.input()) + .isEqualTo(BetaComputerLeftMouseDownInput.builder().build()) + assertThat(betaComputerLeftMouseDownToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftMouseDownToolUseBlock = + BetaComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseDownInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerLeftMouseDownToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftMouseDownToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftMouseDownToolUseBlock) + .isEqualTo(betaComputerLeftMouseDownToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpInputTest.kt new file mode 100644 index 000000000..867dc0775 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftMouseUpInputTest { + + @Test + fun create() { + val betaComputerLeftMouseUpInput = BetaComputerLeftMouseUpInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftMouseUpInput = BetaComputerLeftMouseUpInput.builder().build() + + val roundtrippedBetaComputerLeftMouseUpInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftMouseUpInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftMouseUpInput).isEqualTo(betaComputerLeftMouseUpInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpToolUseBlockTest.kt new file mode 100644 index 000000000..94db4cf38 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerLeftMouseUpToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerLeftMouseUpToolUseBlockTest { + + @Test + fun create() { + val betaComputerLeftMouseUpToolUseBlock = + BetaComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseUpInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerLeftMouseUpToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerLeftMouseUpToolUseBlock.input()) + .isEqualTo(BetaComputerLeftMouseUpInput.builder().build()) + assertThat(betaComputerLeftMouseUpToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerLeftMouseUpToolUseBlock = + BetaComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseUpInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerLeftMouseUpToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerLeftMouseUpToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerLeftMouseUpToolUseBlock) + .isEqualTo(betaComputerLeftMouseUpToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickInputTest.kt new file mode 100644 index 000000000..2c975112d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerMiddleClickInputTest { + + @Test + fun create() { + val betaComputerMiddleClickInput = + BetaComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(betaComputerMiddleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(betaComputerMiddleClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaComputerMiddleClickInput = BetaComputerMiddleClickInput.builder().build() + + val betaComputerMiddleClickInput = + baseBetaComputerMiddleClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(betaComputerMiddleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerMiddleClickInput = + BetaComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedBetaComputerMiddleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerMiddleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerMiddleClickInput).isEqualTo(betaComputerMiddleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickToolUseBlockTest.kt new file mode 100644 index 000000000..380994e0a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMiddleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerMiddleClickToolUseBlockTest { + + @Test + fun create() { + val betaComputerMiddleClickToolUseBlock = + BetaComputerMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerMiddleClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerMiddleClickToolUseBlock.input()) + .isEqualTo( + BetaComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + assertThat(betaComputerMiddleClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerMiddleClickToolUseBlock = + BetaComputerMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerMiddleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerMiddleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerMiddleClickToolUseBlock) + .isEqualTo(betaComputerMiddleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveInputTest.kt new file mode 100644 index 000000000..31bc3c17e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveInputTest.kt @@ -0,0 +1,32 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerMouseMoveInputTest { + + @Test + fun create() { + val betaComputerMouseMoveInput = + BetaComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(betaComputerMouseMoveInput.coordinate()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerMouseMoveInput = + BetaComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + + val roundtrippedBetaComputerMouseMoveInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerMouseMoveInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerMouseMoveInput).isEqualTo(betaComputerMouseMoveInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveToolUseBlockTest.kt new file mode 100644 index 000000000..f0f4033b4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerMouseMoveToolUseBlockTest.kt @@ -0,0 +1,51 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerMouseMoveToolUseBlockTest { + + @Test + fun create() { + val betaComputerMouseMoveToolUseBlock = + BetaComputerMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerMouseMoveToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerMouseMoveToolUseBlock.input()) + .isEqualTo( + BetaComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + ) + assertThat(betaComputerMouseMoveToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerMouseMoveToolUseBlock = + BetaComputerMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerMouseMoveToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerMouseMoveToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerMouseMoveToolUseBlock) + .isEqualTo(betaComputerMouseMoveToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickInputTest.kt new file mode 100644 index 000000000..626d81663 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerRightClickInputTest { + + @Test + fun create() { + val betaComputerRightClickInput = + BetaComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(betaComputerRightClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(betaComputerRightClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaComputerRightClickInput = BetaComputerRightClickInput.builder().build() + + val betaComputerRightClickInput = + baseBetaComputerRightClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(betaComputerRightClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerRightClickInput = + BetaComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedBetaComputerRightClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerRightClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerRightClickInput).isEqualTo(betaComputerRightClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickToolUseBlockTest.kt new file mode 100644 index 000000000..4360820ed --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerRightClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerRightClickToolUseBlockTest { + + @Test + fun create() { + val betaComputerRightClickToolUseBlock = + BetaComputerRightClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerRightClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerRightClickToolUseBlock.input()) + .isEqualTo( + BetaComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + assertThat(betaComputerRightClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerRightClickToolUseBlock = + BetaComputerRightClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerRightClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerRightClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerRightClickToolUseBlock) + .isEqualTo(betaComputerRightClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotInputTest.kt new file mode 100644 index 000000000..dbb1b9cd0 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerScreenshotInputTest { + + @Test + fun create() { + val betaComputerScreenshotInput = BetaComputerScreenshotInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerScreenshotInput = BetaComputerScreenshotInput.builder().build() + + val roundtrippedBetaComputerScreenshotInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerScreenshotInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerScreenshotInput).isEqualTo(betaComputerScreenshotInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotToolUseBlockTest.kt new file mode 100644 index 000000000..95950fbe7 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScreenshotToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerScreenshotToolUseBlockTest { + + @Test + fun create() { + val betaComputerScreenshotToolUseBlock = + BetaComputerScreenshotToolUseBlock.builder() + .id("id") + .input(BetaComputerScreenshotInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerScreenshotToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerScreenshotToolUseBlock.input()) + .isEqualTo(BetaComputerScreenshotInput.builder().build()) + assertThat(betaComputerScreenshotToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerScreenshotToolUseBlock = + BetaComputerScreenshotToolUseBlock.builder() + .id("id") + .input(BetaComputerScreenshotInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerScreenshotToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerScreenshotToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerScreenshotToolUseBlock) + .isEqualTo(betaComputerScreenshotToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollInputTest.kt new file mode 100644 index 000000000..01a8a111f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollInputTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerScrollInputTest { + + @Test + fun create() { + val betaComputerScrollInput = + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(betaComputerScrollInput.scrollAmount()).isEqualTo(0L) + assertThat(betaComputerScrollInput.scrollDirection()) + .isEqualTo(BetaComputerScrollDirection.UP) + assertThat(betaComputerScrollInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(betaComputerScrollInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaComputerScrollInput = + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .build() + + val betaComputerScrollInput = + baseBetaComputerScrollInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(betaComputerScrollInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerScrollInput = + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedBetaComputerScrollInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerScrollInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerScrollInput).isEqualTo(betaComputerScrollInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollToolUseBlockTest.kt new file mode 100644 index 000000000..254d33c31 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerScrollToolUseBlockTest.kt @@ -0,0 +1,69 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerScrollToolUseBlockTest { + + @Test + fun create() { + val betaComputerScrollToolUseBlock = + BetaComputerScrollToolUseBlock.builder() + .id("id") + .input( + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerScrollToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerScrollToolUseBlock.input()) + .isEqualTo( + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + assertThat(betaComputerScrollToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerScrollToolUseBlock = + BetaComputerScrollToolUseBlock.builder() + .id("id") + .input( + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerScrollToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerScrollToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerScrollToolUseBlock) + .isEqualTo(betaComputerScrollToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerToolUseBlockTest.kt new file mode 100644 index 000000000..5a1c8796d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerToolUseBlockTest.kt @@ -0,0 +1,1033 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaComputerToolUseBlockTest { + + @Test + fun ofKey() { + val key = + BetaComputerKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerKeyInput.builder().text("text").repeat(1L).build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofKey(key) + + assertThat(betaComputerToolUseBlock.key()).contains(key) + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofKeyRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofKey( + BetaComputerKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerKeyInput.builder().text("text").repeat(1L).build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofHoldKey() { + val holdKey = + BetaComputerHoldKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofHoldKey(holdKey) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).contains(holdKey) + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofHoldKeyRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofHoldKey( + BetaComputerHoldKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofType() { + val type = + BetaComputerTypeToolUseBlock.builder() + .id("id") + .input(BetaComputerTypeInput.of("text")) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofType(type) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).contains(type) + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofTypeRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofType( + BetaComputerTypeToolUseBlock.builder() + .id("id") + .input(BetaComputerTypeInput.of("text")) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofCursorPosition() { + val cursorPosition = + BetaComputerCursorPositionToolUseBlock.builder() + .id("id") + .input(BetaComputerCursorPositionInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofCursorPosition(cursorPosition) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).contains(cursorPosition) + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofCursorPositionRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofCursorPosition( + BetaComputerCursorPositionToolUseBlock.builder() + .id("id") + .input(BetaComputerCursorPositionInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofMouseMove() { + val mouseMove = + BetaComputerMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofMouseMove(mouseMove) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).contains(mouseMove) + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofMouseMoveRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofMouseMove( + BetaComputerMouseMoveToolUseBlock.builder() + .id("id") + .input( + BetaComputerMouseMoveInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofLeftMouseDown() { + val leftMouseDown = + BetaComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseDownInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofLeftMouseDown(leftMouseDown) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).contains(leftMouseDown) + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftMouseDownRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofLeftMouseDown( + BetaComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseDownInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofLeftMouseUp() { + val leftMouseUp = + BetaComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseUpInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofLeftMouseUp(leftMouseUp) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).contains(leftMouseUp) + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftMouseUpRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofLeftMouseUp( + BetaComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .input(BetaComputerLeftMouseUpInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofLeftClick() { + val leftClick = + BetaComputerLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofLeftClick(leftClick) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).contains(leftClick) + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofLeftClick( + BetaComputerLeftClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofLeftClickDrag() { + val leftClickDrag = + BetaComputerLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofLeftClickDrag(leftClickDrag) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).contains(leftClickDrag) + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftClickDragRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofLeftClickDrag( + BetaComputerLeftClickDragToolUseBlock.builder() + .id("id") + .input( + BetaComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofRightClick() { + val rightClick = + BetaComputerRightClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofRightClick(rightClick) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).contains(rightClick) + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofRightClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofRightClick( + BetaComputerRightClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofMiddleClick() { + val middleClick = + BetaComputerMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofMiddleClick(middleClick) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).contains(middleClick) + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofMiddleClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofMiddleClick( + BetaComputerMiddleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofDoubleClick() { + val doubleClick = + BetaComputerDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofDoubleClick(doubleClick) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).contains(doubleClick) + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofDoubleClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofDoubleClick( + BetaComputerDoubleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofTripleClick() { + val tripleClick = + BetaComputerTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofTripleClick(tripleClick) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).contains(tripleClick) + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofTripleClickRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofTripleClick( + BetaComputerTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofScroll() { + val scroll = + BetaComputerScrollToolUseBlock.builder() + .id("id") + .input( + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofScroll(scroll) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).contains(scroll) + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofScrollRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofScroll( + BetaComputerScrollToolUseBlock.builder() + .id("id") + .input( + BetaComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(BetaComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofWait() { + val wait = + BetaComputerWaitToolUseBlock.builder() + .id("id") + .input(BetaComputerWaitInput.of(300L)) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofWait(wait) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).contains(wait) + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofWaitRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofWait( + BetaComputerWaitToolUseBlock.builder() + .id("id") + .input(BetaComputerWaitInput.of(300L)) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofScreenshot() { + val screenshot = + BetaComputerScreenshotToolUseBlock.builder() + .id("id") + .input(BetaComputerScreenshotInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofScreenshot(screenshot) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).contains(screenshot) + assertThat(betaComputerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofScreenshotRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofScreenshot( + BetaComputerScreenshotToolUseBlock.builder() + .id("id") + .input(BetaComputerScreenshotInput.builder().build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun ofZoom() { + val zoom = + BetaComputerZoomToolUseBlock.builder() + .id("id") + .input(BetaComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .caller(BetaDirectCaller.builder().build()) + .build() + + val betaComputerToolUseBlock = BetaComputerToolUseBlock.ofZoom(zoom) + + assertThat(betaComputerToolUseBlock.key()).isEmpty + assertThat(betaComputerToolUseBlock.holdKey()).isEmpty + assertThat(betaComputerToolUseBlock.type()).isEmpty + assertThat(betaComputerToolUseBlock.cursorPosition()).isEmpty + assertThat(betaComputerToolUseBlock.mouseMove()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseDown()).isEmpty + assertThat(betaComputerToolUseBlock.leftMouseUp()).isEmpty + assertThat(betaComputerToolUseBlock.leftClick()).isEmpty + assertThat(betaComputerToolUseBlock.leftClickDrag()).isEmpty + assertThat(betaComputerToolUseBlock.rightClick()).isEmpty + assertThat(betaComputerToolUseBlock.middleClick()).isEmpty + assertThat(betaComputerToolUseBlock.doubleClick()).isEmpty + assertThat(betaComputerToolUseBlock.tripleClick()).isEmpty + assertThat(betaComputerToolUseBlock.scroll()).isEmpty + assertThat(betaComputerToolUseBlock.wait()).isEmpty + assertThat(betaComputerToolUseBlock.screenshot()).isEmpty + assertThat(betaComputerToolUseBlock.zoom()).contains(zoom) + } + + @Test + fun ofZoomRoundtrip() { + val jsonMapper = jsonMapper() + val betaComputerToolUseBlock = + BetaComputerToolUseBlock.ofZoom( + BetaComputerZoomToolUseBlock.builder() + .id("id") + .input(BetaComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val roundtrippedBetaComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerToolUseBlock).isEqualTo(betaComputerToolUseBlock) + } + + @Test + fun unknownVariantCommonProperties() { + val betaComputerToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf( + "name" to "unknown_variant", + "id" to "id", + "caller" to mapOf("type" to "direct"), + ) + ), + jacksonTypeRef(), + ) + + val e = assertThrows { betaComputerToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(betaComputerToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + + val mismatchedBetaComputerToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from(mapOf("name" to "unknown_variant", "id" to listOf("invalid"))), + jacksonTypeRef(), + ) + + assertThrows { mismatchedBetaComputerToolUseBlock.id() } + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaComputerToolUseBlock = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { betaComputerToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThrows { betaComputerToolUseBlock.id() } + assertThat(betaComputerToolUseBlock.caller()).isEmpty + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickInputTest.kt new file mode 100644 index 000000000..5b275e2d9 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerTripleClickInputTest { + + @Test + fun create() { + val betaComputerTripleClickInput = + BetaComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(betaComputerTripleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(betaComputerTripleClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBetaComputerTripleClickInput = BetaComputerTripleClickInput.builder().build() + + val betaComputerTripleClickInput = + baseBetaComputerTripleClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(betaComputerTripleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerTripleClickInput = + BetaComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedBetaComputerTripleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerTripleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerTripleClickInput).isEqualTo(betaComputerTripleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickToolUseBlockTest.kt new file mode 100644 index 000000000..797562131 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTripleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerTripleClickToolUseBlockTest { + + @Test + fun create() { + val betaComputerTripleClickToolUseBlock = + BetaComputerTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerTripleClickToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerTripleClickToolUseBlock.input()) + .isEqualTo( + BetaComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + assertThat(betaComputerTripleClickToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerTripleClickToolUseBlock = + BetaComputerTripleClickToolUseBlock.builder() + .id("id") + .input( + BetaComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerTripleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerTripleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerTripleClickToolUseBlock) + .isEqualTo(betaComputerTripleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeInputTest.kt new file mode 100644 index 000000000..000f0a16a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerTypeInputTest { + + @Test + fun create() { + val betaComputerTypeInput = BetaComputerTypeInput.of("text") + + assertThat(betaComputerTypeInput.text()).isEqualTo("text") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerTypeInput = BetaComputerTypeInput.of("text") + + val roundtrippedBetaComputerTypeInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerTypeInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerTypeInput).isEqualTo(betaComputerTypeInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeToolUseBlockTest.kt new file mode 100644 index 000000000..a90ae04fd --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerTypeToolUseBlockTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerTypeToolUseBlockTest { + + @Test + fun create() { + val betaComputerTypeToolUseBlock = + BetaComputerTypeToolUseBlock.builder() + .id("id") + .input(BetaComputerTypeInput.of("text")) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerTypeToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerTypeToolUseBlock.input()).isEqualTo(BetaComputerTypeInput.of("text")) + assertThat(betaComputerTypeToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerTypeToolUseBlock = + BetaComputerTypeToolUseBlock.builder() + .id("id") + .input(BetaComputerTypeInput.of("text")) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerTypeToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerTypeToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerTypeToolUseBlock).isEqualTo(betaComputerTypeToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitInputTest.kt new file mode 100644 index 000000000..98905e17b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerWaitInputTest { + + @Test + fun create() { + val betaComputerWaitInput = BetaComputerWaitInput.of(300L) + + assertThat(betaComputerWaitInput.duration()).isEqualTo(300L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerWaitInput = BetaComputerWaitInput.of(300L) + + val roundtrippedBetaComputerWaitInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerWaitInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerWaitInput).isEqualTo(betaComputerWaitInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitToolUseBlockTest.kt new file mode 100644 index 000000000..b1c6e8f3c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerWaitToolUseBlockTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerWaitToolUseBlockTest { + + @Test + fun create() { + val betaComputerWaitToolUseBlock = + BetaComputerWaitToolUseBlock.builder() + .id("id") + .input(BetaComputerWaitInput.of(300L)) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerWaitToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerWaitToolUseBlock.input()).isEqualTo(BetaComputerWaitInput.of(300L)) + assertThat(betaComputerWaitToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerWaitToolUseBlock = + BetaComputerWaitToolUseBlock.builder() + .id("id") + .input(BetaComputerWaitInput.of(300L)) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerWaitToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerWaitToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerWaitToolUseBlock).isEqualTo(betaComputerWaitToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomInputTest.kt new file mode 100644 index 000000000..ae37fa6c6 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerZoomInputTest { + + @Test + fun create() { + val betaComputerZoomInput = BetaComputerZoomInput.of(listOf(0L, 0L, 0L, 0L)) + + assertThat(betaComputerZoomInput.region()).containsExactly(0L, 0L, 0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerZoomInput = BetaComputerZoomInput.of(listOf(0L, 0L, 0L, 0L)) + + val roundtrippedBetaComputerZoomInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerZoomInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerZoomInput).isEqualTo(betaComputerZoomInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomToolUseBlockTest.kt new file mode 100644 index 000000000..a6530b514 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaComputerZoomToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaComputerZoomToolUseBlockTest { + + @Test + fun create() { + val betaComputerZoomToolUseBlock = + BetaComputerZoomToolUseBlock.builder() + .id("id") + .input(BetaComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .caller(BetaDirectCaller.builder().build()) + .build() + + assertThat(betaComputerZoomToolUseBlock.id()).isEqualTo("id") + assertThat(betaComputerZoomToolUseBlock.input()) + .isEqualTo(BetaComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + assertThat(betaComputerZoomToolUseBlock.caller()) + .contains(BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build())) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaComputerZoomToolUseBlock = + BetaComputerZoomToolUseBlock.builder() + .id("id") + .input(BetaComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .caller(BetaDirectCaller.builder().build()) + .build() + + val roundtrippedBetaComputerZoomToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaComputerZoomToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaComputerZoomToolUseBlock).isEqualTo(betaComputerZoomToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockParamTest.kt index c688c26c5..e454160d0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockParamTest.kt @@ -1739,8 +1739,8 @@ internal class BetaContentBlockParamTest { fun ofFallback() { val fallback = BetaFallbackBlockParam.builder() - .from(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) .trigger(JsonValue.from(mapOf())) .build() @@ -1778,8 +1778,8 @@ internal class BetaContentBlockParamTest { val betaContentBlockParam = BetaContentBlockParam.ofFallback( BetaFallbackBlockParam.builder() - .from(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) .trigger(JsonValue.from(mapOf())) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockTest.kt index 016ef0693..3d0c00766 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaContentBlockTest.kt @@ -904,8 +904,8 @@ internal class BetaContentBlockTest { fun ofFallback() { val fallback = BetaFallbackBlock.builder() - .from(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) .trigger(BetaFallbackRefusalTrigger.of(BetaFallbackRefusalTrigger.Category.CYBER)) .build() @@ -937,8 +937,8 @@ internal class BetaContentBlockTest { val betaContentBlock = BetaContentBlock.ofFallback( BetaFallbackBlock.builder() - .from(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) .trigger( BetaFallbackRefusalTrigger.of(BetaFallbackRefusalTrigger.Category.CYBER) ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockParamTest.kt index 8e3ff19fe..6fef3921f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockParamTest.kt @@ -13,15 +13,15 @@ internal class BetaFallbackBlockParamTest { fun create() { val betaFallbackBlockParam = BetaFallbackBlockParam.builder() - .from(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) .trigger(JsonValue.from(mapOf())) .build() assertThat(betaFallbackBlockParam.from()) - .isEqualTo(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) + .isEqualTo(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) assertThat(betaFallbackBlockParam.to()) - .isEqualTo(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) + .isEqualTo(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) assertThat(betaFallbackBlockParam._trigger()) .isEqualTo(JsonValue.from(mapOf())) } @@ -31,8 +31,8 @@ internal class BetaFallbackBlockParamTest { val jsonMapper = jsonMapper() val betaFallbackBlockParam = BetaFallbackBlockParam.builder() - .from(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5)) .trigger(JsonValue.from(mapOf())) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockTest.kt index b950cffb9..52cecce17 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackBlockTest.kt @@ -12,13 +12,13 @@ internal class BetaFallbackBlockTest { fun create() { val betaFallbackBlock = BetaFallbackBlock.builder() - .from(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) .trigger(BetaFallbackRefusalTrigger.of(BetaFallbackRefusalTrigger.Category.CYBER)) .build() - assertThat(betaFallbackBlock.from()).isEqualTo(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) - assertThat(betaFallbackBlock.to()).isEqualTo(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) + assertThat(betaFallbackBlock.from()).isEqualTo(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) + assertThat(betaFallbackBlock.to()).isEqualTo(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) assertThat(betaFallbackBlock.trigger()) .isEqualTo(BetaFallbackRefusalTrigger.of(BetaFallbackRefusalTrigger.Category.CYBER)) } @@ -28,8 +28,8 @@ internal class BetaFallbackBlockTest { val jsonMapper = jsonMapper() val betaFallbackBlock = BetaFallbackBlock.builder() - .from(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) - .to(BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5)) + .from(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) + .to(BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5)) .trigger(BetaFallbackRefusalTrigger.of(BetaFallbackRefusalTrigger.Category.CYBER)) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoParamTest.kt index 60b0951d1..c234e7150 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoParamTest.kt @@ -10,15 +10,15 @@ internal class BetaFallbackInfoParamTest { @Test fun create() { - val betaFallbackInfoParam = BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5) + val betaFallbackInfoParam = BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5) - assertThat(betaFallbackInfoParam.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(betaFallbackInfoParam.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val betaFallbackInfoParam = BetaFallbackInfoParam.of(Model.CLAUDE_SONNET_5_5) + val betaFallbackInfoParam = BetaFallbackInfoParam.of(Model.CLAUDE_HAIKU_5_5) val roundtrippedBetaFallbackInfoParam = jsonMapper.readValue( diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoTest.kt index add11ef7d..6f2a6fc68 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackInfoTest.kt @@ -10,15 +10,15 @@ internal class BetaFallbackInfoTest { @Test fun create() { - val betaFallbackInfo = BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5) + val betaFallbackInfo = BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5) - assertThat(betaFallbackInfo.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(betaFallbackInfo.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val betaFallbackInfo = BetaFallbackInfo.of(Model.CLAUDE_SONNET_5_5) + val betaFallbackInfo = BetaFallbackInfo.of(Model.CLAUDE_HAIKU_5_5) val roundtrippedBetaFallbackInfo = jsonMapper.readValue( diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackMessageIterationUsageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackMessageIterationUsageTest.kt index be3350361..fd2aa84c3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackMessageIterationUsageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackMessageIterationUsageTest.kt @@ -21,7 +21,7 @@ internal class BetaFallbackMessageIterationUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() @@ -35,7 +35,7 @@ internal class BetaFallbackMessageIterationUsageTest { assertThat(betaFallbackMessageIterationUsage.cacheCreationInputTokens()).isEqualTo(0L) assertThat(betaFallbackMessageIterationUsage.cacheReadInputTokens()).isEqualTo(0L) assertThat(betaFallbackMessageIterationUsage.inputTokens()).isEqualTo(0L) - assertThat(betaFallbackMessageIterationUsage.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(betaFallbackMessageIterationUsage.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) assertThat(betaFallbackMessageIterationUsage.outputTokens()).isEqualTo(0L) } @@ -53,7 +53,7 @@ internal class BetaFallbackMessageIterationUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackParamTest.kt index f61de90e4..8387e33bd 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbackParamTest.kt @@ -13,7 +13,7 @@ internal class BetaFallbackParamTest { fun create() { val betaFallbackParam = BetaFallbackParam.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .maxTokens(0L) .outputConfig( BetaOutputConfig.builder() @@ -44,7 +44,7 @@ internal class BetaFallbackParamTest { ) .build() - assertThat(betaFallbackParam.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(betaFallbackParam.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) assertThat(betaFallbackParam.maxTokens()).contains(0L) assertThat(betaFallbackParam.outputConfig()) .contains( @@ -82,7 +82,7 @@ internal class BetaFallbackParamTest { val jsonMapper = jsonMapper() val betaFallbackParam = BetaFallbackParam.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .maxTokens(0L) .outputConfig( BetaOutputConfig.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbacksParamTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbacksParamTest.kt index d40b20a75..23a38d182 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbacksParamTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaFallbacksParamTest.kt @@ -18,7 +18,7 @@ internal class BetaFallbacksParamTest { val fallbackParams = listOf( BetaFallbackParam.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .maxTokens(0L) .outputConfig( BetaOutputConfig.builder() @@ -65,7 +65,7 @@ internal class BetaFallbacksParamTest { BetaFallbacksParam.ofFallbackParams( listOf( BetaFallbackParam.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .maxTokens(0L) .outputConfig( BetaOutputConfig.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageDeltaUsageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageDeltaUsageTest.kt index 3b20de311..b19627295 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageDeltaUsageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageDeltaUsageTest.kt @@ -32,7 +32,7 @@ internal class BetaMessageDeltaUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -65,7 +65,7 @@ internal class BetaMessageDeltaUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -103,7 +103,7 @@ internal class BetaMessageDeltaUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageIterationUsageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageIterationUsageTest.kt index 3f2e6e698..13a5c57d3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageIterationUsageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageIterationUsageTest.kt @@ -21,7 +21,7 @@ internal class BetaMessageIterationUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() @@ -35,7 +35,7 @@ internal class BetaMessageIterationUsageTest { assertThat(betaMessageIterationUsage.cacheCreationInputTokens()).isEqualTo(0L) assertThat(betaMessageIterationUsage.cacheReadInputTokens()).isEqualTo(0L) assertThat(betaMessageIterationUsage.inputTokens()).isEqualTo(0L) - assertThat(betaMessageIterationUsage.model()).contains(Model.CLAUDE_SONNET_5_5) + assertThat(betaMessageIterationUsage.model()).contains(Model.CLAUDE_HAIKU_5_5) assertThat(betaMessageIterationUsage.outputTokens()).isEqualTo(0L) } @@ -53,7 +53,7 @@ internal class BetaMessageIterationUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageTest.kt index e63259d55..9b7ed94ad 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaMessageTest.kt @@ -96,7 +96,7 @@ internal class BetaMessageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -212,7 +212,7 @@ internal class BetaMessageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -327,7 +327,7 @@ internal class BetaMessageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -460,7 +460,7 @@ internal class BetaMessageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageDeltaEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageDeltaEventTest.kt index 9e01a9dae..e2363924f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageDeltaEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageDeltaEventTest.kt @@ -75,7 +75,7 @@ internal class BetaRawMessageDeltaEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -163,7 +163,7 @@ internal class BetaRawMessageDeltaEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -255,7 +255,7 @@ internal class BetaRawMessageDeltaEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -365,7 +365,7 @@ internal class BetaRawMessageDeltaEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStartEventTest.kt index 82212c745..ea96e839d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStartEventTest.kt @@ -96,7 +96,7 @@ internal class BetaRawMessageStartEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -208,7 +208,7 @@ internal class BetaRawMessageStartEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -324,7 +324,7 @@ internal class BetaRawMessageStartEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStreamEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStreamEventTest.kt index 811f480b2..baed036d2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStreamEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaRawMessageStreamEventTest.kt @@ -101,7 +101,7 @@ internal class BetaRawMessageStreamEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -229,7 +229,7 @@ internal class BetaRawMessageStreamEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -332,7 +332,7 @@ internal class BetaRawMessageStreamEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -433,7 +433,7 @@ internal class BetaRawMessageStreamEventTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaResponseToolUnionTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaResponseToolUnionTest.kt index c565762d0..55e609d7b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaResponseToolUnionTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaResponseToolUnionTest.kt @@ -2699,7 +2699,7 @@ internal class BetaResponseToolUnionTest { fun ofAdvisorTool20260301() { val advisorTool20260301 = BetaAdvisorTool20260301.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .addAllowedCaller(BetaAdvisorTool20260301.AllowedCaller.DIRECT) .cacheControl( BetaCacheControlEphemeral.builder() @@ -2757,7 +2757,7 @@ internal class BetaResponseToolUnionTest { val betaResponseToolUnion = BetaResponseToolUnion.ofAdvisorTool20260301( BetaAdvisorTool20260301.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .addAllowedCaller(BetaAdvisorTool20260301.AllowedCaller.DIRECT) .cacheControl( BetaCacheControlEphemeral.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolUnionTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolUnionTest.kt index 8f9a393f5..d430ec6b0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolUnionTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolUnionTest.kt @@ -2681,7 +2681,7 @@ internal class BetaToolUnionTest { fun ofAdvisorTool20260301() { val advisorTool20260301 = BetaAdvisorTool20260301.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .addAllowedCaller(BetaAdvisorTool20260301.AllowedCaller.DIRECT) .cacheControl( BetaCacheControlEphemeral.builder() @@ -2739,7 +2739,7 @@ internal class BetaToolUnionTest { val betaToolUnion = BetaToolUnion.ofAdvisorTool20260301( BetaAdvisorTool20260301.builder() - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .addAllowedCaller(BetaAdvisorTool20260301.AllowedCaller.DIRECT) .cacheControl( BetaCacheControlEphemeral.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolUseCallerTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolUseCallerTest.kt new file mode 100644 index 000000000..b6707bb64 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolUseCallerTest.kt @@ -0,0 +1,143 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaToolUseCallerTest { + + @Test + fun ofDirect() { + val direct = BetaDirectCaller.builder().build() + + val betaToolUseCaller = BetaToolUseCaller.ofDirect(direct) + + assertThat(betaToolUseCaller.direct()).contains(direct) + assertThat(betaToolUseCaller.codeExecution20250825()).isEmpty + assertThat(betaToolUseCaller.codeExecution20260120()).isEmpty + } + + @Test + fun ofDirectRoundtrip() { + val jsonMapper = jsonMapper() + val betaToolUseCaller = BetaToolUseCaller.ofDirect(BetaDirectCaller.builder().build()) + + val roundtrippedBetaToolUseCaller = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaToolUseCaller), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaToolUseCaller).isEqualTo(betaToolUseCaller) + } + + @Test + fun ofCodeExecution20250825() { + val codeExecution20250825 = BetaServerToolCaller.of("srvtoolu_SQfNkl1n_JR_") + + val betaToolUseCaller = BetaToolUseCaller.ofCodeExecution20250825(codeExecution20250825) + + assertThat(betaToolUseCaller.direct()).isEmpty + assertThat(betaToolUseCaller.codeExecution20250825()).contains(codeExecution20250825) + assertThat(betaToolUseCaller.codeExecution20260120()).isEmpty + } + + @Test + fun ofCodeExecution20250825Roundtrip() { + val jsonMapper = jsonMapper() + val betaToolUseCaller = + BetaToolUseCaller.ofCodeExecution20250825( + BetaServerToolCaller.of("srvtoolu_SQfNkl1n_JR_") + ) + + val roundtrippedBetaToolUseCaller = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaToolUseCaller), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaToolUseCaller).isEqualTo(betaToolUseCaller) + } + + @Test + fun ofCodeExecution20260120() { + val codeExecution20260120 = BetaServerToolCaller20260120.of("srvtoolu_SQfNkl1n_JR_") + + val betaToolUseCaller = BetaToolUseCaller.ofCodeExecution20260120(codeExecution20260120) + + assertThat(betaToolUseCaller.direct()).isEmpty + assertThat(betaToolUseCaller.codeExecution20250825()).isEmpty + assertThat(betaToolUseCaller.codeExecution20260120()).contains(codeExecution20260120) + } + + @Test + fun ofCodeExecution20260120Roundtrip() { + val jsonMapper = jsonMapper() + val betaToolUseCaller = + BetaToolUseCaller.ofCodeExecution20260120( + BetaServerToolCaller20260120.of("srvtoolu_SQfNkl1n_JR_") + ) + + val roundtrippedBetaToolUseCaller = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaToolUseCaller), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaToolUseCaller).isEqualTo(betaToolUseCaller) + } + + @Test + fun unknownVariantCommonProperties() { + val betaToolUseCaller = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf("type" to "unknown_variant", "tool_id" to "srvtoolu_SQfNkl1n_JR_") + ), + jacksonTypeRef(), + ) + + val e = assertThrows { betaToolUseCaller.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(betaToolUseCaller.toolId()).contains("srvtoolu_SQfNkl1n_JR_") + + val mismatchedBetaToolUseCaller = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf("type" to "unknown_variant", "tool_id" to listOf("invalid")) + ), + jacksonTypeRef(), + ) + + assertThat(mismatchedBetaToolUseCaller.toolId()).isEmpty + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaToolUseCaller = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { betaToolUseCaller.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(betaToolUseCaller.toolId()).isEmpty + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolsetToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolsetToolUseBlockTest.kt new file mode 100644 index 000000000..3dc268301 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaToolsetToolUseBlockTest.kt @@ -0,0 +1,157 @@ +package com.anthropic.models.beta.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BetaToolsetToolUseBlockTest { + + @Test + fun ofBrowser() { + val browser = + BetaBrowserToolUseBlock.ofNavigate( + BetaBrowserNavigateToolUseBlock.builder() + .id("id") + .input(BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val betaToolsetToolUseBlock = BetaToolsetToolUseBlock.ofBrowser(browser) + + assertThat(betaToolsetToolUseBlock.browser()).contains(browser) + assertThat(betaToolsetToolUseBlock.computer()).isEmpty + assertThat(betaToolsetToolUseBlock.betaToolUseBlock()).isEmpty + } + + @Test + fun ofBrowserRoundtrip() { + val jsonMapper = jsonMapper() + val betaToolsetToolUseBlock = + BetaToolsetToolUseBlock.ofBrowser( + BetaBrowserToolUseBlock.ofNavigate( + BetaBrowserNavigateToolUseBlock.builder() + .id("id") + .input( + BetaBrowserNavigateInput.builder().url("url").tabId("tab_id").build() + ) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + ) + + val roundtrippedBetaToolsetToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaToolsetToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaToolsetToolUseBlock).isEqualTo(betaToolsetToolUseBlock) + } + + @Test + fun ofComputer() { + val computer = + BetaComputerToolUseBlock.ofKey( + BetaComputerKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerKeyInput.builder().text("text").repeat(1L).build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + + val betaToolsetToolUseBlock = BetaToolsetToolUseBlock.ofComputer(computer) + + assertThat(betaToolsetToolUseBlock.browser()).isEmpty + assertThat(betaToolsetToolUseBlock.computer()).contains(computer) + assertThat(betaToolsetToolUseBlock.betaToolUseBlock()).isEmpty + } + + @Test + fun ofComputerRoundtrip() { + val jsonMapper = jsonMapper() + val betaToolsetToolUseBlock = + BetaToolsetToolUseBlock.ofComputer( + BetaComputerToolUseBlock.ofKey( + BetaComputerKeyToolUseBlock.builder() + .id("id") + .input(BetaComputerKeyInput.builder().text("text").repeat(1L).build()) + .caller(BetaDirectCaller.builder().build()) + .build() + ) + ) + + val roundtrippedBetaToolsetToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaToolsetToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaToolsetToolUseBlock).isEqualTo(betaToolsetToolUseBlock) + } + + @Test + fun ofBetaToolUseBlock() { + val betaToolUseBlock = + BetaToolUseBlock.builder() + .id("id") + .input(JsonValue.from(mapOf("foo" to "bar"))) + .name("x") + .caller(BetaDirectCaller.builder().build()) + .toolsetName("toolset_name") + .build() + + val betaToolsetToolUseBlock = BetaToolsetToolUseBlock.ofBetaToolUseBlock(betaToolUseBlock) + + assertThat(betaToolsetToolUseBlock.browser()).isEmpty + assertThat(betaToolsetToolUseBlock.computer()).isEmpty + assertThat(betaToolsetToolUseBlock.betaToolUseBlock()).contains(betaToolUseBlock) + } + + @Test + fun ofBetaToolUseBlockRoundtrip() { + val jsonMapper = jsonMapper() + val betaToolsetToolUseBlock = + BetaToolsetToolUseBlock.ofBetaToolUseBlock( + BetaToolUseBlock.builder() + .id("id") + .input(JsonValue.from(mapOf("foo" to "bar"))) + .name("x") + .caller(BetaDirectCaller.builder().build()) + .toolsetName("toolset_name") + .build() + ) + + val roundtrippedBetaToolsetToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaToolsetToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaToolsetToolUseBlock).isEqualTo(betaToolsetToolUseBlock) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val betaToolsetToolUseBlock = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { betaToolsetToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaUsageTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaUsageTest.kt index 2c5a4c628..4b58c0ed5 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaUsageTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/BetaUsageTest.kt @@ -39,7 +39,7 @@ internal class BetaUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -82,7 +82,7 @@ internal class BetaUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -128,7 +128,7 @@ internal class BetaUsageTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParamsTest.kt index 55be08944..589bb9082 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCountTokensParamsTest.kt @@ -295,7 +295,7 @@ internal class MessageCountTokensParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-user-profile-id", "anthropic-user-profile-id") .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCreateParamsTest.kt index c4783d905..a1a3a6d03 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/MessageCreateParamsTest.kt @@ -347,7 +347,7 @@ internal class MessageCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-user-profile-id", "anthropic-user-profile-id") .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/StructuredContentBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/StructuredContentBlockTest.kt index 7a891fe6b..294b4d0ac 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/StructuredContentBlockTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/StructuredContentBlockTest.kt @@ -261,6 +261,7 @@ internal class StructuredContentBlockTest { BetaContentBlock.ofContainerUpload(CONTAINER_UPLOAD), BetaContentBlock.ofCompaction(COMPACTION), BetaContentBlock.ofFallback(FALLBACK), + BetaContentBlock.ofMcpToolListing(MCP_TOOL_LISTING), ) } @@ -281,6 +282,17 @@ internal class StructuredContentBlockTest { checkAllDelegation(delegator::class, mockDelegate::class, "accept") } + @Test + fun allDelegateVisitorFunctionsExistInDelegatorVisitor() { + // When this fails, add the variant to `Visitor`, `accept()`, `validate()` and + // `contentBlocks()`. `visitText()` has a different signature. + checkAllDelegation( + BetaContentBlock.Visitor::class, + StructuredContentBlock.Visitor::class, + "visitText", + ) + } + @Test fun allDelegatorFunctionsAreTested() { // There are exceptional test cases for some functions. Most other functions are part of the @@ -410,4 +422,19 @@ internal class StructuredContentBlockTest { verify(visitor, times(1)).visitFallback(FALLBACK) verifyNoMoreInteractions(visitor) } + + @Test + fun `accept dispatches mcpToolListing`() { + val visitor = mock>() + val block = + StructuredContentBlock( + X::class.java, + BetaContentBlock.ofMcpToolListing(MCP_TOOL_LISTING), + ) + + block.accept(visitor) + + verify(visitor, times(1)).visitMcpToolListing(MCP_TOOL_LISTING) + verifyNoMoreInteractions(visitor) + } } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParamsTest.kt index a90de8a84..7106d9337 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCancelParamsTest.kt @@ -39,7 +39,7 @@ internal class BatchCancelParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParamsTest.kt index cd876b2b1..d8b03c4b7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchCreateParamsTest.kt @@ -441,7 +441,7 @@ internal class BatchCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-user-profile-id", "anthropic-user-profile-id") .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParamsTest.kt index ecd6e5c9e..60bfd94f6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchDeleteParamsTest.kt @@ -39,7 +39,7 @@ internal class BatchDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchListParamsTest.kt index f051761df..eae219453 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchListParamsTest.kt @@ -35,7 +35,7 @@ internal class BatchListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParamsTest.kt index e994423be..40d10c818 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchResultsParamsTest.kt @@ -39,7 +39,7 @@ internal class BatchResultsParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParamsTest.kt index 858af3e3a..08ba2ffab 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BatchRetrieveParamsTest.kt @@ -39,7 +39,7 @@ internal class BatchRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchIndividualResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchIndividualResponseTest.kt index 72f50cd69..b316b8492 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchIndividualResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchIndividualResponseTest.kt @@ -118,7 +118,7 @@ internal class BetaMessageBatchIndividualResponseTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -236,7 +236,7 @@ internal class BetaMessageBatchIndividualResponseTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -358,7 +358,7 @@ internal class BetaMessageBatchIndividualResponseTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchResultTest.kt index c8fe52d0a..923ee8fff 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchResultTest.kt @@ -120,7 +120,7 @@ internal class BetaMessageBatchResultTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -246,7 +246,7 @@ internal class BetaMessageBatchResultTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchSucceededResultTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchSucceededResultTest.kt index 2b5eb9c6c..ae3781f3f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchSucceededResultTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/messages/batches/BetaMessageBatchSucceededResultTest.kt @@ -114,7 +114,7 @@ internal class BetaMessageBatchSucceededResultTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -226,7 +226,7 @@ internal class BetaMessageBatchSucceededResultTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) @@ -342,7 +342,7 @@ internal class BetaMessageBatchSucceededResultTest { .cacheCreationInputTokens(0L) .cacheReadInputTokens(0L) .inputTokens(0L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .outputTokens(0L) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelCapabilitiesTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelCapabilitiesTest.kt index 30774dc95..8edff0003 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelCapabilitiesTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelCapabilitiesTest.kt @@ -40,6 +40,13 @@ internal class BetaModelCapabilitiesTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -47,6 +54,7 @@ internal class BetaModelCapabilitiesTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -86,6 +94,14 @@ internal class BetaModelCapabilitiesTest { ) assertThat(betaModelCapabilities.imageInput()).isEqualTo(BetaCapabilitySupport.of(true)) assertThat(betaModelCapabilities.pdfInput()).isEqualTo(BetaCapabilitySupport.of(true)) + assertThat(betaModelCapabilities.serverTools()) + .isEqualTo( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) assertThat(betaModelCapabilities.structuredOutputs()) .isEqualTo(BetaCapabilitySupport.of(true)) assertThat(betaModelCapabilities.thinking()) @@ -95,6 +111,7 @@ internal class BetaModelCapabilitiesTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -136,6 +153,13 @@ internal class BetaModelCapabilitiesTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -143,6 +167,7 @@ internal class BetaModelCapabilitiesTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelInfoTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelInfoTest.kt index 478e0edce..801142ba4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelInfoTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaModelInfoTest.kt @@ -46,6 +46,13 @@ internal class BetaModelInfoTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -53,6 +60,7 @@ internal class BetaModelInfoTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -61,9 +69,13 @@ internal class BetaModelInfoTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(BetaModelInfo.Lifecycle.ACTIVE) + .line(BetaModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() assertThat(betaModelInfo.id()).isEqualTo("claude-opus-5") @@ -100,6 +112,13 @@ internal class BetaModelInfoTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -107,6 +126,7 @@ internal class BetaModelInfoTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -116,9 +136,15 @@ internal class BetaModelInfoTest { ) assertThat(betaModelInfo.createdAt()) .isEqualTo(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + assertThat(betaModelInfo.deprecatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(betaModelInfo.displayName()).isEqualTo("Claude Opus 5") + assertThat(betaModelInfo.lifecycle()).isEqualTo(BetaModelInfo.Lifecycle.ACTIVE) + assertThat(betaModelInfo.line()).contains(BetaModelLine.HAIKU) assertThat(betaModelInfo.maxInputTokens()).contains(0L) assertThat(betaModelInfo.maxTokens()).contains(0L) + assertThat(betaModelInfo.retiresAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } @Test @@ -159,6 +185,13 @@ internal class BetaModelInfoTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -166,6 +199,7 @@ internal class BetaModelInfoTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -174,9 +208,13 @@ internal class BetaModelInfoTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(BetaModelInfo.Lifecycle.ACTIVE) + .line(BetaModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val roundtrippedBetaModelInfo = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaServerToolsCapabilityTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaServerToolsCapabilityTest.kt new file mode 100644 index 000000000..fa30e414d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaServerToolsCapabilityTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.beta.models + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BetaServerToolsCapabilityTest { + + @Test + fun create() { + val betaServerToolsCapability = + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + + assertThat(betaServerToolsCapability.codeExecution()) + .isEqualTo(BetaCapabilitySupport.of(true)) + assertThat(betaServerToolsCapability.supported()).isEqualTo(true) + assertThat(betaServerToolsCapability.webSearch()).isEqualTo(BetaCapabilitySupport.of(true)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val betaServerToolsCapability = + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + + val roundtrippedBetaServerToolsCapability = + jsonMapper.readValue( + jsonMapper.writeValueAsString(betaServerToolsCapability), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBetaServerToolsCapability).isEqualTo(betaServerToolsCapability) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingCapabilityTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingCapabilityTest.kt index 564dc5da0..0e3e7f5fa 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingCapabilityTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingCapabilityTest.kt @@ -15,6 +15,7 @@ internal class BetaThinkingCapabilityTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -25,6 +26,7 @@ internal class BetaThinkingCapabilityTest { .isEqualTo( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -39,6 +41,7 @@ internal class BetaThinkingCapabilityTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingTypesTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingTypesTest.kt index 99f3ec3dc..58fd0aaac 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingTypesTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/BetaThinkingTypesTest.kt @@ -12,10 +12,12 @@ internal class BetaThinkingTypesTest { val betaThinkingTypes = BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() assertThat(betaThinkingTypes.adaptive()).isEqualTo(BetaCapabilitySupport.of(true)) + assertThat(betaThinkingTypes.disabled()).isEqualTo(BetaCapabilitySupport.of(true)) assertThat(betaThinkingTypes.enabled()).isEqualTo(BetaCapabilitySupport.of(true)) } @@ -25,6 +27,7 @@ internal class BetaThinkingTypesTest { val betaThinkingTypes = BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListPageResponseTest.kt index 7d117ac82..cccef2f13 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListPageResponseTest.kt @@ -47,6 +47,13 @@ internal class ModelListPageResponseTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -54,6 +61,7 @@ internal class ModelListPageResponseTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -62,9 +70,13 @@ internal class ModelListPageResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(BetaModelInfo.Lifecycle.ACTIVE) + .line(BetaModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .firstId("first_id") @@ -108,6 +120,13 @@ internal class ModelListPageResponseTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -115,6 +134,7 @@ internal class ModelListPageResponseTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -123,9 +143,13 @@ internal class ModelListPageResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(BetaModelInfo.Lifecycle.ACTIVE) + .line(BetaModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) assertThat(modelListPageResponse.firstId()).contains("first_id") @@ -173,6 +197,13 @@ internal class ModelListPageResponseTest { ) .imageInput(BetaCapabilitySupport.of(true)) .pdfInput(BetaCapabilitySupport.of(true)) + .serverTools( + BetaServerToolsCapability.builder() + .codeExecution(BetaCapabilitySupport.of(true)) + .supported(true) + .webSearch(BetaCapabilitySupport.of(true)) + .build() + ) .structuredOutputs(BetaCapabilitySupport.of(true)) .thinking( BetaThinkingCapability.builder() @@ -180,6 +211,7 @@ internal class ModelListPageResponseTest { .types( BetaThinkingTypes.builder() .adaptive(BetaCapabilitySupport.of(true)) + .disabled(BetaCapabilitySupport.of(true)) .enabled(BetaCapabilitySupport.of(true)) .build() ) @@ -188,9 +220,13 @@ internal class ModelListPageResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(BetaModelInfo.Lifecycle.ACTIVE) + .line(BetaModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .firstId("first_id") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListParamsTest.kt index 23c23944e..e78a5a3d8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelListParamsTest.kt @@ -13,6 +13,7 @@ internal class ModelListParamsTest { ModelListParams.builder() .afterId("after_id") .beforeId("before_id") + .addLifecycle(ModelListParams.Lifecycle.ACTIVE) .limit(1L) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -25,6 +26,7 @@ internal class ModelListParamsTest { ModelListParams.builder() .afterId("after_id") .beforeId("before_id") + .addLifecycle(ModelListParams.Lifecycle.ACTIVE) .limit(1L) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -35,7 +37,7 @@ internal class ModelListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -56,6 +58,7 @@ internal class ModelListParamsTest { ModelListParams.builder() .afterId("after_id") .beforeId("before_id") + .addLifecycle(ModelListParams.Lifecycle.ACTIVE) .limit(1L) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -68,6 +71,7 @@ internal class ModelListParamsTest { QueryParams.builder() .put("after_id", "after_id") .put("before_id", "before_id") + .put("lifecycle[]", "active") .put("limit", "1") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelRetrieveParamsTest.kt index 4003360dc..89a5e917b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/models/ModelRetrieveParamsTest.kt @@ -39,7 +39,7 @@ internal class ModelRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParamsTest.kt index 90669c174..8b732ae73 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerArchiveParamsTest.kt @@ -37,7 +37,9 @@ internal class IssuerArchiveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParamsTest.kt index b6fc66023..ae0cf2fb3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerCreateParamsTest.kt @@ -45,7 +45,9 @@ internal class IssuerCreateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParamsTest.kt index 84bf41322..2fdfd4b48 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerListParamsTest.kt @@ -32,7 +32,9 @@ internal class IssuerListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParamsTest.kt index aa859dc6f..172bf3d0c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerRetrieveParamsTest.kt @@ -37,7 +37,9 @@ internal class IssuerRetrieveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParamsTest.kt index 47a439775..30d927b0a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/issuers/IssuerUpdateParamsTest.kt @@ -58,7 +58,9 @@ internal class IssuerUpdateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParamsTest.kt index bcd88745c..c8a7e4a80 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleArchiveParamsTest.kt @@ -36,7 +36,9 @@ internal class RuleArchiveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParamsTest.kt index f266146d4..f2cbab4a3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleCreateParamsTest.kt @@ -86,7 +86,9 @@ internal class RuleCreateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParamsTest.kt index 66dae3840..a014bc7a4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleListParamsTest.kt @@ -34,7 +34,9 @@ internal class RuleListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParamsTest.kt index c174c890e..e1f682a04 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleRetrieveParamsTest.kt @@ -36,7 +36,9 @@ internal class RuleRetrieveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParamsTest.kt index 53da2a303..cfc9c71f4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/RuleUpdateParamsTest.kt @@ -95,7 +95,9 @@ internal class RuleUpdateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParamsTest.kt index d0a68b458..bb052c31e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceAddParamsTest.kt @@ -42,7 +42,9 @@ internal class WorkspaceAddParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParamsTest.kt index ff007fbc9..ebb6659b1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceListParamsTest.kt @@ -41,7 +41,9 @@ internal class WorkspaceListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParamsTest.kt index 44ddd2d2b..9130316dd 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/federation/rules/workspaces/WorkspaceRemoveParamsTest.kt @@ -43,7 +43,9 @@ internal class WorkspaceRemoveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParamsTest.kt index eb6e79bb5..ac5287eaf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceListParamsTest.kt @@ -36,7 +36,13 @@ internal class PluginMarketplaceListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParamsTest.kt index 6120e895d..3eb1bfba6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceRetrieveParamsTest.kt @@ -40,7 +40,13 @@ internal class PluginMarketplaceRetrieveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParamsTest.kt index 59f0bf6bc..ed083edcb 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceUpdateParamsTest.kt @@ -48,7 +48,13 @@ internal class PluginMarketplaceUpdateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParamsTest.kt index d95bef631..0f38ea690 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateArchiveParamsTest.kt @@ -29,7 +29,13 @@ internal class PluginMarketplaceValidateArchiveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParamsTest.kt index b06292ccc..61866ad21 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/pluginmarketplaces/PluginMarketplaceValidateRepositoryParamsTest.kt @@ -29,7 +29,13 @@ internal class PluginMarketplaceValidateRepositoryParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParamsTest.kt index a78e460f2..a0259b20c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginCreateParamsTest.kt @@ -33,7 +33,13 @@ internal class PluginCreateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParamsTest.kt index 979a5f9b0..97fae5832 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginDeleteParamsTest.kt @@ -36,7 +36,13 @@ internal class PluginDeleteParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParamsTest.kt index 8cefb301c..1ac95e1cc 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginListParamsTest.kt @@ -47,7 +47,13 @@ internal class PluginListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParamsTest.kt index 991b4c12d..a23384935 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginRetrieveParamsTest.kt @@ -39,7 +39,13 @@ internal class PluginRetrieveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParamsTest.kt index 6e2e354ad..41ab1cc33 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/PluginUpdateParamsTest.kt @@ -42,7 +42,13 @@ internal class PluginUpdateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParamsTest.kt index 9baff0668..30a3ada7f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingListParamsTest.kt @@ -45,7 +45,13 @@ internal class InstallationSettingListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParamsTest.kt index 1bd46dd2d..9d71ea221 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingRemoveParamsTest.kt @@ -40,7 +40,13 @@ internal class InstallationSettingRemoveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParamsTest.kt index cf094dc18..57487dc14 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/installationsettings/InstallationSettingSetParamsTest.kt @@ -50,7 +50,13 @@ internal class InstallationSettingSetParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParamsTest.kt index c53c64e94..c78a5367b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/shares/ShareListParamsTest.kt @@ -45,7 +45,13 @@ internal class ShareListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParamsTest.kt index 95eedecd0..50e89580c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionCreateParamsTest.kt @@ -46,7 +46,13 @@ internal class VersionCreateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParamsTest.kt index 935a38db5..c463abbea 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionDownloadParamsTest.kt @@ -43,7 +43,13 @@ internal class VersionDownloadParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParamsTest.kt index 0ec25c361..1585770bc 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionListParamsTest.kt @@ -43,7 +43,13 @@ internal class VersionListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParamsTest.kt index 9b49ca7cb..aef91e1bd 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/plugins/versions/VersionRetrieveParamsTest.kt @@ -43,7 +43,13 @@ internal class VersionRetrieveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "ce-plugins-2026-09-01") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRoleTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRoleTest.kt index e548577b9..1d9f19cf2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRoleTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/BetaRbacRoleTest.kt @@ -14,6 +14,7 @@ internal class BetaRbacRoleTest { BetaRbacRole.builder() .id("rbac_role_016J8xVtKpDq3Wy9ZmN2hR4s") .createdAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) + .displayName("Project Editor") .name("Project Editor") .updatedAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) .build() @@ -21,6 +22,7 @@ internal class BetaRbacRoleTest { assertThat(betaRbacRole.id()).isEqualTo("rbac_role_016J8xVtKpDq3Wy9ZmN2hR4s") assertThat(betaRbacRole.createdAt()) .isEqualTo(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) + assertThat(betaRbacRole.displayName()).isEqualTo("Project Editor") assertThat(betaRbacRole.name()).isEqualTo("Project Editor") assertThat(betaRbacRole.updatedAt()) .isEqualTo(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) @@ -33,6 +35,7 @@ internal class BetaRbacRoleTest { BetaRbacRole.builder() .id("rbac_role_016J8xVtKpDq3Wy9ZmN2hR4s") .createdAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) + .displayName("Project Editor") .name("Project Editor") .updatedAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/RbacRoleListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/RbacRoleListPageResponseTest.kt index e95c7a7cb..f824df9d9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/RbacRoleListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/rbacroles/RbacRoleListPageResponseTest.kt @@ -16,6 +16,7 @@ internal class RbacRoleListPageResponseTest { BetaRbacRole.builder() .id("rbac_role_016J8xVtKpDq3Wy9ZmN2hR4s") .createdAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) + .displayName("Project Editor") .name("Project Editor") .updatedAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) .build() @@ -29,6 +30,7 @@ internal class RbacRoleListPageResponseTest { BetaRbacRole.builder() .id("rbac_role_016J8xVtKpDq3Wy9ZmN2hR4s") .createdAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) + .displayName("Project Editor") .name("Project Editor") .updatedAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) .build() @@ -47,6 +49,7 @@ internal class RbacRoleListPageResponseTest { BetaRbacRole.builder() .id("rbac_role_016J8xVtKpDq3Wy9ZmN2hR4s") .createdAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) + .displayName("Project Editor") .name("Project Editor") .updatedAt(OffsetDateTime.parse("2024-10-30T23:58:27.427722Z")) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParamsTest.kt index 5bc172ff8..645fc22d8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountArchiveParamsTest.kt @@ -37,7 +37,9 @@ internal class ServiceAccountArchiveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParamsTest.kt index 056f0f7f4..534e9aa46 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountCreateParamsTest.kt @@ -31,7 +31,9 @@ internal class ServiceAccountCreateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParamsTest.kt index 1b9433bc1..ff4644899 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountListParamsTest.kt @@ -32,7 +32,9 @@ internal class ServiceAccountListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParamsTest.kt index 461788718..e586abfc4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountRetrieveParamsTest.kt @@ -37,7 +37,9 @@ internal class ServiceAccountRetrieveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParamsTest.kt index 6ae2a2de6..367082d6a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/ServiceAccountUpdateParamsTest.kt @@ -41,7 +41,9 @@ internal class ServiceAccountUpdateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParamsTest.kt index 560716586..46d617889 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceAddParamsTest.kt @@ -46,7 +46,9 @@ internal class WorkspaceAddParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParamsTest.kt index aba95aa33..0e6123fe8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceListParamsTest.kt @@ -41,7 +41,9 @@ internal class WorkspaceListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParamsTest.kt index c69d6cbd7..56d0e1f9b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/serviceaccounts/workspaces/WorkspaceRemoveParamsTest.kt @@ -43,7 +43,9 @@ internal class WorkspaceRemoveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParamsTest.kt index c60e4611a..771924bf6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitListParamsTest.kt @@ -32,7 +32,13 @@ internal class SpendLimitListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "spend-limit-reads-2026-09-26") + .joinToString(","), + ) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParamsTest.kt index 109fbc3e1..d365c5109 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/spendlimits/SpendLimitSetParamsTest.kt @@ -1,5 +1,7 @@ package com.anthropic.models.beta.organization.spendlimits +import com.anthropic.core.http.Headers +import com.anthropic.models.beta.AnthropicBeta import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -8,16 +10,51 @@ internal class SpendLimitSetParamsTest { @Test fun create() { SpendLimitSetParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .amount("50000") .userScope("user_01WCz1FkmYMm4gnmykNKUu3Q") .period(BetaSpendLimitPeriod.DAILY) .build() } + @Test + fun headers() { + val params = + SpendLimitSetParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) + .amount("50000") + .userScope("user_01WCz1FkmYMm4gnmykNKUu3Q") + .period(BetaSpendLimitPeriod.DAILY) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo( + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() + ) + } + + @Test + fun headersWithoutOptionalFields() { + val params = + SpendLimitSetParams.builder() + .amount("50000") + .userScope("user_01WCz1FkmYMm4gnmykNKUu3Q") + .build() + + val headers = params._headers() + + assertThat(headers).isEqualTo(Headers.builder().build()) + } + @Test fun body() { val params = SpendLimitSetParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .amount("50000") .userScope("user_01WCz1FkmYMm4gnmykNKUu3Q") .period(BetaSpendLimitPeriod.DAILY) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParamsTest.kt index e91b2f66e..85075bbd8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceCreateParamsTest.kt @@ -60,7 +60,9 @@ internal class WorkspaceCreateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParamsTest.kt index 98fc1ee3d..bc3331be8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/WorkspaceListParamsTest.kt @@ -12,6 +12,7 @@ internal class WorkspaceListParamsTest { .afterId("after_id") .beforeId("before_id") .includeArchived(true) + .includeDefault(true) .limit(1L) .build() } @@ -23,6 +24,7 @@ internal class WorkspaceListParamsTest { .afterId("after_id") .beforeId("before_id") .includeArchived(true) + .includeDefault(true) .limit(1L) .build() @@ -34,6 +36,7 @@ internal class WorkspaceListParamsTest { .put("after_id", "after_id") .put("before_id", "before_id") .put("include_archived", "true") + .put("include_default", "true") .put("limit", "1") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParamsTest.kt index 2db146de7..89c33b59b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountAddParamsTest.kt @@ -46,7 +46,9 @@ internal class ServiceAccountAddParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParamsTest.kt index 6aeee5c0f..517834a6b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountListParamsTest.kt @@ -41,7 +41,9 @@ internal class ServiceAccountListParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParamsTest.kt index 05e3831d3..c6143ced1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRemoveParamsTest.kt @@ -43,7 +43,9 @@ internal class ServiceAccountRemoveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParamsTest.kt index 17cc8bd6c..a277ac929 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountRetrieveParamsTest.kt @@ -43,7 +43,9 @@ internal class ServiceAccountRetrieveParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParamsTest.kt index c134b71c7..e5d57fd54 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/organization/workspaces/serviceaccounts/ServiceAccountUpdateParamsTest.kt @@ -47,7 +47,9 @@ internal class ServiceAccountUpdateParamsTest { assertThat(headers) .isEqualTo( - Headers.builder().put("anthropic-beta", "message-batches-2024-09-24").build() + Headers.builder() + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) + .build() ) } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsOutcomeEvaluationResourceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsOutcomeEvaluationResourceTest.kt index 6ecbe5a20..35d386d86 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsOutcomeEvaluationResourceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsOutcomeEvaluationResourceTest.kt @@ -16,7 +16,7 @@ internal class BetaManagedAgentsOutcomeEvaluationResourceTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type(BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION) .build() @@ -29,7 +29,7 @@ internal class BetaManagedAgentsOutcomeEvaluationResourceTest { .contains("All five sections present with inline citations.") assertThat(betaManagedAgentsOutcomeEvaluationResource.iteration()).isEqualTo(0) assertThat(betaManagedAgentsOutcomeEvaluationResource.outcomeId()) - .isEqualTo("outc_011CZkZRSw2kEfs6ncTVljxP") + .isEqualTo("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsOutcomeEvaluationResource.result()).isEqualTo("satisfied") assertThat(betaManagedAgentsOutcomeEvaluationResource.type()) .isEqualTo(BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION) @@ -44,7 +44,7 @@ internal class BetaManagedAgentsOutcomeEvaluationResourceTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type(BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionAgentTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionAgentTest.kt index 514f2638d..df213e3d6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionAgentTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionAgentTest.kt @@ -123,7 +123,7 @@ internal class BetaManagedAgentsSessionAgentTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -265,7 +265,7 @@ internal class BetaManagedAgentsSessionAgentTest { ), BetaManagedAgentsSessionAgent.Skill.ofCustom( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -413,7 +413,7 @@ internal class BetaManagedAgentsSessionAgentTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt index e2050cdaa..593135072 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionTest.kt @@ -147,7 +147,7 @@ internal class BetaManagedAgentsSessionTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -208,7 +208,7 @@ internal class BetaManagedAgentsSessionTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type(BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION) .build() @@ -225,7 +225,7 @@ internal class BetaManagedAgentsSessionTest { ) .addResource( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -382,7 +382,7 @@ internal class BetaManagedAgentsSessionTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -445,7 +445,7 @@ internal class BetaManagedAgentsSessionTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type(BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION) .build() @@ -464,7 +464,7 @@ internal class BetaManagedAgentsSessionTest { ), BetaManagedAgentsSessionResource.ofGitHubRepository( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -642,7 +642,7 @@ internal class BetaManagedAgentsSessionTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -703,7 +703,7 @@ internal class BetaManagedAgentsSessionTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type(BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION) .build() @@ -720,7 +720,7 @@ internal class BetaManagedAgentsSessionTest { ) .addResource( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionUpdatedEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionUpdatedEventTest.kt index 46d7c8584..a0dcf86fa 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionUpdatedEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/BetaManagedAgentsSessionUpdatedEventTest.kt @@ -147,7 +147,7 @@ internal class BetaManagedAgentsSessionUpdatedEventTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -318,7 +318,7 @@ internal class BetaManagedAgentsSessionUpdatedEventTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -501,7 +501,7 @@ internal class BetaManagedAgentsSessionUpdatedEventTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParamsTest.kt index 7a07d1fc1..b5e32aab2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionArchiveParamsTest.kt @@ -40,7 +40,11 @@ internal class SessionArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionCreateParamsTest.kt index 66346dedb..1413b2d03 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionCreateParamsTest.kt @@ -108,7 +108,11 @@ internal class SessionCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParamsTest.kt index 67f170a4f..451bf54ec 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionDeleteParamsTest.kt @@ -40,7 +40,11 @@ internal class SessionDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt index 644ba47aa..22bc4d3af 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListPageResponseTest.kt @@ -163,7 +163,7 @@ internal class SessionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -226,7 +226,7 @@ internal class SessionListPageResponseTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type( BetaManagedAgentsOutcomeEvaluationResource.Type @@ -246,7 +246,7 @@ internal class SessionListPageResponseTest { ) .addResource( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type( @@ -428,7 +428,7 @@ internal class SessionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -490,7 +490,7 @@ internal class SessionListPageResponseTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type( BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION @@ -509,7 +509,7 @@ internal class SessionListPageResponseTest { ) .addResource( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -703,7 +703,7 @@ internal class SessionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -766,7 +766,7 @@ internal class SessionListPageResponseTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type( BetaManagedAgentsOutcomeEvaluationResource.Type @@ -786,7 +786,7 @@ internal class SessionListPageResponseTest { ) .addResource( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type( @@ -966,7 +966,7 @@ internal class SessionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -1028,7 +1028,7 @@ internal class SessionListPageResponseTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type( BetaManagedAgentsOutcomeEvaluationResource.Type.OUTCOME_EVALUATION @@ -1047,7 +1047,7 @@ internal class SessionListPageResponseTest { ) .addResource( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -1237,7 +1237,7 @@ internal class SessionListPageResponseTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -1300,7 +1300,7 @@ internal class SessionListPageResponseTest { .description("Produce a 2-page summary as summary.md") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .result("satisfied") .type( BetaManagedAgentsOutcomeEvaluationResource.Type @@ -1320,7 +1320,7 @@ internal class SessionListPageResponseTest { ) .addResource( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type( diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt index d866ca682..f7feef5a0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionListParamsTest.kt @@ -56,7 +56,11 @@ internal class SessionListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParamsTest.kt index f30aa66ac..9fbdbf0bf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionRetrieveParamsTest.kt @@ -40,7 +40,11 @@ internal class SessionRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParamsTest.kt index 3b4d68ca3..469ca6464 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/SessionUpdateParamsTest.kt @@ -165,7 +165,11 @@ internal class SessionUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsAgentMessageEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsAgentMessageEventTest.kt index b7a1c2799..d413f7373 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsAgentMessageEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsAgentMessageEventTest.kt @@ -12,14 +12,14 @@ internal class BetaManagedAgentsAgentMessageEventTest { fun create() { val betaManagedAgentsAgentMessageEvent = BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) .build() assertThat(betaManagedAgentsAgentMessageEvent.id()) - .isEqualTo("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .isEqualTo("sevt_011CZkZHPq1jCdq5mbRTjiVn") assertThat(betaManagedAgentsAgentMessageEvent.content()) .containsExactly( BetaManagedAgentsAgentMessageEvent.Content.ofText( @@ -40,7 +40,7 @@ internal class BetaManagedAgentsAgentMessageEventTest { val jsonMapper = jsonMapper() val betaManagedAgentsAgentMessageEvent = BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEventsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEventsTest.kt index 5fe04e399..a888f048a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEventsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSendSessionEventsTest.kt @@ -15,7 +15,7 @@ internal class BetaManagedAgentsSendSessionEventsTest { BetaManagedAgentsSendSessionEvents.builder() .addData( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -27,7 +27,7 @@ internal class BetaManagedAgentsSendSessionEventsTest { .containsExactly( BetaManagedAgentsSendSessionEvents.Data.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -47,7 +47,7 @@ internal class BetaManagedAgentsSendSessionEventsTest { .addData( BetaManagedAgentsSendSessionEvents.Data.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -60,7 +60,7 @@ internal class BetaManagedAgentsSendSessionEventsTest { .containsExactly( BetaManagedAgentsSendSessionEvents.Data.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -76,7 +76,7 @@ internal class BetaManagedAgentsSendSessionEventsTest { BetaManagedAgentsSendSessionEvents.builder() .addData( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt index ba27cc300..20f7b32f8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionEventTest.kt @@ -40,7 +40,7 @@ internal class BetaManagedAgentsSessionEventTest { fun ofUserMessage() { val userMessage = BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -91,7 +91,7 @@ internal class BetaManagedAgentsSessionEventTest { val betaManagedAgentsSessionEvent = BetaManagedAgentsSessionEvent.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -430,7 +430,7 @@ internal class BetaManagedAgentsSessionEventTest { fun ofAgentMessage() { val agentMessage = BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -482,7 +482,7 @@ internal class BetaManagedAgentsSessionEventTest { val betaManagedAgentsSessionEvent = BetaManagedAgentsSessionEvent.ofAgentMessage( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -1566,7 +1566,7 @@ internal class BetaManagedAgentsSessionEventTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() @@ -1620,7 +1620,7 @@ internal class BetaManagedAgentsSessionEventTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() ) @@ -1639,9 +1639,9 @@ internal class BetaManagedAgentsSessionEventTest { fun ofSpanOutcomeEvaluationStart() { val spanOutcomeEvaluationStart = BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type @@ -1696,9 +1696,9 @@ internal class BetaManagedAgentsSessionEventTest { val betaManagedAgentsSessionEvent = BetaManagedAgentsSessionEvent.ofSpanOutcomeEvaluationStart( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type @@ -1724,8 +1724,8 @@ internal class BetaManagedAgentsSessionEventTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( @@ -1792,8 +1792,8 @@ internal class BetaManagedAgentsSessionEventTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( @@ -1992,9 +1992,9 @@ internal class BetaManagedAgentsSessionEventTest { fun ofSpanOutcomeEvaluationOngoing() { val spanOutcomeEvaluationOngoing = BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type @@ -2051,9 +2051,9 @@ internal class BetaManagedAgentsSessionEventTest { val betaManagedAgentsSessionEvent = BetaManagedAgentsSessionEvent.ofSpanOutcomeEvaluationOngoing( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type @@ -2076,10 +2076,10 @@ internal class BetaManagedAgentsSessionEventTest { fun ofUserDefineOutcome() { val userDefineOutcome = BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) @@ -2131,10 +2131,10 @@ internal class BetaManagedAgentsSessionEventTest { val betaManagedAgentsSessionEvent = BetaManagedAgentsSessionEvent.ofUserDefineOutcome( BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) @@ -2308,10 +2308,10 @@ internal class BetaManagedAgentsSessionEventTest { fun ofSessionThreadStatusIdle() { val sessionThreadStatusIdle = BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) @@ -2373,10 +2373,10 @@ internal class BetaManagedAgentsSessionEventTest { val betaManagedAgentsSessionEvent = BetaManagedAgentsSessionEvent.ofSessionThreadStatusIdle( BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) @@ -2776,7 +2776,7 @@ internal class BetaManagedAgentsSessionEventTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -3007,7 +3007,7 @@ internal class BetaManagedAgentsSessionEventTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -3304,7 +3304,7 @@ internal class BetaManagedAgentsSessionEventTest { JsonValue.from( mapOf( "type" to "unknown_variant", - "id" to "sevt_011CZkZGOp0iBcp4kaQSihUmy", + "id" to "sevt_011CZkZGPp1iBcp4kaQSihUm", "processed_at" to "2026-03-15T10:00:00Z", "session_thread_id" to "session_thread_id", "tool_use_id" to "tool_use_id", @@ -3320,7 +3320,7 @@ internal class BetaManagedAgentsSessionEventTest { ), "agent_name" to "Researcher", "iteration" to 0, - "outcome_id" to "outc_011CZkZRSw2kEfs6ncTVljxP", + "outcome_id" to "outc_011CZkZRSw2kEfs6ncTVmjxP", "budget" to mapOf( "max_list_cost" to @@ -3336,7 +3336,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThrows { betaManagedAgentsSessionEvent.validate() } assertThat(e).hasMessageStartingWith("Unknown ") - assertThat(betaManagedAgentsSessionEvent.id()).isEqualTo("sevt_011CZkZGOp0iBcp4kaQSihUmy") + assertThat(betaManagedAgentsSessionEvent.id()).isEqualTo("sevt_011CZkZGPp1iBcp4kaQSihUm") assertThat(betaManagedAgentsSessionEvent.processedAt()) .contains(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(betaManagedAgentsSessionEvent.sessionThreadId()).contains("session_thread_id") @@ -3361,7 +3361,7 @@ internal class BetaManagedAgentsSessionEventTest { assertThat(betaManagedAgentsSessionEvent.agentName()).contains("Researcher") assertThat(betaManagedAgentsSessionEvent.iteration()).contains(0) assertThat(betaManagedAgentsSessionEvent.outcomeId()) - .contains("outc_011CZkZRSw2kEfs6ncTVljxP") + .contains("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsSessionEvent.budget()) .contains( BetaManagedAgentsBudgetLimit.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEventTest.kt index f01459ffd..5ddec9c96 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadCreatedEventTest.kt @@ -15,7 +15,7 @@ internal class BetaManagedAgentsSessionThreadCreatedEventTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() @@ -25,7 +25,7 @@ internal class BetaManagedAgentsSessionThreadCreatedEventTest { assertThat(betaManagedAgentsSessionThreadCreatedEvent.processedAt()) .isEqualTo(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(betaManagedAgentsSessionThreadCreatedEvent.sessionThreadId()) - .isEqualTo("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .isEqualTo("sthr_011CZkZVWa6oJjw1rgXZpnBt") assertThat(betaManagedAgentsSessionThreadCreatedEvent.type()) .isEqualTo(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) } @@ -38,7 +38,7 @@ internal class BetaManagedAgentsSessionThreadCreatedEventTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadStatusIdleEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadStatusIdleEventTest.kt index ffbca0b9f..91a341c07 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadStatusIdleEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSessionThreadStatusIdleEventTest.kt @@ -12,10 +12,10 @@ internal class BetaManagedAgentsSessionThreadStatusIdleEventTest { fun create() { val betaManagedAgentsSessionThreadStatusIdleEvent = BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) @@ -31,13 +31,13 @@ internal class BetaManagedAgentsSessionThreadStatusIdleEventTest { .build() assertThat(betaManagedAgentsSessionThreadStatusIdleEvent.id()) - .isEqualTo("sevt_011CZkZXYc8qKly2tiZbrpDv") + .isEqualTo("sevt_011CZkZXYc8qKmy2tiZbrpDv") assertThat(betaManagedAgentsSessionThreadStatusIdleEvent.agentName()) .isEqualTo("Researcher") assertThat(betaManagedAgentsSessionThreadStatusIdleEvent.processedAt()) .isEqualTo(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(betaManagedAgentsSessionThreadStatusIdleEvent.sessionThreadId()) - .isEqualTo("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .isEqualTo("sthr_011CZkZVWa6oJjw1rgXZpnBt") assertThat(betaManagedAgentsSessionThreadStatusIdleEvent.stopDetails()) .contains( BetaManagedAgentsSessionRefusalStopDetails.builder() @@ -62,10 +62,10 @@ internal class BetaManagedAgentsSessionThreadStatusIdleEventTest { val jsonMapper = jsonMapper() val betaManagedAgentsSessionThreadStatusIdleEvent = BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationEndEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationEndEventTest.kt index 02edb1567..687423816 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationEndEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationEndEventTest.kt @@ -15,8 +15,8 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationEndEventTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( @@ -39,9 +39,9 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationEndEventTest { .isEqualTo("All five sections present with inline citations.") assertThat(betaManagedAgentsSpanOutcomeEvaluationEndEvent.iteration()).isEqualTo(0) assertThat(betaManagedAgentsSpanOutcomeEvaluationEndEvent.outcomeEvaluationStartId()) - .isEqualTo("sevt_011CZkZTUy4mGhu8peVXnlzr") + .isEqualTo("sevt_011CZkZTUy4mGhu8peVXnmzr") assertThat(betaManagedAgentsSpanOutcomeEvaluationEndEvent.outcomeId()) - .isEqualTo("outc_011CZkZRSw2kEfs6ncTVljxP") + .isEqualTo("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsSpanOutcomeEvaluationEndEvent.processedAt()) .isEqualTo(OffsetDateTime.parse("2026-03-15T10:02:31Z")) assertThat(betaManagedAgentsSpanOutcomeEvaluationEndEvent.result()).isEqualTo("satisfied") @@ -69,8 +69,8 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationEndEventTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationOngoingEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationOngoingEventTest.kt index 75dd10f5b..6de8405fd 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationOngoingEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationOngoingEventTest.kt @@ -12,9 +12,9 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationOngoingEventTest { fun create() { val betaManagedAgentsSpanOutcomeEvaluationOngoingEvent = BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type @@ -23,10 +23,10 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationOngoingEventTest { .build() assertThat(betaManagedAgentsSpanOutcomeEvaluationOngoingEvent.id()) - .isEqualTo("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .isEqualTo("sevt_011CZkZbCG2uPpc6xmDfvTzh") assertThat(betaManagedAgentsSpanOutcomeEvaluationOngoingEvent.iteration()).isEqualTo(0) assertThat(betaManagedAgentsSpanOutcomeEvaluationOngoingEvent.outcomeId()) - .isEqualTo("outc_011CZkZRSw2kEfs6ncTVljxP") + .isEqualTo("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsSpanOutcomeEvaluationOngoingEvent.processedAt()) .isEqualTo(OffsetDateTime.parse("2026-03-15T10:02:14Z")) assertThat(betaManagedAgentsSpanOutcomeEvaluationOngoingEvent.type()) @@ -41,9 +41,9 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationOngoingEventTest { val jsonMapper = jsonMapper() val betaManagedAgentsSpanOutcomeEvaluationOngoingEvent = BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationStartEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationStartEventTest.kt index 8ffa75134..e9234a3b8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationStartEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsSpanOutcomeEvaluationStartEventTest.kt @@ -12,9 +12,9 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationStartEventTest { fun create() { val betaManagedAgentsSpanOutcomeEvaluationStartEvent = BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type @@ -23,10 +23,10 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationStartEventTest { .build() assertThat(betaManagedAgentsSpanOutcomeEvaluationStartEvent.id()) - .isEqualTo("sevt_011CZkZTUy4mGhu8peVXnlzr") + .isEqualTo("sevt_011CZkZTUy4mGhu8peVXnmzr") assertThat(betaManagedAgentsSpanOutcomeEvaluationStartEvent.iteration()).isEqualTo(0) assertThat(betaManagedAgentsSpanOutcomeEvaluationStartEvent.outcomeId()) - .isEqualTo("outc_011CZkZRSw2kEfs6ncTVljxP") + .isEqualTo("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsSpanOutcomeEvaluationStartEvent.processedAt()) .isEqualTo(OffsetDateTime.parse("2026-03-15T10:02:14Z")) assertThat(betaManagedAgentsSpanOutcomeEvaluationStartEvent.type()) @@ -40,9 +40,9 @@ internal class BetaManagedAgentsSpanOutcomeEvaluationStartEventTest { val jsonMapper = jsonMapper() val betaManagedAgentsSpanOutcomeEvaluationStartEvent = BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt index d8239c6cc..306ae524a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsStreamSessionEventsTest.kt @@ -43,7 +43,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { fun ofUserMessage() { val userMessage = BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -97,7 +97,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { val betaManagedAgentsStreamSessionEvents = BetaManagedAgentsStreamSessionEvents.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -445,7 +445,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { fun ofAgentMessage() { val agentMessage = BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -499,7 +499,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { val betaManagedAgentsStreamSessionEvents = BetaManagedAgentsStreamSessionEvents.ofAgentMessage( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -1617,7 +1617,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() @@ -1673,7 +1673,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() ) @@ -1692,9 +1692,9 @@ internal class BetaManagedAgentsStreamSessionEventsTest { fun ofSpanOutcomeEvaluationStart() { val spanOutcomeEvaluationStart = BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type @@ -1753,9 +1753,9 @@ internal class BetaManagedAgentsStreamSessionEventsTest { val betaManagedAgentsStreamSessionEvents = BetaManagedAgentsStreamSessionEvents.ofSpanOutcomeEvaluationStart( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type @@ -1781,8 +1781,8 @@ internal class BetaManagedAgentsStreamSessionEventsTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( @@ -1853,8 +1853,8 @@ internal class BetaManagedAgentsStreamSessionEventsTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( @@ -2057,9 +2057,9 @@ internal class BetaManagedAgentsStreamSessionEventsTest { fun ofSpanOutcomeEvaluationOngoing() { val spanOutcomeEvaluationOngoing = BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type @@ -2118,9 +2118,9 @@ internal class BetaManagedAgentsStreamSessionEventsTest { val betaManagedAgentsStreamSessionEvents = BetaManagedAgentsStreamSessionEvents.ofSpanOutcomeEvaluationOngoing( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type @@ -2143,10 +2143,10 @@ internal class BetaManagedAgentsStreamSessionEventsTest { fun ofUserDefineOutcome() { val userDefineOutcome = BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) @@ -2201,10 +2201,10 @@ internal class BetaManagedAgentsStreamSessionEventsTest { val betaManagedAgentsStreamSessionEvents = BetaManagedAgentsStreamSessionEvents.ofUserDefineOutcome( BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) @@ -2384,10 +2384,10 @@ internal class BetaManagedAgentsStreamSessionEventsTest { fun ofSessionThreadStatusIdle() { val sessionThreadStatusIdle = BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) @@ -2451,10 +2451,10 @@ internal class BetaManagedAgentsStreamSessionEventsTest { val betaManagedAgentsStreamSessionEvents = BetaManagedAgentsStreamSessionEvents.ofSessionThreadStatusIdle( BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) @@ -2860,7 +2860,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -3093,7 +3093,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -3560,7 +3560,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { JsonValue.from( mapOf( "type" to "unknown_variant", - "id" to "sevt_011CZkZGOp0iBcp4kaQSihUmy", + "id" to "sevt_011CZkZGPp1iBcp4kaQSihUm", "processed_at" to "2026-03-15T10:00:00Z", "session_thread_id" to "session_thread_id", "tool_use_id" to "tool_use_id", @@ -3576,7 +3576,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { ), "agent_name" to "Researcher", "iteration" to 0, - "outcome_id" to "outc_011CZkZRSw2kEfs6ncTVljxP", + "outcome_id" to "outc_011CZkZRSw2kEfs6ncTVmjxP", "budget" to mapOf( "max_list_cost" to @@ -3595,7 +3595,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(e).hasMessageStartingWith("Unknown ") assertThat(betaManagedAgentsStreamSessionEvents.id()) - .contains("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .contains("sevt_011CZkZGPp1iBcp4kaQSihUm") assertThat(betaManagedAgentsStreamSessionEvents.processedAt()) .contains(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(betaManagedAgentsStreamSessionEvents.sessionThreadId()) @@ -3621,7 +3621,7 @@ internal class BetaManagedAgentsStreamSessionEventsTest { assertThat(betaManagedAgentsStreamSessionEvents.agentName()).contains("Researcher") assertThat(betaManagedAgentsStreamSessionEvents.iteration()).contains(0) assertThat(betaManagedAgentsStreamSessionEvents.outcomeId()) - .contains("outc_011CZkZRSw2kEfs6ncTVljxP") + .contains("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsStreamSessionEvents.budget()) .contains( BetaManagedAgentsBudgetLimit.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserDefineOutcomeEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserDefineOutcomeEventTest.kt index 6b95a56e6..2bf006d98 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserDefineOutcomeEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserDefineOutcomeEventTest.kt @@ -12,22 +12,22 @@ internal class BetaManagedAgentsUserDefineOutcomeEventTest { fun create() { val betaManagedAgentsUserDefineOutcomeEvent = BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) .build() assertThat(betaManagedAgentsUserDefineOutcomeEvent.id()) - .isEqualTo("sevt_011CZkZSTx3lFgt7odUWmkyq") + .isEqualTo("sevt_011CZkZSTx3mFgt7odUWmkyq") assertThat(betaManagedAgentsUserDefineOutcomeEvent.description()) .isEqualTo("Produce a 2-page summary as summary.md") assertThat(betaManagedAgentsUserDefineOutcomeEvent.maxIterations()).contains(3) assertThat(betaManagedAgentsUserDefineOutcomeEvent.outcomeId()) - .isEqualTo("outc_011CZkZRSw2kEfs6ncTVljxP") + .isEqualTo("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsUserDefineOutcomeEvent.processedAt()) .isEqualTo(OffsetDateTime.parse("2026-03-15T10:02:14Z")) assertThat(betaManagedAgentsUserDefineOutcomeEvent.rubric()) @@ -48,10 +48,10 @@ internal class BetaManagedAgentsUserDefineOutcomeEventTest { val jsonMapper = jsonMapper() val betaManagedAgentsUserDefineOutcomeEvent = BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserMessageEventTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserMessageEventTest.kt index 40a3248a6..91f1205eb 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserMessageEventTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/BetaManagedAgentsUserMessageEventTest.kt @@ -12,14 +12,14 @@ internal class BetaManagedAgentsUserMessageEventTest { fun create() { val betaManagedAgentsUserMessageEvent = BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() assertThat(betaManagedAgentsUserMessageEvent.id()) - .isEqualTo("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .isEqualTo("sevt_011CZkZGPp1iBcp4kaQSihUm") assertThat(betaManagedAgentsUserMessageEvent.content()) .containsExactly( BetaManagedAgentsUserMessageEvent.Content.ofText( @@ -40,7 +40,7 @@ internal class BetaManagedAgentsUserMessageEventTest { val jsonMapper = jsonMapper() val betaManagedAgentsUserMessageEvent = BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponseTest.kt index fafe99853..aa6a377ab 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListPageResponseTest.kt @@ -15,7 +15,7 @@ internal class EventListPageResponseTest { EventListPageResponse.builder() .addData( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -23,7 +23,7 @@ internal class EventListPageResponseTest { ) .addData( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -36,7 +36,7 @@ internal class EventListPageResponseTest { .containsExactly( BetaManagedAgentsSessionEvent.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -44,7 +44,7 @@ internal class EventListPageResponseTest { ), BetaManagedAgentsSessionEvent.ofAgentMessage( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -64,7 +64,7 @@ internal class EventListPageResponseTest { .addData( BetaManagedAgentsSessionEvent.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -74,7 +74,7 @@ internal class EventListPageResponseTest { .addData( BetaManagedAgentsSessionEvent.ofAgentMessage( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -87,7 +87,7 @@ internal class EventListPageResponseTest { .containsExactly( BetaManagedAgentsSessionEvent.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -95,7 +95,7 @@ internal class EventListPageResponseTest { ), BetaManagedAgentsSessionEvent.ofAgentMessage( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -111,7 +111,7 @@ internal class EventListPageResponseTest { EventListPageResponse.builder() .addData( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -119,7 +119,7 @@ internal class EventListPageResponseTest { ) .addData( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListParamsTest.kt index 0a6737240..844e936db 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventListParamsTest.kt @@ -57,7 +57,11 @@ internal class EventListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventSendParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventSendParamsTest.kt index 5c74f895f..7b9a8ac6c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventSendParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventSendParamsTest.kt @@ -72,7 +72,11 @@ internal class EventSendParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParamsTest.kt index f0bd4ee06..87725f251 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/events/EventStreamParamsTest.kt @@ -43,7 +43,11 @@ internal class EventStreamParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsGitHubRepositoryResourceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsGitHubRepositoryResourceTest.kt index 84b8776bd..9ebb49f3c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsGitHubRepositoryResourceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsGitHubRepositoryResourceTest.kt @@ -13,7 +13,7 @@ internal class BetaManagedAgentsGitHubRepositoryResourceTest { fun create() { val betaManagedAgentsGitHubRepositoryResource = BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -23,7 +23,7 @@ internal class BetaManagedAgentsGitHubRepositoryResourceTest { .build() assertThat(betaManagedAgentsGitHubRepositoryResource.id()) - .isEqualTo("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .isEqualTo("sesrsc_011CZkZCKr6eXym1gWMPdQiu") assertThat(betaManagedAgentsGitHubRepositoryResource.createdAt()) .isEqualTo(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(betaManagedAgentsGitHubRepositoryResource.mountPath()) @@ -50,7 +50,7 @@ internal class BetaManagedAgentsGitHubRepositoryResourceTest { val jsonMapper = jsonMapper() val betaManagedAgentsGitHubRepositoryResource = BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsSessionResourceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsSessionResourceTest.kt index be16d096e..65b5929d2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsSessionResourceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/BetaManagedAgentsSessionResourceTest.kt @@ -17,7 +17,7 @@ internal class BetaManagedAgentsSessionResourceTest { fun ofGitHubRepository() { val githubRepository = BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -40,7 +40,7 @@ internal class BetaManagedAgentsSessionResourceTest { val betaManagedAgentsSessionResource = BetaManagedAgentsSessionResource.ofGitHubRepository( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -159,7 +159,7 @@ internal class BetaManagedAgentsSessionResourceTest { JsonValue.from( mapOf( "type" to "unknown_variant", - "id" to "sesrsc_011CZkZCKr6eXyl0gWMOdQiu", + "id" to "sesrsc_011CZkZCKr6eXym1gWMPdQiu", "created_at" to "2026-03-15T10:00:00Z", "mount_path" to "/workspace/example-repo", "updated_at" to "2026-03-15T10:00:00Z", @@ -175,7 +175,7 @@ internal class BetaManagedAgentsSessionResourceTest { assertThat(e).hasMessageStartingWith("Unknown ") assertThat(betaManagedAgentsSessionResource.id()) - .contains("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .contains("sesrsc_011CZkZCKr6eXym1gWMPdQiu") assertThat(betaManagedAgentsSessionResource.createdAt()) .contains(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(betaManagedAgentsSessionResource.mountPath()).contains("/workspace/example-repo") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParamsTest.kt index 2bbc58947..b7473f1ef 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceAddParamsTest.kt @@ -63,7 +63,11 @@ internal class ResourceAddParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParamsTest.kt index 3ccbe3c15..f893604fa 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceDeleteParamsTest.kt @@ -46,7 +46,11 @@ internal class ResourceDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListPageResponseTest.kt index 200379160..32e99884a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListPageResponseTest.kt @@ -24,7 +24,7 @@ internal class ResourceListPageResponseTest { ) .addData( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -50,7 +50,7 @@ internal class ResourceListPageResponseTest { ), BetaManagedAgentsSessionResource.ofGitHubRepository( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -81,7 +81,7 @@ internal class ResourceListPageResponseTest { ) .addData( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParamsTest.kt index 6e14a62be..45dc4ca3e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceListParamsTest.kt @@ -44,7 +44,11 @@ internal class ResourceListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParamsTest.kt index 800cba723..9bcd5657c 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveParamsTest.kt @@ -46,7 +46,11 @@ internal class ResourceRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveResponseTest.kt index 539a37f4f..a2d5585f9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceRetrieveResponseTest.kt @@ -17,7 +17,7 @@ internal class ResourceRetrieveResponseTest { fun ofGitHubRepository() { val githubRepository = BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -39,7 +39,7 @@ internal class ResourceRetrieveResponseTest { val resourceRetrieveResponse = ResourceRetrieveResponse.ofGitHubRepository( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -154,7 +154,7 @@ internal class ResourceRetrieveResponseTest { JsonValue.from( mapOf( "type" to "unknown_variant", - "id" to "sesrsc_011CZkZCKr6eXyl0gWMOdQiu", + "id" to "sesrsc_011CZkZCKr6eXym1gWMPdQiu", "created_at" to "2026-03-15T10:00:00Z", "mount_path" to "/workspace/example-repo", "updated_at" to "2026-03-15T10:00:00Z", @@ -166,7 +166,7 @@ internal class ResourceRetrieveResponseTest { val e = assertThrows { resourceRetrieveResponse.validate() } assertThat(e).hasMessageStartingWith("Unknown ") - assertThat(resourceRetrieveResponse.id()).contains("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + assertThat(resourceRetrieveResponse.id()).contains("sesrsc_011CZkZCKr6eXym1gWMPdQiu") assertThat(resourceRetrieveResponse.createdAt()) .contains(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(resourceRetrieveResponse.mountPath()).contains("/workspace/example-repo") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParamsTest.kt index 6ff6539d6..0b0aba5f6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateParamsTest.kt @@ -49,7 +49,11 @@ internal class ResourceUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateResponseTest.kt index a5b155a56..2992fffd2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/resources/ResourceUpdateResponseTest.kt @@ -17,7 +17,7 @@ internal class ResourceUpdateResponseTest { fun ofGitHubRepository() { val githubRepository = BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -39,7 +39,7 @@ internal class ResourceUpdateResponseTest { val resourceUpdateResponse = ResourceUpdateResponse.ofGitHubRepository( BetaManagedAgentsGitHubRepositoryResource.builder() - .id("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + .id("sesrsc_011CZkZCKr6eXym1gWMPdQiu") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .mountPath("/workspace/example-repo") .type(BetaManagedAgentsGitHubRepositoryResource.Type.GITHUB_REPOSITORY) @@ -154,7 +154,7 @@ internal class ResourceUpdateResponseTest { JsonValue.from( mapOf( "type" to "unknown_variant", - "id" to "sesrsc_011CZkZCKr6eXyl0gWMOdQiu", + "id" to "sesrsc_011CZkZCKr6eXym1gWMPdQiu", "created_at" to "2026-03-15T10:00:00Z", "mount_path" to "/workspace/example-repo", "updated_at" to "2026-03-15T10:00:00Z", @@ -166,7 +166,7 @@ internal class ResourceUpdateResponseTest { val e = assertThrows { resourceUpdateResponse.validate() } assertThat(e).hasMessageStartingWith("Unknown ") - assertThat(resourceUpdateResponse.id()).contains("sesrsc_011CZkZCKr6eXyl0gWMOdQiu") + assertThat(resourceUpdateResponse.id()).contains("sesrsc_011CZkZCKr6eXym1gWMPdQiu") assertThat(resourceUpdateResponse.createdAt()) .contains(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(resourceUpdateResponse.mountPath()).contains("/workspace/example-repo") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThreadTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThreadTest.kt index e5c990ddb..7a686183e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThreadTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsSessionThreadTest.kt @@ -27,7 +27,7 @@ internal class BetaManagedAgentsSessionThreadTest { fun create() { val betaManagedAgentsSessionThread = BetaManagedAgentsSessionThread.builder() - .id("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .id("sthr_011CZkZVWa6oJjw1rgXZpnBt") .agent( BetaManagedAgentsSessionThreadAgent.builder() .id("agent_011CZkYqphY8vELVzwCUpqiQ") @@ -136,7 +136,7 @@ internal class BetaManagedAgentsSessionThreadTest { ) .build() - assertThat(betaManagedAgentsSessionThread.id()).isEqualTo("sthr_011CZkZVWa6oIjw0rgXZpnBt") + assertThat(betaManagedAgentsSessionThread.id()).isEqualTo("sthr_011CZkZVWa6oJjw1rgXZpnBt") assertThat(betaManagedAgentsSessionThread.agent()) .isEqualTo( BetaManagedAgentsSessionThread.Agent.ofAgent( @@ -260,7 +260,7 @@ internal class BetaManagedAgentsSessionThreadTest { val jsonMapper = jsonMapper() val betaManagedAgentsSessionThread = BetaManagedAgentsSessionThread.builder() - .id("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .id("sthr_011CZkZVWa6oJjw1rgXZpnBt") .agent( BetaManagedAgentsSessionThreadAgent.builder() .id("agent_011CZkYqphY8vELVzwCUpqiQ") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt index b135022d0..7915584cd 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/BetaManagedAgentsStreamSessionThreadEventsTest.kt @@ -84,7 +84,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { fun ofUserMessage() { val userMessage = BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -141,7 +141,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { val betaManagedAgentsStreamSessionThreadEvents = BetaManagedAgentsStreamSessionThreadEvents.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -502,7 +502,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { fun ofAgentMessage() { val agentMessage = BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -559,7 +559,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { val betaManagedAgentsStreamSessionThreadEvents = BetaManagedAgentsStreamSessionThreadEvents.ofAgentMessage( BetaManagedAgentsAgentMessageEvent.builder() - .id("sevt_011CZkZHPq1jCdq5lbRTjiVnz") + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") .addTextContent("Let me look up order #1234 for you.") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) @@ -1723,7 +1723,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() @@ -1782,7 +1782,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { .id("sevt_011CZkZWXb7pJkx1shYaqoCu") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .type(BetaManagedAgentsSessionThreadCreatedEvent.Type.SESSION_THREAD_CREATED) .build() ) @@ -1801,9 +1801,9 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { fun ofSpanOutcomeEvaluationStart() { val spanOutcomeEvaluationStart = BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type @@ -1865,9 +1865,9 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { val betaManagedAgentsStreamSessionThreadEvents = BetaManagedAgentsStreamSessionThreadEvents.ofSpanOutcomeEvaluationStart( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.builder() - .id("sevt_011CZkZTUy4mGhu8peVXnlzr") + .id("sevt_011CZkZTUy4mGhu8peVXnmzr") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationStartEvent.Type @@ -1893,8 +1893,8 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( @@ -1968,8 +1968,8 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { .id("sevt_011CZkZUVz5nHiv9qfWYomas") .explanation("All five sections present with inline citations.") .iteration(0) - .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnlzr") - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeEvaluationStartId("sevt_011CZkZTUy4mGhu8peVXnmzr") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:31Z")) .result("satisfied") .type( @@ -2180,9 +2180,9 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { fun ofSpanOutcomeEvaluationOngoing() { val spanOutcomeEvaluationOngoing = BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type @@ -2243,9 +2243,9 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { val betaManagedAgentsStreamSessionThreadEvents = BetaManagedAgentsStreamSessionThreadEvents.ofSpanOutcomeEvaluationOngoing( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.builder() - .id("sevt_011CZkZbCG2uOpc6xmDfvTzh") + .id("sevt_011CZkZbCG2uPpc6xmDfvTzh") .iteration(0) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .type( BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent.Type @@ -2268,10 +2268,10 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { fun ofUserDefineOutcome() { val userDefineOutcome = BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) @@ -2329,10 +2329,10 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { val betaManagedAgentsStreamSessionThreadEvents = BetaManagedAgentsStreamSessionThreadEvents.ofUserDefineOutcome( BetaManagedAgentsUserDefineOutcomeEvent.builder() - .id("sevt_011CZkZSTx3lFgt7odUWmkyq") + .id("sevt_011CZkZSTx3mFgt7odUWmkyq") .description("Produce a 2-page summary as summary.md") .maxIterations(3) - .outcomeId("outc_011CZkZRSw2kEfs6ncTVljxP") + .outcomeId("outc_011CZkZRSw2kEfs6ncTVmjxP") .processedAt(OffsetDateTime.parse("2026-03-15T10:02:14Z")) .textRubric("Must cover all five sections; cite sources inline.") .type(BetaManagedAgentsUserDefineOutcomeEvent.Type.USER_DEFINE_OUTCOME) @@ -2519,10 +2519,10 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { fun ofSessionThreadStatusIdle() { val sessionThreadStatusIdle = BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) @@ -2591,10 +2591,10 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { val betaManagedAgentsStreamSessionThreadEvents = BetaManagedAgentsStreamSessionThreadEvents.ofSessionThreadStatusIdle( BetaManagedAgentsSessionThreadStatusIdleEvent.builder() - .id("sevt_011CZkZXYc8qKly2tiZbrpDv") + .id("sevt_011CZkZXYc8qKmy2tiZbrpDv") .agentName("Researcher") .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) - .sessionThreadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .sessionThreadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .stopDetails( BetaManagedAgentsSessionRefusalStopDetails.builder() .category(BetaManagedAgentsSessionRefusalStopDetails.Category.CYBER) @@ -3008,7 +3008,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -3245,7 +3245,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { ) .addSkill( BetaManagedAgentsCustomSkill.builder() - .skillId("skill_011CZkZFNu9hAbo3jZPRgTlx") + .skillId("skill_011CZkZFNu9hAbo3jZPRgTmx") .type(BetaManagedAgentsCustomSkill.Type.CUSTOM) .version("2") .build() @@ -3725,7 +3725,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { JsonValue.from( mapOf( "type" to "unknown_variant", - "id" to "sevt_011CZkZGOp0iBcp4kaQSihUmy", + "id" to "sevt_011CZkZGPp1iBcp4kaQSihUm", "processed_at" to "2026-03-15T10:00:00Z", "session_thread_id" to "session_thread_id", "tool_use_id" to "tool_use_id", @@ -3741,7 +3741,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { ), "agent_name" to "Researcher", "iteration" to 0, - "outcome_id" to "outc_011CZkZRSw2kEfs6ncTVljxP", + "outcome_id" to "outc_011CZkZRSw2kEfs6ncTVmjxP", "budget" to mapOf( "max_list_cost" to @@ -3760,7 +3760,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(e).hasMessageStartingWith("Unknown ") assertThat(betaManagedAgentsStreamSessionThreadEvents.id()) - .contains("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .contains("sevt_011CZkZGPp1iBcp4kaQSihUm") assertThat(betaManagedAgentsStreamSessionThreadEvents.processedAt()) .contains(OffsetDateTime.parse("2026-03-15T10:00:00Z")) assertThat(betaManagedAgentsStreamSessionThreadEvents.sessionThreadId()) @@ -3786,7 +3786,7 @@ internal class BetaManagedAgentsStreamSessionThreadEventsTest { assertThat(betaManagedAgentsStreamSessionThreadEvents.agentName()).contains("Researcher") assertThat(betaManagedAgentsStreamSessionThreadEvents.iteration()).contains(0) assertThat(betaManagedAgentsStreamSessionThreadEvents.outcomeId()) - .contains("outc_011CZkZRSw2kEfs6ncTVljxP") + .contains("outc_011CZkZRSw2kEfs6ncTVmjxP") assertThat(betaManagedAgentsStreamSessionThreadEvents.budget()) .contains( BetaManagedAgentsBudgetLimit.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParamsTest.kt index 7c52e9fa0..ad584a899 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadArchiveParamsTest.kt @@ -11,7 +11,7 @@ internal class ThreadArchiveParamsTest { fun create() { ThreadArchiveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -22,11 +22,11 @@ internal class ThreadArchiveParamsTest { val params = ThreadArchiveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() assertThat(params._pathParam(0)).isEqualTo("sesn_011CZkZAtmR3yMPDzynEDxu7") - assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oIjw0rgXZpnBt") + assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oJjw1rgXZpnBt") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -36,7 +36,7 @@ internal class ThreadArchiveParamsTest { val params = ThreadArchiveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -46,7 +46,11 @@ internal class ThreadArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -57,7 +61,7 @@ internal class ThreadArchiveParamsTest { val params = ThreadArchiveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() val headers = params._headers() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListPageResponseTest.kt index ee497228a..7ac89567f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListPageResponseTest.kt @@ -30,7 +30,7 @@ internal class ThreadListPageResponseTest { ThreadListPageResponse.builder() .addData( BetaManagedAgentsSessionThread.builder() - .id("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .id("sthr_011CZkZVWa6oJjw1rgXZpnBt") .agent( BetaManagedAgentsSessionThreadAgent.builder() .id("agent_011CZkYqphY8vELVzwCUpqiQ") @@ -147,7 +147,7 @@ internal class ThreadListPageResponseTest { assertThat(threadListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsSessionThread.builder() - .id("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .id("sthr_011CZkZVWa6oJjw1rgXZpnBt") .agent( BetaManagedAgentsSessionThreadAgent.builder() .id("agent_011CZkYqphY8vELVzwCUpqiQ") @@ -269,7 +269,7 @@ internal class ThreadListPageResponseTest { .toBuilder() .addData( BetaManagedAgentsSessionThread.builder() - .id("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .id("sthr_011CZkZVWa6oJjw1rgXZpnBt") .agent( BetaManagedAgentsSessionThreadAgent.builder() .id("agent_011CZkYqphY8vELVzwCUpqiQ") @@ -385,7 +385,7 @@ internal class ThreadListPageResponseTest { assertThat(threadListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsSessionThread.builder() - .id("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .id("sthr_011CZkZVWa6oJjw1rgXZpnBt") .agent( BetaManagedAgentsSessionThreadAgent.builder() .id("agent_011CZkYqphY8vELVzwCUpqiQ") @@ -504,7 +504,7 @@ internal class ThreadListPageResponseTest { ThreadListPageResponse.builder() .addData( BetaManagedAgentsSessionThread.builder() - .id("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .id("sthr_011CZkZVWa6oJjw1rgXZpnBt") .agent( BetaManagedAgentsSessionThreadAgent.builder() .id("agent_011CZkYqphY8vELVzwCUpqiQ") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParamsTest.kt index ff735268a..82a0bda51 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadListParamsTest.kt @@ -44,7 +44,11 @@ internal class ThreadListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParamsTest.kt index 049f29039..278d0ffbf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/ThreadRetrieveParamsTest.kt @@ -11,7 +11,7 @@ internal class ThreadRetrieveParamsTest { fun create() { ThreadRetrieveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -22,11 +22,11 @@ internal class ThreadRetrieveParamsTest { val params = ThreadRetrieveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() assertThat(params._pathParam(0)).isEqualTo("sesn_011CZkZAtmR3yMPDzynEDxu7") - assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oIjw0rgXZpnBt") + assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oJjw1rgXZpnBt") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -36,7 +36,7 @@ internal class ThreadRetrieveParamsTest { val params = ThreadRetrieveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -46,7 +46,11 @@ internal class ThreadRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -57,7 +61,7 @@ internal class ThreadRetrieveParamsTest { val params = ThreadRetrieveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() val headers = params._headers() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponseTest.kt index 256fede0e..d5e99a42d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListPageResponseTest.kt @@ -1,6 +1,7 @@ package com.anthropic.models.beta.sessions.threads.events import com.anthropic.core.jsonMapper +import com.anthropic.models.beta.sessions.events.BetaManagedAgentsAgentMessageEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsSessionEvent import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEvent import com.fasterxml.jackson.module.kotlin.jacksonTypeRef @@ -17,27 +18,43 @@ internal class EventListPageResponseTest { EventListPageResponse.builder() .addData( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) - .nextPage("next_page") + .addData( + BetaManagedAgentsAgentMessageEvent.builder() + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") + .addTextContent("Let me look up order #1234 for you.") + .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) + .build() + ) + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() assertThat(eventListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsSessionEvent.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() - ) + ), + BetaManagedAgentsSessionEvent.ofAgentMessage( + BetaManagedAgentsAgentMessageEvent.builder() + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") + .addTextContent("Let me look up order #1234 for you.") + .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) + .build() + ), ) - assertThat(eventListPageResponse.nextPage()).contains("next_page") + assertThat(eventListPageResponse.nextPage()).contains("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") } @Test @@ -50,25 +67,43 @@ internal class EventListPageResponseTest { .addData( BetaManagedAgentsSessionEvent.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) ) + .addData( + BetaManagedAgentsSessionEvent.ofAgentMessage( + BetaManagedAgentsAgentMessageEvent.builder() + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") + .addTextContent("Let me look up order #1234 for you.") + .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) + .build() + ) + ) .build() assertThat(eventListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsSessionEvent.ofUserMessage( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() - ) + ), + BetaManagedAgentsSessionEvent.ofAgentMessage( + BetaManagedAgentsAgentMessageEvent.builder() + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") + .addTextContent("Let me look up order #1234 for you.") + .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) + .build() + ), ) } @@ -79,13 +114,21 @@ internal class EventListPageResponseTest { EventListPageResponse.builder() .addData( BetaManagedAgentsUserMessageEvent.builder() - .id("sevt_011CZkZGOp0iBcp4kaQSihUmy") + .id("sevt_011CZkZGPp1iBcp4kaQSihUm") .addTextContent("Where is my order #1234?") .type(BetaManagedAgentsUserMessageEvent.Type.USER_MESSAGE) .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) .build() ) - .nextPage("next_page") + .addData( + BetaManagedAgentsAgentMessageEvent.builder() + .id("sevt_011CZkZHPq1jCdq5mbRTjiVn") + .addTextContent("Let me look up order #1234 for you.") + .processedAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) + .type(BetaManagedAgentsAgentMessageEvent.Type.AGENT_MESSAGE) + .build() + ) + .nextPage("page_MjAyNS0wNS0xNFQwMDowMDowMFo=") .build() val roundtrippedEventListPageResponse = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParamsTest.kt index 23d5c5884..01a945b03 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventListParamsTest.kt @@ -12,7 +12,7 @@ internal class EventListParamsTest { fun create() { EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .limit(0) .page("page") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) @@ -25,11 +25,11 @@ internal class EventListParamsTest { val params = EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() assertThat(params._pathParam(0)).isEqualTo("sesn_011CZkZAtmR3yMPDzynEDxu7") - assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oIjw0rgXZpnBt") + assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oJjw1rgXZpnBt") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -39,7 +39,7 @@ internal class EventListParamsTest { val params = EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .limit(0) .page("page") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) @@ -51,7 +51,11 @@ internal class EventListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -62,7 +66,7 @@ internal class EventListParamsTest { val params = EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() val headers = params._headers() @@ -75,7 +79,7 @@ internal class EventListParamsTest { val params = EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .limit(0) .page("page") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) @@ -93,7 +97,7 @@ internal class EventListParamsTest { val params = EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() val queryParams = params._queryParams() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParamsTest.kt index 0697bd614..96f83ebc2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/sessions/threads/events/EventStreamParamsTest.kt @@ -13,7 +13,7 @@ internal class EventStreamParamsTest { fun create() { EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addEventDelta(BetaManagedAgentsDeltaType.AGENT_MESSAGE) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -25,11 +25,11 @@ internal class EventStreamParamsTest { val params = EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() assertThat(params._pathParam(0)).isEqualTo("sesn_011CZkZAtmR3yMPDzynEDxu7") - assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oIjw0rgXZpnBt") + assertThat(params._pathParam(1)).isEqualTo("sthr_011CZkZVWa6oJjw1rgXZpnBt") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -39,7 +39,7 @@ internal class EventStreamParamsTest { val params = EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addEventDelta(BetaManagedAgentsDeltaType.AGENT_MESSAGE) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -50,7 +50,11 @@ internal class EventStreamParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -61,7 +65,7 @@ internal class EventStreamParamsTest { val params = EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() val headers = params._headers() @@ -74,7 +78,7 @@ internal class EventStreamParamsTest { val params = EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addEventDelta(BetaManagedAgentsDeltaType.AGENT_MESSAGE) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -91,7 +95,7 @@ internal class EventStreamParamsTest { val params = EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() val queryParams = params._queryParams() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillCreateParamsTest.kt index 6ef3d6592..95913b730 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillCreateParamsTest.kt @@ -34,7 +34,7 @@ internal class SkillCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillDeleteParamsTest.kt index 9b0b4083d..31486d453 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillDeleteParamsTest.kt @@ -39,7 +39,7 @@ internal class SkillDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillListParamsTest.kt index b884e4e71..2c0edcc48 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillListParamsTest.kt @@ -35,7 +35,7 @@ internal class SkillListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParamsTest.kt index 1e8d9e453..a59659af9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/SkillRetrieveParamsTest.kt @@ -39,7 +39,7 @@ internal class SkillRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParamsTest.kt index 604752a61..943e2bef4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionCreateParamsTest.kt @@ -47,7 +47,7 @@ internal class VersionCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParamsTest.kt index 2e84ad97d..575f3a04b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDeleteParamsTest.kt @@ -42,7 +42,7 @@ internal class VersionDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParamsTest.kt index 11892e548..d71c68f12 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionDownloadParamsTest.kt @@ -42,7 +42,7 @@ internal class VersionDownloadParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionListParamsTest.kt index 6a0b42b60..8ae1723df 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionListParamsTest.kt @@ -44,7 +44,7 @@ internal class VersionListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParamsTest.kt index 9f0362d9e..b8815c361 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/skills/versions/VersionRetrieveParamsTest.kt @@ -42,7 +42,7 @@ internal class VersionRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParamsTest.kt index 0596d7a52..581d9cf8b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelArchiveParamsTest.kt @@ -39,7 +39,11 @@ internal class TunnelArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParamsTest.kt index 4b36cde2d..154a93ad8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelCreateParamsTest.kt @@ -30,7 +30,11 @@ internal class TunnelCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelListParamsTest.kt index 9a21aa73e..fd8cbb19e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelListParamsTest.kt @@ -35,7 +35,11 @@ internal class TunnelListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParamsTest.kt index fd57bf7dd..4dc7e022d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRetrieveParamsTest.kt @@ -39,7 +39,11 @@ internal class TunnelRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParamsTest.kt index 7b7266f79..89ed5db78 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRevealTokenParamsTest.kt @@ -39,7 +39,11 @@ internal class TunnelRevealTokenParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParamsTest.kt index 4e3e1052f..85addde0e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/TunnelRotateTokenParamsTest.kt @@ -41,7 +41,11 @@ internal class TunnelRotateTokenParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParamsTest.kt index cf6664236..f8e320fb8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateArchiveParamsTest.kt @@ -46,7 +46,11 @@ internal class CertificateArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParamsTest.kt index 6a9472613..2e97c5f19 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateCreateParamsTest.kt @@ -45,7 +45,11 @@ internal class CertificateCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParamsTest.kt index af0bea85d..558e1403e 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateListParamsTest.kt @@ -46,7 +46,11 @@ internal class CertificateListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParamsTest.kt index b1a44b0c4..828c4857b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/tunnels/certificates/CertificateRetrieveParamsTest.kt @@ -46,7 +46,11 @@ internal class CertificateRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "mcp-tunnels-2026-06-22") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParamsTest.kt index bbe4a87fa..d0a155b25 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateEnrollmentUrlParamsTest.kt @@ -42,7 +42,11 @@ internal class UserProfileCreateEnrollmentUrlParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "user-profiles-2026-08-18") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParamsTest.kt index ec99c8e3d..5628563b2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileCreateParamsTest.kt @@ -63,7 +63,11 @@ internal class UserProfileCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "user-profiles-2026-08-18") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParamsTest.kt index 97fae19d3..e8d67b4b8 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileListParamsTest.kt @@ -37,7 +37,11 @@ internal class UserProfileListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "user-profiles-2026-08-18") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParamsTest.kt index e8465b214..750d6ebdc 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileRetrieveParamsTest.kt @@ -42,7 +42,11 @@ internal class UserProfileRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "user-profiles-2026-08-18") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParamsTest.kt index 7d116dd4d..f3dcdf3ba 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/userprofiles/UserProfileUpdateParamsTest.kt @@ -86,7 +86,11 @@ internal class UserProfileUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "user-profiles-2026-08-18") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParamsTest.kt index b51a74b4d..f4bd9b23b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultArchiveParamsTest.kt @@ -39,7 +39,11 @@ internal class VaultArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultCreateParamsTest.kt index da661a962..eba1cd7be 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultCreateParamsTest.kt @@ -41,7 +41,11 @@ internal class VaultCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParamsTest.kt index 6fff83d67..7ee7e155a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultDeleteParamsTest.kt @@ -39,7 +39,11 @@ internal class VaultDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultListParamsTest.kt index 83b59b0de..f80b63ea6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultListParamsTest.kt @@ -35,7 +35,11 @@ internal class VaultListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParamsTest.kt index e64dc76ea..29b74c147 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultRetrieveParamsTest.kt @@ -39,7 +39,11 @@ internal class VaultRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParamsTest.kt index 75f1f66d3..1ba361e7f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/VaultUpdateParamsTest.kt @@ -52,7 +52,11 @@ internal class VaultUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialTest.kt index 09050829a..b3a4343d3 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialTest.kt @@ -13,7 +13,7 @@ internal class BetaManagedAgentsCredentialTest { fun create() { val betaManagedAgentsCredential = BetaManagedAgentsCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .archivedAt(null) .staticBearerAuth("https://example-server.modelcontextprotocol.io/sse") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -28,7 +28,7 @@ internal class BetaManagedAgentsCredentialTest { .displayName("Example credential") .build() - assertThat(betaManagedAgentsCredential.id()).isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + assertThat(betaManagedAgentsCredential.id()).isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") assertThat(betaManagedAgentsCredential.archivedAt()).isEmpty assertThat(betaManagedAgentsCredential.auth()) .isEqualTo( @@ -60,7 +60,7 @@ internal class BetaManagedAgentsCredentialTest { val jsonMapper = jsonMapper() val betaManagedAgentsCredential = BetaManagedAgentsCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .archivedAt(null) .staticBearerAuth("https://example-server.modelcontextprotocol.io/sse") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialValidationTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialValidationTest.kt index 2bb8f1aca..a730a5024 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialValidationTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsCredentialValidationTest.kt @@ -12,7 +12,7 @@ internal class BetaManagedAgentsCredentialValidationTest { fun create() { val betaManagedAgentsCredentialValidation = BetaManagedAgentsCredentialValidation.builder() - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .hasRefreshToken(true) .mcpProbe( BetaManagedAgentsMcpProbe.builder() @@ -47,7 +47,7 @@ internal class BetaManagedAgentsCredentialValidationTest { .build() assertThat(betaManagedAgentsCredentialValidation.credentialId()) - .isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") assertThat(betaManagedAgentsCredentialValidation.hasRefreshToken()).isEqualTo(true) assertThat(betaManagedAgentsCredentialValidation.mcpProbe()) .contains( @@ -92,7 +92,7 @@ internal class BetaManagedAgentsCredentialValidationTest { val jsonMapper = jsonMapper() val betaManagedAgentsCredentialValidation = BetaManagedAgentsCredentialValidation.builder() - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .hasRefreshToken(true) .mcpProbe( BetaManagedAgentsMcpProbe.builder() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsDeletedCredentialTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsDeletedCredentialTest.kt index 1738e0c47..20d3e7552 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsDeletedCredentialTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/BetaManagedAgentsDeletedCredentialTest.kt @@ -11,12 +11,12 @@ internal class BetaManagedAgentsDeletedCredentialTest { fun create() { val betaManagedAgentsDeletedCredential = BetaManagedAgentsDeletedCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .type(BetaManagedAgentsDeletedCredential.Type.VAULT_CREDENTIAL_DELETED) .build() assertThat(betaManagedAgentsDeletedCredential.id()) - .isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") assertThat(betaManagedAgentsDeletedCredential.type()) .isEqualTo(BetaManagedAgentsDeletedCredential.Type.VAULT_CREDENTIAL_DELETED) } @@ -26,7 +26,7 @@ internal class BetaManagedAgentsDeletedCredentialTest { val jsonMapper = jsonMapper() val betaManagedAgentsDeletedCredential = BetaManagedAgentsDeletedCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .type(BetaManagedAgentsDeletedCredential.Type.VAULT_CREDENTIAL_DELETED) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParamsTest.kt index 6388f0621..b95bd83f2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialArchiveParamsTest.kt @@ -11,7 +11,7 @@ internal class CredentialArchiveParamsTest { fun create() { CredentialArchiveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -22,11 +22,11 @@ internal class CredentialArchiveParamsTest { val params = CredentialArchiveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() assertThat(params._pathParam(0)).isEqualTo("vlt_011CZkZDLs7fYzm1hXNPeRjv") - assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -36,7 +36,7 @@ internal class CredentialArchiveParamsTest { val params = CredentialArchiveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -46,7 +46,11 @@ internal class CredentialArchiveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -57,7 +61,7 @@ internal class CredentialArchiveParamsTest { val params = CredentialArchiveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() val headers = params._headers() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParamsTest.kt index 7f06cdc38..edf7ec237 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialCreateParamsTest.kt @@ -76,7 +76,11 @@ internal class CredentialCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParamsTest.kt index f955b9dff..8c7d39f14 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialDeleteParamsTest.kt @@ -11,7 +11,7 @@ internal class CredentialDeleteParamsTest { fun create() { CredentialDeleteParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -22,11 +22,11 @@ internal class CredentialDeleteParamsTest { val params = CredentialDeleteParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() assertThat(params._pathParam(0)).isEqualTo("vlt_011CZkZDLs7fYzm1hXNPeRjv") - assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -36,7 +36,7 @@ internal class CredentialDeleteParamsTest { val params = CredentialDeleteParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -46,7 +46,11 @@ internal class CredentialDeleteParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -57,7 +61,7 @@ internal class CredentialDeleteParamsTest { val params = CredentialDeleteParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() val headers = params._headers() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListPageResponseTest.kt index 218600e3e..9381c1bf9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListPageResponseTest.kt @@ -16,7 +16,7 @@ internal class CredentialListPageResponseTest { CredentialListPageResponse.builder() .addData( BetaManagedAgentsCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .archivedAt(null) .staticBearerAuth("https://example-server.modelcontextprotocol.io/sse") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -37,7 +37,7 @@ internal class CredentialListPageResponseTest { assertThat(credentialListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .archivedAt(null) .staticBearerAuth("https://example-server.modelcontextprotocol.io/sse") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -65,7 +65,7 @@ internal class CredentialListPageResponseTest { .toBuilder() .addData( BetaManagedAgentsCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .archivedAt(null) .staticBearerAuth("https://example-server.modelcontextprotocol.io/sse") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -85,7 +85,7 @@ internal class CredentialListPageResponseTest { assertThat(credentialListPageResponse.data().getOrNull()) .containsExactly( BetaManagedAgentsCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .archivedAt(null) .staticBearerAuth("https://example-server.modelcontextprotocol.io/sse") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) @@ -109,7 +109,7 @@ internal class CredentialListPageResponseTest { CredentialListPageResponse.builder() .addData( BetaManagedAgentsCredential.builder() - .id("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .id("vcrd_011CZkZEMt8gZan2iYPQfSkw") .archivedAt(null) .staticBearerAuth("https://example-server.modelcontextprotocol.io/sse") .createdAt(OffsetDateTime.parse("2026-03-15T10:00:00Z")) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParamsTest.kt index 3a8d6b722..417d6c18d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialListParamsTest.kt @@ -46,7 +46,11 @@ internal class CredentialListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParamsTest.kt index 41ba856c8..8e742fdff 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialMcpOAuthValidateParamsTest.kt @@ -11,7 +11,7 @@ internal class CredentialMcpOAuthValidateParamsTest { fun create() { CredentialMcpOAuthValidateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -22,11 +22,11 @@ internal class CredentialMcpOAuthValidateParamsTest { val params = CredentialMcpOAuthValidateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() assertThat(params._pathParam(0)).isEqualTo("vlt_011CZkZDLs7fYzm1hXNPeRjv") - assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -36,7 +36,7 @@ internal class CredentialMcpOAuthValidateParamsTest { val params = CredentialMcpOAuthValidateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -46,7 +46,11 @@ internal class CredentialMcpOAuthValidateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -57,7 +61,7 @@ internal class CredentialMcpOAuthValidateParamsTest { val params = CredentialMcpOAuthValidateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() val headers = params._headers() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParamsTest.kt index cc0927b40..514f43020 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialRetrieveParamsTest.kt @@ -11,7 +11,7 @@ internal class CredentialRetrieveParamsTest { fun create() { CredentialRetrieveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -22,11 +22,11 @@ internal class CredentialRetrieveParamsTest { val params = CredentialRetrieveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() assertThat(params._pathParam(0)).isEqualTo("vlt_011CZkZDLs7fYzm1hXNPeRjv") - assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -36,7 +36,7 @@ internal class CredentialRetrieveParamsTest { val params = CredentialRetrieveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -46,7 +46,11 @@ internal class CredentialRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -57,7 +61,7 @@ internal class CredentialRetrieveParamsTest { val params = CredentialRetrieveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() val headers = params._headers() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParamsTest.kt index 8402f1847..8ad71cc50 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/beta/vaults/credentials/CredentialUpdateParamsTest.kt @@ -13,7 +13,7 @@ internal class CredentialUpdateParamsTest { fun create() { CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .auth( @@ -52,11 +52,11 @@ internal class CredentialUpdateParamsTest { val params = CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() assertThat(params._pathParam(0)).isEqualTo("vlt_011CZkZDLs7fYzm1hXNPeRjv") - assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYOQfSkw") + assertThat(params._pathParam(1)).isEqualTo("vcrd_011CZkZEMt8gZan2iYPQfSkw") // out-of-bound path param assertThat(params._pathParam(2)).isEqualTo("") } @@ -66,7 +66,7 @@ internal class CredentialUpdateParamsTest { val params = CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .auth( @@ -104,7 +104,11 @@ internal class CredentialUpdateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put( + "anthropic-beta", + listOf("message-batches-2024-09-24", "managed-agents-2026-04-01") + .joinToString(","), + ) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -115,7 +119,7 @@ internal class CredentialUpdateParamsTest { val params = CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() val headers = params._headers() @@ -128,7 +132,7 @@ internal class CredentialUpdateParamsTest { val params = CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .auth( @@ -202,7 +206,7 @@ internal class CredentialUpdateParamsTest { val params = CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .build() val body = params._body() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionCreateParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionCreateParamsTest.kt index 1c23485a0..5d2b7e2da 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionCreateParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionCreateParamsTest.kt @@ -16,7 +16,7 @@ internal class CompletionCreateParamsTest { .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") @@ -33,7 +33,7 @@ internal class CompletionCreateParamsTest { .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") @@ -47,7 +47,7 @@ internal class CompletionCreateParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -58,7 +58,7 @@ internal class CompletionCreateParamsTest { val params = CompletionCreateParams.builder() .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .build() @@ -74,7 +74,7 @@ internal class CompletionCreateParamsTest { .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) .addStopSequence("string") @@ -86,7 +86,7 @@ internal class CompletionCreateParamsTest { val body = params._body() assertThat(body.maxTokensToSample()).isEqualTo(256L) - assertThat(body.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(body.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) assertThat(body.prompt()).isEqualTo("\n\nHuman: Hello, world!\n\nAssistant:") assertThat(body.metadata()) .contains(Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build()) @@ -101,14 +101,14 @@ internal class CompletionCreateParamsTest { val params = CompletionCreateParams.builder() .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .build() val body = params._body() assertThat(body.maxTokensToSample()).isEqualTo(256L) - assertThat(body.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(body.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) assertThat(body.prompt()).isEqualTo("\n\nHuman: Hello, world!\n\nAssistant:") } } diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionTest.kt index b77944b03..a1f0af03b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/completions/CompletionTest.kt @@ -14,13 +14,13 @@ internal class CompletionTest { Completion.builder() .id("compl_018CKm6gsux7P8yMcwZbeCPw") .completion(" Hello! My name is Claude.") - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .stopReason("stop_sequence") .build() assertThat(completion.id()).isEqualTo("compl_018CKm6gsux7P8yMcwZbeCPw") assertThat(completion.completion()).isEqualTo(" Hello! My name is Claude.") - assertThat(completion.model()).isEqualTo(Model.CLAUDE_SONNET_5_5) + assertThat(completion.model()).isEqualTo(Model.CLAUDE_HAIKU_5_5) assertThat(completion.stopReason()).contains("stop_sequence") } @@ -31,7 +31,7 @@ internal class CompletionTest { Completion.builder() .id("compl_018CKm6gsux7P8yMcwZbeCPw") .completion(" Hello! My name is Claude.") - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .stopReason("stop_sequence") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserClickTargetTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserClickTargetTest.kt new file mode 100644 index 000000000..56fa0bec8 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserClickTargetTest.kt @@ -0,0 +1,81 @@ +package com.anthropic.models.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BrowserClickTargetTest { + + @Test + fun ofCoordinate() { + val coordinate = BrowserCoordinateTarget.builder().x(0L).y(0L).build() + + val browserClickTarget = BrowserClickTarget.ofCoordinate(coordinate) + + assertThat(browserClickTarget.coordinate()).contains(coordinate) + assertThat(browserClickTarget.ref()).isEmpty + } + + @Test + fun ofCoordinateRoundtrip() { + val jsonMapper = jsonMapper() + val browserClickTarget = + BrowserClickTarget.ofCoordinate(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + + val roundtrippedBrowserClickTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserClickTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserClickTarget).isEqualTo(browserClickTarget) + } + + @Test + fun ofRef() { + val ref = BrowserRefTarget.of("ref") + + val browserClickTarget = BrowserClickTarget.ofRef(ref) + + assertThat(browserClickTarget.coordinate()).isEmpty + assertThat(browserClickTarget.ref()).contains(ref) + } + + @Test + fun ofRefRoundtrip() { + val jsonMapper = jsonMapper() + val browserClickTarget = BrowserClickTarget.ofRef(BrowserRefTarget.of("ref")) + + val roundtrippedBrowserClickTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserClickTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserClickTarget).isEqualTo(browserClickTarget) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val browserClickTarget = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { browserClickTarget.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCloseTabInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCloseTabInputTest.kt new file mode 100644 index 000000000..3207273d0 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCloseTabInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserCloseTabInputTest { + + @Test + fun create() { + val browserCloseTabInput = BrowserCloseTabInput.of("tab_id") + + assertThat(browserCloseTabInput.tabId()).isEqualTo("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserCloseTabInput = BrowserCloseTabInput.of("tab_id") + + val roundtrippedBrowserCloseTabInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserCloseTabInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserCloseTabInput).isEqualTo(browserCloseTabInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCloseTabToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCloseTabToolUseBlockTest.kt new file mode 100644 index 000000000..91445de67 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCloseTabToolUseBlockTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserCloseTabToolUseBlockTest { + + @Test + fun create() { + val browserCloseTabToolUseBlock = + BrowserCloseTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserCloseTabInput.of("tab_id")) + .build() + + assertThat(browserCloseTabToolUseBlock.id()).isEqualTo("id") + assertThat(browserCloseTabToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserCloseTabToolUseBlock.input()).isEqualTo(BrowserCloseTabInput.of("tab_id")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserCloseTabToolUseBlock = + BrowserCloseTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserCloseTabInput.of("tab_id")) + .build() + + val roundtrippedBrowserCloseTabToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserCloseTabToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserCloseTabToolUseBlock).isEqualTo(browserCloseTabToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCoordinateTargetTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCoordinateTargetTest.kt new file mode 100644 index 000000000..d592e2717 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserCoordinateTargetTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserCoordinateTargetTest { + + @Test + fun create() { + val browserCoordinateTarget = BrowserCoordinateTarget.builder().x(0L).y(0L).build() + + assertThat(browserCoordinateTarget.x()).isEqualTo(0L) + assertThat(browserCoordinateTarget.y()).isEqualTo(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserCoordinateTarget = BrowserCoordinateTarget.builder().x(0L).y(0L).build() + + val roundtrippedBrowserCoordinateTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserCoordinateTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserCoordinateTarget).isEqualTo(browserCoordinateTarget) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserDoubleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserDoubleClickInputTest.kt new file mode 100644 index 000000000..550c23fde --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserDoubleClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserDoubleClickInputTest { + + @Test + fun create() { + val browserDoubleClickInput = + BrowserDoubleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(browserDoubleClickInput.target()) + .isEqualTo( + BrowserClickTarget.ofCoordinate( + BrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(browserDoubleClickInput.modifiers()).contains("modifiers") + assertThat(browserDoubleClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserDoubleClickInput = + BrowserDoubleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBrowserDoubleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserDoubleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserDoubleClickInput).isEqualTo(browserDoubleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserDoubleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserDoubleClickToolUseBlockTest.kt new file mode 100644 index 000000000..111b6f479 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserDoubleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserDoubleClickToolUseBlockTest { + + @Test + fun create() { + val browserDoubleClickToolUseBlock = + BrowserDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserDoubleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserDoubleClickToolUseBlock.id()).isEqualTo("id") + assertThat(browserDoubleClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserDoubleClickToolUseBlock.input()) + .isEqualTo( + BrowserDoubleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserDoubleClickToolUseBlock = + BrowserDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserDoubleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserDoubleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserDoubleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserDoubleClickToolUseBlock) + .isEqualTo(browserDoubleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFileUploadInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFileUploadInputTest.kt new file mode 100644 index 000000000..09f7588f9 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFileUploadInputTest.kt @@ -0,0 +1,57 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserFileUploadInputTest { + + @Test + fun create() { + val browserFileUploadInput = + BrowserFileUploadInput.builder() + .target(BrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + + assertThat(browserFileUploadInput.target()).isEqualTo(BrowserRefTarget.of("ref")) + assertThat(browserFileUploadInput.documentIds().getOrNull()).containsExactly("string") + assertThat(browserFileUploadInput.paths().getOrNull()).containsExactly("string") + assertThat(browserFileUploadInput.tabId()).contains("tab_id") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseBrowserFileUploadInput = BrowserFileUploadInput.of(BrowserRefTarget.of("ref")) + + val browserFileUploadInput = + baseBrowserFileUploadInput.toBuilder().addDocumentId("string").addPath("string").build() + + assertThat(browserFileUploadInput.documentIds().getOrNull()).containsExactly("string") + assertThat(browserFileUploadInput.paths().getOrNull()).containsExactly("string") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserFileUploadInput = + BrowserFileUploadInput.builder() + .target(BrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + + val roundtrippedBrowserFileUploadInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFileUploadInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFileUploadInput).isEqualTo(browserFileUploadInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFileUploadToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFileUploadToolUseBlockTest.kt new file mode 100644 index 000000000..7e94a855e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFileUploadToolUseBlockTest.kt @@ -0,0 +1,66 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserFileUploadToolUseBlockTest { + + @Test + fun create() { + val browserFileUploadToolUseBlock = + BrowserFileUploadToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFileUploadInput.builder() + .target(BrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserFileUploadToolUseBlock.id()).isEqualTo("id") + assertThat(browserFileUploadToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserFileUploadToolUseBlock.input()) + .isEqualTo( + BrowserFileUploadInput.builder() + .target(BrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserFileUploadToolUseBlock = + BrowserFileUploadToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFileUploadInput.builder() + .target(BrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserFileUploadToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFileUploadToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFileUploadToolUseBlock) + .isEqualTo(browserFileUploadToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFindInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFindInputTest.kt new file mode 100644 index 000000000..f9a84ae8d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFindInputTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserFindInputTest { + + @Test + fun create() { + val browserFindInput = BrowserFindInput.builder().query("query").tabId("tab_id").build() + + assertThat(browserFindInput.query()).isEqualTo("query") + assertThat(browserFindInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserFindInput = BrowserFindInput.builder().query("query").tabId("tab_id").build() + + val roundtrippedBrowserFindInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFindInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFindInput).isEqualTo(browserFindInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFindToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFindToolUseBlockTest.kt new file mode 100644 index 000000000..9126178f3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFindToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserFindToolUseBlockTest { + + @Test + fun create() { + val browserFindToolUseBlock = + BrowserFindToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserFindInput.builder().query("query").tabId("tab_id").build()) + .build() + + assertThat(browserFindToolUseBlock.id()).isEqualTo("id") + assertThat(browserFindToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserFindToolUseBlock.input()) + .isEqualTo(BrowserFindInput.builder().query("query").tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserFindToolUseBlock = + BrowserFindToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserFindInput.builder().query("query").tabId("tab_id").build()) + .build() + + val roundtrippedBrowserFindToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFindToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFindToolUseBlock).isEqualTo(browserFindToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputInputTest.kt new file mode 100644 index 000000000..074280c15 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputInputTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserFormInputInputTest { + + @Test + fun create() { + val browserFormInputInput = + BrowserFormInputInput.builder() + .target(BrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + + assertThat(browserFormInputInput.target()).isEqualTo(BrowserRefTarget.of("ref")) + assertThat(browserFormInputInput.value()) + .isEqualTo(BrowserFormInputValue.ofString("string")) + assertThat(browserFormInputInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserFormInputInput = + BrowserFormInputInput.builder() + .target(BrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + + val roundtrippedBrowserFormInputInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFormInputInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFormInputInput).isEqualTo(browserFormInputInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputToolUseBlockTest.kt new file mode 100644 index 000000000..883dd474e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputToolUseBlockTest.kt @@ -0,0 +1,62 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserFormInputToolUseBlockTest { + + @Test + fun create() { + val browserFormInputToolUseBlock = + BrowserFormInputToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFormInputInput.builder() + .target(BrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserFormInputToolUseBlock.id()).isEqualTo("id") + assertThat(browserFormInputToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserFormInputToolUseBlock.input()) + .isEqualTo( + BrowserFormInputInput.builder() + .target(BrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserFormInputToolUseBlock = + BrowserFormInputToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFormInputInput.builder() + .target(BrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserFormInputToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFormInputToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFormInputToolUseBlock).isEqualTo(browserFormInputToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputValueTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputValueTest.kt new file mode 100644 index 000000000..6543e182b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserFormInputValueTest.kt @@ -0,0 +1,104 @@ +package com.anthropic.models.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BrowserFormInputValueTest { + + @Test + fun ofString() { + val string = "string" + + val browserFormInputValue = BrowserFormInputValue.ofString(string) + + assertThat(browserFormInputValue.string()).contains(string) + assertThat(browserFormInputValue.number()).isEmpty + assertThat(browserFormInputValue.bool()).isEmpty + } + + @Test + fun ofStringRoundtrip() { + val jsonMapper = jsonMapper() + val browserFormInputValue = BrowserFormInputValue.ofString("string") + + val roundtrippedBrowserFormInputValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFormInputValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFormInputValue).isEqualTo(browserFormInputValue) + } + + @Test + fun ofNumber() { + val number = 0.0 + + val browserFormInputValue = BrowserFormInputValue.ofNumber(number) + + assertThat(browserFormInputValue.string()).isEmpty + assertThat(browserFormInputValue.number()).contains(number) + assertThat(browserFormInputValue.bool()).isEmpty + } + + @Test + fun ofNumberRoundtrip() { + val jsonMapper = jsonMapper() + val browserFormInputValue = BrowserFormInputValue.ofNumber(0.0) + + val roundtrippedBrowserFormInputValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFormInputValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFormInputValue).isEqualTo(browserFormInputValue) + } + + @Test + fun ofBool() { + val bool = true + + val browserFormInputValue = BrowserFormInputValue.ofBool(bool) + + assertThat(browserFormInputValue.string()).isEmpty + assertThat(browserFormInputValue.number()).isEmpty + assertThat(browserFormInputValue.bool()).contains(bool) + } + + @Test + fun ofBoolRoundtrip() { + val jsonMapper = jsonMapper() + val browserFormInputValue = BrowserFormInputValue.ofBool(true) + + val roundtrippedBrowserFormInputValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserFormInputValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserFormInputValue).isEqualTo(browserFormInputValue) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + OBJECT(JsonValue.from(mapOf("invalid" to "object"))), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val browserFormInputValue = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { browserFormInputValue.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserGetPageTextInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserGetPageTextInputTest.kt new file mode 100644 index 000000000..86ea4ed2b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserGetPageTextInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserGetPageTextInputTest { + + @Test + fun create() { + val browserGetPageTextInput = BrowserGetPageTextInput.builder().tabId("tab_id").build() + + assertThat(browserGetPageTextInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserGetPageTextInput = BrowserGetPageTextInput.builder().tabId("tab_id").build() + + val roundtrippedBrowserGetPageTextInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserGetPageTextInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserGetPageTextInput).isEqualTo(browserGetPageTextInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserGetPageTextToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserGetPageTextToolUseBlockTest.kt new file mode 100644 index 000000000..fbabba17f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserGetPageTextToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserGetPageTextToolUseBlockTest { + + @Test + fun create() { + val browserGetPageTextToolUseBlock = + BrowserGetPageTextToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserGetPageTextInput.builder().tabId("tab_id").build()) + .build() + + assertThat(browserGetPageTextToolUseBlock.id()).isEqualTo("id") + assertThat(browserGetPageTextToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserGetPageTextToolUseBlock.input()) + .isEqualTo(BrowserGetPageTextInput.builder().tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserGetPageTextToolUseBlock = + BrowserGetPageTextToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserGetPageTextInput.builder().tabId("tab_id").build()) + .build() + + val roundtrippedBrowserGetPageTextToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserGetPageTextToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserGetPageTextToolUseBlock) + .isEqualTo(browserGetPageTextToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoldKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoldKeyInputTest.kt new file mode 100644 index 000000000..f72a5a8a2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoldKeyInputTest.kt @@ -0,0 +1,34 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserHoldKeyInputTest { + + @Test + fun create() { + val browserHoldKeyInput = + BrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + + assertThat(browserHoldKeyInput.duration()).isEqualTo(0.0) + assertThat(browserHoldKeyInput.text()).isEqualTo("text") + assertThat(browserHoldKeyInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserHoldKeyInput = + BrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + + val roundtrippedBrowserHoldKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserHoldKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserHoldKeyInput).isEqualTo(browserHoldKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoldKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoldKeyToolUseBlockTest.kt new file mode 100644 index 000000000..1de73fdc8 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoldKeyToolUseBlockTest.kt @@ -0,0 +1,50 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserHoldKeyToolUseBlockTest { + + @Test + fun create() { + val browserHoldKeyToolUseBlock = + BrowserHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + ) + .build() + + assertThat(browserHoldKeyToolUseBlock.id()).isEqualTo("id") + assertThat(browserHoldKeyToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserHoldKeyToolUseBlock.input()) + .isEqualTo( + BrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserHoldKeyToolUseBlock = + BrowserHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + ) + .build() + + val roundtrippedBrowserHoldKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserHoldKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserHoldKeyToolUseBlock).isEqualTo(browserHoldKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoverInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoverInputTest.kt new file mode 100644 index 000000000..c6869be43 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoverInputTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserHoverInputTest { + + @Test + fun create() { + val browserHoverInput = + BrowserHoverInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(browserHoverInput.target()) + .isEqualTo( + BrowserClickTarget.ofCoordinate( + BrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(browserHoverInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserHoverInput = + BrowserHoverInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBrowserHoverInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserHoverInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserHoverInput).isEqualTo(browserHoverInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoverToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoverToolUseBlockTest.kt new file mode 100644 index 000000000..e01373478 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserHoverToolUseBlockTest.kt @@ -0,0 +1,59 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserHoverToolUseBlockTest { + + @Test + fun create() { + val browserHoverToolUseBlock = + BrowserHoverToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoverInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserHoverToolUseBlock.id()).isEqualTo("id") + assertThat(browserHoverToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserHoverToolUseBlock.input()) + .isEqualTo( + BrowserHoverInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserHoverToolUseBlock = + BrowserHoverToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoverInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserHoverToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserHoverToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserHoverToolUseBlock).isEqualTo(browserHoverToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserJavascriptExecInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserJavascriptExecInputTest.kt new file mode 100644 index 000000000..326055ea6 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserJavascriptExecInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserJavascriptExecInputTest { + + @Test + fun create() { + val browserJavascriptExecInput = + BrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + + assertThat(browserJavascriptExecInput.text()).isEqualTo("text") + assertThat(browserJavascriptExecInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserJavascriptExecInput = + BrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + + val roundtrippedBrowserJavascriptExecInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserJavascriptExecInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserJavascriptExecInput).isEqualTo(browserJavascriptExecInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserJavascriptExecToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserJavascriptExecToolUseBlockTest.kt new file mode 100644 index 000000000..b786ad61a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserJavascriptExecToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserJavascriptExecToolUseBlockTest { + + @Test + fun create() { + val browserJavascriptExecToolUseBlock = + BrowserJavascriptExecToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build()) + .build() + + assertThat(browserJavascriptExecToolUseBlock.id()).isEqualTo("id") + assertThat(browserJavascriptExecToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserJavascriptExecToolUseBlock.input()) + .isEqualTo(BrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserJavascriptExecToolUseBlock = + BrowserJavascriptExecToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build()) + .build() + + val roundtrippedBrowserJavascriptExecToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserJavascriptExecToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserJavascriptExecToolUseBlock) + .isEqualTo(browserJavascriptExecToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserKeyInputTest.kt new file mode 100644 index 000000000..3f85d2db2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserKeyInputTest.kt @@ -0,0 +1,34 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserKeyInputTest { + + @Test + fun create() { + val browserKeyInput = + BrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + + assertThat(browserKeyInput.text()).isEqualTo("text") + assertThat(browserKeyInput.repeat()).contains(1L) + assertThat(browserKeyInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserKeyInput = + BrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + + val roundtrippedBrowserKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserKeyInput).isEqualTo(browserKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserKeyToolUseBlockTest.kt new file mode 100644 index 000000000..efaceea2b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserKeyToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserKeyToolUseBlockTest { + + @Test + fun create() { + val browserKeyToolUseBlock = + BrowserKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build()) + .build() + + assertThat(browserKeyToolUseBlock.id()).isEqualTo("id") + assertThat(browserKeyToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserKeyToolUseBlock.input()) + .isEqualTo(BrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserKeyToolUseBlock = + BrowserKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build()) + .build() + + val roundtrippedBrowserKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserKeyToolUseBlock).isEqualTo(browserKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickDragInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickDragInputTest.kt new file mode 100644 index 000000000..fa2a9c742 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickDragInputTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftClickDragInputTest { + + @Test + fun create() { + val browserLeftClickDragInput = + BrowserLeftClickDragInput.builder() + .from(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(browserLeftClickDragInput.from()) + .isEqualTo(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(browserLeftClickDragInput.target()) + .isEqualTo(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(browserLeftClickDragInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftClickDragInput = + BrowserLeftClickDragInput.builder() + .from(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBrowserLeftClickDragInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftClickDragInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftClickDragInput).isEqualTo(browserLeftClickDragInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickDragToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickDragToolUseBlockTest.kt new file mode 100644 index 000000000..5c9779001 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickDragToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftClickDragToolUseBlockTest { + + @Test + fun create() { + val browserLeftClickDragToolUseBlock = + BrowserLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickDragInput.builder() + .from(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserLeftClickDragToolUseBlock.id()).isEqualTo("id") + assertThat(browserLeftClickDragToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserLeftClickDragToolUseBlock.input()) + .isEqualTo( + BrowserLeftClickDragInput.builder() + .from(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftClickDragToolUseBlock = + BrowserLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickDragInput.builder() + .from(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserLeftClickDragToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftClickDragToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftClickDragToolUseBlock) + .isEqualTo(browserLeftClickDragToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickInputTest.kt new file mode 100644 index 000000000..39ad574ee --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftClickInputTest { + + @Test + fun create() { + val browserLeftClickInput = + BrowserLeftClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(browserLeftClickInput.target()) + .isEqualTo( + BrowserClickTarget.ofCoordinate( + BrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(browserLeftClickInput.modifiers()).contains("modifiers") + assertThat(browserLeftClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftClickInput = + BrowserLeftClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBrowserLeftClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftClickInput).isEqualTo(browserLeftClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickToolUseBlockTest.kt new file mode 100644 index 000000000..12f30ef23 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftClickToolUseBlockTest.kt @@ -0,0 +1,62 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftClickToolUseBlockTest { + + @Test + fun create() { + val browserLeftClickToolUseBlock = + BrowserLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserLeftClickToolUseBlock.id()).isEqualTo("id") + assertThat(browserLeftClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserLeftClickToolUseBlock.input()) + .isEqualTo( + BrowserLeftClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftClickToolUseBlock = + BrowserLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserLeftClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftClickToolUseBlock).isEqualTo(browserLeftClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownInputTest.kt new file mode 100644 index 000000000..448a9507f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownInputTest.kt @@ -0,0 +1,40 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftMouseDownInputTest { + + @Test + fun create() { + val browserLeftMouseDownInput = + BrowserLeftMouseDownInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(browserLeftMouseDownInput.target()) + .isEqualTo(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(browserLeftMouseDownInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftMouseDownInput = + BrowserLeftMouseDownInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBrowserLeftMouseDownInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftMouseDownInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftMouseDownInput).isEqualTo(browserLeftMouseDownInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownToolUseBlockTest.kt new file mode 100644 index 000000000..2a3f1d921 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseDownToolUseBlockTest.kt @@ -0,0 +1,60 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftMouseDownToolUseBlockTest { + + @Test + fun create() { + val browserLeftMouseDownToolUseBlock = + BrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseDownInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserLeftMouseDownToolUseBlock.id()).isEqualTo("id") + assertThat(browserLeftMouseDownToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserLeftMouseDownToolUseBlock.input()) + .isEqualTo( + BrowserLeftMouseDownInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftMouseDownToolUseBlock = + BrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseDownInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserLeftMouseDownToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftMouseDownToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftMouseDownToolUseBlock) + .isEqualTo(browserLeftMouseDownToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpInputTest.kt new file mode 100644 index 000000000..96f4293ed --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpInputTest.kt @@ -0,0 +1,40 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftMouseUpInputTest { + + @Test + fun create() { + val browserLeftMouseUpInput = + BrowserLeftMouseUpInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(browserLeftMouseUpInput.target()) + .isEqualTo(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(browserLeftMouseUpInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftMouseUpInput = + BrowserLeftMouseUpInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBrowserLeftMouseUpInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftMouseUpInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftMouseUpInput).isEqualTo(browserLeftMouseUpInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpToolUseBlockTest.kt new file mode 100644 index 000000000..c4b35923a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserLeftMouseUpToolUseBlockTest.kt @@ -0,0 +1,60 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserLeftMouseUpToolUseBlockTest { + + @Test + fun create() { + val browserLeftMouseUpToolUseBlock = + BrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseUpInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserLeftMouseUpToolUseBlock.id()).isEqualTo("id") + assertThat(browserLeftMouseUpToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserLeftMouseUpToolUseBlock.input()) + .isEqualTo( + BrowserLeftMouseUpInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserLeftMouseUpToolUseBlock = + BrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseUpInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserLeftMouseUpToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserLeftMouseUpToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserLeftMouseUpToolUseBlock) + .isEqualTo(browserLeftMouseUpToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserListTabsInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserListTabsInputTest.kt new file mode 100644 index 000000000..ad855c30f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserListTabsInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserListTabsInputTest { + + @Test + fun create() { + val browserListTabsInput = BrowserListTabsInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserListTabsInput = BrowserListTabsInput.builder().build() + + val roundtrippedBrowserListTabsInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserListTabsInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserListTabsInput).isEqualTo(browserListTabsInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserListTabsToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserListTabsToolUseBlockTest.kt new file mode 100644 index 000000000..acbe89166 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserListTabsToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserListTabsToolUseBlockTest { + + @Test + fun create() { + val browserListTabsToolUseBlock = + BrowserListTabsToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserListTabsInput.builder().build()) + .build() + + assertThat(browserListTabsToolUseBlock.id()).isEqualTo("id") + assertThat(browserListTabsToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserListTabsToolUseBlock.input()) + .isEqualTo(BrowserListTabsInput.builder().build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserListTabsToolUseBlock = + BrowserListTabsToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserListTabsInput.builder().build()) + .build() + + val roundtrippedBrowserListTabsToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserListTabsToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserListTabsToolUseBlock).isEqualTo(browserListTabsToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMiddleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMiddleClickInputTest.kt new file mode 100644 index 000000000..b55adec76 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMiddleClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserMiddleClickInputTest { + + @Test + fun create() { + val browserMiddleClickInput = + BrowserMiddleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(browserMiddleClickInput.target()) + .isEqualTo( + BrowserClickTarget.ofCoordinate( + BrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(browserMiddleClickInput.modifiers()).contains("modifiers") + assertThat(browserMiddleClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserMiddleClickInput = + BrowserMiddleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBrowserMiddleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserMiddleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserMiddleClickInput).isEqualTo(browserMiddleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMiddleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMiddleClickToolUseBlockTest.kt new file mode 100644 index 000000000..36405671e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMiddleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserMiddleClickToolUseBlockTest { + + @Test + fun create() { + val browserMiddleClickToolUseBlock = + BrowserMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMiddleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserMiddleClickToolUseBlock.id()).isEqualTo("id") + assertThat(browserMiddleClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserMiddleClickToolUseBlock.input()) + .isEqualTo( + BrowserMiddleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserMiddleClickToolUseBlock = + BrowserMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMiddleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserMiddleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserMiddleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserMiddleClickToolUseBlock) + .isEqualTo(browserMiddleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMouseMoveInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMouseMoveInputTest.kt new file mode 100644 index 000000000..3f4b04f81 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMouseMoveInputTest.kt @@ -0,0 +1,40 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserMouseMoveInputTest { + + @Test + fun create() { + val browserMouseMoveInput = + BrowserMouseMoveInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + assertThat(browserMouseMoveInput.target()) + .isEqualTo(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(browserMouseMoveInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserMouseMoveInput = + BrowserMouseMoveInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + + val roundtrippedBrowserMouseMoveInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserMouseMoveInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserMouseMoveInput).isEqualTo(browserMouseMoveInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMouseMoveToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMouseMoveToolUseBlockTest.kt new file mode 100644 index 000000000..bd789cdc5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserMouseMoveToolUseBlockTest.kt @@ -0,0 +1,59 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserMouseMoveToolUseBlockTest { + + @Test + fun create() { + val browserMouseMoveToolUseBlock = + BrowserMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMouseMoveInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserMouseMoveToolUseBlock.id()).isEqualTo("id") + assertThat(browserMouseMoveToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserMouseMoveToolUseBlock.input()) + .isEqualTo( + BrowserMouseMoveInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserMouseMoveToolUseBlock = + BrowserMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMouseMoveInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserMouseMoveToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserMouseMoveToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserMouseMoveToolUseBlock).isEqualTo(browserMouseMoveToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNavigateInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNavigateInputTest.kt new file mode 100644 index 000000000..355cc4da1 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNavigateInputTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserNavigateInputTest { + + @Test + fun create() { + val browserNavigateInput = BrowserNavigateInput.builder().url("url").tabId("tab_id").build() + + assertThat(browserNavigateInput.url()).isEqualTo("url") + assertThat(browserNavigateInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserNavigateInput = BrowserNavigateInput.builder().url("url").tabId("tab_id").build() + + val roundtrippedBrowserNavigateInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserNavigateInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserNavigateInput).isEqualTo(browserNavigateInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNavigateToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNavigateToolUseBlockTest.kt new file mode 100644 index 000000000..03fa01e17 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNavigateToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserNavigateToolUseBlockTest { + + @Test + fun create() { + val browserNavigateToolUseBlock = + BrowserNavigateToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .build() + + assertThat(browserNavigateToolUseBlock.id()).isEqualTo("id") + assertThat(browserNavigateToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserNavigateToolUseBlock.input()) + .isEqualTo(BrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserNavigateToolUseBlock = + BrowserNavigateToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .build() + + val roundtrippedBrowserNavigateToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserNavigateToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserNavigateToolUseBlock).isEqualTo(browserNavigateToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNewTabInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNewTabInputTest.kt new file mode 100644 index 000000000..202679bee --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNewTabInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserNewTabInputTest { + + @Test + fun create() { + val browserNewTabInput = BrowserNewTabInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserNewTabInput = BrowserNewTabInput.builder().build() + + val roundtrippedBrowserNewTabInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserNewTabInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserNewTabInput).isEqualTo(browserNewTabInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNewTabToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNewTabToolUseBlockTest.kt new file mode 100644 index 000000000..da8cdba07 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserNewTabToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserNewTabToolUseBlockTest { + + @Test + fun create() { + val browserNewTabToolUseBlock = + BrowserNewTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNewTabInput.builder().build()) + .build() + + assertThat(browserNewTabToolUseBlock.id()).isEqualTo("id") + assertThat(browserNewTabToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserNewTabToolUseBlock.input()) + .isEqualTo(BrowserNewTabInput.builder().build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserNewTabToolUseBlock = + BrowserNewTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNewTabInput.builder().build()) + .build() + + val roundtrippedBrowserNewTabToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserNewTabToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserNewTabToolUseBlock).isEqualTo(browserNewTabToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadConsoleInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadConsoleInputTest.kt new file mode 100644 index 000000000..4dfc9b2e4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadConsoleInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserReadConsoleInputTest { + + @Test + fun create() { + val browserReadConsoleInput = BrowserReadConsoleInput.builder().tabId("tab_id").build() + + assertThat(browserReadConsoleInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserReadConsoleInput = BrowserReadConsoleInput.builder().tabId("tab_id").build() + + val roundtrippedBrowserReadConsoleInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserReadConsoleInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserReadConsoleInput).isEqualTo(browserReadConsoleInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadConsoleToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadConsoleToolUseBlockTest.kt new file mode 100644 index 000000000..70468050f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadConsoleToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserReadConsoleToolUseBlockTest { + + @Test + fun create() { + val browserReadConsoleToolUseBlock = + BrowserReadConsoleToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadConsoleInput.builder().tabId("tab_id").build()) + .build() + + assertThat(browserReadConsoleToolUseBlock.id()).isEqualTo("id") + assertThat(browserReadConsoleToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserReadConsoleToolUseBlock.input()) + .isEqualTo(BrowserReadConsoleInput.builder().tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserReadConsoleToolUseBlock = + BrowserReadConsoleToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadConsoleInput.builder().tabId("tab_id").build()) + .build() + + val roundtrippedBrowserReadConsoleToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserReadConsoleToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserReadConsoleToolUseBlock) + .isEqualTo(browserReadConsoleToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadNetworkInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadNetworkInputTest.kt new file mode 100644 index 000000000..ce0cf87e4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadNetworkInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserReadNetworkInputTest { + + @Test + fun create() { + val browserReadNetworkInput = BrowserReadNetworkInput.builder().tabId("tab_id").build() + + assertThat(browserReadNetworkInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserReadNetworkInput = BrowserReadNetworkInput.builder().tabId("tab_id").build() + + val roundtrippedBrowserReadNetworkInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserReadNetworkInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserReadNetworkInput).isEqualTo(browserReadNetworkInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadNetworkToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadNetworkToolUseBlockTest.kt new file mode 100644 index 000000000..1fe49a471 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadNetworkToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserReadNetworkToolUseBlockTest { + + @Test + fun create() { + val browserReadNetworkToolUseBlock = + BrowserReadNetworkToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadNetworkInput.builder().tabId("tab_id").build()) + .build() + + assertThat(browserReadNetworkToolUseBlock.id()).isEqualTo("id") + assertThat(browserReadNetworkToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserReadNetworkToolUseBlock.input()) + .isEqualTo(BrowserReadNetworkInput.builder().tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserReadNetworkToolUseBlock = + BrowserReadNetworkToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadNetworkInput.builder().tabId("tab_id").build()) + .build() + + val roundtrippedBrowserReadNetworkToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserReadNetworkToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserReadNetworkToolUseBlock) + .isEqualTo(browserReadNetworkToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadPageInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadPageInputTest.kt new file mode 100644 index 000000000..23fb857c4 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadPageInputTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserReadPageInputTest { + + @Test + fun create() { + val browserReadPageInput = + BrowserReadPageInput.builder() + .depth(1L) + .filter(BrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + + assertThat(browserReadPageInput.depth()).contains(1L) + assertThat(browserReadPageInput.filter()).contains(BrowserReadPageFilter.ALL) + assertThat(browserReadPageInput.ref()).contains("ref") + assertThat(browserReadPageInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserReadPageInput = + BrowserReadPageInput.builder() + .depth(1L) + .filter(BrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + + val roundtrippedBrowserReadPageInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserReadPageInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserReadPageInput).isEqualTo(browserReadPageInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadPageToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadPageToolUseBlockTest.kt new file mode 100644 index 000000000..0f3152003 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserReadPageToolUseBlockTest.kt @@ -0,0 +1,65 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserReadPageToolUseBlockTest { + + @Test + fun create() { + val browserReadPageToolUseBlock = + BrowserReadPageToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserReadPageInput.builder() + .depth(1L) + .filter(BrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserReadPageToolUseBlock.id()).isEqualTo("id") + assertThat(browserReadPageToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserReadPageToolUseBlock.input()) + .isEqualTo( + BrowserReadPageInput.builder() + .depth(1L) + .filter(BrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserReadPageToolUseBlock = + BrowserReadPageToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserReadPageInput.builder() + .depth(1L) + .filter(BrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserReadPageToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserReadPageToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserReadPageToolUseBlock).isEqualTo(browserReadPageToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRefTargetTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRefTargetTest.kt new file mode 100644 index 000000000..b70d49307 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRefTargetTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserRefTargetTest { + + @Test + fun create() { + val browserRefTarget = BrowserRefTarget.of("ref") + + assertThat(browserRefTarget.ref()).isEqualTo("ref") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserRefTarget = BrowserRefTarget.of("ref") + + val roundtrippedBrowserRefTarget = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserRefTarget), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserRefTarget).isEqualTo(browserRefTarget) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRightClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRightClickInputTest.kt new file mode 100644 index 000000000..e229fd53c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRightClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserRightClickInputTest { + + @Test + fun create() { + val browserRightClickInput = + BrowserRightClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(browserRightClickInput.target()) + .isEqualTo( + BrowserClickTarget.ofCoordinate( + BrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(browserRightClickInput.modifiers()).contains("modifiers") + assertThat(browserRightClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserRightClickInput = + BrowserRightClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBrowserRightClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserRightClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserRightClickInput).isEqualTo(browserRightClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRightClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRightClickToolUseBlockTest.kt new file mode 100644 index 000000000..38b49fbea --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserRightClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserRightClickToolUseBlockTest { + + @Test + fun create() { + val browserRightClickToolUseBlock = + BrowserRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserRightClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserRightClickToolUseBlock.id()).isEqualTo("id") + assertThat(browserRightClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserRightClickToolUseBlock.input()) + .isEqualTo( + BrowserRightClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserRightClickToolUseBlock = + BrowserRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserRightClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserRightClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserRightClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserRightClickToolUseBlock) + .isEqualTo(browserRightClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScreenshotInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScreenshotInputTest.kt new file mode 100644 index 000000000..260694fe2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScreenshotInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserScreenshotInputTest { + + @Test + fun create() { + val browserScreenshotInput = BrowserScreenshotInput.builder().tabId("tab_id").build() + + assertThat(browserScreenshotInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserScreenshotInput = BrowserScreenshotInput.builder().tabId("tab_id").build() + + val roundtrippedBrowserScreenshotInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserScreenshotInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserScreenshotInput).isEqualTo(browserScreenshotInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScreenshotToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScreenshotToolUseBlockTest.kt new file mode 100644 index 000000000..8c69878f6 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScreenshotToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserScreenshotToolUseBlockTest { + + @Test + fun create() { + val browserScreenshotToolUseBlock = + BrowserScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserScreenshotInput.builder().tabId("tab_id").build()) + .build() + + assertThat(browserScreenshotToolUseBlock.id()).isEqualTo("id") + assertThat(browserScreenshotToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserScreenshotToolUseBlock.input()) + .isEqualTo(BrowserScreenshotInput.builder().tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserScreenshotToolUseBlock = + BrowserScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserScreenshotInput.builder().tabId("tab_id").build()) + .build() + + val roundtrippedBrowserScreenshotToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserScreenshotToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserScreenshotToolUseBlock) + .isEqualTo(browserScreenshotToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollInputTest.kt new file mode 100644 index 000000000..5b9c74ee5 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollInputTest.kt @@ -0,0 +1,46 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserScrollInputTest { + + @Test + fun create() { + val browserScrollInput = + BrowserScrollInput.builder() + .scrollDirection(BrowserScrollDirection.UP) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + + assertThat(browserScrollInput.scrollDirection()).isEqualTo(BrowserScrollDirection.UP) + assertThat(browserScrollInput.target()) + .isEqualTo(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + assertThat(browserScrollInput.scrollAmount()).contains(1L) + assertThat(browserScrollInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserScrollInput = + BrowserScrollInput.builder() + .scrollDirection(BrowserScrollDirection.UP) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + + val roundtrippedBrowserScrollInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserScrollInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserScrollInput).isEqualTo(browserScrollInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToInputTest.kt new file mode 100644 index 000000000..7ad71a6cb --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToInputTest.kt @@ -0,0 +1,39 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserScrollToInputTest { + + @Test + fun create() { + val browserScrollToInput = + BrowserScrollToInput.builder() + .target(BrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + + assertThat(browserScrollToInput.target()).isEqualTo(BrowserRefTarget.of("ref")) + assertThat(browserScrollToInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserScrollToInput = + BrowserScrollToInput.builder() + .target(BrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + + val roundtrippedBrowserScrollToInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserScrollToInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserScrollToInput).isEqualTo(browserScrollToInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToToolUseBlockTest.kt new file mode 100644 index 000000000..69ee9c453 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToToolUseBlockTest.kt @@ -0,0 +1,59 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserScrollToToolUseBlockTest { + + @Test + fun create() { + val browserScrollToToolUseBlock = + BrowserScrollToToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollToInput.builder() + .target(BrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserScrollToToolUseBlock.id()).isEqualTo("id") + assertThat(browserScrollToToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserScrollToToolUseBlock.input()) + .isEqualTo( + BrowserScrollToInput.builder() + .target(BrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserScrollToToolUseBlock = + BrowserScrollToToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollToInput.builder() + .target(BrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserScrollToToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserScrollToToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserScrollToToolUseBlock).isEqualTo(browserScrollToToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToolUseBlockTest.kt new file mode 100644 index 000000000..5e1370d04 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserScrollToolUseBlockTest.kt @@ -0,0 +1,65 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserScrollToolUseBlockTest { + + @Test + fun create() { + val browserScrollToolUseBlock = + BrowserScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollInput.builder() + .scrollDirection(BrowserScrollDirection.UP) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserScrollToolUseBlock.id()).isEqualTo("id") + assertThat(browserScrollToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserScrollToolUseBlock.input()) + .isEqualTo( + BrowserScrollInput.builder() + .scrollDirection(BrowserScrollDirection.UP) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserScrollToolUseBlock = + BrowserScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollInput.builder() + .scrollDirection(BrowserScrollDirection.UP) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserScrollToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserScrollToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserScrollToolUseBlock).isEqualTo(browserScrollToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserSwitchTabInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserSwitchTabInputTest.kt new file mode 100644 index 000000000..a86b8d95c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserSwitchTabInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserSwitchTabInputTest { + + @Test + fun create() { + val browserSwitchTabInput = BrowserSwitchTabInput.of("tab_id") + + assertThat(browserSwitchTabInput.tabId()).isEqualTo("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserSwitchTabInput = BrowserSwitchTabInput.of("tab_id") + + val roundtrippedBrowserSwitchTabInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserSwitchTabInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserSwitchTabInput).isEqualTo(browserSwitchTabInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserSwitchTabToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserSwitchTabToolUseBlockTest.kt new file mode 100644 index 000000000..f114a32c9 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserSwitchTabToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserSwitchTabToolUseBlockTest { + + @Test + fun create() { + val browserSwitchTabToolUseBlock = + BrowserSwitchTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserSwitchTabInput.of("tab_id")) + .build() + + assertThat(browserSwitchTabToolUseBlock.id()).isEqualTo("id") + assertThat(browserSwitchTabToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserSwitchTabToolUseBlock.input()) + .isEqualTo(BrowserSwitchTabInput.of("tab_id")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserSwitchTabToolUseBlock = + BrowserSwitchTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserSwitchTabInput.of("tab_id")) + .build() + + val roundtrippedBrowserSwitchTabToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserSwitchTabToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserSwitchTabToolUseBlock).isEqualTo(browserSwitchTabToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserToolUseBlockTest.kt new file mode 100644 index 000000000..3df81d69c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserToolUseBlockTest.kt @@ -0,0 +1,2280 @@ +package com.anthropic.models.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class BrowserToolUseBlockTest { + + @Test + fun ofNavigate() { + val navigate = + BrowserNavigateToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofNavigate(navigate) + + assertThat(browserToolUseBlock.navigate()).contains(navigate) + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofNavigateRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofNavigate( + BrowserNavigateToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofListTabs() { + val listTabs = + BrowserListTabsToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserListTabsInput.builder().build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofListTabs(listTabs) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).contains(listTabs) + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofListTabsRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofListTabs( + BrowserListTabsToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserListTabsInput.builder().build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofNewTab() { + val newTab = + BrowserNewTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNewTabInput.builder().build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofNewTab(newTab) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).contains(newTab) + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofNewTabRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofNewTab( + BrowserNewTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNewTabInput.builder().build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofSwitchTab() { + val switchTab = + BrowserSwitchTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserSwitchTabInput.of("tab_id")) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofSwitchTab(switchTab) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).contains(switchTab) + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofSwitchTabRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofSwitchTab( + BrowserSwitchTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserSwitchTabInput.of("tab_id")) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofCloseTab() { + val closeTab = + BrowserCloseTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserCloseTabInput.of("tab_id")) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofCloseTab(closeTab) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).contains(closeTab) + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofCloseTabRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofCloseTab( + BrowserCloseTabToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserCloseTabInput.of("tab_id")) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofReadPage() { + val readPage = + BrowserReadPageToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserReadPageInput.builder() + .depth(1L) + .filter(BrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofReadPage(readPage) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).contains(readPage) + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofReadPageRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofReadPage( + BrowserReadPageToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserReadPageInput.builder() + .depth(1L) + .filter(BrowserReadPageFilter.ALL) + .ref("ref") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofGetPageText() { + val getPageText = + BrowserGetPageTextToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserGetPageTextInput.builder().tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofGetPageText(getPageText) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).contains(getPageText) + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofGetPageTextRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofGetPageText( + BrowserGetPageTextToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserGetPageTextInput.builder().tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofReadConsole() { + val readConsole = + BrowserReadConsoleToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadConsoleInput.builder().tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofReadConsole(readConsole) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).contains(readConsole) + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofReadConsoleRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofReadConsole( + BrowserReadConsoleToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadConsoleInput.builder().tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofReadNetwork() { + val readNetwork = + BrowserReadNetworkToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadNetworkInput.builder().tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofReadNetwork(readNetwork) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).contains(readNetwork) + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofReadNetworkRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofReadNetwork( + BrowserReadNetworkToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserReadNetworkInput.builder().tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofFind() { + val find = + BrowserFindToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserFindInput.builder().query("query").tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofFind(find) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).contains(find) + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofFindRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofFind( + BrowserFindToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserFindInput.builder().query("query").tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofFormInput() { + val formInput = + BrowserFormInputToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFormInputInput.builder() + .target(BrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofFormInput(formInput) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).contains(formInput) + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofFormInputRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofFormInput( + BrowserFormInputToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFormInputInput.builder() + .target(BrowserRefTarget.of("ref")) + .value("string") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofFileUpload() { + val fileUpload = + BrowserFileUploadToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFileUploadInput.builder() + .target(BrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofFileUpload(fileUpload) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).contains(fileUpload) + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofFileUploadRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofFileUpload( + BrowserFileUploadToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserFileUploadInput.builder() + .target(BrowserRefTarget.of("ref")) + .addDocumentId("string") + .addPath("string") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofScrollTo() { + val scrollTo = + BrowserScrollToToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollToInput.builder() + .target(BrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofScrollTo(scrollTo) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).contains(scrollTo) + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofScrollToRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofScrollTo( + BrowserScrollToToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollToInput.builder() + .target(BrowserRefTarget.of("ref")) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofScreenshot() { + val screenshot = + BrowserScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserScreenshotInput.builder().tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofScreenshot(screenshot) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).contains(screenshot) + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofScreenshotRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofScreenshot( + BrowserScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserScreenshotInput.builder().tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofZoom() { + val zoom = + BrowserZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofZoom(zoom) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).contains(zoom) + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofZoomRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofZoom( + BrowserZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofLeftClick() { + val leftClick = + BrowserLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofLeftClick(leftClick) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).contains(leftClick) + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftClickRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofLeftClick( + BrowserLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofRightClick() { + val rightClick = + BrowserRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserRightClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofRightClick(rightClick) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).contains(rightClick) + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofRightClickRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofRightClick( + BrowserRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserRightClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofMiddleClick() { + val middleClick = + BrowserMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMiddleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofMiddleClick(middleClick) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).contains(middleClick) + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofMiddleClickRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofMiddleClick( + BrowserMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMiddleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofDoubleClick() { + val doubleClick = + BrowserDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserDoubleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofDoubleClick(doubleClick) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).contains(doubleClick) + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofDoubleClickRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofDoubleClick( + BrowserDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserDoubleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofTripleClick() { + val tripleClick = + BrowserTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserTripleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofTripleClick(tripleClick) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).contains(tripleClick) + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofTripleClickRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofTripleClick( + BrowserTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserTripleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofHover() { + val hover = + BrowserHoverToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoverInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofHover(hover) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).contains(hover) + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofHoverRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofHover( + BrowserHoverToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoverInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofLeftClickDrag() { + val leftClickDrag = + BrowserLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickDragInput.builder() + .from(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofLeftClickDrag(leftClickDrag) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).contains(leftClickDrag) + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftClickDragRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofLeftClickDrag( + BrowserLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftClickDragInput.builder() + .from(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofLeftMouseDown() { + val leftMouseDown = + BrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseDownInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofLeftMouseDown(leftMouseDown) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).contains(leftMouseDown) + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftMouseDownRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofLeftMouseDown( + BrowserLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseDownInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofLeftMouseUp() { + val leftMouseUp = + BrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseUpInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofLeftMouseUp(leftMouseUp) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).contains(leftMouseUp) + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofLeftMouseUpRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofLeftMouseUp( + BrowserLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserLeftMouseUpInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofMouseMove() { + val mouseMove = + BrowserMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMouseMoveInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofMouseMove(mouseMove) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).contains(mouseMove) + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofMouseMoveRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofMouseMove( + BrowserMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserMouseMoveInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofScroll() { + val scroll = + BrowserScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollInput.builder() + .scrollDirection(BrowserScrollDirection.UP) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofScroll(scroll) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).contains(scroll) + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofScrollRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofScroll( + BrowserScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserScrollInput.builder() + .scrollDirection(BrowserScrollDirection.UP) + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .scrollAmount(1L) + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofType() { + val type = + BrowserTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofType(type) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).contains(type) + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofTypeRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofType( + BrowserTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofKey() { + val key = + BrowserKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofKey(key) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).contains(key) + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofKeyRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofKey( + BrowserKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserKeyInput.builder().text("text").repeat(1L).tabId("tab_id").build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofHoldKey() { + val holdKey = + BrowserHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoldKeyInput.builder().duration(0.0).text("text").tabId("tab_id").build() + ) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofHoldKey(holdKey) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).contains(holdKey) + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofHoldKeyRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofHoldKey( + BrowserHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserHoldKeyInput.builder() + .duration(0.0) + .text("text") + .tabId("tab_id") + .build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofWait() { + val wait = + BrowserWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofWait(wait) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).contains(wait) + assertThat(browserToolUseBlock.javascriptExec()).isEmpty + } + + @Test + fun ofWaitRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofWait( + BrowserWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun ofJavascriptExec() { + val javascriptExec = + BrowserJavascriptExecToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build()) + .build() + + val browserToolUseBlock = BrowserToolUseBlock.ofJavascriptExec(javascriptExec) + + assertThat(browserToolUseBlock.navigate()).isEmpty + assertThat(browserToolUseBlock.listTabs()).isEmpty + assertThat(browserToolUseBlock.newTab()).isEmpty + assertThat(browserToolUseBlock.switchTab()).isEmpty + assertThat(browserToolUseBlock.closeTab()).isEmpty + assertThat(browserToolUseBlock.readPage()).isEmpty + assertThat(browserToolUseBlock.getPageText()).isEmpty + assertThat(browserToolUseBlock.readConsole()).isEmpty + assertThat(browserToolUseBlock.readNetwork()).isEmpty + assertThat(browserToolUseBlock.find()).isEmpty + assertThat(browserToolUseBlock.formInput()).isEmpty + assertThat(browserToolUseBlock.fileUpload()).isEmpty + assertThat(browserToolUseBlock.scrollTo()).isEmpty + assertThat(browserToolUseBlock.screenshot()).isEmpty + assertThat(browserToolUseBlock.zoom()).isEmpty + assertThat(browserToolUseBlock.leftClick()).isEmpty + assertThat(browserToolUseBlock.rightClick()).isEmpty + assertThat(browserToolUseBlock.middleClick()).isEmpty + assertThat(browserToolUseBlock.doubleClick()).isEmpty + assertThat(browserToolUseBlock.tripleClick()).isEmpty + assertThat(browserToolUseBlock.hover()).isEmpty + assertThat(browserToolUseBlock.leftClickDrag()).isEmpty + assertThat(browserToolUseBlock.leftMouseDown()).isEmpty + assertThat(browserToolUseBlock.leftMouseUp()).isEmpty + assertThat(browserToolUseBlock.mouseMove()).isEmpty + assertThat(browserToolUseBlock.scroll()).isEmpty + assertThat(browserToolUseBlock.type()).isEmpty + assertThat(browserToolUseBlock.key()).isEmpty + assertThat(browserToolUseBlock.holdKey()).isEmpty + assertThat(browserToolUseBlock.wait()).isEmpty + assertThat(browserToolUseBlock.javascriptExec()).contains(javascriptExec) + } + + @Test + fun ofJavascriptExecRoundtrip() { + val jsonMapper = jsonMapper() + val browserToolUseBlock = + BrowserToolUseBlock.ofJavascriptExec( + BrowserJavascriptExecToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserJavascriptExecInput.builder().text("text").tabId("tab_id").build() + ) + .build() + ) + + val roundtrippedBrowserToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserToolUseBlock).isEqualTo(browserToolUseBlock) + } + + @Test + fun unknownVariantCommonProperties() { + val browserToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf( + "name" to "unknown_variant", + "id" to "id", + "caller" to mapOf("type" to "direct"), + ) + ), + jacksonTypeRef(), + ) + + val e = assertThrows { browserToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(browserToolUseBlock.id()).isEqualTo("id") + assertThat(browserToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + + val mismatchedBrowserToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from(mapOf("name" to "unknown_variant", "id" to listOf("invalid"))), + jacksonTypeRef(), + ) + + assertThrows { mismatchedBrowserToolUseBlock.id() } + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val browserToolUseBlock = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { browserToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThrows { browserToolUseBlock.id() } + assertThrows { browserToolUseBlock.caller() } + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTripleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTripleClickInputTest.kt new file mode 100644 index 000000000..bfc58f92c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTripleClickInputTest.kt @@ -0,0 +1,47 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserTripleClickInputTest { + + @Test + fun create() { + val browserTripleClickInput = + BrowserTripleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + assertThat(browserTripleClickInput.target()) + .isEqualTo( + BrowserClickTarget.ofCoordinate( + BrowserCoordinateTarget.builder().x(0L).y(0L).build() + ) + ) + assertThat(browserTripleClickInput.modifiers()).contains("modifiers") + assertThat(browserTripleClickInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserTripleClickInput = + BrowserTripleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + + val roundtrippedBrowserTripleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserTripleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserTripleClickInput).isEqualTo(browserTripleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTripleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTripleClickToolUseBlockTest.kt new file mode 100644 index 000000000..a30bba44f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTripleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserTripleClickToolUseBlockTest { + + @Test + fun create() { + val browserTripleClickToolUseBlock = + BrowserTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserTripleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserTripleClickToolUseBlock.id()).isEqualTo("id") + assertThat(browserTripleClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserTripleClickToolUseBlock.input()) + .isEqualTo( + BrowserTripleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserTripleClickToolUseBlock = + BrowserTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserTripleClickInput.builder() + .target(BrowserCoordinateTarget.builder().x(0L).y(0L).build()) + .modifiers("modifiers") + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserTripleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserTripleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserTripleClickToolUseBlock) + .isEqualTo(browserTripleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTypeInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTypeInputTest.kt new file mode 100644 index 000000000..8c1b63c6b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTypeInputTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserTypeInputTest { + + @Test + fun create() { + val browserTypeInput = BrowserTypeInput.builder().text("text").tabId("tab_id").build() + + assertThat(browserTypeInput.text()).isEqualTo("text") + assertThat(browserTypeInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserTypeInput = BrowserTypeInput.builder().text("text").tabId("tab_id").build() + + val roundtrippedBrowserTypeInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserTypeInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserTypeInput).isEqualTo(browserTypeInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTypeToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTypeToolUseBlockTest.kt new file mode 100644 index 000000000..262c5fd6a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserTypeToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserTypeToolUseBlockTest { + + @Test + fun create() { + val browserTypeToolUseBlock = + BrowserTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .build() + + assertThat(browserTypeToolUseBlock.id()).isEqualTo("id") + assertThat(browserTypeToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserTypeToolUseBlock.input()) + .isEqualTo(BrowserTypeInput.builder().text("text").tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserTypeToolUseBlock = + BrowserTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserTypeInput.builder().text("text").tabId("tab_id").build()) + .build() + + val roundtrippedBrowserTypeToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserTypeToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserTypeToolUseBlock).isEqualTo(browserTypeToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserWaitInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserWaitInputTest.kt new file mode 100644 index 000000000..1cf297283 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserWaitInputTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserWaitInputTest { + + @Test + fun create() { + val browserWaitInput = BrowserWaitInput.builder().duration(0.0).tabId("tab_id").build() + + assertThat(browserWaitInput.duration()).isEqualTo(0.0) + assertThat(browserWaitInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserWaitInput = BrowserWaitInput.builder().duration(0.0).tabId("tab_id").build() + + val roundtrippedBrowserWaitInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserWaitInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserWaitInput).isEqualTo(browserWaitInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserWaitToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserWaitToolUseBlockTest.kt new file mode 100644 index 000000000..9007f975f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserWaitToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserWaitToolUseBlockTest { + + @Test + fun create() { + val browserWaitToolUseBlock = + BrowserWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .build() + + assertThat(browserWaitToolUseBlock.id()).isEqualTo("id") + assertThat(browserWaitToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserWaitToolUseBlock.input()) + .isEqualTo(BrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserWaitToolUseBlock = + BrowserWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserWaitInput.builder().duration(0.0).tabId("tab_id").build()) + .build() + + val roundtrippedBrowserWaitToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserWaitToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserWaitToolUseBlock).isEqualTo(browserWaitToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserZoomInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserZoomInputTest.kt new file mode 100644 index 000000000..beaf5b960 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserZoomInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserZoomInputTest { + + @Test + fun create() { + val browserZoomInput = + BrowserZoomInput.builder().region(listOf(0L, 0L, 0L, 0L)).tabId("tab_id").build() + + assertThat(browserZoomInput.region()).containsExactly(0L, 0L, 0L, 0L) + assertThat(browserZoomInput.tabId()).contains("tab_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserZoomInput = + BrowserZoomInput.builder().region(listOf(0L, 0L, 0L, 0L)).tabId("tab_id").build() + + val roundtrippedBrowserZoomInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserZoomInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserZoomInput).isEqualTo(browserZoomInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserZoomToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserZoomToolUseBlockTest.kt new file mode 100644 index 000000000..8faf71376 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/BrowserZoomToolUseBlockTest.kt @@ -0,0 +1,56 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BrowserZoomToolUseBlockTest { + + @Test + fun create() { + val browserZoomToolUseBlock = + BrowserZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .build() + + assertThat(browserZoomToolUseBlock.id()).isEqualTo("id") + assertThat(browserZoomToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(browserZoomToolUseBlock.input()) + .isEqualTo( + BrowserZoomInput.builder().region(listOf(0L, 0L, 0L, 0L)).tabId("tab_id").build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val browserZoomToolUseBlock = + BrowserZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + BrowserZoomInput.builder() + .region(listOf(0L, 0L, 0L, 0L)) + .tabId("tab_id") + .build() + ) + .build() + + val roundtrippedBrowserZoomToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(browserZoomToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBrowserZoomToolUseBlock).isEqualTo(browserZoomToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerCursorPositionInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerCursorPositionInputTest.kt new file mode 100644 index 000000000..0521537c7 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerCursorPositionInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerCursorPositionInputTest { + + @Test + fun create() { + val computerCursorPositionInput = ComputerCursorPositionInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerCursorPositionInput = ComputerCursorPositionInput.builder().build() + + val roundtrippedComputerCursorPositionInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerCursorPositionInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerCursorPositionInput).isEqualTo(computerCursorPositionInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerCursorPositionToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerCursorPositionToolUseBlockTest.kt new file mode 100644 index 000000000..e648c11a2 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerCursorPositionToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerCursorPositionToolUseBlockTest { + + @Test + fun create() { + val computerCursorPositionToolUseBlock = + ComputerCursorPositionToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerCursorPositionInput.builder().build()) + .build() + + assertThat(computerCursorPositionToolUseBlock.id()).isEqualTo("id") + assertThat(computerCursorPositionToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerCursorPositionToolUseBlock.input()) + .isEqualTo(ComputerCursorPositionInput.builder().build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerCursorPositionToolUseBlock = + ComputerCursorPositionToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerCursorPositionInput.builder().build()) + .build() + + val roundtrippedComputerCursorPositionToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerCursorPositionToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerCursorPositionToolUseBlock) + .isEqualTo(computerCursorPositionToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerDoubleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerDoubleClickInputTest.kt new file mode 100644 index 000000000..98fd7a12d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerDoubleClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerDoubleClickInputTest { + + @Test + fun create() { + val computerDoubleClickInput = + ComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(computerDoubleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(computerDoubleClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseComputerDoubleClickInput = ComputerDoubleClickInput.builder().build() + + val computerDoubleClickInput = + baseComputerDoubleClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(computerDoubleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerDoubleClickInput = + ComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedComputerDoubleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerDoubleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerDoubleClickInput).isEqualTo(computerDoubleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerDoubleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerDoubleClickToolUseBlockTest.kt new file mode 100644 index 000000000..f395de395 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerDoubleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerDoubleClickToolUseBlockTest { + + @Test + fun create() { + val computerDoubleClickToolUseBlock = + ComputerDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + assertThat(computerDoubleClickToolUseBlock.id()).isEqualTo("id") + assertThat(computerDoubleClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerDoubleClickToolUseBlock.input()) + .isEqualTo( + ComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerDoubleClickToolUseBlock = + ComputerDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val roundtrippedComputerDoubleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerDoubleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerDoubleClickToolUseBlock) + .isEqualTo(computerDoubleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerHoldKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerHoldKeyInputTest.kt new file mode 100644 index 000000000..be49425c8 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerHoldKeyInputTest.kt @@ -0,0 +1,33 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerHoldKeyInputTest { + + @Test + fun create() { + val computerHoldKeyInput = + ComputerHoldKeyInput.builder().duration(300L).text("text").build() + + assertThat(computerHoldKeyInput.duration()).isEqualTo(300L) + assertThat(computerHoldKeyInput.text()).isEqualTo("text") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerHoldKeyInput = + ComputerHoldKeyInput.builder().duration(300L).text("text").build() + + val roundtrippedComputerHoldKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerHoldKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerHoldKeyInput).isEqualTo(computerHoldKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerHoldKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerHoldKeyToolUseBlockTest.kt new file mode 100644 index 000000000..b2b4b47a3 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerHoldKeyToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerHoldKeyToolUseBlockTest { + + @Test + fun create() { + val computerHoldKeyToolUseBlock = + ComputerHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .build() + + assertThat(computerHoldKeyToolUseBlock.id()).isEqualTo("id") + assertThat(computerHoldKeyToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerHoldKeyToolUseBlock.input()) + .isEqualTo(ComputerHoldKeyInput.builder().duration(300L).text("text").build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerHoldKeyToolUseBlock = + ComputerHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .build() + + val roundtrippedComputerHoldKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerHoldKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerHoldKeyToolUseBlock).isEqualTo(computerHoldKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerKeyInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerKeyInputTest.kt new file mode 100644 index 000000000..5e5c0570b --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerKeyInputTest.kt @@ -0,0 +1,31 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerKeyInputTest { + + @Test + fun create() { + val computerKeyInput = ComputerKeyInput.builder().text("text").repeat(1L).build() + + assertThat(computerKeyInput.text()).isEqualTo("text") + assertThat(computerKeyInput.repeat()).contains(1L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerKeyInput = ComputerKeyInput.builder().text("text").repeat(1L).build() + + val roundtrippedComputerKeyInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerKeyInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerKeyInput).isEqualTo(computerKeyInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerKeyToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerKeyToolUseBlockTest.kt new file mode 100644 index 000000000..07c3ee9bc --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerKeyToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerKeyToolUseBlockTest { + + @Test + fun create() { + val computerKeyToolUseBlock = + ComputerKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerKeyInput.builder().text("text").repeat(1L).build()) + .build() + + assertThat(computerKeyToolUseBlock.id()).isEqualTo("id") + assertThat(computerKeyToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerKeyToolUseBlock.input()) + .isEqualTo(ComputerKeyInput.builder().text("text").repeat(1L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerKeyToolUseBlock = + ComputerKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerKeyInput.builder().text("text").repeat(1L).build()) + .build() + + val roundtrippedComputerKeyToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerKeyToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerKeyToolUseBlock).isEqualTo(computerKeyToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickDragInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickDragInputTest.kt new file mode 100644 index 000000000..f68e19e05 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickDragInputTest.kt @@ -0,0 +1,46 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftClickDragInputTest { + + @Test + fun create() { + val computerLeftClickDragInput = + ComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + + assertThat(computerLeftClickDragInput.coordinate()).containsExactly(0L, 0L) + assertThat(computerLeftClickDragInput.startCoordinate()).containsExactly(0L, 0L) + assertThat(computerLeftClickDragInput.text()).contains("text") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftClickDragInput = + ComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + + val roundtrippedComputerLeftClickDragInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftClickDragInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftClickDragInput).isEqualTo(computerLeftClickDragInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickDragToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickDragToolUseBlockTest.kt new file mode 100644 index 000000000..351c94f68 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickDragToolUseBlockTest.kt @@ -0,0 +1,69 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftClickDragToolUseBlockTest { + + @Test + fun create() { + val computerLeftClickDragToolUseBlock = + ComputerLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .build() + + assertThat(computerLeftClickDragToolUseBlock.id()).isEqualTo("id") + assertThat(computerLeftClickDragToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerLeftClickDragToolUseBlock.input()) + .isEqualTo( + ComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftClickDragToolUseBlock = + ComputerLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .build() + + val roundtrippedComputerLeftClickDragToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftClickDragToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftClickDragToolUseBlock) + .isEqualTo(computerLeftClickDragToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickInputTest.kt new file mode 100644 index 000000000..1c4339e6e --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftClickInputTest { + + @Test + fun create() { + val computerLeftClickInput = + ComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(computerLeftClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(computerLeftClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseComputerLeftClickInput = ComputerLeftClickInput.builder().build() + + val computerLeftClickInput = + baseComputerLeftClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(computerLeftClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftClickInput = + ComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedComputerLeftClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftClickInput).isEqualTo(computerLeftClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickToolUseBlockTest.kt new file mode 100644 index 000000000..53b1e28b7 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftClickToolUseBlockTest { + + @Test + fun create() { + val computerLeftClickToolUseBlock = + ComputerLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + assertThat(computerLeftClickToolUseBlock.id()).isEqualTo("id") + assertThat(computerLeftClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerLeftClickToolUseBlock.input()) + .isEqualTo( + ComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftClickToolUseBlock = + ComputerLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val roundtrippedComputerLeftClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftClickToolUseBlock) + .isEqualTo(computerLeftClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownInputTest.kt new file mode 100644 index 000000000..d30ab515a --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftMouseDownInputTest { + + @Test + fun create() { + val computerLeftMouseDownInput = ComputerLeftMouseDownInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftMouseDownInput = ComputerLeftMouseDownInput.builder().build() + + val roundtrippedComputerLeftMouseDownInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftMouseDownInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftMouseDownInput).isEqualTo(computerLeftMouseDownInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownToolUseBlockTest.kt new file mode 100644 index 000000000..068464a53 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseDownToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftMouseDownToolUseBlockTest { + + @Test + fun create() { + val computerLeftMouseDownToolUseBlock = + ComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseDownInput.builder().build()) + .build() + + assertThat(computerLeftMouseDownToolUseBlock.id()).isEqualTo("id") + assertThat(computerLeftMouseDownToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerLeftMouseDownToolUseBlock.input()) + .isEqualTo(ComputerLeftMouseDownInput.builder().build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftMouseDownToolUseBlock = + ComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseDownInput.builder().build()) + .build() + + val roundtrippedComputerLeftMouseDownToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftMouseDownToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftMouseDownToolUseBlock) + .isEqualTo(computerLeftMouseDownToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpInputTest.kt new file mode 100644 index 000000000..aafc0120d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftMouseUpInputTest { + + @Test + fun create() { + val computerLeftMouseUpInput = ComputerLeftMouseUpInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftMouseUpInput = ComputerLeftMouseUpInput.builder().build() + + val roundtrippedComputerLeftMouseUpInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftMouseUpInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftMouseUpInput).isEqualTo(computerLeftMouseUpInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpToolUseBlockTest.kt new file mode 100644 index 000000000..85721938c --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerLeftMouseUpToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerLeftMouseUpToolUseBlockTest { + + @Test + fun create() { + val computerLeftMouseUpToolUseBlock = + ComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseUpInput.builder().build()) + .build() + + assertThat(computerLeftMouseUpToolUseBlock.id()).isEqualTo("id") + assertThat(computerLeftMouseUpToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerLeftMouseUpToolUseBlock.input()) + .isEqualTo(ComputerLeftMouseUpInput.builder().build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerLeftMouseUpToolUseBlock = + ComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseUpInput.builder().build()) + .build() + + val roundtrippedComputerLeftMouseUpToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerLeftMouseUpToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerLeftMouseUpToolUseBlock) + .isEqualTo(computerLeftMouseUpToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMiddleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMiddleClickInputTest.kt new file mode 100644 index 000000000..7ea0dbd53 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMiddleClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerMiddleClickInputTest { + + @Test + fun create() { + val computerMiddleClickInput = + ComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(computerMiddleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(computerMiddleClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseComputerMiddleClickInput = ComputerMiddleClickInput.builder().build() + + val computerMiddleClickInput = + baseComputerMiddleClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(computerMiddleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerMiddleClickInput = + ComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedComputerMiddleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerMiddleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerMiddleClickInput).isEqualTo(computerMiddleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMiddleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMiddleClickToolUseBlockTest.kt new file mode 100644 index 000000000..6ca5c706f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMiddleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerMiddleClickToolUseBlockTest { + + @Test + fun create() { + val computerMiddleClickToolUseBlock = + ComputerMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + assertThat(computerMiddleClickToolUseBlock.id()).isEqualTo("id") + assertThat(computerMiddleClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerMiddleClickToolUseBlock.input()) + .isEqualTo( + ComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerMiddleClickToolUseBlock = + ComputerMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val roundtrippedComputerMiddleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerMiddleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerMiddleClickToolUseBlock) + .isEqualTo(computerMiddleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMouseMoveInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMouseMoveInputTest.kt new file mode 100644 index 000000000..c8114fe14 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMouseMoveInputTest.kt @@ -0,0 +1,32 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerMouseMoveInputTest { + + @Test + fun create() { + val computerMouseMoveInput = + ComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(computerMouseMoveInput.coordinate()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerMouseMoveInput = + ComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + + val roundtrippedComputerMouseMoveInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerMouseMoveInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerMouseMoveInput).isEqualTo(computerMouseMoveInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMouseMoveToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMouseMoveToolUseBlockTest.kt new file mode 100644 index 000000000..fdbf0ca67 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerMouseMoveToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerMouseMoveToolUseBlockTest { + + @Test + fun create() { + val computerMouseMoveToolUseBlock = + ComputerMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build()) + .build() + + assertThat(computerMouseMoveToolUseBlock.id()).isEqualTo("id") + assertThat(computerMouseMoveToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerMouseMoveToolUseBlock.input()) + .isEqualTo(ComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerMouseMoveToolUseBlock = + ComputerMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build()) + .build() + + val roundtrippedComputerMouseMoveToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerMouseMoveToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerMouseMoveToolUseBlock) + .isEqualTo(computerMouseMoveToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerRightClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerRightClickInputTest.kt new file mode 100644 index 000000000..77d2fe1e9 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerRightClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerRightClickInputTest { + + @Test + fun create() { + val computerRightClickInput = + ComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(computerRightClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(computerRightClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseComputerRightClickInput = ComputerRightClickInput.builder().build() + + val computerRightClickInput = + baseComputerRightClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(computerRightClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerRightClickInput = + ComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedComputerRightClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerRightClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerRightClickInput).isEqualTo(computerRightClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerRightClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerRightClickToolUseBlockTest.kt new file mode 100644 index 000000000..bb0eb5fcd --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerRightClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerRightClickToolUseBlockTest { + + @Test + fun create() { + val computerRightClickToolUseBlock = + ComputerRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + assertThat(computerRightClickToolUseBlock.id()).isEqualTo("id") + assertThat(computerRightClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerRightClickToolUseBlock.input()) + .isEqualTo( + ComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerRightClickToolUseBlock = + ComputerRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val roundtrippedComputerRightClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerRightClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerRightClickToolUseBlock) + .isEqualTo(computerRightClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScreenshotInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScreenshotInputTest.kt new file mode 100644 index 000000000..05db4db77 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScreenshotInputTest.kt @@ -0,0 +1,28 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerScreenshotInputTest { + + @Test + fun create() { + val computerScreenshotInput = ComputerScreenshotInput.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerScreenshotInput = ComputerScreenshotInput.builder().build() + + val roundtrippedComputerScreenshotInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerScreenshotInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerScreenshotInput).isEqualTo(computerScreenshotInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScreenshotToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScreenshotToolUseBlockTest.kt new file mode 100644 index 000000000..032ef64ea --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScreenshotToolUseBlockTest.kt @@ -0,0 +1,45 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerScreenshotToolUseBlockTest { + + @Test + fun create() { + val computerScreenshotToolUseBlock = + ComputerScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerScreenshotInput.builder().build()) + .build() + + assertThat(computerScreenshotToolUseBlock.id()).isEqualTo("id") + assertThat(computerScreenshotToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerScreenshotToolUseBlock.input()) + .isEqualTo(ComputerScreenshotInput.builder().build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerScreenshotToolUseBlock = + ComputerScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerScreenshotInput.builder().build()) + .build() + + val roundtrippedComputerScreenshotToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerScreenshotToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerScreenshotToolUseBlock) + .isEqualTo(computerScreenshotToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScrollInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScrollInputTest.kt new file mode 100644 index 000000000..804fd0cc9 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScrollInputTest.kt @@ -0,0 +1,62 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerScrollInputTest { + + @Test + fun create() { + val computerScrollInput = + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(computerScrollInput.scrollAmount()).isEqualTo(0L) + assertThat(computerScrollInput.scrollDirection()).isEqualTo(ComputerScrollDirection.UP) + assertThat(computerScrollInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(computerScrollInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseComputerScrollInput = + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .build() + + val computerScrollInput = + baseComputerScrollInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(computerScrollInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerScrollInput = + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedComputerScrollInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerScrollInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerScrollInput).isEqualTo(computerScrollInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScrollToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScrollToolUseBlockTest.kt new file mode 100644 index 000000000..c0fadfcdd --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerScrollToolUseBlockTest.kt @@ -0,0 +1,68 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerScrollToolUseBlockTest { + + @Test + fun create() { + val computerScrollToolUseBlock = + ComputerScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + assertThat(computerScrollToolUseBlock.id()).isEqualTo("id") + assertThat(computerScrollToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerScrollToolUseBlock.input()) + .isEqualTo( + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerScrollToolUseBlock = + ComputerScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val roundtrippedComputerScrollToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerScrollToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerScrollToolUseBlock).isEqualTo(computerScrollToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerToolUseBlockTest.kt new file mode 100644 index 000000000..ffb9eb05d --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerToolUseBlockTest.kt @@ -0,0 +1,1028 @@ +package com.anthropic.models.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ComputerToolUseBlockTest { + + @Test + fun ofKey() { + val key = + ComputerKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerKeyInput.builder().text("text").repeat(1L).build()) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofKey(key) + + assertThat(computerToolUseBlock.key()).contains(key) + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofKeyRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofKey( + ComputerKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerKeyInput.builder().text("text").repeat(1L).build()) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofHoldKey() { + val holdKey = + ComputerHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofHoldKey(holdKey) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).contains(holdKey) + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofHoldKeyRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofHoldKey( + ComputerHoldKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerHoldKeyInput.builder().duration(300L).text("text").build()) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofType() { + val type = + ComputerTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerTypeInput.of("text")) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofType(type) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).contains(type) + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofTypeRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofType( + ComputerTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerTypeInput.of("text")) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofCursorPosition() { + val cursorPosition = + ComputerCursorPositionToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerCursorPositionInput.builder().build()) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofCursorPosition(cursorPosition) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).contains(cursorPosition) + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofCursorPositionRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofCursorPosition( + ComputerCursorPositionToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerCursorPositionInput.builder().build()) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofMouseMove() { + val mouseMove = + ComputerMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build()) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofMouseMove(mouseMove) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).contains(mouseMove) + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofMouseMoveRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofMouseMove( + ComputerMouseMoveToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerMouseMoveInput.builder().addCoordinate(0L).addCoordinate(0L).build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofLeftMouseDown() { + val leftMouseDown = + ComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseDownInput.builder().build()) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofLeftMouseDown(leftMouseDown) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).contains(leftMouseDown) + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftMouseDownRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofLeftMouseDown( + ComputerLeftMouseDownToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseDownInput.builder().build()) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofLeftMouseUp() { + val leftMouseUp = + ComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseUpInput.builder().build()) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofLeftMouseUp(leftMouseUp) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).contains(leftMouseUp) + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftMouseUpRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofLeftMouseUp( + ComputerLeftMouseUpToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerLeftMouseUpInput.builder().build()) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofLeftClick() { + val leftClick = + ComputerLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofLeftClick(leftClick) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).contains(leftClick) + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftClickRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofLeftClick( + ComputerLeftClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofLeftClickDrag() { + val leftClickDrag = + ComputerLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofLeftClickDrag(leftClickDrag) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).contains(leftClickDrag) + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofLeftClickDragRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofLeftClickDrag( + ComputerLeftClickDragToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerLeftClickDragInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .addStartCoordinate(0L) + .addStartCoordinate(0L) + .text("text") + .build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofRightClick() { + val rightClick = + ComputerRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofRightClick(rightClick) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).contains(rightClick) + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofRightClickRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofRightClick( + ComputerRightClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerRightClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofMiddleClick() { + val middleClick = + ComputerMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofMiddleClick(middleClick) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).contains(middleClick) + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofMiddleClickRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofMiddleClick( + ComputerMiddleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerMiddleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofDoubleClick() { + val doubleClick = + ComputerDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofDoubleClick(doubleClick) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).contains(doubleClick) + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofDoubleClickRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofDoubleClick( + ComputerDoubleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerDoubleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofTripleClick() { + val tripleClick = + ComputerTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofTripleClick(tripleClick) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).contains(tripleClick) + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofTripleClickRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofTripleClick( + ComputerTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofScroll() { + val scroll = + ComputerScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofScroll(scroll) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).contains(scroll) + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofScrollRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofScroll( + ComputerScrollToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerScrollInput.builder() + .scrollAmount(0L) + .scrollDirection(ComputerScrollDirection.UP) + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofWait() { + val wait = + ComputerWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerWaitInput.of(300L)) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofWait(wait) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).contains(wait) + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofWaitRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofWait( + ComputerWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerWaitInput.of(300L)) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofScreenshot() { + val screenshot = + ComputerScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerScreenshotInput.builder().build()) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofScreenshot(screenshot) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).contains(screenshot) + assertThat(computerToolUseBlock.zoom()).isEmpty + } + + @Test + fun ofScreenshotRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofScreenshot( + ComputerScreenshotToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerScreenshotInput.builder().build()) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun ofZoom() { + val zoom = + ComputerZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .build() + + val computerToolUseBlock = ComputerToolUseBlock.ofZoom(zoom) + + assertThat(computerToolUseBlock.key()).isEmpty + assertThat(computerToolUseBlock.holdKey()).isEmpty + assertThat(computerToolUseBlock.type()).isEmpty + assertThat(computerToolUseBlock.cursorPosition()).isEmpty + assertThat(computerToolUseBlock.mouseMove()).isEmpty + assertThat(computerToolUseBlock.leftMouseDown()).isEmpty + assertThat(computerToolUseBlock.leftMouseUp()).isEmpty + assertThat(computerToolUseBlock.leftClick()).isEmpty + assertThat(computerToolUseBlock.leftClickDrag()).isEmpty + assertThat(computerToolUseBlock.rightClick()).isEmpty + assertThat(computerToolUseBlock.middleClick()).isEmpty + assertThat(computerToolUseBlock.doubleClick()).isEmpty + assertThat(computerToolUseBlock.tripleClick()).isEmpty + assertThat(computerToolUseBlock.scroll()).isEmpty + assertThat(computerToolUseBlock.wait()).isEmpty + assertThat(computerToolUseBlock.screenshot()).isEmpty + assertThat(computerToolUseBlock.zoom()).contains(zoom) + } + + @Test + fun ofZoomRoundtrip() { + val jsonMapper = jsonMapper() + val computerToolUseBlock = + ComputerToolUseBlock.ofZoom( + ComputerZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .build() + ) + + val roundtrippedComputerToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerToolUseBlock).isEqualTo(computerToolUseBlock) + } + + @Test + fun unknownVariantCommonProperties() { + val computerToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf( + "name" to "unknown_variant", + "id" to "id", + "caller" to mapOf("type" to "direct"), + ) + ), + jacksonTypeRef(), + ) + + val e = assertThrows { computerToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(computerToolUseBlock.id()).isEqualTo("id") + assertThat(computerToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + + val mismatchedComputerToolUseBlock = + jsonMapper() + .convertValue( + JsonValue.from(mapOf("name" to "unknown_variant", "id" to listOf("invalid"))), + jacksonTypeRef(), + ) + + assertThrows { mismatchedComputerToolUseBlock.id() } + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val computerToolUseBlock = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { computerToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThrows { computerToolUseBlock.id() } + assertThrows { computerToolUseBlock.caller() } + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTripleClickInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTripleClickInputTest.kt new file mode 100644 index 000000000..37ee40f74 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTripleClickInputTest.kt @@ -0,0 +1,52 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerTripleClickInputTest { + + @Test + fun create() { + val computerTripleClickInput = + ComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + assertThat(computerTripleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + assertThat(computerTripleClickInput.text()).contains("text") + } + + @Test + fun addToUnsetListsOnToBuilder() { + val baseComputerTripleClickInput = ComputerTripleClickInput.builder().build() + + val computerTripleClickInput = + baseComputerTripleClickInput.toBuilder().addCoordinate(0L).addCoordinate(0L).build() + + assertThat(computerTripleClickInput.coordinate().getOrNull()).containsExactly(0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerTripleClickInput = + ComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + + val roundtrippedComputerTripleClickInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerTripleClickInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerTripleClickInput).isEqualTo(computerTripleClickInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTripleClickToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTripleClickToolUseBlockTest.kt new file mode 100644 index 000000000..e05074726 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTripleClickToolUseBlockTest.kt @@ -0,0 +1,63 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerTripleClickToolUseBlockTest { + + @Test + fun create() { + val computerTripleClickToolUseBlock = + ComputerTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + assertThat(computerTripleClickToolUseBlock.id()).isEqualTo("id") + assertThat(computerTripleClickToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerTripleClickToolUseBlock.input()) + .isEqualTo( + ComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerTripleClickToolUseBlock = + ComputerTripleClickToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input( + ComputerTripleClickInput.builder() + .addCoordinate(0L) + .addCoordinate(0L) + .text("text") + .build() + ) + .build() + + val roundtrippedComputerTripleClickToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerTripleClickToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerTripleClickToolUseBlock) + .isEqualTo(computerTripleClickToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTypeInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTypeInputTest.kt new file mode 100644 index 000000000..c59462d12 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTypeInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerTypeInputTest { + + @Test + fun create() { + val computerTypeInput = ComputerTypeInput.of("text") + + assertThat(computerTypeInput.text()).isEqualTo("text") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerTypeInput = ComputerTypeInput.of("text") + + val roundtrippedComputerTypeInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerTypeInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerTypeInput).isEqualTo(computerTypeInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTypeToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTypeToolUseBlockTest.kt new file mode 100644 index 000000000..a72481a24 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerTypeToolUseBlockTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerTypeToolUseBlockTest { + + @Test + fun create() { + val computerTypeToolUseBlock = + ComputerTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerTypeInput.of("text")) + .build() + + assertThat(computerTypeToolUseBlock.id()).isEqualTo("id") + assertThat(computerTypeToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerTypeToolUseBlock.input()).isEqualTo(ComputerTypeInput.of("text")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerTypeToolUseBlock = + ComputerTypeToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerTypeInput.of("text")) + .build() + + val roundtrippedComputerTypeToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerTypeToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerTypeToolUseBlock).isEqualTo(computerTypeToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerWaitInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerWaitInputTest.kt new file mode 100644 index 000000000..249a4a862 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerWaitInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerWaitInputTest { + + @Test + fun create() { + val computerWaitInput = ComputerWaitInput.of(300L) + + assertThat(computerWaitInput.duration()).isEqualTo(300L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerWaitInput = ComputerWaitInput.of(300L) + + val roundtrippedComputerWaitInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerWaitInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerWaitInput).isEqualTo(computerWaitInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerWaitToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerWaitToolUseBlockTest.kt new file mode 100644 index 000000000..1d2ed65d0 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerWaitToolUseBlockTest.kt @@ -0,0 +1,43 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerWaitToolUseBlockTest { + + @Test + fun create() { + val computerWaitToolUseBlock = + ComputerWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerWaitInput.of(300L)) + .build() + + assertThat(computerWaitToolUseBlock.id()).isEqualTo("id") + assertThat(computerWaitToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerWaitToolUseBlock.input()).isEqualTo(ComputerWaitInput.of(300L)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerWaitToolUseBlock = + ComputerWaitToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerWaitInput.of(300L)) + .build() + + val roundtrippedComputerWaitToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerWaitToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerWaitToolUseBlock).isEqualTo(computerWaitToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerZoomInputTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerZoomInputTest.kt new file mode 100644 index 000000000..6768278c6 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerZoomInputTest.kt @@ -0,0 +1,30 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerZoomInputTest { + + @Test + fun create() { + val computerZoomInput = ComputerZoomInput.of(listOf(0L, 0L, 0L, 0L)) + + assertThat(computerZoomInput.region()).containsExactly(0L, 0L, 0L, 0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerZoomInput = ComputerZoomInput.of(listOf(0L, 0L, 0L, 0L)) + + val roundtrippedComputerZoomInput = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerZoomInput), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerZoomInput).isEqualTo(computerZoomInput) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerZoomToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerZoomToolUseBlockTest.kt new file mode 100644 index 000000000..c577b3927 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ComputerZoomToolUseBlockTest.kt @@ -0,0 +1,44 @@ +package com.anthropic.models.messages + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ComputerZoomToolUseBlockTest { + + @Test + fun create() { + val computerZoomToolUseBlock = + ComputerZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .build() + + assertThat(computerZoomToolUseBlock.id()).isEqualTo("id") + assertThat(computerZoomToolUseBlock.caller()) + .isEqualTo(ToolUseCaller.ofDirect(DirectCaller.builder().build())) + assertThat(computerZoomToolUseBlock.input()) + .isEqualTo(ComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val computerZoomToolUseBlock = + ComputerZoomToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerZoomInput.of(listOf(0L, 0L, 0L, 0L))) + .build() + + val roundtrippedComputerZoomToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(computerZoomToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedComputerZoomToolUseBlock).isEqualTo(computerZoomToolUseBlock) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/StructuredContentBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/StructuredContentBlockTest.kt index 117eabbf2..6d0f95bbb 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/StructuredContentBlockTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/StructuredContentBlockTest.kt @@ -208,6 +208,17 @@ internal class StructuredContentBlockTest { checkAllDelegation(delegator::class, mockDelegate::class, "accept") } + @Test + fun allDelegateVisitorFunctionsExistInDelegatorVisitor() { + // When this fails, add the variant to `Visitor`, `accept()` and `validate()`. + // `visitText()` has a different signature. + checkAllDelegation( + ContentBlock.Visitor::class, + StructuredContentBlock.Visitor::class, + "visitText", + ) + } + @Test fun allDelegatorFunctionsAreTested() { // There are exceptional test cases for some functions. Most other functions are part of the diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ToolUseCallerTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ToolUseCallerTest.kt new file mode 100644 index 000000000..942168e6f --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ToolUseCallerTest.kt @@ -0,0 +1,141 @@ +package com.anthropic.models.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ToolUseCallerTest { + + @Test + fun ofDirect() { + val direct = DirectCaller.builder().build() + + val toolUseCaller = ToolUseCaller.ofDirect(direct) + + assertThat(toolUseCaller.direct()).contains(direct) + assertThat(toolUseCaller.codeExecution20250825()).isEmpty + assertThat(toolUseCaller.codeExecution20260120()).isEmpty + } + + @Test + fun ofDirectRoundtrip() { + val jsonMapper = jsonMapper() + val toolUseCaller = ToolUseCaller.ofDirect(DirectCaller.builder().build()) + + val roundtrippedToolUseCaller = + jsonMapper.readValue( + jsonMapper.writeValueAsString(toolUseCaller), + jacksonTypeRef(), + ) + + assertThat(roundtrippedToolUseCaller).isEqualTo(toolUseCaller) + } + + @Test + fun ofCodeExecution20250825() { + val codeExecution20250825 = ServerToolCaller.of("srvtoolu_SQfNkl1n_JR_") + + val toolUseCaller = ToolUseCaller.ofCodeExecution20250825(codeExecution20250825) + + assertThat(toolUseCaller.direct()).isEmpty + assertThat(toolUseCaller.codeExecution20250825()).contains(codeExecution20250825) + assertThat(toolUseCaller.codeExecution20260120()).isEmpty + } + + @Test + fun ofCodeExecution20250825Roundtrip() { + val jsonMapper = jsonMapper() + val toolUseCaller = + ToolUseCaller.ofCodeExecution20250825(ServerToolCaller.of("srvtoolu_SQfNkl1n_JR_")) + + val roundtrippedToolUseCaller = + jsonMapper.readValue( + jsonMapper.writeValueAsString(toolUseCaller), + jacksonTypeRef(), + ) + + assertThat(roundtrippedToolUseCaller).isEqualTo(toolUseCaller) + } + + @Test + fun ofCodeExecution20260120() { + val codeExecution20260120 = ServerToolCaller20260120.of("srvtoolu_SQfNkl1n_JR_") + + val toolUseCaller = ToolUseCaller.ofCodeExecution20260120(codeExecution20260120) + + assertThat(toolUseCaller.direct()).isEmpty + assertThat(toolUseCaller.codeExecution20250825()).isEmpty + assertThat(toolUseCaller.codeExecution20260120()).contains(codeExecution20260120) + } + + @Test + fun ofCodeExecution20260120Roundtrip() { + val jsonMapper = jsonMapper() + val toolUseCaller = + ToolUseCaller.ofCodeExecution20260120( + ServerToolCaller20260120.of("srvtoolu_SQfNkl1n_JR_") + ) + + val roundtrippedToolUseCaller = + jsonMapper.readValue( + jsonMapper.writeValueAsString(toolUseCaller), + jacksonTypeRef(), + ) + + assertThat(roundtrippedToolUseCaller).isEqualTo(toolUseCaller) + } + + @Test + fun unknownVariantCommonProperties() { + val toolUseCaller = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf("type" to "unknown_variant", "tool_id" to "srvtoolu_SQfNkl1n_JR_") + ), + jacksonTypeRef(), + ) + + val e = assertThrows { toolUseCaller.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(toolUseCaller.toolId()).contains("srvtoolu_SQfNkl1n_JR_") + + val mismatchedToolUseCaller = + jsonMapper() + .convertValue( + JsonValue.from( + mapOf("type" to "unknown_variant", "tool_id" to listOf("invalid")) + ), + jacksonTypeRef(), + ) + + assertThat(mismatchedToolUseCaller.toolId()).isEmpty + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val toolUseCaller = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { toolUseCaller.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + + assertThat(toolUseCaller.toolId()).isEmpty + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ToolsetToolUseBlockTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ToolsetToolUseBlockTest.kt new file mode 100644 index 000000000..782ebb7f7 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/messages/ToolsetToolUseBlockTest.kt @@ -0,0 +1,155 @@ +package com.anthropic.models.messages + +import com.anthropic.core.JsonValue +import com.anthropic.core.jsonMapper +import com.anthropic.errors.AnthropicInvalidDataException +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class ToolsetToolUseBlockTest { + + @Test + fun ofBrowser() { + val browser = + BrowserToolUseBlock.ofNavigate( + BrowserNavigateToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .build() + ) + + val toolsetToolUseBlock = ToolsetToolUseBlock.ofBrowser(browser) + + assertThat(toolsetToolUseBlock.browser()).contains(browser) + assertThat(toolsetToolUseBlock.computer()).isEmpty + assertThat(toolsetToolUseBlock.toolUseBlock()).isEmpty + } + + @Test + fun ofBrowserRoundtrip() { + val jsonMapper = jsonMapper() + val toolsetToolUseBlock = + ToolsetToolUseBlock.ofBrowser( + BrowserToolUseBlock.ofNavigate( + BrowserNavigateToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(BrowserNavigateInput.builder().url("url").tabId("tab_id").build()) + .build() + ) + ) + + val roundtrippedToolsetToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(toolsetToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedToolsetToolUseBlock).isEqualTo(toolsetToolUseBlock) + } + + @Test + fun ofComputer() { + val computer = + ComputerToolUseBlock.ofKey( + ComputerKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerKeyInput.builder().text("text").repeat(1L).build()) + .build() + ) + + val toolsetToolUseBlock = ToolsetToolUseBlock.ofComputer(computer) + + assertThat(toolsetToolUseBlock.browser()).isEmpty + assertThat(toolsetToolUseBlock.computer()).contains(computer) + assertThat(toolsetToolUseBlock.toolUseBlock()).isEmpty + } + + @Test + fun ofComputerRoundtrip() { + val jsonMapper = jsonMapper() + val toolsetToolUseBlock = + ToolsetToolUseBlock.ofComputer( + ComputerToolUseBlock.ofKey( + ComputerKeyToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(ComputerKeyInput.builder().text("text").repeat(1L).build()) + .build() + ) + ) + + val roundtrippedToolsetToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(toolsetToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedToolsetToolUseBlock).isEqualTo(toolsetToolUseBlock) + } + + @Test + fun ofToolUseBlock() { + val toolUseBlock = + ToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(JsonValue.from(mapOf("foo" to "bar"))) + .name("x") + .toolsetName("toolset_name") + .build() + + val toolsetToolUseBlock = ToolsetToolUseBlock.ofToolUseBlock(toolUseBlock) + + assertThat(toolsetToolUseBlock.browser()).isEmpty + assertThat(toolsetToolUseBlock.computer()).isEmpty + assertThat(toolsetToolUseBlock.toolUseBlock()).contains(toolUseBlock) + } + + @Test + fun ofToolUseBlockRoundtrip() { + val jsonMapper = jsonMapper() + val toolsetToolUseBlock = + ToolsetToolUseBlock.ofToolUseBlock( + ToolUseBlock.builder() + .id("id") + .caller(DirectCaller.builder().build()) + .input(JsonValue.from(mapOf("foo" to "bar"))) + .name("x") + .toolsetName("toolset_name") + .build() + ) + + val roundtrippedToolsetToolUseBlock = + jsonMapper.readValue( + jsonMapper.writeValueAsString(toolsetToolUseBlock), + jacksonTypeRef(), + ) + + assertThat(roundtrippedToolsetToolUseBlock).isEqualTo(toolsetToolUseBlock) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val toolsetToolUseBlock = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { toolsetToolUseBlock.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelCapabilitiesTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelCapabilitiesTest.kt index d47569bcf..63971fa4d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelCapabilitiesTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelCapabilitiesTest.kt @@ -34,6 +34,13 @@ internal class ModelCapabilitiesTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -41,6 +48,7 @@ internal class ModelCapabilitiesTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -73,6 +81,14 @@ internal class ModelCapabilitiesTest { ) assertThat(modelCapabilities.imageInput()).isEqualTo(CapabilitySupport.of(true)) assertThat(modelCapabilities.pdfInput()).isEqualTo(CapabilitySupport.of(true)) + assertThat(modelCapabilities.serverTools()) + .isEqualTo( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) assertThat(modelCapabilities.structuredOutputs()).isEqualTo(CapabilitySupport.of(true)) assertThat(modelCapabilities.thinking()) .isEqualTo( @@ -81,6 +97,7 @@ internal class ModelCapabilitiesTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -116,6 +133,13 @@ internal class ModelCapabilitiesTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -123,6 +147,7 @@ internal class ModelCapabilitiesTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelInfoTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelInfoTest.kt index ae3a1f182..e6357abcf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelInfoTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelInfoTest.kt @@ -38,6 +38,13 @@ internal class ModelInfoTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -45,6 +52,7 @@ internal class ModelInfoTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -53,9 +61,13 @@ internal class ModelInfoTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(ModelInfo.Lifecycle.ACTIVE) + .line(ModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() assertThat(modelInfo.id()).isEqualTo("claude-opus-5") @@ -85,6 +97,13 @@ internal class ModelInfoTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -92,6 +111,7 @@ internal class ModelInfoTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -100,9 +120,14 @@ internal class ModelInfoTest { .build() ) assertThat(modelInfo.createdAt()).isEqualTo(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + assertThat(modelInfo.deprecatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(modelInfo.displayName()).isEqualTo("Claude Opus 5") + assertThat(modelInfo.lifecycle()).isEqualTo(ModelInfo.Lifecycle.ACTIVE) + assertThat(modelInfo.line()).contains(ModelLine.HAIKU) assertThat(modelInfo.maxInputTokens()).contains(0L) assertThat(modelInfo.maxTokens()).contains(0L) + assertThat(modelInfo.retiresAt()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) } @Test @@ -136,6 +161,13 @@ internal class ModelInfoTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -143,6 +175,7 @@ internal class ModelInfoTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -151,9 +184,13 @@ internal class ModelInfoTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(ModelInfo.Lifecycle.ACTIVE) + .line(ModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() val roundtrippedModelInfo = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListPageResponseTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListPageResponseTest.kt index ee33aa9fe..61b72e937 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListPageResponseTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListPageResponseTest.kt @@ -40,6 +40,13 @@ internal class ModelListPageResponseTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -47,6 +54,7 @@ internal class ModelListPageResponseTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -55,9 +63,13 @@ internal class ModelListPageResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(ModelInfo.Lifecycle.ACTIVE) + .line(ModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .firstId("first_id") @@ -94,6 +106,13 @@ internal class ModelListPageResponseTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -101,6 +120,7 @@ internal class ModelListPageResponseTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -109,9 +129,13 @@ internal class ModelListPageResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(ModelInfo.Lifecycle.ACTIVE) + .line(ModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) assertThat(modelListPageResponse.firstId()).contains("first_id") @@ -152,6 +176,13 @@ internal class ModelListPageResponseTest { ) .imageInput(CapabilitySupport.of(true)) .pdfInput(CapabilitySupport.of(true)) + .serverTools( + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + ) .structuredOutputs(CapabilitySupport.of(true)) .thinking( ThinkingCapability.builder() @@ -159,6 +190,7 @@ internal class ModelListPageResponseTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -167,9 +199,13 @@ internal class ModelListPageResponseTest { .build() ) .createdAt(OffsetDateTime.parse("2026-07-24T00:00:00Z")) + .deprecatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .displayName("Claude Opus 5") + .lifecycle(ModelInfo.Lifecycle.ACTIVE) + .line(ModelLine.HAIKU) .maxInputTokens(0L) .maxTokens(0L) + .retiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() ) .firstId("first_id") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListParamsTest.kt index 91f8e939c..44941aa36 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelListParamsTest.kt @@ -13,6 +13,7 @@ internal class ModelListParamsTest { ModelListParams.builder() .afterId("after_id") .beforeId("before_id") + .addLifecycle(ModelListParams.Lifecycle.ACTIVE) .limit(1L) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -25,6 +26,7 @@ internal class ModelListParamsTest { ModelListParams.builder() .afterId("after_id") .beforeId("before_id") + .addLifecycle(ModelListParams.Lifecycle.ACTIVE) .limit(1L) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -35,7 +37,7 @@ internal class ModelListParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) @@ -56,6 +58,7 @@ internal class ModelListParamsTest { ModelListParams.builder() .afterId("after_id") .beforeId("before_id") + .addLifecycle(ModelListParams.Lifecycle.ACTIVE) .limit(1L) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") @@ -68,6 +71,7 @@ internal class ModelListParamsTest { QueryParams.builder() .put("after_id", "after_id") .put("before_id", "before_id") + .put("lifecycle[]", "active") .put("limit", "1") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelRetrieveParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelRetrieveParamsTest.kt index bba3262bb..762c7fa32 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelRetrieveParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ModelRetrieveParamsTest.kt @@ -39,7 +39,7 @@ internal class ModelRetrieveParamsTest { assertThat(headers) .isEqualTo( Headers.builder() - .put("anthropic-beta", "message-batches-2024-09-24") + .put("anthropic-beta", listOf("message-batches-2024-09-24").joinToString(",")) .put("anthropic-workspace-id", "wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ServerToolsCapabilityTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ServerToolsCapabilityTest.kt new file mode 100644 index 000000000..1f3fef3d1 --- /dev/null +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ServerToolsCapabilityTest.kt @@ -0,0 +1,42 @@ +package com.anthropic.models.models + +import com.anthropic.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ServerToolsCapabilityTest { + + @Test + fun create() { + val serverToolsCapability = + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + + assertThat(serverToolsCapability.codeExecution()).isEqualTo(CapabilitySupport.of(true)) + assertThat(serverToolsCapability.supported()).isEqualTo(true) + assertThat(serverToolsCapability.webSearch()).isEqualTo(CapabilitySupport.of(true)) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val serverToolsCapability = + ServerToolsCapability.builder() + .codeExecution(CapabilitySupport.of(true)) + .supported(true) + .webSearch(CapabilitySupport.of(true)) + .build() + + val roundtrippedServerToolsCapability = + jsonMapper.readValue( + jsonMapper.writeValueAsString(serverToolsCapability), + jacksonTypeRef(), + ) + + assertThat(roundtrippedServerToolsCapability).isEqualTo(serverToolsCapability) + } +} diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingCapabilityTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingCapabilityTest.kt index 599323ddc..de2aed7b5 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingCapabilityTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingCapabilityTest.kt @@ -15,6 +15,7 @@ internal class ThinkingCapabilityTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -25,6 +26,7 @@ internal class ThinkingCapabilityTest { .isEqualTo( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) @@ -39,6 +41,7 @@ internal class ThinkingCapabilityTest { .types( ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingTypesTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingTypesTest.kt index 000891914..64f74201f 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingTypesTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/models/ThinkingTypesTest.kt @@ -12,10 +12,12 @@ internal class ThinkingTypesTest { val thinkingTypes = ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() assertThat(thinkingTypes.adaptive()).isEqualTo(CapabilitySupport.of(true)) + assertThat(thinkingTypes.disabled()).isEqualTo(CapabilitySupport.of(true)) assertThat(thinkingTypes.enabled()).isEqualTo(CapabilitySupport.of(true)) } @@ -25,6 +27,7 @@ internal class ThinkingTypesTest { val thinkingTypes = ThinkingTypes.builder() .adaptive(CapabilitySupport.of(true)) + .disabled(CapabilitySupport.of(true)) .enabled(CapabilitySupport.of(true)) .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParamsTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParamsTest.kt index c4c1f0178..6b0549c54 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParamsTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/models/organization/workspaces/WorkspaceListParamsTest.kt @@ -12,6 +12,7 @@ internal class WorkspaceListParamsTest { .afterId("after_id") .beforeId("before_id") .includeArchived(true) + .includeDefault(true) .limit(1L) .build() } @@ -23,6 +24,7 @@ internal class WorkspaceListParamsTest { .afterId("after_id") .beforeId("before_id") .includeArchived(true) + .includeDefault(true) .limit(1L) .build() @@ -34,6 +36,7 @@ internal class WorkspaceListParamsTest { .put("after_id", "after_id") .put("before_id", "before_id") .put("include_archived", "true") + .put("include_default", "true") .put("limit", "1") .build() ) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/CompletionServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/CompletionServiceAsyncTest.kt index 5d3aaf318..3b76dab91 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/CompletionServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/CompletionServiceAsyncTest.kt @@ -27,7 +27,7 @@ internal class CompletionServiceAsyncTest { .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() @@ -58,7 +58,7 @@ internal class CompletionServiceAsyncTest { .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/AgentServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/AgentServiceAsyncTest.kt index 382129d17..58bd00ed0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/AgentServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/AgentServiceAsyncTest.kt @@ -18,7 +18,6 @@ import com.anthropic.models.beta.agents.BetaManagedAgentsModelConfigParams import com.anthropic.models.beta.agents.BetaManagedAgentsMultiagentSelfParams import com.anthropic.models.beta.agents.BetaManagedAgentsUrlMcpServerParams import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagentParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -111,7 +110,6 @@ internal class AgentServiceAsyncTest { betaManagedAgentsAgent.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -234,7 +232,6 @@ internal class AgentServiceAsyncTest { betaManagedAgentsAgent.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncTest.kt index 0cc7dfb0d..9e38182b9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentRunServiceAsyncTest.kt @@ -4,14 +4,12 @@ import com.anthropic.TestServerExtension import com.anthropic.client.okhttp.AnthropicOkHttpClientAsync import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class DeploymentRunServiceAsyncTest { - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -34,7 +32,6 @@ internal class DeploymentRunServiceAsyncTest { betaManagedAgentsDeploymentRun.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncTest.kt index 2e521282e..53c7feb73 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/DeploymentServiceAsyncTest.kt @@ -18,7 +18,6 @@ import com.anthropic.models.beta.sessions.BetaManagedAgentsBudgetLimit import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -91,7 +90,6 @@ internal class DeploymentServiceAsyncTest { betaManagedAgentsDeployment.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -181,7 +179,6 @@ internal class DeploymentServiceAsyncTest { betaManagedAgentsDeployment.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/MemoryStoreServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/MemoryStoreServiceAsyncTest.kt index 029839261..4af3ad138 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/MemoryStoreServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/MemoryStoreServiceAsyncTest.kt @@ -9,7 +9,6 @@ import com.anthropic.models.beta.memorystores.MemoryStoreCreateParams import com.anthropic.models.beta.memorystores.MemoryStoreDeleteParams import com.anthropic.models.beta.memorystores.MemoryStoreRetrieveParams import com.anthropic.models.beta.memorystores.MemoryStoreUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -95,7 +94,6 @@ internal class MemoryStoreServiceAsyncTest { betaManagedAgentsMemoryStore.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/SessionServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/SessionServiceAsyncTest.kt index a81a1452a..d00dea6d7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/SessionServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/SessionServiceAsyncTest.kt @@ -21,7 +21,6 @@ import com.anthropic.models.beta.sessions.SessionRetrieveParams import com.anthropic.models.beta.sessions.SessionUpdateParams import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -190,7 +189,6 @@ internal class SessionServiceAsyncTest { betaManagedAgentsSession.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/TunnelServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/TunnelServiceAsyncTest.kt index 9a4b8663b..3f2c02ba9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/TunnelServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/TunnelServiceAsyncTest.kt @@ -8,7 +8,6 @@ import com.anthropic.models.beta.tunnels.TunnelCreateParams import com.anthropic.models.beta.tunnels.TunnelRetrieveParams import com.anthropic.models.beta.tunnels.TunnelRevealTokenParams import com.anthropic.models.beta.tunnels.TunnelRotateTokenParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -37,7 +36,6 @@ internal class TunnelServiceAsyncTest { betaTunnel.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -60,7 +58,6 @@ internal class TunnelServiceAsyncTest { betaTunnel.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/VaultServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/VaultServiceAsyncTest.kt index f640b5bd6..7883321c7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/VaultServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/VaultServiceAsyncTest.kt @@ -9,7 +9,6 @@ import com.anthropic.models.beta.vaults.VaultCreateParams import com.anthropic.models.beta.vaults.VaultDeleteParams import com.anthropic.models.beta.vaults.VaultRetrieveParams import com.anthropic.models.beta.vaults.VaultUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -93,7 +92,6 @@ internal class VaultServiceAsyncTest { betaManagedAgentsVault.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/agents/VersionServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/agents/VersionServiceAsyncTest.kt index 650a13ad3..3ae453ff4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/agents/VersionServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/agents/VersionServiceAsyncTest.kt @@ -2,14 +2,12 @@ package com.anthropic.services.async.beta.agents import com.anthropic.TestServerExtension import com.anthropic.client.okhttp.AnthropicOkHttpClientAsync -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class VersionServiceAsyncTest { - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/environments/WorkServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/environments/WorkServiceAsyncTest.kt index 406c059cd..5f0d607f4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/environments/WorkServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/environments/WorkServiceAsyncTest.kt @@ -14,7 +14,6 @@ import com.anthropic.models.beta.environments.work.WorkStatsParams import com.anthropic.models.beta.environments.work.WorkStopParams import com.anthropic.models.beta.environments.work.WorkUpdateParams import kotlin.jvm.optionals.getOrNull -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -74,7 +73,6 @@ internal class WorkServiceAsyncTest { betaSelfHostedWork.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -161,7 +159,6 @@ internal class WorkServiceAsyncTest { unwrappedBetaSelfHostedWork?.validate() } - @Disabled("buildURL drops path-level query params") @Test fun stats() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryServiceAsyncTest.kt index 97f029e1d..efdd44a02 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryServiceAsyncTest.kt @@ -9,7 +9,6 @@ import com.anthropic.models.beta.memorystores.memories.MemoryCreateParams import com.anthropic.models.beta.memorystores.memories.MemoryDeleteParams import com.anthropic.models.beta.memorystores.memories.MemoryRetrieveParams import com.anthropic.models.beta.memorystores.memories.MemoryUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -97,7 +96,6 @@ internal class MemoryServiceAsyncTest { betaManagedAgentsMemory.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryVersionServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryVersionServiceAsyncTest.kt index 4836f7989..eb6f859f4 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryVersionServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/memorystores/MemoryVersionServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.memorystores.memories.BetaManagedAgentsMemoryView import com.anthropic.models.beta.memorystores.memoryversions.MemoryVersionRedactParams import com.anthropic.models.beta.memorystores.memoryversions.MemoryVersionRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -37,7 +36,6 @@ internal class MemoryVersionServiceAsyncTest { betaManagedAgentsMemoryVersion.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncTest.kt index 07cc00e91..8f555da1b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/organization/SpendLimitServiceAsyncTest.kt @@ -2,6 +2,7 @@ package com.anthropic.services.async.beta.organization import com.anthropic.TestServerExtension import com.anthropic.client.okhttp.AnthropicOkHttpClientAsync +import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.organization.spendlimits.BetaSpendLimitPeriod import com.anthropic.models.beta.organization.spendlimits.SpendLimitSetParams import org.junit.jupiter.api.Test @@ -67,6 +68,7 @@ internal class SpendLimitServiceAsyncTest { val betaSpendLimitFuture = spendLimitServiceAsync.set( SpendLimitSetParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .amount("50000") .userScope("user_01WCz1FkmYMm4gnmykNKUu3Q") .period(BetaSpendLimitPeriod.DAILY) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/EventServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/EventServiceAsyncTest.kt index bd7ac689f..e7dc2eaaf 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/EventServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/EventServiceAsyncTest.kt @@ -8,14 +8,12 @@ import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams import com.anthropic.models.beta.sessions.events.EventSendParams import com.anthropic.models.beta.sessions.events.EventStreamParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EventServiceAsyncTest { - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ResourceServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ResourceServiceAsyncTest.kt index 43b3dbffa..fc80b2cea 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ResourceServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ResourceServiceAsyncTest.kt @@ -8,14 +8,12 @@ import com.anthropic.models.beta.sessions.resources.ResourceAddParams import com.anthropic.models.beta.sessions.resources.ResourceDeleteParams import com.anthropic.models.beta.sessions.resources.ResourceRetrieveParams import com.anthropic.models.beta.sessions.resources.ResourceUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ResourceServiceAsyncTest { - @Disabled("prism can't find endpoint with beta only tag") @Test fun retrieve() { val client = @@ -39,7 +37,6 @@ internal class ResourceServiceAsyncTest { resource.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun update() { val client = @@ -64,7 +61,6 @@ internal class ResourceServiceAsyncTest { resource.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun list() { val client = @@ -80,7 +76,6 @@ internal class ResourceServiceAsyncTest { page.response().validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun delete() { val client = @@ -105,7 +100,6 @@ internal class ResourceServiceAsyncTest { betaManagedAgentsDeleteSessionResource.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun add() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ThreadServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ThreadServiceAsyncTest.kt index cc0cb4023..8abff7e10 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ThreadServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/ThreadServiceAsyncTest.kt @@ -5,7 +5,6 @@ import com.anthropic.client.okhttp.AnthropicOkHttpClientAsync import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.sessions.threads.ThreadArchiveParams import com.anthropic.models.beta.sessions.threads.ThreadRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,7 +24,7 @@ internal class ThreadServiceAsyncTest { threadServiceAsync.retrieve( ThreadRetrieveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -35,7 +34,6 @@ internal class ThreadServiceAsyncTest { betaManagedAgentsSessionThread.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -64,7 +62,7 @@ internal class ThreadServiceAsyncTest { threadServiceAsync.archive( ThreadArchiveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/threads/EventServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/threads/EventServiceAsyncTest.kt index 93ba15a5d..658e6aa7d 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/threads/EventServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/sessions/threads/EventServiceAsyncTest.kt @@ -6,14 +6,12 @@ import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.sessions.BetaManagedAgentsDeltaType import com.anthropic.models.beta.sessions.threads.events.EventListParams import com.anthropic.models.beta.sessions.threads.events.EventStreamParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EventServiceAsyncTest { - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -27,7 +25,7 @@ internal class EventServiceAsyncTest { eventServiceAsync.list( EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() ) @@ -48,7 +46,7 @@ internal class EventServiceAsyncTest { eventServiceAsync.streamStreaming( EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addEventDelta(BetaManagedAgentsDeltaType.AGENT_MESSAGE) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/tunnels/CertificateServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/tunnels/CertificateServiceAsyncTest.kt index d821159fe..d621af973 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/tunnels/CertificateServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/tunnels/CertificateServiceAsyncTest.kt @@ -6,7 +6,6 @@ import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.tunnels.certificates.CertificateArchiveParams import com.anthropic.models.beta.tunnels.certificates.CertificateCreateParams import com.anthropic.models.beta.tunnels.certificates.CertificateRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -36,7 +35,6 @@ internal class CertificateServiceAsyncTest { betaTunnelCertificate.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -60,7 +58,6 @@ internal class CertificateServiceAsyncTest { betaTunnelCertificate.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/vaults/CredentialServiceAsyncTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/vaults/CredentialServiceAsyncTest.kt index 8778c2d0f..31d06d8ad 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/vaults/CredentialServiceAsyncTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/async/beta/vaults/CredentialServiceAsyncTest.kt @@ -15,7 +15,6 @@ import com.anthropic.models.beta.vaults.credentials.CredentialMcpOAuthValidatePa import com.anthropic.models.beta.vaults.credentials.CredentialRetrieveParams import com.anthropic.models.beta.vaults.credentials.CredentialUpdateParams import java.time.OffsetDateTime -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -70,7 +69,7 @@ internal class CredentialServiceAsyncTest { credentialServiceAsync.retrieve( CredentialRetrieveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -93,7 +92,7 @@ internal class CredentialServiceAsyncTest { credentialServiceAsync.update( CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .auth( @@ -132,7 +131,6 @@ internal class CredentialServiceAsyncTest { betaManagedAgentsCredential.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -161,7 +159,7 @@ internal class CredentialServiceAsyncTest { credentialServiceAsync.delete( CredentialDeleteParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -184,7 +182,7 @@ internal class CredentialServiceAsyncTest { credentialServiceAsync.archive( CredentialArchiveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -194,7 +192,6 @@ internal class CredentialServiceAsyncTest { betaManagedAgentsCredential.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun mcpOAuthValidate() { val client = @@ -208,7 +205,7 @@ internal class CredentialServiceAsyncTest { credentialServiceAsync.mcpOAuthValidate( CredentialMcpOAuthValidateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt index d116e08eb..1e89d2681 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/CompletionServiceTest.kt @@ -27,7 +27,7 @@ internal class CompletionServiceTest { .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() @@ -57,7 +57,7 @@ internal class CompletionServiceTest { .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .maxTokensToSample(256L) - .model(Model.CLAUDE_SONNET_5_5) + .model(Model.CLAUDE_HAIKU_5_5) .prompt("\n\nHuman: Hello, world!\n\nAssistant:") .metadata( Metadata.builder().userId("13803d75-b4b5-4c3e-b2a2-6f21399b021b").build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/AgentServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/AgentServiceTest.kt index b6bf15e2c..d966126f0 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/AgentServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/AgentServiceTest.kt @@ -18,7 +18,6 @@ import com.anthropic.models.beta.agents.BetaManagedAgentsModelConfigParams import com.anthropic.models.beta.agents.BetaManagedAgentsMultiagentSelfParams import com.anthropic.models.beta.agents.BetaManagedAgentsUrlMcpServerParams import com.anthropic.models.beta.sessions.BetaManagedAgentsMultiagentParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -110,7 +109,6 @@ internal class AgentServiceTest { betaManagedAgentsAgent.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -231,7 +229,6 @@ internal class AgentServiceTest { betaManagedAgentsAgent.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceTest.kt index 1ce69ef4a..7f0222351 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentRunServiceTest.kt @@ -4,14 +4,12 @@ import com.anthropic.TestServerExtension import com.anthropic.client.okhttp.AnthropicOkHttpClient import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.deploymentruns.DeploymentRunRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class DeploymentRunServiceTest { - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -33,7 +31,6 @@ internal class DeploymentRunServiceTest { betaManagedAgentsDeploymentRun.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceTest.kt index cc2535c96..353cb9fe9 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/DeploymentServiceTest.kt @@ -18,7 +18,6 @@ import com.anthropic.models.beta.sessions.BetaManagedAgentsBudgetLimit import com.anthropic.models.beta.sessions.BetaManagedAgentsFileResourceParams import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -90,7 +89,6 @@ internal class DeploymentServiceTest { betaManagedAgentsDeployment.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -178,7 +176,6 @@ internal class DeploymentServiceTest { betaManagedAgentsDeployment.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MemoryStoreServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MemoryStoreServiceTest.kt index 815e2b0c5..5b1420c88 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MemoryStoreServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/MemoryStoreServiceTest.kt @@ -9,7 +9,6 @@ import com.anthropic.models.beta.memorystores.MemoryStoreCreateParams import com.anthropic.models.beta.memorystores.MemoryStoreDeleteParams import com.anthropic.models.beta.memorystores.MemoryStoreRetrieveParams import com.anthropic.models.beta.memorystores.MemoryStoreUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -92,7 +91,6 @@ internal class MemoryStoreServiceTest { betaManagedAgentsMemoryStore.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/SessionServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/SessionServiceTest.kt index d07b32115..978cc421b 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/SessionServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/SessionServiceTest.kt @@ -21,7 +21,6 @@ import com.anthropic.models.beta.sessions.SessionRetrieveParams import com.anthropic.models.beta.sessions.SessionUpdateParams import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -187,7 +186,6 @@ internal class SessionServiceTest { betaManagedAgentsSession.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/TunnelServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/TunnelServiceTest.kt index 78ac458b7..ecb5a3ae7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/TunnelServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/TunnelServiceTest.kt @@ -8,7 +8,6 @@ import com.anthropic.models.beta.tunnels.TunnelCreateParams import com.anthropic.models.beta.tunnels.TunnelRetrieveParams import com.anthropic.models.beta.tunnels.TunnelRevealTokenParams import com.anthropic.models.beta.tunnels.TunnelRotateTokenParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -36,7 +35,6 @@ internal class TunnelServiceTest { betaTunnel.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -58,7 +56,6 @@ internal class TunnelServiceTest { betaTunnel.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/VaultServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/VaultServiceTest.kt index 5642b61b7..ea51272b6 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/VaultServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/VaultServiceTest.kt @@ -9,7 +9,6 @@ import com.anthropic.models.beta.vaults.VaultCreateParams import com.anthropic.models.beta.vaults.VaultDeleteParams import com.anthropic.models.beta.vaults.VaultRetrieveParams import com.anthropic.models.beta.vaults.VaultUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -90,7 +89,6 @@ internal class VaultServiceTest { betaManagedAgentsVault.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/agents/VersionServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/agents/VersionServiceTest.kt index 9e57c3542..d3c55da52 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/agents/VersionServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/agents/VersionServiceTest.kt @@ -2,14 +2,12 @@ package com.anthropic.services.blocking.beta.agents import com.anthropic.TestServerExtension import com.anthropic.client.okhttp.AnthropicOkHttpClient -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class VersionServiceTest { - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/environments/WorkServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/environments/WorkServiceTest.kt index 5df06ab7c..9994df925 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/environments/WorkServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/environments/WorkServiceTest.kt @@ -14,7 +14,6 @@ import com.anthropic.models.beta.environments.work.WorkStatsParams import com.anthropic.models.beta.environments.work.WorkStopParams import com.anthropic.models.beta.environments.work.WorkUpdateParams import kotlin.jvm.optionals.getOrNull -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -72,7 +71,6 @@ internal class WorkServiceTest { betaSelfHostedWork.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -155,7 +153,6 @@ internal class WorkServiceTest { unwrappedBetaSelfHostedWork?.validate() } - @Disabled("buildURL drops path-level query params") @Test fun stats() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryServiceTest.kt index 2bc191320..859ca8124 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryServiceTest.kt @@ -9,7 +9,6 @@ import com.anthropic.models.beta.memorystores.memories.MemoryCreateParams import com.anthropic.models.beta.memorystores.memories.MemoryDeleteParams import com.anthropic.models.beta.memorystores.memories.MemoryRetrieveParams import com.anthropic.models.beta.memorystores.memories.MemoryUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -94,7 +93,6 @@ internal class MemoryServiceTest { betaManagedAgentsMemory.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryVersionServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryVersionServiceTest.kt index 400dfdf1e..beeeb51b7 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryVersionServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/memorystores/MemoryVersionServiceTest.kt @@ -6,7 +6,6 @@ import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.memorystores.memories.BetaManagedAgentsMemoryView import com.anthropic.models.beta.memorystores.memoryversions.MemoryVersionRedactParams import com.anthropic.models.beta.memorystores.memoryversions.MemoryVersionRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -36,7 +35,6 @@ internal class MemoryVersionServiceTest { betaManagedAgentsMemoryVersion.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceTest.kt index 75a066008..a50fe50ac 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/organization/SpendLimitServiceTest.kt @@ -2,6 +2,7 @@ package com.anthropic.services.blocking.beta.organization import com.anthropic.TestServerExtension import com.anthropic.client.okhttp.AnthropicOkHttpClient +import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.organization.spendlimits.BetaSpendLimitPeriod import com.anthropic.models.beta.organization.spendlimits.SpendLimitSetParams import org.junit.jupiter.api.Test @@ -64,6 +65,7 @@ internal class SpendLimitServiceTest { val betaSpendLimit = spendLimitService.set( SpendLimitSetParams.builder() + .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .amount("50000") .userScope("user_01WCz1FkmYMm4gnmykNKUu3Q") .period(BetaSpendLimitPeriod.DAILY) diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/EventServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/EventServiceTest.kt index e6b2552af..0e8f6d1a2 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/EventServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/EventServiceTest.kt @@ -8,14 +8,12 @@ import com.anthropic.models.beta.sessions.events.BetaManagedAgentsTextBlock import com.anthropic.models.beta.sessions.events.BetaManagedAgentsUserMessageEventParams import com.anthropic.models.beta.sessions.events.EventSendParams import com.anthropic.models.beta.sessions.events.EventStreamParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EventServiceTest { - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ResourceServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ResourceServiceTest.kt index eeefa6394..246964a5a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ResourceServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ResourceServiceTest.kt @@ -8,14 +8,12 @@ import com.anthropic.models.beta.sessions.resources.ResourceAddParams import com.anthropic.models.beta.sessions.resources.ResourceDeleteParams import com.anthropic.models.beta.sessions.resources.ResourceRetrieveParams import com.anthropic.models.beta.sessions.resources.ResourceUpdateParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ResourceServiceTest { - @Disabled("prism can't find endpoint with beta only tag") @Test fun retrieve() { val client = @@ -38,7 +36,6 @@ internal class ResourceServiceTest { resource.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun update() { val client = @@ -62,7 +59,6 @@ internal class ResourceServiceTest { resource.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun list() { val client = @@ -77,7 +73,6 @@ internal class ResourceServiceTest { page.response().validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun delete() { val client = @@ -100,7 +95,6 @@ internal class ResourceServiceTest { betaManagedAgentsDeleteSessionResource.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun add() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ThreadServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ThreadServiceTest.kt index f1d5c727e..1faa61abd 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ThreadServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/ThreadServiceTest.kt @@ -5,7 +5,6 @@ import com.anthropic.client.okhttp.AnthropicOkHttpClient import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.sessions.threads.ThreadArchiveParams import com.anthropic.models.beta.sessions.threads.ThreadRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -25,7 +24,7 @@ internal class ThreadServiceTest { threadService.retrieve( ThreadRetrieveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -34,7 +33,6 @@ internal class ThreadServiceTest { betaManagedAgentsSessionThread.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -62,7 +60,7 @@ internal class ThreadServiceTest { threadService.archive( ThreadArchiveParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/threads/EventServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/threads/EventServiceTest.kt index fd9aba5af..761bd4f58 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/threads/EventServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/sessions/threads/EventServiceTest.kt @@ -6,14 +6,12 @@ import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.sessions.BetaManagedAgentsDeltaType import com.anthropic.models.beta.sessions.threads.events.EventListParams import com.anthropic.models.beta.sessions.threads.events.EventStreamParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class EventServiceTest { - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -27,7 +25,7 @@ internal class EventServiceTest { eventService.list( EventListParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .build() ) @@ -47,7 +45,7 @@ internal class EventServiceTest { eventService.streamStreaming( EventStreamParams.builder() .sessionId("sesn_011CZkZAtmR3yMPDzynEDxu7") - .threadId("sthr_011CZkZVWa6oIjw0rgXZpnBt") + .threadId("sthr_011CZkZVWa6oJjw1rgXZpnBt") .addEventDelta(BetaManagedAgentsDeltaType.AGENT_MESSAGE) .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/tunnels/CertificateServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/tunnels/CertificateServiceTest.kt index 69c4c9515..69dd0050a 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/tunnels/CertificateServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/tunnels/CertificateServiceTest.kt @@ -6,7 +6,6 @@ import com.anthropic.models.beta.AnthropicBeta import com.anthropic.models.beta.tunnels.certificates.CertificateArchiveParams import com.anthropic.models.beta.tunnels.certificates.CertificateCreateParams import com.anthropic.models.beta.tunnels.certificates.CertificateRetrieveParams -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -35,7 +34,6 @@ internal class CertificateServiceTest { betaTunnelCertificate.validate() } - @Disabled("buildURL drops path-level query params") @Test fun retrieve() { val client = @@ -58,7 +56,6 @@ internal class CertificateServiceTest { betaTunnelCertificate.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = diff --git a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/vaults/CredentialServiceTest.kt b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/vaults/CredentialServiceTest.kt index a20208544..92b15b0b1 100644 --- a/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/vaults/CredentialServiceTest.kt +++ b/anthropic-java-core/src/test/kotlin/com/anthropic/services/blocking/beta/vaults/CredentialServiceTest.kt @@ -15,7 +15,6 @@ import com.anthropic.models.beta.vaults.credentials.CredentialMcpOAuthValidatePa import com.anthropic.models.beta.vaults.credentials.CredentialRetrieveParams import com.anthropic.models.beta.vaults.credentials.CredentialUpdateParams import java.time.OffsetDateTime -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -69,7 +68,7 @@ internal class CredentialServiceTest { credentialService.retrieve( CredentialRetrieveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -91,7 +90,7 @@ internal class CredentialServiceTest { credentialService.update( CredentialUpdateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .auth( @@ -129,7 +128,6 @@ internal class CredentialServiceTest { betaManagedAgentsCredential.validate() } - @Disabled("buildURL drops path-level query params") @Test fun list() { val client = @@ -157,7 +155,7 @@ internal class CredentialServiceTest { credentialService.delete( CredentialDeleteParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -179,7 +177,7 @@ internal class CredentialServiceTest { credentialService.archive( CredentialArchiveParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() @@ -188,7 +186,6 @@ internal class CredentialServiceTest { betaManagedAgentsCredential.validate() } - @Disabled("prism can't find endpoint with beta only tag") @Test fun mcpOAuthValidate() { val client = @@ -202,7 +199,7 @@ internal class CredentialServiceTest { credentialService.mcpOAuthValidate( CredentialMcpOAuthValidateParams.builder() .vaultId("vlt_011CZkZDLs7fYzm1hXNPeRjv") - .credentialId("vcrd_011CZkZEMt8gZan2iYOQfSkw") + .credentialId("vcrd_011CZkZEMt8gZan2iYPQfSkw") .addBeta(AnthropicBeta.MESSAGE_BATCHES_2024_09_24) .workspaceId("wrkspc_011CZkZaBF1tNoB5wlCeusgy") .build() diff --git a/anthropic-java-ecosystem-test/build.gradle.kts b/anthropic-java-ecosystem-test/build.gradle.kts index aac680180..64a1c4191 100644 --- a/anthropic-java-ecosystem-test/build.gradle.kts +++ b/anthropic-java-ecosystem-test/build.gradle.kts @@ -130,6 +130,7 @@ val proguardJar by tasks.registering(proguard.gradle.ProGuardTask::class) { configuration("./test.pro") configuration("../anthropic-java-core/src/main/resources/META-INF/proguard/anthropic-java-core.pro") + configuration("../anthropic-java-client-okhttp/src/main/resources/META-INF/proguard/anthropic-java-client-okhttp.pro") } val testProGuard by tasks.registering(JavaExec::class) { @@ -155,6 +156,7 @@ val r8Jar by tasks.registering(JavaExec::class) { val proguardConfigs = listOf( "./test.pro", "../anthropic-java-core/src/main/resources/META-INF/proguard/anthropic-java-core.pro", + "../anthropic-java-client-okhttp/src/main/resources/META-INF/proguard/anthropic-java-client-okhttp.pro", ) args = listOf( @@ -162,11 +164,8 @@ val r8Jar by tasks.registering(JavaExec::class) { "--classfile", "--output", r8JarFile.get().asFile.absolutePath, "--lib", System.getProperty("java.home"), - "--pg-conf", proguardConfigs[0], - "--pg-conf", proguardConfigs[1], "--pg-map-output", layout.buildDirectory.file("r8-mapping.txt").get().asFile.absolutePath, - shadowJarFile.get().asFile.absolutePath, - ) + ) + proguardConfigs.flatMap { listOf("--pg-conf", it) } + shadowJarFile.get().asFile.absolutePath // `args` is an `@Input` on `JavaExec` (so the paths above already affect // the cache key), but the file *contents* behind those paths are not diff --git a/anthropic-java-ecosystem-test/src/test/java/com/anthropic/ecosystem/Java8UsageMain.java b/anthropic-java-ecosystem-test/src/test/java/com/anthropic/ecosystem/Java8UsageMain.java index 44b53083e..158f6d538 100644 --- a/anthropic-java-ecosystem-test/src/test/java/com/anthropic/ecosystem/Java8UsageMain.java +++ b/anthropic-java-ecosystem-test/src/test/java/com/anthropic/ecosystem/Java8UsageMain.java @@ -3,7 +3,10 @@ import com.anthropic.client.AnthropicClient; import com.anthropic.client.okhttp.AnthropicOkHttpClient; import com.anthropic.core.ObjectMappers; -import com.anthropic.models.messages.Base64ImageSource; +import com.anthropic.models.messages.BashCodeExecutionToolResultBlockParam; +import com.anthropic.models.messages.BashCodeExecutionToolResultErrorCode; +import com.anthropic.models.messages.BashCodeExecutionToolResultErrorParam; +import com.anthropic.models.messages.CacheControlEphemeral; import com.fasterxml.jackson.databind.json.JsonMapper; // Exercises basic SDK usage from Java and is executed on a real JDK 8 runtime to catch @@ -24,11 +27,16 @@ public static void main(String[] args) throws Exception { require(client.beta() != null, "beta"); JsonMapper mapper = ObjectMappers.jsonMapper(); - Base64ImageSource src = Base64ImageSource.builder() - .data("U3RhaW5sZXNzIHJvY2tz") - .mediaType(Base64ImageSource.MediaType.IMAGE_JPEG) + BashCodeExecutionToolResultBlockParam src = BashCodeExecutionToolResultBlockParam.builder() + .content(BashCodeExecutionToolResultErrorParam.of( + BashCodeExecutionToolResultErrorCode.INVALID_TOOL_INPUT)) + .toolUseId("srvtoolu_SQfNkl1n_JR_") + .cacheControl(CacheControlEphemeral.builder() + .ttl(CacheControlEphemeral.Ttl.TTL_5M) + .build()) .build(); - Base64ImageSource roundTripped = mapper.readValue(mapper.writeValueAsString(src), Base64ImageSource.class); + BashCodeExecutionToolResultBlockParam roundTripped = + mapper.readValue(mapper.writeValueAsString(src), BashCodeExecutionToolResultBlockParam.class); require(roundTripped.equals(src), "Jackson round-trip equality"); System.out.println("Java 8 usage check passed."); diff --git a/anthropic-java-ecosystem-test/src/test/kotlin/com/anthropic/ecosystem/EcosystemCompatibilityTest.kt b/anthropic-java-ecosystem-test/src/test/kotlin/com/anthropic/ecosystem/EcosystemCompatibilityTest.kt index 6415a9b18..f6ec785bb 100644 --- a/anthropic-java-ecosystem-test/src/test/kotlin/com/anthropic/ecosystem/EcosystemCompatibilityTest.kt +++ b/anthropic-java-ecosystem-test/src/test/kotlin/com/anthropic/ecosystem/EcosystemCompatibilityTest.kt @@ -1,14 +1,23 @@ package com.anthropic.ecosystem import com.anthropic.client.okhttp.AnthropicOkHttpClient +import com.anthropic.core.JsonValue import com.anthropic.core.jsonMapper -import com.anthropic.models.messages.Base64ImageSource +import com.anthropic.errors.BadRequestException +import com.anthropic.models.messages.BashCodeExecutionToolResultBlockParam import com.anthropic.models.messages.BashCodeExecutionToolResultErrorCode -import com.anthropic.models.messages.BrowserStateChange +import com.anthropic.models.messages.BrowserClickTarget +import com.anthropic.models.messages.MessageCreateParams +import com.anthropic.models.messages.Model import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.net.InetAddress +import java.net.ServerSocket +import java.net.URI +import kotlin.concurrent.thread import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.jupiter.api.Test internal class EcosystemCompatibilityTest { @@ -36,10 +45,19 @@ internal class EcosystemCompatibilityTest { @Test fun proguardRules() { - val rulesFile = - javaClass.classLoader.getResourceAsStream("META-INF/proguard/anthropic-java-core.pro") + assertThat( + javaClass.classLoader.getResourceAsStream( + "META-INF/proguard/anthropic-java-core.pro" + ) + ) + .isNotNull() - assertThat(rulesFile).isNotNull() + assertThat( + javaClass.classLoader.getResourceAsStream( + "META-INF/proguard/anthropic-java-client-okhttp.pro" + ) + ) + .isNotNull() } @Test @@ -57,42 +75,145 @@ internal class EcosystemCompatibilityTest { } @Test - fun base64ImageSourceRoundtrip() { + fun request() { + ServerSocket(0, 1, InetAddress.getLoopbackAddress()).use { server -> + // Fails every request, so that the test doesn't depend on the response of the method. + thread(isDaemon = true) { + server.accept().use { socket -> + val input = socket.getInputStream() + input.bufferedReader().lineSequence().first { it.isEmpty() } + socket + .getOutputStream() + .write( + "HTTP/1.1 400 Bad Request\r\nContent-Length: 2\r\nConnection: close\r\n\r\n{}" + .toByteArray() + ) + socket.shutdownOutput() + // Closing the socket with the rest of the request unread could reset the + // connection. + input.readBytes() + } + } + val client = + AnthropicOkHttpClient.builder() + .baseUrl( + URI( + "http", + null, + server.inetAddress.hostAddress, + server.localPort, + null, + null, + null, + ) + .toString() + ) + .apiKey("my-anthropic-api-key") + .build() + + assertThatThrownBy { + client + .messages() + .create( + MessageCreateParams.builder() + .maxTokens(1024L) + .addUserMessage("Hello, world") + .model(Model.CLAUDE_OPUS_5) + .build() + ) + } + .isInstanceOf(BadRequestException::class.java) + + client.close() + } + } + + @Test + fun jsonValueRoundtrip() { + val jsonMapper = jsonMapper() + val jsonValue = + jsonMapper.readValue( + "{\"values\":[1,2.5,\"three\",true,null],\"nested\":{\"key\":\"value\"}}", + jacksonTypeRef(), + ) + + val roundtrippedJsonValue = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jsonValue), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJsonValue).isEqualTo(jsonValue) + } + + @Test + fun bashCodeExecutionToolResultBlockParamRoundtrip() { + val jsonMapper = jsonMapper() + val bashCodeExecutionToolResultBlockParam = + jsonMapper.readValue( + "{\"content\":{\"error_code\":\"invalid_tool_input\",\"type\":\"bash_code_execution_tool_result_error\"},\"tool_use_id\":\"srvtoolu_SQfNkl1n_JR_\",\"type\":\"bash_code_execution_tool_result\",\"cache_control\":{\"type\":\"ephemeral\",\"ttl\":\"5m\"}}", + jacksonTypeRef(), + ) + + val roundtrippedBashCodeExecutionToolResultBlockParam = + jsonMapper.readValue( + jsonMapper.writeValueAsString(bashCodeExecutionToolResultBlockParam), + jacksonTypeRef(), + ) + + bashCodeExecutionToolResultBlockParam.validate() + assertThat(roundtrippedBashCodeExecutionToolResultBlockParam) + .isEqualTo(bashCodeExecutionToolResultBlockParam) + } + + @Test + fun bashCodeExecutionToolResultBlockParamWithoutOptionalFieldsRoundtrip() { val jsonMapper = jsonMapper() - val base64ImageSource = - Base64ImageSource.builder() - .data("U3RhaW5sZXNzIHJvY2tz") - .mediaType(Base64ImageSource.MediaType.IMAGE_JPEG) - .build() + val bashCodeExecutionToolResultBlockParam = + jsonMapper.readValue( + "{\"content\":{\"error_code\":\"invalid_tool_input\",\"type\":\"bash_code_execution_tool_result_error\"},\"tool_use_id\":\"srvtoolu_SQfNkl1n_JR_\",\"type\":\"bash_code_execution_tool_result\"}", + jacksonTypeRef(), + ) - val roundtrippedBase64ImageSource = + val roundtrippedBashCodeExecutionToolResultBlockParam = jsonMapper.readValue( - jsonMapper.writeValueAsString(base64ImageSource), - jacksonTypeRef(), + jsonMapper.writeValueAsString(bashCodeExecutionToolResultBlockParam), + jacksonTypeRef(), ) - assertThat(roundtrippedBase64ImageSource).isEqualTo(base64ImageSource) + bashCodeExecutionToolResultBlockParam.validate() + assertThat(bashCodeExecutionToolResultBlockParam._cacheControl().isMissing()).isTrue() + assertThat(roundtrippedBashCodeExecutionToolResultBlockParam) + .isEqualTo(bashCodeExecutionToolResultBlockParam) } @Test - fun browserStateChangeRoundtrip() { + fun browserClickTargetRoundtrip() { val jsonMapper = jsonMapper() - val browserStateChange = BrowserStateChange.ofTabOpened("tab_id") + val browserClickTarget = + jsonMapper.readValue( + "{\"type\":\"coordinate\",\"x\":0,\"y\":0}", + jacksonTypeRef(), + ) - val roundtrippedBrowserStateChange = + val roundtrippedBrowserClickTarget = jsonMapper.readValue( - jsonMapper.writeValueAsString(browserStateChange), - jacksonTypeRef(), + jsonMapper.writeValueAsString(browserClickTarget), + jacksonTypeRef(), ) - assertThat(roundtrippedBrowserStateChange).isEqualTo(browserStateChange) + browserClickTarget.validate() + assertThat(roundtrippedBrowserClickTarget).isEqualTo(browserClickTarget) } @Test fun bashCodeExecutionToolResultErrorCodeRoundtrip() { val jsonMapper = jsonMapper() val bashCodeExecutionToolResultErrorCode = - BashCodeExecutionToolResultErrorCode.INVALID_TOOL_INPUT + jsonMapper.readValue( + "\"invalid_tool_input\"", + jacksonTypeRef(), + ) val roundtrippedBashCodeExecutionToolResultErrorCode = jsonMapper.readValue( @@ -100,6 +221,7 @@ internal class EcosystemCompatibilityTest { jacksonTypeRef(), ) + bashCodeExecutionToolResultErrorCode.validate() assertThat(roundtrippedBashCodeExecutionToolResultErrorCode) .isEqualTo(bashCodeExecutionToolResultErrorCode) } diff --git a/anthropic-java-ecosystem-test/test.pro b/anthropic-java-ecosystem-test/test.pro index b933a3e44..21f48c91d 100644 --- a/anthropic-java-ecosystem-test/test.pro +++ b/anthropic-java-ecosystem-test/test.pro @@ -1,5 +1,6 @@ -# Specify the entrypoint where ProGuard starts to determine what's reachable. --keep class com.anthropic.ecosystem.** { *; } +# Specify the entrypoint where ProGuard starts to determine what's reachable. Nothing else in the package is kept so +# that the classes the test deserializes aren't also instantiated by the other consumers, which build them. +-keep class com.anthropic.ecosystem.EcosystemCompatibilityTest* { *; } # For the testing framework. -keep class org.junit.** { *; } diff --git a/build.gradle.kts b/build.gradle.kts index 42607634e..e8c5931d7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ allprojects { group = "com.anthropic" - version = "2.68.0" // x-release-please-version + version = "2.69.0" // x-release-please-version } // Modules get these from `anthropic.java`; the root project applies no convention, so register diff --git a/buildSrc/src/main/kotlin/anthropic.detekt.gradle.kts b/buildSrc/src/main/kotlin/anthropic.detekt.gradle.kts index 58dba49bc..13b829767 100644 --- a/buildSrc/src/main/kotlin/anthropic.detekt.gradle.kts +++ b/buildSrc/src/main/kotlin/anthropic.detekt.gradle.kts @@ -74,7 +74,6 @@ private val toolchainJdkHome = listOf("main", "test").forEach { sourceSetName -> val sourceSet = the()[sourceSetName] - // The files that `detektMain` and `detektTest` check. val kotlinFiles = the().sourceSets[sourceSetName].kotlin.matching { include("**/*.kt", "**/*.kts") @@ -84,6 +83,24 @@ listOf("main", "test").forEach { sourceSetName -> val configFiles = the().config val baselineFile = baselineFileFor("detekt$taskSuffix") val passedFile = layout.buildDirectory.file("detekt-changed/$sourceSetName-passed") + + // The plugin sets these only on tasks it registers. Keep them as on `detekt$taskSuffix`. + fun Detekt.configureLikeSourceSetTask() { + val extension = project.the() + classpath.setFrom(typeResolutionClasspath) + jdkHome.set(toolchainJdkHome) + config.setFrom(configFiles) + baseline.fileProvider(provider { baselineFile.takeIf(File::exists) }) + debug = extension.debug + parallel = extension.parallel + allRules = extension.allRules + buildUponDefaultConfig = extension.buildUponDefaultConfig + disableDefaultRuleSets = extension.disableDefaultRuleSets + autoCorrect = extension.autoCorrect + ignoreFailures = extension.ignoreFailures + extension.basePath?.let { basePath = it } + } + val changedFiles = tasks.register("detektChangedFiles$taskSuffix") { source.from(kotlinFiles) @@ -106,16 +123,38 @@ listOf("main", "test").forEach { sourceSetName -> // `source` is compared by file name and content. With the list as an input too, a result // is taken from the build cache only for the same paths. inputs.files(fileList).withPropertyName("fileList") - // The plugin sets these only on tasks it registers. Keep them as on `detekt$taskSuffix`. - classpath.setFrom(typeResolutionClasspath) - jdkHome.set(toolchainJdkHome) - config.setFrom(configFiles) - parallel = project.the().parallel - baseline.fileProvider(provider { baselineFile.takeIf(File::exists) }) + configureLikeSourceSetTask() // `detektChangedMain` and `detektChangedTest` would write the same report files. reports { listOf(xml, html, txt, sarif, md).forEach { it.required.set(false) } } // See `DetektChangedFiles.passed`. outputs.file(passedFile).withPropertyName("passed") doLast { passedFile.get().asFile.writeText("") } } + + // Type resolution, most of detekt's time in a big source set, uses one thread. So several tasks + // each check part of the files. Gradle runs them at once only with the configuration cache on. + // A task sees the other parts as compiled classes, where smart casts on public properties fail. + if (project.name == "anthropic-java-core") { + val sliceCount = 8 + val slices = + (0 until sliceCount).map { slice -> + tasks.register("detekt${taskSuffix}Slice$slice") { + description = + "Runs detekt on one of $sliceCount parts of the $sourceSetName Kotlin " + + "files; detekt$taskSuffix runs all parts." + setSource(kotlinFiles) + // Directories must pass, or Gradle does not look inside them. + include { + it.isDirectory || Math.floorMod(it.name.hashCode(), sliceCount) == slice + } + configureLikeSourceSetTask() + val dir = layout.buildDirectory.dir("reports/detekt/$sourceSetName-$slice") + reportsDir.set(dir.map { it.asFile }) + } + } + tasks.named("detekt$taskSuffix") { + setSource(files()) + dependsOn(slices) + } + } } diff --git a/scripts/mock-spec.json.gz b/scripts/mock-spec.json.gz index 0373316a6..0573ff2dc 100644 Binary files a/scripts/mock-spec.json.gz and b/scripts/mock-spec.json.gz differ