diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aaa4cc9..017bd77 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' @@ -17,7 +19,7 @@ jobs: timeout-minutes: 15 name: lint runs-on: ${{ github.repository == 'stainless-sdks/arcade-engine-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 @@ -44,7 +46,7 @@ jobs: contents: read id-token: write runs-on: ${{ github.repository == 'stainless-sdks/arcade-engine-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - uses: actions/checkout@v6 diff --git a/.gitignore b/.gitignore index b1346e6..90b85e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log .gradle .idea .kotlin diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e8285b7..4f9005e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.5" + ".": "0.1.0-alpha.6" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index f7c06a5..8b2cd98 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 30 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/arcade-ai%2Farcade-engine-6ff494eafa2c154892716407682bb2296cff4f18c45765c5fb16bdf36f452ae1.yml -openapi_spec_hash: 63dde2481a7d51042a241bfba232b0b0 -config_hash: bf64816643634a621cd0ffd93d9c4347 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/arcade-ai%2Farcade-engine-1ef78b1a5567d95e588e2e41522ada4568b5ef06258a7b1a752226f58d3c519e.yml +openapi_spec_hash: 7ad5c8d91d66b56d56b0788b5ef40d77 +config_hash: 2d4163acdeacd75903f978cd79c35d14 diff --git a/CHANGELOG.md b/CHANGELOG.md index 30401cf..12ce757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,40 @@ # Changelog +## 0.1.0-alpha.6 (2026-04-10) + +Full Changelog: [v0.1.0-alpha.5...v0.1.0-alpha.6](https://github.com/ArcadeAI/arcade-java/compare/v0.1.0-alpha.5...v0.1.0-alpha.6) + +### Features + +* **api:** api update ([acfd5b0](https://github.com/ArcadeAI/arcade-java/commit/acfd5b0aedbb445e1269a6b879111ff19c8aeef5)) +* **api:** api update ([5871f8b](https://github.com/ArcadeAI/arcade-java/commit/5871f8b7d0a2a89a6cbb57561a292b32381c74b6)) + + +### Bug Fixes + +* **client:** allow updating header/query affecting fields in `toBuilder()` ([f86e1f2](https://github.com/ArcadeAI/arcade-java/commit/f86e1f2dff33a369dd6d52119ce670747dfd2392)) + + +### Chores + +* **ci:** skip lint on metadata-only changes ([d5942be](https://github.com/ArcadeAI/arcade-java/commit/d5942be3ea63057a3267602dc72046e71d9a5855)) +* **internal:** bump ktfmt ([f38504b](https://github.com/ArcadeAI/arcade-java/commit/f38504b554f72ac9f701716ff1ad40ec5f1a47b2)) +* **internal:** tweak CI branches ([5213191](https://github.com/ArcadeAI/arcade-java/commit/521319108a7b064979e96ecf2fff5e74681b56bf)) +* **internal:** update gitignore ([c9b3d8f](https://github.com/ArcadeAI/arcade-java/commit/c9b3d8f8b7825876526e6dca16859c9f12fcce37)) +* **internal:** update multipart form array serialization ([abeec96](https://github.com/ArcadeAI/arcade-java/commit/abeec961730398bb0c49f01ea13312468be4787c)) +* **internal:** update retry delay tests ([993657b](https://github.com/ArcadeAI/arcade-java/commit/993657b3ac45eafee6b85f76a578f2c6daaacfe2)) +* **tests:** bump steady to v0.19.4 ([0d022df](https://github.com/ArcadeAI/arcade-java/commit/0d022dfe027631ea83e1794bcb9e79824ab28f0f)) +* **tests:** bump steady to v0.19.5 ([d186f97](https://github.com/ArcadeAI/arcade-java/commit/d186f9769310ebff3584418642cc0b31a13e1d1c)) +* **tests:** bump steady to v0.19.6 ([b5094e5](https://github.com/ArcadeAI/arcade-java/commit/b5094e5507917137cf7b30c90e1028c122bd1331)) +* **tests:** bump steady to v0.19.7 ([231a1a7](https://github.com/ArcadeAI/arcade-java/commit/231a1a764782bb5bdcd1118630b3bbd544333aa4)) +* **tests:** bump steady to v0.20.1 ([b936990](https://github.com/ArcadeAI/arcade-java/commit/b93699052685356a902c34f38d8e46a617e77454)) +* **tests:** bump steady to v0.20.2 ([7dfba2e](https://github.com/ArcadeAI/arcade-java/commit/7dfba2ef15e2c5f6412a64f23cde8138159c42ea)) + + +### Refactors + +* **tests:** switch from prism to steady ([ae8ff34](https://github.com/ArcadeAI/arcade-java/commit/ae8ff343537d6ff24a3346fac27516c2bc3e07d9)) + ## 0.1.0-alpha.5 (2026-03-16) Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/ArcadeAI/arcade-java/compare/v0.1.0-alpha.4...v0.1.0-alpha.5) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f910db9..ed588bf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -40,7 +40,7 @@ Most tests require you to [run a mock server](https://github.com/stoplightio/pri ./scripts/mock --daemon ``` -The mock serer will run in the background allowing you to run tests from the command line `./gradlew test` or from your IDE. +The mock server will run in the background allowing you to run tests from the command line `./gradlew test` or from your IDE. To stop the mock server run: ```shell @@ -62,3 +62,22 @@ To format and fix all issues automatically: ```sh $ ./scripts/format ``` + +## Release and pull request process + +As mentioned above, most of the code in this repository is generated. So the pull requests process may different from what you are expecting. Here are the steps: + +- Custom code changes should target the `next` branch in [`ArcadeAI/arcade-java`](https://github.com/arcadeai/arcade-java). +- Be selective on what you are changing, as this may cause [merge conflicts](https://www.stainless.com/docs/sdks/configure/custom-code) with the generated code. +- Create a new pull request against `next`, CI will build and test it. +- Once it is merged to `next`, and when there have been upstream changes to the OpenAPI spec, you will see a pull request titled "release: " (where `` is the next version to be released) +- Review it, most of the changes will have been generated, make sure the changes from your pull request are included. +- Approve the PR, and merge it. + - The `next` branch will be rebased to `main`, so you will need to rewrite the branch, something like: `git fetch origin next && git reset --hard origin/next` +- Once changes are merged to `main` a CI job will deploy the version to [Maven Central](https://central.sonatype.com/search?q=arcade-java). There may be a delay between the time it is published until the time it shows up in the Maven Central search results. + +## Troubleshooting tips + +If you are running into issues deploying to Maven Central, run the [`Release Doctor`](https://github.com/ArcadeAI/arcade-java/actions/workflows/release-doctor.yml) CI job, this will check that the required environment variables are set correctly. + +The [`CI` workflow](https://github.com/ArcadeAI/arcade-java/blob/main/.github/workflows/ci.yml), includes a couple of `if` statments that look like: `github.repository == 'stainless-sdks/arcade-engine-java'`. These are ONLY used for pre-release builds when the Stainless SDK code is generated. These are NOT used currently (in the future if there are multiple Java project repositories, this Maven repository could be used to test nightly builds). Otherwise, [build from source](#building-the-repository-from-source). diff --git a/README.md b/README.md index e1b0ef4..624b6de 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/dev.arcade/arcade-java)](https://central.sonatype.com/artifact/dev.arcade/arcade-java/0.1.0-alpha.5) -[![javadoc](https://javadoc.io/badge2/dev.arcade/arcade-java/0.1.0-alpha.5/javadoc.svg)](https://javadoc.io/doc/dev.arcade/arcade-java/0.1.0-alpha.5) +[![Maven Central](https://img.shields.io/maven-central/v/dev.arcade/arcade-java)](https://central.sonatype.com/artifact/dev.arcade/arcade-java/0.1.0-alpha.6) +[![javadoc](https://javadoc.io/badge2/dev.arcade/arcade-java/0.1.0-alpha.6/javadoc.svg)](https://javadoc.io/doc/dev.arcade/arcade-java/0.1.0-alpha.6) @@ -13,7 +13,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [docs.arcade.dev](https://docs.arcade.dev). Javadocs are available on [javadoc.io](https://javadoc.io/doc/dev.arcade/arcade-java/0.1.0-alpha.5). +The REST API documentation can be found on [docs.arcade.dev](https://docs.arcade.dev). Javadocs are available on [javadoc.io](https://javadoc.io/doc/dev.arcade/arcade-java/0.1.0-alpha.6). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.arcade.dev](https://docs.arcade ### Gradle ```kotlin -implementation("dev.arcade:arcade-java:0.1.0-alpha.5") +implementation("dev.arcade:arcade-java:0.1.0-alpha.6") ``` ### Maven @@ -33,7 +33,7 @@ implementation("dev.arcade:arcade-java:0.1.0-alpha.5") dev.arcade arcade-java - 0.1.0-alpha.5 + 0.1.0-alpha.6 ``` diff --git a/arcade-java-core/src/main/kotlin/dev/arcade/core/ClientOptions.kt b/arcade-java-core/src/main/kotlin/dev/arcade/core/ClientOptions.kt index 65f5de9..4daef8f 100644 --- a/arcade-java-core/src/main/kotlin/dev/arcade/core/ClientOptions.kt +++ b/arcade-java-core/src/main/kotlin/dev/arcade/core/ClientOptions.kt @@ -453,13 +453,14 @@ private constructor( headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) + // We replace after all the default headers to allow end-users to overwrite them. + headers.replaceAll(this.headers.build()) + queryParams.replaceAll(this.queryParams.build()) apiKey.let { if (!it.isEmpty()) { - headers.put("Authorization", it) + headers.replace("Authorization", it) } } - headers.replaceAll(this.headers.build()) - queryParams.replaceAll(this.queryParams.build()) return ClientOptions( httpClient, diff --git a/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/ToolListParams.kt b/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/ToolListParams.kt index f5c8025..ad4ae18 100644 --- a/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/ToolListParams.kt +++ b/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/ToolListParams.kt @@ -14,9 +14,13 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Returns a page of tools from the engine configuration, optionally filtered by toolkit */ +/** + * Returns a page of tools from the engine configuration, optionally filtered by toolkit and/or + * metadata + */ class ToolListParams private constructor( + private val filter: String?, private val includeAllVersions: Boolean?, private val includeFormat: List?, private val limit: Long?, @@ -27,6 +31,13 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** + * JSON metadata filter. Array fields (service_domains, operations): shorthand array or object + * with any_of/all_of/none_of operators (case-insensitive). Boolean fields: read_only, + * destructive, idempotent, open_world. Extras: case-sensitive key-value subset match. + */ + fun filter(): Optional = Optional.ofNullable(filter) + /** Include all versions of each tool */ fun includeAllVersions(): Optional = Optional.ofNullable(includeAllVersions) @@ -64,6 +75,7 @@ private constructor( /** A builder for [ToolListParams]. */ class Builder internal constructor() { + private var filter: String? = null private var includeAllVersions: Boolean? = null private var includeFormat: MutableList? = null private var limit: Long? = null @@ -75,6 +87,7 @@ private constructor( @JvmSynthetic internal fun from(toolListParams: ToolListParams) = apply { + filter = toolListParams.filter includeAllVersions = toolListParams.includeAllVersions includeFormat = toolListParams.includeFormat?.toMutableList() limit = toolListParams.limit @@ -85,6 +98,17 @@ private constructor( additionalQueryParams = toolListParams.additionalQueryParams.toBuilder() } + /** + * JSON metadata filter. Array fields (service_domains, operations): shorthand array or + * object with any_of/all_of/none_of operators (case-insensitive). Boolean fields: + * read_only, destructive, idempotent, open_world. Extras: case-sensitive key-value subset + * match. + */ + fun filter(filter: String?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + /** Include all versions of each tool */ fun includeAllVersions(includeAllVersions: Boolean?) = apply { this.includeAllVersions = includeAllVersions @@ -266,6 +290,7 @@ private constructor( */ fun build(): ToolListParams = ToolListParams( + filter, includeAllVersions, includeFormat?.toImmutable(), limit, @@ -282,6 +307,7 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { + filter?.let { put("filter", it) } includeAllVersions?.let { put("include_all_versions", it.toString()) } includeFormat?.let { put("include_format", it.joinToString(",") { it.toString() }) } limit?.let { put("limit", it.toString()) } @@ -433,6 +459,7 @@ private constructor( } return other is ToolListParams && + filter == other.filter && includeAllVersions == other.includeAllVersions && includeFormat == other.includeFormat && limit == other.limit && @@ -445,6 +472,7 @@ private constructor( override fun hashCode(): Int = Objects.hash( + filter, includeAllVersions, includeFormat, limit, @@ -456,5 +484,5 @@ private constructor( ) override fun toString() = - "ToolListParams{includeAllVersions=$includeAllVersions, includeFormat=$includeFormat, limit=$limit, offset=$offset, toolkit=$toolkit, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ToolListParams{filter=$filter, includeAllVersions=$includeAllVersions, includeFormat=$includeFormat, limit=$limit, offset=$offset, toolkit=$toolkit, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/formatted/FormattedListParams.kt b/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/formatted/FormattedListParams.kt index 3112f34..4231263 100644 --- a/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/formatted/FormattedListParams.kt +++ b/arcade-java-core/src/main/kotlin/dev/arcade/models/tools/formatted/FormattedListParams.kt @@ -15,6 +15,7 @@ import kotlin.jvm.optionals.getOrNull */ class FormattedListParams private constructor( + private val filter: String?, private val format: String?, private val includeAllVersions: Boolean?, private val limit: Long?, @@ -25,6 +26,13 @@ private constructor( private val additionalQueryParams: QueryParams, ) : Params { + /** + * JSON metadata filter. Array fields (service_domains, operations): shorthand array or object + * with any_of/all_of/none_of operators (case-insensitive). Boolean fields: read_only, + * destructive, idempotent, open_world. Extras: case-sensitive key-value subset match. + */ + fun filter(): Optional = Optional.ofNullable(filter) + /** Provider format */ fun format(): Optional = Optional.ofNullable(format) @@ -62,6 +70,7 @@ private constructor( /** A builder for [FormattedListParams]. */ class Builder internal constructor() { + private var filter: String? = null private var format: String? = null private var includeAllVersions: Boolean? = null private var limit: Long? = null @@ -73,6 +82,7 @@ private constructor( @JvmSynthetic internal fun from(formattedListParams: FormattedListParams) = apply { + filter = formattedListParams.filter format = formattedListParams.format includeAllVersions = formattedListParams.includeAllVersions limit = formattedListParams.limit @@ -83,6 +93,17 @@ private constructor( additionalQueryParams = formattedListParams.additionalQueryParams.toBuilder() } + /** + * JSON metadata filter. Array fields (service_domains, operations): shorthand array or + * object with any_of/all_of/none_of operators (case-insensitive). Boolean fields: + * read_only, destructive, idempotent, open_world. Extras: case-sensitive key-value subset + * match. + */ + fun filter(filter: String?) = apply { this.filter = filter } + + /** Alias for calling [Builder.filter] with `filter.orElse(null)`. */ + fun filter(filter: Optional) = filter(filter.getOrNull()) + /** Provider format */ fun format(format: String?) = apply { this.format = format } @@ -251,6 +272,7 @@ private constructor( */ fun build(): FormattedListParams = FormattedListParams( + filter, format, includeAllVersions, limit, @@ -267,6 +289,7 @@ private constructor( override fun _queryParams(): QueryParams = QueryParams.builder() .apply { + filter?.let { put("filter", it) } format?.let { put("format", it) } includeAllVersions?.let { put("include_all_versions", it.toString()) } limit?.let { put("limit", it.toString()) } @@ -283,6 +306,7 @@ private constructor( } return other is FormattedListParams && + filter == other.filter && format == other.format && includeAllVersions == other.includeAllVersions && limit == other.limit && @@ -295,6 +319,7 @@ private constructor( override fun hashCode(): Int = Objects.hash( + filter, format, includeAllVersions, limit, @@ -306,5 +331,5 @@ private constructor( ) override fun toString() = - "FormattedListParams{format=$format, includeAllVersions=$includeAllVersions, limit=$limit, offset=$offset, toolkit=$toolkit, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FormattedListParams{filter=$filter, format=$format, includeAllVersions=$includeAllVersions, limit=$limit, offset=$offset, toolkit=$toolkit, userId=$userId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/arcade-java-core/src/main/kotlin/dev/arcade/models/workers/WorkerResponse.kt b/arcade-java-core/src/main/kotlin/dev/arcade/models/workers/WorkerResponse.kt index 51843b5..45ff0b1 100644 --- a/arcade-java-core/src/main/kotlin/dev/arcade/models/workers/WorkerResponse.kt +++ b/arcade-java-core/src/main/kotlin/dev/arcade/models/workers/WorkerResponse.kt @@ -1297,8 +1297,10 @@ private constructor( class Mcp @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val externalId: JsonField, private val headers: JsonField, private val oauth2: JsonField, + private val redirectUri: JsonField, private val retry: JsonField, private val secrets: JsonField, private val timeout: JsonField, @@ -1308,13 +1310,35 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("external_id") + @ExcludeMissing + externalId: JsonField = JsonMissing.of(), @JsonProperty("headers") @ExcludeMissing headers: JsonField = JsonMissing.of(), @JsonProperty("oauth2") @ExcludeMissing oauth2: JsonField = JsonMissing.of(), + @JsonProperty("redirect_uri") + @ExcludeMissing + redirectUri: JsonField = JsonMissing.of(), @JsonProperty("retry") @ExcludeMissing retry: JsonField = JsonMissing.of(), @JsonProperty("secrets") @ExcludeMissing secrets: JsonField = JsonMissing.of(), @JsonProperty("timeout") @ExcludeMissing timeout: JsonField = JsonMissing.of(), @JsonProperty("uri") @ExcludeMissing uri: JsonField = JsonMissing.of(), - ) : this(headers, oauth2, retry, secrets, timeout, uri, mutableMapOf()) + ) : this( + externalId, + headers, + oauth2, + redirectUri, + retry, + secrets, + timeout, + uri, + mutableMapOf(), + ) + + /** + * @throws ArcadeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalId(): Optional = externalId.getOptional("external_id") /** * @throws ArcadeInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -1328,6 +1352,12 @@ private constructor( */ fun oauth2(): Optional = oauth2.getOptional("oauth2") + /** + * @throws ArcadeInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun redirectUri(): Optional = redirectUri.getOptional("redirect_uri") + /** * @throws ArcadeInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1352,6 +1382,15 @@ private constructor( */ fun uri(): Optional = uri.getOptional("uri") + /** + * Returns the raw JSON value of [externalId]. + * + * Unlike [externalId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_id") + @ExcludeMissing + fun _externalId(): JsonField = externalId + /** * Returns the raw JSON value of [headers]. * @@ -1366,6 +1405,15 @@ private constructor( */ @JsonProperty("oauth2") @ExcludeMissing fun _oauth2(): JsonField = oauth2 + /** + * Returns the raw JSON value of [redirectUri]. + * + * Unlike [redirectUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("redirect_uri") + @ExcludeMissing + fun _redirectUri(): JsonField = redirectUri + /** * Returns the raw JSON value of [retry]. * @@ -1415,8 +1463,10 @@ private constructor( /** A builder for [Mcp]. */ class Builder internal constructor() { + private var externalId: JsonField = JsonMissing.of() private var headers: JsonField = JsonMissing.of() private var oauth2: JsonField = JsonMissing.of() + private var redirectUri: JsonField = JsonMissing.of() private var retry: JsonField = JsonMissing.of() private var secrets: JsonField = JsonMissing.of() private var timeout: JsonField = JsonMissing.of() @@ -1425,8 +1475,10 @@ private constructor( @JvmSynthetic internal fun from(mcp: Mcp) = apply { + externalId = mcp.externalId headers = mcp.headers oauth2 = mcp.oauth2 + redirectUri = mcp.redirectUri retry = mcp.retry secrets = mcp.secrets timeout = mcp.timeout @@ -1434,6 +1486,17 @@ private constructor( additionalProperties = mcp.additionalProperties.toMutableMap() } + fun externalId(externalId: String) = externalId(JsonField.of(externalId)) + + /** + * Sets [Builder.externalId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + fun headers(headers: Headers) = headers(JsonField.of(headers)) /** @@ -1456,6 +1519,19 @@ private constructor( */ fun oauth2(oauth2: JsonField) = apply { this.oauth2 = oauth2 } + fun redirectUri(redirectUri: String) = redirectUri(JsonField.of(redirectUri)) + + /** + * Sets [Builder.redirectUri] to an arbitrary JSON value. + * + * You should usually call [Builder.redirectUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun redirectUri(redirectUri: JsonField) = apply { + this.redirectUri = redirectUri + } + fun retry(retry: Long) = retry(JsonField.of(retry)) /** @@ -1526,8 +1602,10 @@ private constructor( */ fun build(): Mcp = Mcp( + externalId, headers, oauth2, + redirectUri, retry, secrets, timeout, @@ -1543,8 +1621,10 @@ private constructor( return@apply } + externalId() headers().ifPresent { it.validate() } oauth2().ifPresent { it.validate() } + redirectUri() retry() secrets().ifPresent { it.validate() } timeout() @@ -1568,8 +1648,10 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (headers.asKnown().getOrNull()?.validity() ?: 0) + + (if (externalId.asKnown().isPresent) 1 else 0) + + (headers.asKnown().getOrNull()?.validity() ?: 0) + (oauth2.asKnown().getOrNull()?.validity() ?: 0) + + (if (redirectUri.asKnown().isPresent) 1 else 0) + (if (retry.asKnown().isPresent) 1 else 0) + (secrets.asKnown().getOrNull()?.validity() ?: 0) + (if (timeout.asKnown().isPresent) 1 else 0) + @@ -2572,8 +2654,10 @@ private constructor( } return other is Mcp && + externalId == other.externalId && headers == other.headers && oauth2 == other.oauth2 && + redirectUri == other.redirectUri && retry == other.retry && secrets == other.secrets && timeout == other.timeout && @@ -2582,13 +2666,23 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(headers, oauth2, retry, secrets, timeout, uri, additionalProperties) + Objects.hash( + externalId, + headers, + oauth2, + redirectUri, + retry, + secrets, + timeout, + uri, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Mcp{headers=$headers, oauth2=$oauth2, retry=$retry, secrets=$secrets, timeout=$timeout, uri=$uri, additionalProperties=$additionalProperties}" + "Mcp{externalId=$externalId, headers=$headers, oauth2=$oauth2, redirectUri=$redirectUri, retry=$retry, secrets=$secrets, timeout=$timeout, uri=$uri, additionalProperties=$additionalProperties}" } class Requirements diff --git a/arcade-java-core/src/main/kotlin/dev/arcade/services/async/ToolServiceAsync.kt b/arcade-java-core/src/main/kotlin/dev/arcade/services/async/ToolServiceAsync.kt index 4a773b7..c59e0f6 100644 --- a/arcade-java-core/src/main/kotlin/dev/arcade/services/async/ToolServiceAsync.kt +++ b/arcade-java-core/src/main/kotlin/dev/arcade/services/async/ToolServiceAsync.kt @@ -38,7 +38,10 @@ interface ToolServiceAsync { fun formatted(): FormattedServiceAsync - /** Returns a page of tools from the engine configuration, optionally filtered by toolkit */ + /** + * Returns a page of tools from the engine configuration, optionally filtered by toolkit and/or + * metadata + */ fun list(): CompletableFuture = list(ToolListParams.none()) /** @see list */ diff --git a/arcade-java-core/src/main/kotlin/dev/arcade/services/blocking/ToolService.kt b/arcade-java-core/src/main/kotlin/dev/arcade/services/blocking/ToolService.kt index 22a6d53..c10f1fa 100644 --- a/arcade-java-core/src/main/kotlin/dev/arcade/services/blocking/ToolService.kt +++ b/arcade-java-core/src/main/kotlin/dev/arcade/services/blocking/ToolService.kt @@ -38,7 +38,10 @@ interface ToolService { fun formatted(): FormattedService - /** Returns a page of tools from the engine configuration, optionally filtered by toolkit */ + /** + * Returns a page of tools from the engine configuration, optionally filtered by toolkit and/or + * metadata + */ fun list(): ToolListPage = list(ToolListParams.none()) /** @see list */ diff --git a/arcade-java-core/src/test/kotlin/dev/arcade/core/ClientOptionsTest.kt b/arcade-java-core/src/test/kotlin/dev/arcade/core/ClientOptionsTest.kt index 8a79f69..10e787e 100644 --- a/arcade-java-core/src/test/kotlin/dev/arcade/core/ClientOptionsTest.kt +++ b/arcade-java-core/src/test/kotlin/dev/arcade/core/ClientOptionsTest.kt @@ -16,6 +16,29 @@ internal class ClientOptionsTest { private val httpClient = mock() + @Test + fun putHeader_canOverwriteDefaultHeader() { + val clientOptions = + ClientOptions.builder() + .httpClient(httpClient) + .putHeader("User-Agent", "My User Agent") + .apiKey("My API Key") + .build() + + assertThat(clientOptions.headers.values("User-Agent")).containsExactly("My User Agent") + } + + @Test + fun toBuilder_bearerCanBeUpdated() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).apiKey("My API Key").build() + + clientOptions = clientOptions.toBuilder().apiKey("another My API Key").build() + + assertThat(clientOptions.headers.values("Authorization")) + .containsExactly("another My API Key") + } + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { var clientOptions = diff --git a/arcade-java-core/src/test/kotlin/dev/arcade/core/http/RetryingHttpClientTest.kt b/arcade-java-core/src/test/kotlin/dev/arcade/core/http/RetryingHttpClientTest.kt index 1e64d8e..b7a4609 100644 --- a/arcade-java-core/src/test/kotlin/dev/arcade/core/http/RetryingHttpClientTest.kt +++ b/arcade-java-core/src/test/kotlin/dev/arcade/core/http/RetryingHttpClientTest.kt @@ -400,9 +400,9 @@ internal class RetryingHttpClientTest { assertThat(sleeper.durations).hasSize(3) // retries=1: 0.5s * [0.75, 1.0] assertThat(sleeper.durations[0]).isBetween(Duration.ofMillis(375), Duration.ofMillis(500)) - // retries=2: 1.0s * [0.75, 1.0] + // retries=2: 1s * [0.75, 1.0] assertThat(sleeper.durations[1]).isBetween(Duration.ofMillis(750), Duration.ofMillis(1000)) - // retries=3: 2.0s * [0.75, 1.0] + // retries=3: 2s * [0.75, 1.0] assertThat(sleeper.durations[2]).isBetween(Duration.ofMillis(1500), Duration.ofMillis(2000)) assertNoResponseLeaks() } @@ -427,9 +427,9 @@ internal class RetryingHttpClientTest { assertThat(response.statusCode()).isEqualTo(503) verify(7, postRequestedFor(urlPathEqualTo("/something"))) assertThat(sleeper.durations).hasSize(6) - // retries=5: min(0.5 * 2^4, 8) = 8.0s * [0.75, 1.0] + // retries=5: backoff hits the 8s cap * [0.75, 1.0] assertThat(sleeper.durations[4]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) - // retries=6: min(0.5 * 2^5, 8) = min(16, 8) = 8.0s * [0.75, 1.0] (capped) + // retries=6: still capped at 8s * [0.75, 1.0] assertThat(sleeper.durations[5]).isBetween(Duration.ofMillis(6000), Duration.ofMillis(8000)) assertNoResponseLeaks() } diff --git a/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/ToolListParamsTest.kt b/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/ToolListParamsTest.kt index 2c07652..9f3f267 100644 --- a/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/ToolListParamsTest.kt +++ b/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/ToolListParamsTest.kt @@ -11,6 +11,7 @@ internal class ToolListParamsTest { @Test fun create() { ToolListParams.builder() + .filter("filter") .includeAllVersions(true) .addIncludeFormat(ToolListParams.IncludeFormat.ARCADE) .limit(0L) @@ -24,6 +25,7 @@ internal class ToolListParamsTest { fun queryParams() { val params = ToolListParams.builder() + .filter("filter") .includeAllVersions(true) .addIncludeFormat(ToolListParams.IncludeFormat.ARCADE) .limit(0L) @@ -37,6 +39,7 @@ internal class ToolListParamsTest { assertThat(queryParams) .isEqualTo( QueryParams.builder() + .put("filter", "filter") .put("include_all_versions", "true") .put("include_format", listOf("arcade").joinToString(",")) .put("limit", "0") diff --git a/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/formatted/FormattedListParamsTest.kt b/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/formatted/FormattedListParamsTest.kt index 48d2dad..06a3344 100644 --- a/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/formatted/FormattedListParamsTest.kt +++ b/arcade-java-core/src/test/kotlin/dev/arcade/models/tools/formatted/FormattedListParamsTest.kt @@ -11,6 +11,7 @@ internal class FormattedListParamsTest { @Test fun create() { FormattedListParams.builder() + .filter("filter") .format("format") .includeAllVersions(true) .limit(0L) @@ -24,6 +25,7 @@ internal class FormattedListParamsTest { fun queryParams() { val params = FormattedListParams.builder() + .filter("filter") .format("format") .includeAllVersions(true) .limit(0L) @@ -37,6 +39,7 @@ internal class FormattedListParamsTest { assertThat(queryParams) .isEqualTo( QueryParams.builder() + .put("filter", "filter") .put("format", "format") .put("include_all_versions", "true") .put("limit", "0") diff --git a/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerListPageResponseTest.kt b/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerListPageResponseTest.kt index bfe4dee..36db9bd 100644 --- a/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerListPageResponseTest.kt +++ b/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerListPageResponseTest.kt @@ -43,6 +43,7 @@ internal class WorkerListPageResponseTest { .managed(true) .mcp( WorkerResponse.Mcp.builder() + .externalId("external_id") .headers( WorkerResponse.Mcp.Headers.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -68,6 +69,7 @@ internal class WorkerListPageResponseTest { .addSupportedScope("string") .build() ) + .redirectUri("redirect_uri") .retry(0L) .secrets( WorkerResponse.Mcp.Secrets.builder() @@ -142,6 +144,7 @@ internal class WorkerListPageResponseTest { .managed(true) .mcp( WorkerResponse.Mcp.builder() + .externalId("external_id") .headers( WorkerResponse.Mcp.Headers.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -167,6 +170,7 @@ internal class WorkerListPageResponseTest { .addSupportedScope("string") .build() ) + .redirectUri("redirect_uri") .retry(0L) .secrets( WorkerResponse.Mcp.Secrets.builder() @@ -244,6 +248,7 @@ internal class WorkerListPageResponseTest { .managed(true) .mcp( WorkerResponse.Mcp.builder() + .externalId("external_id") .headers( WorkerResponse.Mcp.Headers.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -269,6 +274,7 @@ internal class WorkerListPageResponseTest { .addSupportedScope("string") .build() ) + .redirectUri("redirect_uri") .retry(0L) .secrets( WorkerResponse.Mcp.Secrets.builder() diff --git a/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerResponseTest.kt b/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerResponseTest.kt index c280d01..bf49033 100644 --- a/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerResponseTest.kt +++ b/arcade-java-core/src/test/kotlin/dev/arcade/models/workers/WorkerResponseTest.kt @@ -40,6 +40,7 @@ internal class WorkerResponseTest { .managed(true) .mcp( WorkerResponse.Mcp.builder() + .externalId("external_id") .headers( WorkerResponse.Mcp.Headers.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -64,6 +65,7 @@ internal class WorkerResponseTest { .addSupportedScope("string") .build() ) + .redirectUri("redirect_uri") .retry(0L) .secrets( WorkerResponse.Mcp.Secrets.builder() @@ -131,6 +133,7 @@ internal class WorkerResponseTest { assertThat(workerResponse.mcp()) .contains( WorkerResponse.Mcp.builder() + .externalId("external_id") .headers( WorkerResponse.Mcp.Headers.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -153,6 +156,7 @@ internal class WorkerResponseTest { .addSupportedScope("string") .build() ) + .redirectUri("redirect_uri") .retry(0L) .secrets( WorkerResponse.Mcp.Secrets.builder() @@ -223,6 +227,7 @@ internal class WorkerResponseTest { .managed(true) .mcp( WorkerResponse.Mcp.builder() + .externalId("external_id") .headers( WorkerResponse.Mcp.Headers.builder() .putAdditionalProperty("foo", JsonValue.from("string")) @@ -247,6 +252,7 @@ internal class WorkerResponseTest { .addSupportedScope("string") .build() ) + .redirectUri("redirect_uri") .retry(0L) .secrets( WorkerResponse.Mcp.Secrets.builder() diff --git a/build.gradle.kts b/build.gradle.kts index 2348249..59c4067 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "dev.arcade" - version = "0.1.0-alpha.5" // x-release-please-version + version = "0.1.0-alpha.6" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/arcade.kotlin.gradle.kts b/buildSrc/src/main/kotlin/arcade.kotlin.gradle.kts index 08c21f3..1fa9c32 100644 --- a/buildSrc/src/main/kotlin/arcade.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/arcade.kotlin.gradle.kts @@ -40,7 +40,7 @@ tasks.withType().configureEach { val ktfmt by configurations.creating dependencies { - ktfmt("com.facebook:ktfmt:0.56") + ktfmt("com.facebook:ktfmt:0.61") } fun registerKtfmt( diff --git a/scripts/fast-format b/scripts/fast-format index 1b3bc47..35a1dee 100755 --- a/scripts/fast-format +++ b/scripts/fast-format @@ -24,8 +24,8 @@ if [ ! -f "$FILE_LIST" ]; then exit 1 fi -if ! command -v ktfmt-fast-format &> /dev/null; then - echo "Error: ktfmt-fast-format not found" +if ! command -v ktfmt &> /dev/null; then + echo "Error: ktfmt not found" exit 1 fi @@ -36,7 +36,7 @@ echo "==> Done looking for Kotlin files" if [[ -n "$kt_files" ]]; then echo "==> will format Kotlin files" - echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt-fast-format --kotlinlang-style "$@" + echo "$kt_files" | tr '\n' '\0' | xargs -0 ktfmt --kotlinlang-style "$@" else echo "No Kotlin files to format -- expected outcome during incremental formatting" fi diff --git a/scripts/mock b/scripts/mock index bcf3b39..5cd7c15 100755 --- a/scripts/mock +++ b/scripts/mock @@ -19,34 +19,34 @@ fi echo "==> Starting mock server with URL ${URL}" -# Run prism mock on the given spec +# Run steady mock on the given spec if [ "$1" == "--daemon" ]; then # Pre-install the package so the download doesn't eat into the startup timeout - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version + npm exec --package=@stdy/cli@0.20.2 -- steady --version - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & - # Wait for server to come online (max 30s) + # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" attempts=0 - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do + if ! kill -0 $! 2>/dev/null; then + echo + cat .stdy.log + exit 1 + fi attempts=$((attempts + 1)) if [ "$attempts" -ge 300 ]; then echo - echo "Timed out waiting for Prism server to start" - cat .prism.log + echo "Timed out waiting for Steady server to start" + cat .stdy.log exit 1 fi echo -n "." sleep 0.1 done - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - echo else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index 047bc1d..61c1163 100755 --- a/scripts/test +++ b/scripts/test @@ -9,8 +9,8 @@ GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 +function steady_is_running() { + curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1 } kill_server_on_port() { @@ -25,7 +25,7 @@ function is_overriding_api_base_url() { [ -n "$TEST_API_BASE_URL" ] } -if ! is_overriding_api_base_url && ! prism_is_running ; then +if ! is_overriding_api_base_url && ! steady_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT @@ -36,19 +36,19 @@ fi if is_overriding_api_base_url ; then echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" +elif ! steady_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" + echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}" echo fi