Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cyclops-sdk): make HttpRequest.timeout_secs optional and add HttpRequestBuilder (#6998)

r33drichards13b21db48d1f
diff --git a/libs/fleet/scripts/generate-sdk-bindings.sh b/libs/fleet/scripts/generate-sdk-bindings.sh
index 39b98681e5..44937b8e0e 100755
--- a/libs/fleet/scripts/generate-sdk-bindings.sh
+++ b/libs/fleet/scripts/generate-sdk-bindings.sh
@@ -844,8 +844,8 @@ def replace_buffer(match):
text, buffer_replacements = re.subn(buffer_pattern, replace_buffer, text)
if buffer_replacements != 23:
raise SystemExit(f"expected 23 Ruby Rust-buffer future wrappers, found {buffer_replacements}")
-if len(re.findall(r"result = FleetSdk\.rust_call_with_error\(SdkBuildError,:uniffi_[a-z0-9_]*builder_build,", text)) != 6:
- raise SystemExit("expected six synchronous Ruby SDK builder build calls")
+if len(re.findall(r"result = FleetSdk\.rust_call_with_error\(SdkBuildError,:uniffi_[a-z0-9_]*builder_build,", text)) != 7:
+ raise SystemExit("expected seven synchronous Ruby SDK builder build calls")
void_pattern = r"(?m)^(\s*)FleetSdk\.rust_call_with_error\(([^,]+),:([a-z0-9_]+),(.*)\)$"
def replace_void(match):
diff --git a/libs/fleet/sdk-bindings/examples/python/live_app_controlled.py b/libs/fleet/sdk-bindings/examples/python/live_app_controlled.py
index 1b286716b2..0b08251646 100755
--- a/libs/fleet/sdk-bindings/examples/python/live_app_controlled.py
+++ b/libs/fleet/sdk-bindings/examples/python/live_app_controlled.py
@@ -11,7 +11,7 @@ from fleet_sdk import (
CyclopsConfiguration,
CyclopsCredentials,
HttpHeader,
- HttpRequest,
+ HttpRequestBuilder,
OsGymSandboxTemplateSpec,
OsGymSandboxWarmPoolSpec,
SandboxService,
@@ -70,16 +70,17 @@ async def initialize_mcp(client: CyclopsClient, sandbox) -> int:
sandbox,
"mcp",
"/mcp",
- HttpRequest(
- method="POST",
- url="https://ignored.invalid/mcp",
- headers=[
+ HttpRequestBuilder()
+ .method("POST")
+ .url("https://ignored.invalid/mcp")
+ .headers(
+ [
HttpHeader(name="accept", value="application/json, text/event-stream"),
HttpHeader(name="content-type", value="application/json"),
- ],
- body=body,
- timeout_secs=None,
- ),
+ ]
+ )
+ .body(body)
+ .build(),
)
if 200 <= response.status < 300:
return response.status
diff --git a/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb b/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb
index 913ffd187d..6e4cad4157 100644
--- a/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb
+++ b/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb
@@ -50,7 +50,7 @@ client = FleetSdk::CyclopsClient.connect(FleetSdk::CyclopsConfiguration.new(base
pool = client.create_pool(FleetSdk::CreatePoolRequest.new(namespace: 'default', spec: spec))
claim = client.create_claim(FleetSdk::CreateClaimRequest.new(pool: pool, spec: FleetSdk::ClaimSpec.new(sandbox_template_ref: FleetSdk::SandboxTemplateRef.new(name: pool.metadata.name), warmpool: nil, bind_deadline: nil, lifecycle: nil)))
sandbox = client.wait_claim(claim)
-service = client.service_request(sandbox, 'mcp', '/mcp', FleetSdk::HttpRequest.new(method: 'POST', url: 'https://ignored.invalid/mcp', headers: [], body: '{"offline":true}'.b, timeout_secs: nil))
+service = client.service_request(sandbox, 'mcp', '/mcp', FleetSdk::HttpRequestBuilder.new.method('POST').url('https://ignored.invalid/mcp').headers([]).body('{"offline":true}'.b).build)
client.delete_claim(claim)
client.delete_pool(pool)
transport.assert_exhausted!
diff --git a/libs/fleet/sdk-bindings/examples/ruby/live_app_controlled.rb b/libs/fleet/sdk-bindings/examples/ruby/live_app_controlled.rb
index 3cef4c4306..0cbc683a4a 100755
--- a/libs/fleet/sdk-bindings/examples/ruby/live_app_controlled.rb
+++ b/libs/fleet/sdk-bindings/examples/ruby/live_app_controlled.rb
@@ -32,7 +32,7 @@ def initialize_mcp(client, sandbox)
body = JSON.generate(jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2025-03-26', capabilities: {}, clientInfo: { name: 'cyclops-uniffi-ruby', version: '0.1.0' } }).b
deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + 300
loop do
- response = client.service_request(sandbox, 'mcp', '/mcp', FleetSdk::HttpRequest.new(method: 'POST', url: 'https://ignored.invalid/mcp', headers: [FleetSdk::HttpHeader.new(name: 'accept', value: 'application/json, text/event-stream'), FleetSdk::HttpHeader.new(name: 'content-type', value: 'application/json')], body: body, timeout_secs: nil))
+ response = client.service_request(sandbox, 'mcp', '/mcp', FleetSdk::HttpRequestBuilder.new.method('POST').url('https://ignored.invalid/mcp').headers([FleetSdk::HttpHeader.new(name: 'accept', value: 'application/json, text/event-stream'), FleetSdk::HttpHeader.new(name: 'content-type', value: 'application/json')]).body(body).build)
return response.status if response.status.between?(200, 299)
if [502, 503, 504].include?(response.status) && Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadline
sleep 5
diff --git a/libs/fleet/sdk-bindings/kotlin/ai/cua/cyclops/sdk/fleet_sdk.kt b/libs/fleet/sdk-bindings/kotlin/ai/cua/cyclops/sdk/fleet_sdk.kt
index 9291bddfca..7a55af2a76 100644
--- a/libs/fleet/sdk-bindings/kotlin/ai/cua/cyclops/sdk/fleet_sdk.kt
+++ b/libs/fleet/sdk-bindings/kotlin/ai/cua/cyclops/sdk/fleet_sdk.kt
@@ -798,6 +798,18 @@ internal object IntegrityCheckingUniffiLib {
): Short
external fun uniffi_cyclops_sdk_checksum_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit(
): Short
+ external fun uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body(
+ ): Short
+ external fun uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build(
+ ): Short
+ external fun uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers(
+ ): Short
+ external fun uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method(
+ ): Short
+ external fun uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs(
+ ): Short
+ external fun uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url(
+ ): Short
external fun uniffi_cyclops_sdk_checksum_method_templatebuilder_api_version(
): Short
external fun uniffi_cyclops_sdk_checksum_method_templatebuilder_build(
@@ -834,6 +846,8 @@ internal object IntegrityCheckingUniffiLib {
): Short
external fun uniffi_cyclops_sdk_checksum_constructor_cyclopstokenproviderconfigurationbuilder_new(
): Short
+ external fun uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new(
+ ): Short
external fun uniffi_cyclops_sdk_checksum_constructor_templatebuilder_new(
): Short
external fun ffi_cyclops_sdk_uniffi_contract_version(
@@ -1019,6 +1033,24 @@ external fun uniffi_cyclops_sdk_fn_method_cyclopstokenproviderconfigurationbuild
): Long
external fun uniffi_cyclops_sdk_fn_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit(`ptr`: Long,`value`: Int,uniffi_out_err: UniffiRustCallStatus,
): Long
+external fun uniffi_cyclops_sdk_fn_clone_httprequestbuilder(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
+): Long
+external fun uniffi_cyclops_sdk_fn_free_httprequestbuilder(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
+): Unit
+external fun uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new(uniffi_out_err: UniffiRustCallStatus,
+): Long
+external fun uniffi_cyclops_sdk_fn_method_httprequestbuilder_body(`ptr`: Long,`value`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
+): Long
+external fun uniffi_cyclops_sdk_fn_method_httprequestbuilder_build(`ptr`: Long,uniffi_out_err: UniffiRustCallStatus,
+): RustBuffer.ByValue
+external fun uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers(`ptr`: Long,`value`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
+): Long
+external fun uniffi_cyclops_sdk_fn_method_httprequestbuilder_method(`ptr`: Long,`value`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
+): Long
+external fun uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs(`ptr`: Long,`value`: Long,uniffi_out_err: UniffiRustCallStatus,
+): Long
+external fun uniffi_cyclops_sdk_fn_method_httprequestbuilder_url(`ptr`: Long,`value`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
+): Long
external fun uniffi_cyclops_sdk_fn_clone_templatebuilder(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
): Long
external fun uniffi_cyclops_sdk_fn_free_templatebuilder(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
@@ -1298,6 +1330,24 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
if (lib.uniffi_cyclops_sdk_checksum_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit() != 6865.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
+ if (lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body() != 9054.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
+ if (lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build() != 14573.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
+ if (lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers() != 19982.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
+ if (lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method() != 4078.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
+ if (lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs() != 40941.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
+ if (lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url() != 12282.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
if (lib.uniffi_cyclops_sdk_checksum_method_templatebuilder_api_version() != 65471.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
@@ -1352,6 +1402,9 @@ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
if (lib.uniffi_cyclops_sdk_checksum_constructor_cyclopstokenproviderconfigurationbuilder_new() != 43069.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
+ if (lib.uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new() != 25892.toShort()) {
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ }
if (lib.uniffi_cyclops_sdk_checksum_constructor_templatebuilder_new() != 19815.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
@@ -5307,6 +5360,340 @@ public object FfiConverterTypeHttpClient: FfiConverter<HttpClient, Long> {
//
+public interface HttpRequestBuilderInterface {
+
+ fun `body`(`value`: kotlin.ByteArray): HttpRequestBuilder
+
+ fun `build`(): HttpRequest
+
+ fun `headers`(`value`: List<HttpHeader>): HttpRequestBuilder
+
+ fun `method`(`value`: kotlin.String): HttpRequestBuilder
+
+ fun `timeoutSecs`(`value`: kotlin.ULong): HttpRequestBuilder
+
+ fun `url`(`value`: kotlin.String): HttpRequestBuilder
+
+ companion object
+}
+
+open class HttpRequestBuilder: Disposable, AutoCloseable, HttpRequestBuilderInterface
+{
+
+ @Suppress("UNUSED_PARAMETER")
+ /**
+ * @suppress
+ */
+ constructor(withHandle: UniffiWithHandle, handle: Long) {
+ this.handle = handle
+ this.cleanable = UniffiLib.CLEANER.register(this, UniffiCleanAction(handle))
+ }
+
+ /**
+ * @suppress
+ *
+ * This constructor can be used to instantiate a fake object. Only used for tests. Any
+ * attempt to actually use an object constructed this way will fail as there is no
+ * connected Rust object.
+ */
+ @Suppress("UNUSED_PARAMETER")
+ constructor(noHandle: NoHandle) {
+ this.handle = 0
+ this.cleanable = null
+ }
+ constructor() :
+ this(UniffiWithHandle,
+ uniffiRustCall() { _status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new(
+
+ _status)
+}
+ )
+
+ protected val handle: Long
+ protected val cleanable: UniffiCleaner.Cleanable?
+
+ private val wasDestroyed = AtomicBoolean(false)
+ private val callCounter = AtomicLong(1)
+
+ override fun destroy() {
+ // Only allow a single call to this method.
+ // TODO: maybe we should log a warning if called more than once?
+ if (this.wasDestroyed.compareAndSet(false, true)) {
+ // This decrement always matches the initial count of 1 given at creation time.
+ if (this.callCounter.decrementAndGet() == 0L) {
+ cleanable?.clean()
+ }
+ }
+ }
+
+ @Synchronized
+ override fun close() {
+ this.destroy()
+ }
+
+ internal inline fun <R> callWithHandle(block: (handle: Long) -> R): R {
+ // Check and increment the call counter, to keep the object alive.
+ // This needs a compare-and-set retry loop in case of concurrent updates.
+ do {
+ val c = this.callCounter.get()
+ if (c == 0L) {
+ throw IllegalStateException("${this.javaClass.simpleName} object has already been destroyed")
+ }
+ if (c == Long.MAX_VALUE) {
+ throw IllegalStateException("${this.javaClass.simpleName} call counter would overflow")
+ }
+ } while (! this.callCounter.compareAndSet(c, c + 1L))
+ // Now we can safely do the method call without the handle being freed concurrently.
+ try {
+ return block(this.uniffiCloneHandle())
+ } finally {
+ // This decrement always matches the increment we performed above.
+ if (this.callCounter.decrementAndGet() == 0L) {
+ cleanable?.clean()
+ }
+ }
+ }
+
+ // Use a static inner class instead of a closure so as not to accidentally
+ // capture `this` as part of the cleanable's action.
+ private class UniffiCleanAction(private val handle: Long) : Runnable {
+ override fun run() {
+ if (handle == 0.toLong()) {
+ // Fake object created with `NoHandle`, don't try to free.
+ return;
+ }
+ uniffiRustCall { status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_free_httprequestbuilder(handle, status)
+ }
+ }
+ }
+
+ /**
+ * @suppress
+ */
+ fun uniffiCloneHandle(): Long {
+ if (handle == 0.toLong()) {
+ throw InternalException("uniffiCloneHandle() called on NoHandle object");
+ }
+ return uniffiRustCall() { status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_clone_httprequestbuilder(handle, status)
+ }
+ }
+
+ override fun `body`(`value`: kotlin.ByteArray): HttpRequestBuilder {
+ return FfiConverterTypeHttpRequestBuilder.lift(
+ callWithHandle {
+ uniffiRustCall() { _status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_body(
+ it,
+ FfiConverterByteArray.lower(`value`),_status)
+}
+ }
+ )
+ }
+
+
+
+ @Throws(SdkBuildException::class)override fun `build`(): HttpRequest {
+ return FfiConverterTypeHttpRequest.lift(
+ callWithHandle {
+ uniffiRustCallWithError(SdkBuildException) { _status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_build(
+ it,
+ _status)
+}
+ }
+ )
+ }
+
+
+ override fun `headers`(`value`: List<HttpHeader>): HttpRequestBuilder {
+ return FfiConverterTypeHttpRequestBuilder.lift(
+ callWithHandle {
+ uniffiRustCall() { _status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers(
+ it,
+ FfiConverterSequenceTypeHttpHeader.lower(`value`),_status)
+}
+ }
+ )
+ }
+
+
+ override fun `method`(`value`: kotlin.String): HttpRequestBuilder {
+ return FfiConverterTypeHttpRequestBuilder.lift(
+ callWithHandle {
+ uniffiRustCall() { _status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_method(
+ it,
+ FfiConverterString.lower(`value`),_status)
+}
+ }
+ )
+ }
+
+
+ override fun `timeoutSecs`(`value`: kotlin.ULong): HttpRequestBuilder {
+ return FfiConverterTypeHttpRequestBuilder.lift(
+ callWithHandle {
+ uniffiRustCall() { _status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs(
+ it,
+ FfiConverterULong.lower(`value`),_status)
+}
+ }
+ )
+ }
+
+
+ override fun `url`(`value`: kotlin.String): HttpRequestBuilder {
+ return FfiConverterTypeHttpRequestBuilder.lift(
+ callWithHandle {
+ uniffiRustCall() { _status ->
+ UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_url(
+ it,
+ FfiConverterString.lower(`value`),_status)
+}
+ }
+ )
+ }
+
+
+
+
+
+
+
+
+
+ /**
+ * @suppress
+ */
+ companion object
+
+}
+
+
+/**
+ * @suppress
+ */
+public object FfiConverterTypeHttpRequestBuilder: FfiConverter<HttpRequestBuilder, Long> {
+ override fun lower(value: HttpRequestBuilder): Long {
+ return value.uniffiCloneHandle()
+ }
+
+ override fun lift(value: Long): HttpRequestBuilder {
+ return HttpRequestBuilder(UniffiWithHandle, value)
+ }
+
+ override fun read(buf: ByteBuffer): HttpRequestBuilder {
+ return lift(buf.getLong())
+ }
+
+ override fun allocationSize(value: HttpRequestBuilder) = 8UL
+
+ override fun write(value: HttpRequestBuilder, buf: ByteBuffer) {
+ buf.putLong(lower(value))
+ }
+}
+
+
+// This template implements a class for working with a Rust struct via a handle
+// to the live Rust struct on the other side of the FFI.
+//
+// There's some subtlety here, because we have to be careful not to operate on a Rust
+// struct after it has been dropped, and because we must expose a public API for freeing
+// theq Kotlin wrapper object in lieu of reliable finalizers. The core requirements are:
+//
+// * Each instance holds an opaque handle to the underlying Rust struct.
+// Method calls need to read this handle from the object's state and pass it in to
+// the Rust FFI.
+//
+// * When an instance is no longer needed, its handle should be passed to a
+// special destructor function provided by the Rust FFI, which will drop the
+// underlying Rust struct.
+//
+// * Given an instance, calling code is expected to call the special
+// `destroy` method in order to free it after use, either by calling it explicitly
+// or by using a higher-level helper like the `use` method. Failing to do so risks
+// leaking the underlying Rust struct.
+//
+// * We can't assume that calling code will do the right thing, and must be prepared
+// to handle Kotlin method calls executing concurrently with or even after a call to
+// `destroy`, and to handle multiple (possibly concurrent!) calls to `destroy`.
+//
+// * We must never allow Rust code to operate on the underlying Rust struct after
+// the destructor has been called, and must never call the destructor more than once.
+// Doing so may trigger memory unsafety.
+//
+// * To mitigate many of the risks of leaking memory and use-after-free unsafety, a `Cleaner`
+// is implemented to call the destructor when the Kotlin object becomes unreachable.
+// This is done in a background thread. This is not a panacea, and client code should be aware that
+// 1. the thread may starve if some there are objects that have poorly performing
+// `drop` methods or do significant work in their `drop` methods.
+// 2. the thread is shared across the whole library. This can be tuned by using `android_cleaner = true`,
+// or `android = true` in the [`kotlin` section of the `uniffi.toml` file](https://mozilla.github.io/uniffi-rs/kotlin/configuration.html).
+//
+// If we try to implement this with mutual exclusion on access to the handle, there is the
+// possibility of a race between a method call and a concurrent call to `destroy`:
+//
+// * Thread A starts a method call, reads the value of the handle, but is interrupted
+// before it can pass the handle over the FFI to Rust.
+// * Thread B calls `destroy` and frees the underlying Rust struct.
+// * Thread A resumes, passing the already-read handle value to Rust and triggering
+// a use-after-free.
+//
+// One possible solution would be to use a `ReadWriteLock`, with each method call taking
+// a read lock (and thus allowed to run concurrently) and the special `destroy` method
+// taking a write lock (and thus blocking on live method calls). However, we aim not to
+// generate methods with any hidden blocking semantics, and a `destroy` method that might
+// block if called incorrectly seems to meet that bar.
+//
+// So, we achieve our goals by giving each instance an associated `AtomicLong` counter to track
+// the number of in-flight method calls, and an `AtomicBoolean` flag to indicate whether `destroy`
+// has been called. These are updated according to the following rules:
+//
+// * The initial value of the counter is 1, indicating a live object with no in-flight calls.
+// The initial value for the flag is false.
+//
+// * At the start of each method call, we atomically check the counter.
+// If it is 0 then the underlying Rust struct has already been destroyed and the call is aborted.
+// If it is nonzero them we atomically increment it by 1 and proceed with the method call.
+//
+// * At the end of each method call, we atomically decrement and check the counter.
+// If it has reached zero then we destroy the underlying Rust struct.
+//
+// * When `destroy` is called, we atomically flip the flag from false to true.
+// If the flag was already true we silently fail.
+// Otherwise we atomically decrement and check the counter.
+// If it has reached zero then we destroy the underlying Rust struct.
+//
+// Astute readers may observe that this all sounds very similar to the way that Rust's `Arc<T>` works,
+// and indeed it is, with the addition of a flag to guard against multiple calls to `destroy`.
+//
+// The overall effect is that the underlying Rust struct is destroyed only when `destroy` has been
+// called *and* all in-flight method calls have completed, avoiding violating any of the expectations
+// of the underlying Rust code.
+//
+// This makes a cleaner a better alternative to _not_ calling `destroy()` as
+// and when the object is finished with, but the abstraction is not perfect: if the Rust object's `drop`
+// method is slow, and/or there are many objects to cleanup, and it's on a low end Android device, then the cleaner
+// thread may be starved, and the app will leak memory.
+//
+// In this case, `destroy`ing manually may be a better solution.
+//
+// The cleaner can live side by side with the manual calling of `destroy`. In the order of responsiveness, uniffi objects
+// with Rust peers are reclaimed:
+//
+// 1. By calling the `destroy` method of the object, which calls `rustObject.free()`. If that doesn't happen:
+// 2. When the object becomes unreachable, AND the Cleaner thread gets to call `rustObject.free()`. If the thread is starved then:
+// 3. The memory is reclaimed when the process terminates.
+//
+// [1] https://stackoverflow.com/questions/24376768/can-java-finalize-an-object-when-it-is-still-in-scope/24380219
+//
+
+
public interface TemplateBuilderInterface {
fun `apiVersion`(`value`: kotlin.String): TemplateBuilder
@@ -5929,7 +6316,12 @@ data class HttpRequest (
,
var `body`: kotlin.ByteArray?
,
- var `timeoutSecs`: kotlin.ULong?
+ /**
+ * Per-request timeout. Defaults to absent so callers written against the
+ * pre-timeout record shape keep constructing requests unchanged; absent
+ * falls back to the native client's 30-second default.
+ */
+ var `timeoutSecs`: kotlin.ULong? = null
){
diff --git a/libs/fleet/sdk-bindings/python/contract_fixture.py b/libs/fleet/sdk-bindings/python/contract_fixture.py
index c1bf1f5da0..1d0a6dda0c 100644
--- a/libs/fleet/sdk-bindings/python/contract_fixture.py
+++ b/libs/fleet/sdk-bindings/python/contract_fixture.py
@@ -4,8 +4,8 @@ import re
from dataclasses import dataclass
from fleet_sdk import (ClaimSpec, CreateClaimRequest, CreatePoolRequest, CyclopsClient,
- CyclopsConfiguration, CyclopsCredentials, HttpClient, HttpRequest, HttpResponse,
- OsGymSandboxWarmPoolSpec, Sandbox, SandboxTemplateRef, VmTemplate)
+ CyclopsConfiguration, CyclopsCredentials, HttpClient, HttpRequest, HttpRequestBuilder,
+ HttpResponse, OsGymSandboxWarmPoolSpec, Sandbox, SandboxTemplateRef, VmTemplate)
BASE = 'https://cyclops.invalid'
TOKEN = 'https://keycloak.invalid/realms/offline/protocol/openid-connect/token'
@@ -69,7 +69,10 @@ def offline_sandbox():
return Sandbox(namespace='default', claim='default', name='offline-sandbox', services=['mcp'])
def service_request(body):
- return HttpRequest(method='POST', url='https://ignored.invalid/mcp', headers=[], body=body, timeout_secs=None)
+ builder = HttpRequestBuilder().method('POST').url('https://ignored.invalid/mcp').headers([])
+ if body is not None:
+ builder = builder.body(body)
+ return builder.build()
def pool_spec():
return OsGymSandboxWarmPoolSpec(replicas=1, sandbox_template_ref=SandboxTemplateRef(name='default'), autoscaling=None)
diff --git a/libs/fleet/sdk-bindings/python/fleet_sdk/_sdk.py b/libs/fleet/sdk-bindings/python/fleet_sdk/_sdk.py
index c5ecedd73d..4b9836901c 100644
--- a/libs/fleet/sdk-bindings/python/fleet_sdk/_sdk.py
+++ b/libs/fleet/sdk-bindings/python/fleet_sdk/_sdk.py
@@ -602,6 +602,20 @@ def _uniffi_check_api_checksums(lib):
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cyclops_sdk_checksum_method_httpclient_execute() != 38803:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new() != 25892:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body() != 9054:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build() != 14573:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers() != 19982:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method() != 4078:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs() != 40941:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
+ if lib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url() != 12282:
+ raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cyclops_sdk_checksum_constructor_templatebuilder_new() != 19815:
raise InternalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
if lib.uniffi_cyclops_sdk_checksum_method_templatebuilder_api_version() != 65471:
@@ -967,6 +981,16 @@ _UniffiLib.uniffi_cyclops_sdk_fn_free_httpclient.argtypes = (
ctypes.POINTER(_UniffiRustCallStatus),
)
_UniffiLib.uniffi_cyclops_sdk_fn_free_httpclient.restype = None
+_UniffiLib.uniffi_cyclops_sdk_fn_clone_httprequestbuilder.argtypes = (
+ ctypes.c_uint64,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_clone_httprequestbuilder.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cyclops_sdk_fn_free_httprequestbuilder.argtypes = (
+ ctypes.c_uint64,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_free_httprequestbuilder.restype = None
_UniffiLib.uniffi_cyclops_sdk_fn_clone_templatebuilder.argtypes = (
ctypes.c_uint64,
ctypes.POINTER(_UniffiRustCallStatus),
@@ -1343,6 +1367,45 @@ _UniffiLib.uniffi_cyclops_sdk_fn_method_httpclient_execute.argtypes = (
_UniffiRustBuffer,
)
_UniffiLib.uniffi_cyclops_sdk_fn_method_httpclient_execute.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new.argtypes = (
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_body.argtypes = (
+ ctypes.c_uint64,
+ _UniffiRustBuffer,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_body.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_build.argtypes = (
+ ctypes.c_uint64,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_build.restype = _UniffiRustBuffer
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers.argtypes = (
+ ctypes.c_uint64,
+ _UniffiRustBuffer,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_method.argtypes = (
+ ctypes.c_uint64,
+ _UniffiRustBuffer,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_method.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs.argtypes = (
+ ctypes.c_uint64,
+ ctypes.c_uint64,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs.restype = ctypes.c_uint64
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_url.argtypes = (
+ ctypes.c_uint64,
+ _UniffiRustBuffer,
+ ctypes.POINTER(_UniffiRustCallStatus),
+)
+_UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_url.restype = ctypes.c_uint64
_UniffiLib.uniffi_cyclops_sdk_fn_constructor_templatebuilder_new.argtypes = (
ctypes.POINTER(_UniffiRustCallStatus),
)
@@ -1562,6 +1625,27 @@ _UniffiLib.uniffi_cyclops_sdk_checksum_method_cyclopstokenproviderconfigurationb
_UniffiLib.uniffi_cyclops_sdk_checksum_method_httpclient_execute.argtypes = (
)
_UniffiLib.uniffi_cyclops_sdk_checksum_method_httpclient_execute.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new.argtypes = (
+)
+_UniffiLib.uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body.argtypes = (
+)
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build.argtypes = (
+)
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers.argtypes = (
+)
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method.argtypes = (
+)
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs.argtypes = (
+)
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs.restype = ctypes.c_uint16
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url.argtypes = (
+)
+_UniffiLib.uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url.restype = ctypes.c_uint16
_UniffiLib.uniffi_cyclops_sdk_checksum_constructor_templatebuilder_new.argtypes = (
)
_UniffiLib.uniffi_cyclops_sdk_checksum_constructor_templatebuilder_new.restype = ctypes.c_uint16
@@ -2608,12 +2692,15 @@ class _UniffiFfiConverterOptionalUInt64(_UniffiConverterRustBuffer):
@dataclass
class HttpRequest:
- def __init__(self, *, method:str, url:str, headers:typing.List[HttpHeader], body:typing.Optional[bytes], timeout_secs:typing.Optional[int]):
+ def __init__(self, *, method:str, url:str, headers:typing.List[HttpHeader], body:typing.Optional[bytes], timeout_secs:typing.Optional[int] = _DEFAULT):
self.method = method
self.url = url
self.headers = headers
self.body = body
- self.timeout_secs = timeout_secs
+ if timeout_secs is _DEFAULT:
+ self.timeout_secs = None
+ else:
+ self.timeout_secs = timeout_secs
@@ -5193,6 +5280,171 @@ class _UniffiFfiConverterTypeHttpClient:
buf.write_u64(cls.lower(value))
+class HttpRequestBuilderProtocol(typing.Protocol):
+
+ def body(self, value: bytes) -> HttpRequestBuilder:
+ raise NotImplementedError
+ def build(self, ) -> HttpRequest:
+ raise NotImplementedError
+ def headers(self, value: typing.List[HttpHeader]) -> HttpRequestBuilder:
+ raise NotImplementedError
+ def method(self, value: str) -> HttpRequestBuilder:
+ raise NotImplementedError
+ def timeout_secs(self, value: int) -> HttpRequestBuilder:
+ raise NotImplementedError
+ def url(self, value: str) -> HttpRequestBuilder:
+ raise NotImplementedError
+
+class HttpRequestBuilder(HttpRequestBuilderProtocol):
+
+ _handle: ctypes.c_uint64
+ def __init__(self, ):
+ _uniffi_lowered_args = (
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeHttpRequestBuilder.lift
+ _uniffi_error_converter = None
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new,
+ *_uniffi_lowered_args,
+ )
+ self._handle = _uniffi_ffi_result
+
+ def __del__(self):
+ # In case of partial initialization of instances.
+ handle = getattr(self, "_handle", None)
+ if handle is not None:
+ _uniffi_rust_call(_UniffiLib.uniffi_cyclops_sdk_fn_free_httprequestbuilder, handle)
+
+ def _uniffi_clone_handle(self):
+ return _uniffi_rust_call(_UniffiLib.uniffi_cyclops_sdk_fn_clone_httprequestbuilder, self._handle)
+
+ # Used by alternative constructors or any methods which return this type.
+ @classmethod
+ def _uniffi_make_instance(cls, handle):
+ # Lightly yucky way to bypass the usual __init__ logic
+ # and just create a new instance with the required handle.
+ inst = cls.__new__(cls)
+ inst._handle = handle
+ return inst
+ def body(self, value: bytes) -> HttpRequestBuilder:
+
+ _UniffiFfiConverterBytes.check_lower(value)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ _UniffiFfiConverterBytes.lower(value),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeHttpRequestBuilder.lift
+ _uniffi_error_converter = None
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_body,
+ *_uniffi_lowered_args,
+ )
+ return _uniffi_lift_return(_uniffi_ffi_result)
+ def build(self, ) -> HttpRequest:
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeHttpRequest.lift
+ _uniffi_error_converter = _UniffiFfiConverterTypeSdkBuildError
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_build,
+ *_uniffi_lowered_args,
+ )
+ return _uniffi_lift_return(_uniffi_ffi_result)
+ def headers(self, value: typing.List[HttpHeader]) -> HttpRequestBuilder:
+
+ _UniffiFfiConverterSequenceTypeHttpHeader.check_lower(value)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ _UniffiFfiConverterSequenceTypeHttpHeader.lower(value),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeHttpRequestBuilder.lift
+ _uniffi_error_converter = None
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers,
+ *_uniffi_lowered_args,
+ )
+ return _uniffi_lift_return(_uniffi_ffi_result)
+ def method(self, value: str) -> HttpRequestBuilder:
+
+ _UniffiFfiConverterString.check_lower(value)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ _UniffiFfiConverterString.lower(value),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeHttpRequestBuilder.lift
+ _uniffi_error_converter = None
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_method,
+ *_uniffi_lowered_args,
+ )
+ return _uniffi_lift_return(_uniffi_ffi_result)
+ def timeout_secs(self, value: int) -> HttpRequestBuilder:
+
+ _UniffiFfiConverterUInt64.check_lower(value)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ _UniffiFfiConverterUInt64.lower(value),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeHttpRequestBuilder.lift
+ _uniffi_error_converter = None
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs,
+ *_uniffi_lowered_args,
+ )
+ return _uniffi_lift_return(_uniffi_ffi_result)
+ def url(self, value: str) -> HttpRequestBuilder:
+
+ _UniffiFfiConverterString.check_lower(value)
+ _uniffi_lowered_args = (
+ self._uniffi_clone_handle(),
+ _UniffiFfiConverterString.lower(value),
+ )
+ _uniffi_lift_return = _UniffiFfiConverterTypeHttpRequestBuilder.lift
+ _uniffi_error_converter = None
+ _uniffi_ffi_result = _uniffi_rust_call_with_error(
+ _uniffi_error_converter,
+ _UniffiLib.uniffi_cyclops_sdk_fn_method_httprequestbuilder_url,
+ *_uniffi_lowered_args,
+ )
+ return _uniffi_lift_return(_uniffi_ffi_result)
+
+
+
+
+
+class _UniffiFfiConverterTypeHttpRequestBuilder:
+ @staticmethod
+ def lift(value: int) -> HttpRequestBuilder:
+ return HttpRequestBuilder._uniffi_make_instance(value)
+
+ @staticmethod
+ def check_lower(value: HttpRequestBuilder):
+ if not isinstance(value, HttpRequestBuilder):
+ raise TypeError("Expected HttpRequestBuilder instance, {} found".format(type(value).__name__))
+
+ @staticmethod
+ def lower(value: HttpRequestBuilder) -> ctypes.c_uint64:
+ return value._uniffi_clone_handle()
+
+ @classmethod
+ def read(cls, buf: _UniffiRustBuffer) -> HttpRequestBuilder:
+ ptr = buf.read_u64()
+ if ptr == 0:
+ raise InternalError("Raw handle value was null")
+ return cls.lift(ptr)
+
+ @classmethod
+ def write(cls, value: HttpRequestBuilder, buf: _UniffiRustBuffer):
+ buf.write_u64(cls.lower(value))
+
+
class TemplateBuilderProtocol(typing.Protocol):
def api_version(self, value: str) -> TemplateBuilder:
@@ -5394,6 +5646,8 @@ __all__ = [
"CyclopsTokenProviderConfigurationBuilderProtocol",
"HttpClientImpl",
"HttpClient",
+ "HttpRequestBuilder",
+ "HttpRequestBuilderProtocol",
"TemplateBuilder",
"TemplateBuilderProtocol",
]
diff --git a/libs/fleet/sdk-bindings/python/tests/test_builders.py b/libs/fleet/sdk-bindings/python/tests/test_builders.py
index f3bab3e5d5..0f03de1e62 100644
--- a/libs/fleet/sdk-bindings/python/tests/test_builders.py
+++ b/libs/fleet/sdk-bindings/python/tests/test_builders.py
@@ -60,6 +60,38 @@ class GeneratedBuilderTest(unittest.TestCase):
self.assertIs(type(reference), fleet_sdk.SandboxTemplateRef)
self.assertEqual(reference.name, "legacy")
+ def test_http_request_builder_skips_optionals_and_enforces_required_fields(self):
+ request = (
+ fleet_sdk.HttpRequestBuilder()
+ .method("GET")
+ .url("https://run.cua.ai/v1/pools")
+ .headers([])
+ .build()
+ )
+ bounded = (
+ fleet_sdk.HttpRequestBuilder()
+ .method("GET")
+ .url("https://run.cua.ai/v1/pools")
+ .headers([])
+ .timeout_secs(30)
+ .build()
+ )
+
+ self.assertIs(type(request), fleet_sdk.HttpRequest)
+ self.assertIsNone(request.body)
+ self.assertIsNone(request.timeout_secs)
+ self.assertEqual(bounded.timeout_secs, 30)
+ with self.assertRaises(fleet_sdk.SdkBuildError.MissingRequiredField) as error:
+ fleet_sdk.HttpRequestBuilder().method("GET").headers([]).build()
+ self.assertEqual(error.exception.record_type, "HttpRequest")
+ self.assertEqual(error.exception.field, "url")
+
+ def test_http_request_constructor_treats_timeout_secs_as_optional(self):
+ request = fleet_sdk.HttpRequest(
+ method="GET", url="https://run.cua.ai/v1/pools", headers=[], body=None
+ )
+ self.assertIsNone(request.timeout_secs)
+
def test_remaining_frontend_builders_are_generated(self):
configuration = (
fleet_sdk.CyclopsTokenProviderConfigurationBuilder()
diff --git a/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rb b/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rb
index b3071eb925..8a565a5494 100644
--- a/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rb
+++ b/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rb
@@ -1010,6 +1010,13 @@ class RustBufferStream
return HttpClient.uniffi_allocate(handle)
end
+ # The Object type HttpRequestBuilder.
+
+ def readTypeHttpRequestBuilder
+ handle = unpack_from 8, 'Q>'
+ return HttpRequestBuilder.uniffi_allocate(handle)
+ end
+
# The Object type TemplateBuilder.
def readTypeTemplateBuilder
@@ -1692,6 +1699,13 @@ class RustBufferBuilder
pack_into(8, 'Q>', handle)
end
+ # The Object type HttpRequestBuilder.
+
+ def write_TypeHttpRequestBuilder(obj)
+ handle = HttpRequestBuilder.uniffi_lower obj
+ pack_into(8, 'Q>', handle)
+ end
+
# The Object type TemplateBuilder.
def write_TypeTemplateBuilder(obj)
@@ -2750,6 +2764,33 @@ module UniFFILib
attach_function :uniffi_cyclops_sdk_fn_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit,
[:uint64, :uint32, RustCallStatus.by_ref],
:uint64
+ attach_function :uniffi_cyclops_sdk_fn_clone_httprequestbuilder,
+ [:uint64, RustCallStatus.by_ref],
+ :uint64
+ attach_function :uniffi_cyclops_sdk_fn_free_httprequestbuilder,
+ [:uint64, RustCallStatus.by_ref],
+ :void
+ attach_function :uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new,
+ [RustCallStatus.by_ref],
+ :uint64
+ attach_function :uniffi_cyclops_sdk_fn_method_httprequestbuilder_body,
+ [:uint64, RustBuffer.by_value, RustCallStatus.by_ref],
+ :uint64
+ attach_function :uniffi_cyclops_sdk_fn_method_httprequestbuilder_build,
+ [:uint64, RustCallStatus.by_ref],
+ RustBuffer.by_value
+ attach_function :uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers,
+ [:uint64, RustBuffer.by_value, RustCallStatus.by_ref],
+ :uint64
+ attach_function :uniffi_cyclops_sdk_fn_method_httprequestbuilder_method,
+ [:uint64, RustBuffer.by_value, RustCallStatus.by_ref],
+ :uint64
+ attach_function :uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs,
+ [:uint64, :uint64, RustCallStatus.by_ref],
+ :uint64
+ attach_function :uniffi_cyclops_sdk_fn_method_httprequestbuilder_url,
+ [:uint64, RustBuffer.by_value, RustCallStatus.by_ref],
+ :uint64
attach_function :uniffi_cyclops_sdk_fn_clone_templatebuilder,
[:uint64, RustCallStatus.by_ref],
:uint64
@@ -2930,6 +2971,24 @@ module UniFFILib
attach_function :uniffi_cyclops_sdk_checksum_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit,
[RustCallStatus.by_ref],
:uint16
+ attach_function :uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body,
+ [RustCallStatus.by_ref],
+ :uint16
+ attach_function :uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build,
+ [RustCallStatus.by_ref],
+ :uint16
+ attach_function :uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers,
+ [RustCallStatus.by_ref],
+ :uint16
+ attach_function :uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method,
+ [RustCallStatus.by_ref],
+ :uint16
+ attach_function :uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs,
+ [RustCallStatus.by_ref],
+ :uint16
+ attach_function :uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url,
+ [RustCallStatus.by_ref],
+ :uint16
attach_function :uniffi_cyclops_sdk_checksum_method_templatebuilder_api_version,
[RustCallStatus.by_ref],
:uint16
@@ -2984,6 +3043,9 @@ module UniFFILib
attach_function :uniffi_cyclops_sdk_checksum_constructor_cyclopstokenproviderconfigurationbuilder_new,
[RustCallStatus.by_ref],
:uint16
+ attach_function :uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new,
+ [RustCallStatus.by_ref],
+ :uint16
attach_function :uniffi_cyclops_sdk_checksum_constructor_templatebuilder_new,
[RustCallStatus.by_ref],
:uint16
@@ -3224,7 +3286,7 @@ end
class HttpRequest
attr_reader :method, :url, :headers, :body, :timeout_secs
- def initialize(method:, url:, headers:, body:, timeout_secs:)
+ def initialize(method:, url:, headers:, body:, timeout_secs: nil)
@method = method
@url = url
@headers = headers
@@ -4471,6 +4533,93 @@ end
return CyclopsTokenProviderConfigurationBuilder.uniffi_allocate(result)
end
+end
+
+ class HttpRequestBuilder
+
+ # A private helper for initializing instances of the class from a raw handle,
+ # bypassing any initialization logic and ensuring they are GC'd properly.
+ def self.uniffi_allocate(handle)
+ inst = allocate
+ inst.instance_variable_set :@handle, handle
+ ObjectSpace.define_finalizer(inst, uniffi_define_finalizer_by_handle(handle, inst.object_id))
+ return inst
+ end
+
+ # A private helper for registering an object finalizer.
+ # N.B. it's important that this does not capture a reference
+ # to the actual instance, only its underlying handle.
+ def self.uniffi_define_finalizer_by_handle(handle, object_id)
+ Proc.new do |_id|
+ FleetSdk.rust_call(
+ :uniffi_cyclops_sdk_fn_free_httprequestbuilder,
+ handle
+ )
+ end
+ end
+
+ # A private helper for lowering instances into a raw handle.
+ # This does an explicit typecheck, because accidentally lowering a different type of
+ # object in a place where this type is expected, could lead to memory unsafety.
+ def self.uniffi_check_lower(inst)
+ if not inst.is_a? self
+ raise TypeError.new "Expected a HttpRequestBuilder instance, got #{inst}"
+ end
+ end
+
+ def uniffi_clone_handle()
+ return FleetSdk.rust_call(
+ :uniffi_cyclops_sdk_fn_clone_httprequestbuilder,
+ @handle
+ )
+ end
+
+ def self.uniffi_lower(inst)
+ return inst.uniffi_clone_handle()
+ end
+ def initialize()
+ handle = FleetSdk.rust_call(:uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new,)
+ @handle = handle
+ ObjectSpace.define_finalizer(self, self.class.uniffi_define_finalizer_by_handle(handle, self.object_id))
+ end
+
+
+
+ def body(value)
+ value = FleetSdk::uniffi_bytes(value)
+
+ result = FleetSdk.rust_call(:uniffi_cyclops_sdk_fn_method_httprequestbuilder_body,uniffi_clone_handle(),RustBuffer.allocFromBytes(value))
+ return HttpRequestBuilder.uniffi_allocate(result)
+ end
+ def build()
+ result = FleetSdk.rust_call_with_error(SdkBuildError,:uniffi_cyclops_sdk_fn_method_httprequestbuilder_build,uniffi_clone_handle(),)
+ return result.consumeIntoTypeHttpRequest
+ end
+ def headers(value)
+ value = value
+ RustBuffer.check_lower_SequenceTypeHttpHeader(value)
+ result = FleetSdk.rust_call(:uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers,uniffi_clone_handle(),RustBuffer.alloc_from_SequenceTypeHttpHeader(value))
+ return HttpRequestBuilder.uniffi_allocate(result)
+ end
+ def method(value)
+ value = FleetSdk::uniffi_utf8(value)
+
+ result = FleetSdk.rust_call(:uniffi_cyclops_sdk_fn_method_httprequestbuilder_method,uniffi_clone_handle(),RustBuffer.allocFromString(value))
+ return HttpRequestBuilder.uniffi_allocate(result)
+ end
+ def timeout_secs(value)
+ value = FleetSdk::uniffi_in_range(value, "u64", 0, 2**64)
+
+ result = FleetSdk.rust_call(:uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs,uniffi_clone_handle(),value)
+ return HttpRequestBuilder.uniffi_allocate(result)
+ end
+ def url(value)
+ value = FleetSdk::uniffi_utf8(value)
+
+ result = FleetSdk.rust_call(:uniffi_cyclops_sdk_fn_method_httprequestbuilder_url,uniffi_clone_handle(),RustBuffer.allocFromString(value))
+ return HttpRequestBuilder.uniffi_allocate(result)
+ end
+
end
class TemplateBuilder
diff --git a/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb b/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb
index 568321e87f..46015c28b2 100644
--- a/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb
+++ b/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb
@@ -102,7 +102,9 @@ def configuration
end
def service_request(body)
- FleetSdk::HttpRequest.new(method: 'POST', url: 'https://ignored.invalid/mcp', headers: [], body: body, timeout_secs: nil)
+ builder = FleetSdk::HttpRequestBuilder.new.method('POST').url('https://ignored.invalid/mcp').headers([])
+ builder = builder.body(body) unless body.nil?
+ builder.build
end
sandbox = FleetSdk::Sandbox.new(namespace: 'default', claim: 'default', name: 'offline-sandbox', services: ['mcp'])
diff --git a/libs/fleet/sdk-bindings/ruby/tests/test_builders.rb b/libs/fleet/sdk-bindings/ruby/tests/test_builders.rb
index 821dee49a4..5d4cc9825e 100644
--- a/libs/fleet/sdk-bindings/ruby/tests/test_builders.rb
+++ b/libs/fleet/sdk-bindings/ruby/tests/test_builders.rb
@@ -39,3 +39,17 @@ begin
raise 'missing claim pool did not fail'
rescue FleetSdk::SdkBuildError::MissingRequiredField
end
+http_request = FleetSdk::HttpRequestBuilder.new.method('GET').url('https://run.cua.ai/v1/pools').headers([]).build
+raise 'wrong http request type' unless http_request.instance_of?(FleetSdk::HttpRequest)
+raise 'optional body was not omitted' unless http_request.body.nil?
+raise 'optional timeout was not omitted' unless http_request.timeout_secs.nil?
+bounded = FleetSdk::HttpRequestBuilder.new.method('GET').url('https://run.cua.ai/v1/pools').headers([]).timeout_secs(30).build
+raise 'wrong bounded timeout' unless bounded.timeout_secs == 30
+begin
+ FleetSdk::HttpRequestBuilder.new.method('GET').headers([]).build
+ raise 'missing http request url did not fail'
+rescue FleetSdk::SdkBuildError::MissingRequiredField => error
+ raise 'wrong http request error' unless error.record_type == 'HttpRequest' && error.field == 'url'
+end
+legacy_http_request = FleetSdk::HttpRequest.new(method: 'GET', url: 'https://run.cua.ai/v1/pools', headers: [], body: nil)
+raise 'constructor timeout default changed' unless legacy_http_request.timeout_secs.nil?
diff --git a/libs/fleet/sdk-bindings/swift/CyclopsSdk.swift b/libs/fleet/sdk-bindings/swift/CyclopsSdk.swift
index f75d399d99..fdab5d5772 100644
--- a/libs/fleet/sdk-bindings/swift/CyclopsSdk.swift
+++ b/libs/fleet/sdk-bindings/swift/CyclopsSdk.swift
@@ -2559,6 +2559,184 @@ public func FfiConverterTypeHttpClient_lower(_ value: HttpClient) -> UInt64 {
+public protocol HttpRequestBuilderProtocol: AnyObject, Sendable {
+
+ func body(value: Data) -> HttpRequestBuilder
+
+ func build() throws -> HttpRequest
+
+ func headers(value: [HttpHeader]) -> HttpRequestBuilder
+
+ func method(value: String) -> HttpRequestBuilder
+
+ func timeoutSecs(value: UInt64) -> HttpRequestBuilder
+
+ func url(value: String) -> HttpRequestBuilder
+
+}
+open class HttpRequestBuilder: HttpRequestBuilderProtocol, @unchecked Sendable {
+ fileprivate let handle: UInt64
+
+ /// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
+#if swift(>=5.8)
+ @_documentation(visibility: private)
+#endif
+ public struct NoHandle {
+ public init() {}
+ }
+
+ // TODO: We'd like this to be `private` but for Swifty reasons,
+ // we can't implement `FfiConverter` without making this `required` and we can't
+ // make it `required` without making it `public`.
+#if swift(>=5.8)
+ @_documentation(visibility: private)
+#endif
+ required public init(unsafeFromHandle handle: UInt64) {
+ self.handle = handle
+ }
+
+ // This constructor can be used to instantiate a fake object.
+ // - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
+ //
+ // - Warning:
+ // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
+#if swift(>=5.8)
+ @_documentation(visibility: private)
+#endif
+ public init(noHandle: NoHandle) {
+ self.handle = 0
+ }
+
+#if swift(>=5.8)
+ @_documentation(visibility: private)
+#endif
+ public func uniffiCloneHandle() -> UInt64 {
+ return try! rustCall { uniffi_cyclops_sdk_fn_clone_httprequestbuilder(self.handle, $0) }
+ }
+public convenience init() {
+ let handle =
+ try! rustCall() {
+ uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new($0
+ )
+}
+ self.init(unsafeFromHandle: handle)
+}
+
+ deinit {
+ if handle == 0 {
+ // Mock objects have handle=0 don't try to free them
+ return
+ }
+
+ try! rustCall { uniffi_cyclops_sdk_fn_free_httprequestbuilder(handle, $0) }
+ }
+
+
+
+
+open func body(value: Data) -> HttpRequestBuilder {
+ return try! FfiConverterTypeHttpRequestBuilder_lift(try! rustCall() {
+ uniffi_cyclops_sdk_fn_method_httprequestbuilder_body(
+ self.uniffiCloneHandle(),
+ FfiConverterData.lower(value),$0
+ )
+})
+}
+
+open func build()throws -> HttpRequest {
+ return try FfiConverterTypeHttpRequest_lift(try rustCallWithError(FfiConverterTypeSdkBuildError_lift) {
+ uniffi_cyclops_sdk_fn_method_httprequestbuilder_build(
+ self.uniffiCloneHandle(),$0
+ )
+})
+}
+
+open func headers(value: [HttpHeader]) -> HttpRequestBuilder {
+ return try! FfiConverterTypeHttpRequestBuilder_lift(try! rustCall() {
+ uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers(
+ self.uniffiCloneHandle(),
+ FfiConverterSequenceTypeHttpHeader.lower(value),$0
+ )
+})
+}
+
+open func method(value: String) -> HttpRequestBuilder {
+ return try! FfiConverterTypeHttpRequestBuilder_lift(try! rustCall() {
+ uniffi_cyclops_sdk_fn_method_httprequestbuilder_method(
+ self.uniffiCloneHandle(),
+ FfiConverterString.lower(value),$0
+ )
+})
+}
+
+open func timeoutSecs(value: UInt64) -> HttpRequestBuilder {
+ return try! FfiConverterTypeHttpRequestBuilder_lift(try! rustCall() {
+ uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs(
+ self.uniffiCloneHandle(),
+ FfiConverterUInt64.lower(value),$0
+ )
+})
+}
+
+open func url(value: String) -> HttpRequestBuilder {
+ return try! FfiConverterTypeHttpRequestBuilder_lift(try! rustCall() {
+ uniffi_cyclops_sdk_fn_method_httprequestbuilder_url(
+ self.uniffiCloneHandle(),
+ FfiConverterString.lower(value),$0
+ )
+})
+}
+
+
+
+}
+
+
+#if swift(>=5.8)
+@_documentation(visibility: private)
+#endif
+public struct FfiConverterTypeHttpRequestBuilder: FfiConverter {
+ typealias FfiType = UInt64
+ typealias SwiftType = HttpRequestBuilder
+
+ public static func lift(_ handle: UInt64) throws -> HttpRequestBuilder {
+ return HttpRequestBuilder(unsafeFromHandle: handle)
+ }
+
+ public static func lower(_ value: HttpRequestBuilder) -> UInt64 {
+ return value.uniffiCloneHandle()
+ }
+
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HttpRequestBuilder {
+ let handle: UInt64 = try readInt(&buf)
+ return try lift(handle)
+ }
+
+ public static func write(_ value: HttpRequestBuilder, into buf: inout [UInt8]) {
+ writeInt(&buf, lower(value))
+ }
+}
+
+
+#if swift(>=5.8)
+@_documentation(visibility: private)
+#endif
+public func FfiConverterTypeHttpRequestBuilder_lift(_ handle: UInt64) throws -> HttpRequestBuilder {
+ return try FfiConverterTypeHttpRequestBuilder.lift(handle)
+}
+
+#if swift(>=5.8)
+@_documentation(visibility: private)
+#endif
+public func FfiConverterTypeHttpRequestBuilder_lower(_ value: HttpRequestBuilder) -> UInt64 {
+ return FfiConverterTypeHttpRequestBuilder.lower(value)
+}
+
+
+
+
+
+
public protocol TemplateBuilderProtocol: AnyObject, Sendable {
func apiVersion(value: String) -> TemplateBuilder
@@ -3223,11 +3401,21 @@ public struct HttpRequest: Equatable, Hashable {
public var url: String
public var headers: [HttpHeader]
public var body: Data?
+ /**
+ * Per-request timeout. Defaults to absent so callers written against the
+ * pre-timeout record shape keep constructing requests unchanged; absent
+ * falls back to the native client's 30-second default.
+ */
public var timeoutSecs: UInt64?
// Default memberwise initializers are never public by default, so we
// declare one manually.
- public init(method: String, url: String, headers: [HttpHeader], body: Data?, timeoutSecs: UInt64?) {
+ public init(method: String, url: String, headers: [HttpHeader], body: Data?,
+ /**
+ * Per-request timeout. Defaults to absent so callers written against the
+ * pre-timeout record shape keep constructing requests unchanged; absent
+ * falls back to the native client's 30-second default.
+ */timeoutSecs: UInt64? = nil) {
self.method = method
self.url = url
self.headers = headers
@@ -4858,6 +5046,24 @@ private let initializationResult: InitializationResult = {
if (uniffi_cyclops_sdk_checksum_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit() != 6865) {
return InitializationResult.apiChecksumMismatch
}
+ if (uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body() != 9054) {
+ return InitializationResult.apiChecksumMismatch
+ }
+ if (uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build() != 14573) {
+ return InitializationResult.apiChecksumMismatch
+ }
+ if (uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers() != 19982) {
+ return InitializationResult.apiChecksumMismatch
+ }
+ if (uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method() != 4078) {
+ return InitializationResult.apiChecksumMismatch
+ }
+ if (uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs() != 40941) {
+ return InitializationResult.apiChecksumMismatch
+ }
+ if (uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url() != 12282) {
+ return InitializationResult.apiChecksumMismatch
+ }
if (uniffi_cyclops_sdk_checksum_method_templatebuilder_api_version() != 65471) {
return InitializationResult.apiChecksumMismatch
}
@@ -4912,6 +5118,9 @@ private let initializationResult: InitializationResult = {
if (uniffi_cyclops_sdk_checksum_constructor_cyclopstokenproviderconfigurationbuilder_new() != 43069) {
return InitializationResult.apiChecksumMismatch
}
+ if (uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new() != 25892) {
+ return InitializationResult.apiChecksumMismatch
+ }
if (uniffi_cyclops_sdk_checksum_constructor_templatebuilder_new() != 19815) {
return InitializationResult.apiChecksumMismatch
}
diff --git a/libs/fleet/sdk-bindings/swift/CyclopsSdkFFI.h b/libs/fleet/sdk-bindings/swift/CyclopsSdkFFI.h
index d3a84fd998..90e7fc0397 100644
--- a/libs/fleet/sdk-bindings/swift/CyclopsSdkFFI.h
+++ b/libs/fleet/sdk-bindings/swift/CyclopsSdkFFI.h
@@ -683,6 +683,52 @@ uint64_t uniffi_cyclops_sdk_fn_method_cyclopstokenproviderconfigurationbuilder_p
uint64_t uniffi_cyclops_sdk_fn_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit(uint64_t ptr, uint32_t value, RustCallStatus *_Nonnull out_status
);
#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_CLONE_HTTPREQUESTBUILDER
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_CLONE_HTTPREQUESTBUILDER
+uint64_t uniffi_cyclops_sdk_fn_clone_httprequestbuilder(uint64_t handle, RustCallStatus *_Nonnull out_status
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_FREE_HTTPREQUESTBUILDER
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_FREE_HTTPREQUESTBUILDER
+void uniffi_cyclops_sdk_fn_free_httprequestbuilder(uint64_t handle, RustCallStatus *_Nonnull out_status
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_CONSTRUCTOR_HTTPREQUESTBUILDER_NEW
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_CONSTRUCTOR_HTTPREQUESTBUILDER_NEW
+uint64_t uniffi_cyclops_sdk_fn_constructor_httprequestbuilder_new(RustCallStatus *_Nonnull out_status
+
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_BODY
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_BODY
+uint64_t uniffi_cyclops_sdk_fn_method_httprequestbuilder_body(uint64_t ptr, RustBuffer value, RustCallStatus *_Nonnull out_status
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_BUILD
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_BUILD
+RustBuffer uniffi_cyclops_sdk_fn_method_httprequestbuilder_build(uint64_t ptr, RustCallStatus *_Nonnull out_status
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_HEADERS
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_HEADERS
+uint64_t uniffi_cyclops_sdk_fn_method_httprequestbuilder_headers(uint64_t ptr, RustBuffer value, RustCallStatus *_Nonnull out_status
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_METHOD
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_METHOD
+uint64_t uniffi_cyclops_sdk_fn_method_httprequestbuilder_method(uint64_t ptr, RustBuffer value, RustCallStatus *_Nonnull out_status
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_TIMEOUT_SECS
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_TIMEOUT_SECS
+uint64_t uniffi_cyclops_sdk_fn_method_httprequestbuilder_timeout_secs(uint64_t ptr, uint64_t value, RustCallStatus *_Nonnull out_status
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_URL
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_METHOD_HTTPREQUESTBUILDER_URL
+uint64_t uniffi_cyclops_sdk_fn_method_httprequestbuilder_url(uint64_t ptr, RustBuffer value, RustCallStatus *_Nonnull out_status
+);
+#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_CLONE_TEMPLATEBUILDER
#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_FN_CLONE_TEMPLATEBUILDER
uint64_t uniffi_cyclops_sdk_fn_clone_templatebuilder(uint64_t handle, RustCallStatus *_Nonnull out_status
@@ -1270,6 +1316,42 @@ uint16_t uniffi_cyclops_sdk_checksum_method_cyclopstokenproviderconfigurationbui
#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_CYCLOPSTOKENPROVIDERCONFIGURATIONBUILDER_POOL_POLL_LIMIT
uint16_t uniffi_cyclops_sdk_checksum_method_cyclopstokenproviderconfigurationbuilder_pool_poll_limit(void
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_BODY
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_BODY
+uint16_t uniffi_cyclops_sdk_checksum_method_httprequestbuilder_body(void
+
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_BUILD
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_BUILD
+uint16_t uniffi_cyclops_sdk_checksum_method_httprequestbuilder_build(void
+
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_HEADERS
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_HEADERS
+uint16_t uniffi_cyclops_sdk_checksum_method_httprequestbuilder_headers(void
+
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_METHOD
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_METHOD
+uint16_t uniffi_cyclops_sdk_checksum_method_httprequestbuilder_method(void
+
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_TIMEOUT_SECS
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_TIMEOUT_SECS
+uint16_t uniffi_cyclops_sdk_checksum_method_httprequestbuilder_timeout_secs(void
+
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_URL
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_HTTPREQUESTBUILDER_URL
+uint16_t uniffi_cyclops_sdk_checksum_method_httprequestbuilder_url(void
+
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_METHOD_TEMPLATEBUILDER_API_VERSION
@@ -1378,6 +1460,12 @@ uint16_t uniffi_cyclops_sdk_checksum_constructor_cyclopscredentials_new(void
#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_CONSTRUCTOR_CYCLOPSTOKENPROVIDERCONFIGURATIONBUILDER_NEW
uint16_t uniffi_cyclops_sdk_checksum_constructor_cyclopstokenproviderconfigurationbuilder_new(void
+);
+#endif
+#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_CONSTRUCTOR_HTTPREQUESTBUILDER_NEW
+#define UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_CONSTRUCTOR_HTTPREQUESTBUILDER_NEW
+uint16_t uniffi_cyclops_sdk_checksum_constructor_httprequestbuilder_new(void
+
);
#endif
#ifndef UNIFFI_FFIDEF_UNIFFI_CYCLOPS_SDK_CHECKSUM_CONSTRUCTOR_TEMPLATEBUILDER_NEW
diff --git a/libs/fleet/sdk/src/lib.rs b/libs/fleet/sdk/src/lib.rs
index 7b525c4ab6..c879983b15 100644
--- a/libs/fleet/sdk/src/lib.rs
+++ b/libs/fleet/sdk/src/lib.rs
@@ -22,8 +22,9 @@ pub use types::{
CreatePoolRequestBuilder, CreateTemplateRequest, CreateTemplateRequestBuilder,
CreateUserApiKeyRequest, CreateUserApiKeyRequestBuilder, CyclopsConfiguration,
CyclopsCredentials, CyclopsTokenProviderConfiguration,
- CyclopsTokenProviderConfigurationBuilder, HttpHeader, HttpRequest, HttpResponse, Namespace,
- NewUserApiKey, Pool, ResourceMetadata, Sandbox, Template, TemplateBuilder, UserApiKey,
+ CyclopsTokenProviderConfigurationBuilder, HttpHeader, HttpRequest, HttpRequestBuilder,
+ HttpResponse, Namespace, NewUserApiKey, Pool, ResourceMetadata, Sandbox, Template,
+ TemplateBuilder, UserApiKey,
};
uniffi::setup_scaffolding!("fleet_sdk");
diff --git a/libs/fleet/sdk/src/types.rs b/libs/fleet/sdk/src/types.rs
index e897f05742..aac65b4fc3 100644
--- a/libs/fleet/sdk/src/types.rs
+++ b/libs/fleet/sdk/src/types.rs
@@ -287,12 +287,27 @@ pub struct HttpHeader {
pub value: String,
}
-#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)]
+#[derive(
+ Clone,
+ Debug,
+ PartialEq,
+ Eq,
+ Serialize,
+ Deserialize,
+ uniffi::Record,
+ uniffi_builder_derive::UniffiBuilder,
+)]
+#[uniffi_builder(crate::SdkBuildError)]
pub struct HttpRequest {
pub method: String,
pub url: String,
pub headers: Vec<HttpHeader>,
pub body: Option<Vec<u8>>,
+ /// Per-request timeout. Defaults to absent so callers written against the
+ /// pre-timeout record shape keep constructing requests unchanged; absent
+ /// falls back to the native client's 30-second default.
+ #[serde(default)]
+ #[uniffi(default = None)]
pub timeout_secs: Option<u64>,
}
diff --git a/libs/fleet/sdk/tests/public_api.rs b/libs/fleet/sdk/tests/public_api.rs
index 95c5a3979b..561c0c8211 100644
--- a/libs/fleet/sdk/tests/public_api.rs
+++ b/libs/fleet/sdk/tests/public_api.rs
@@ -2,8 +2,8 @@ use std::sync::Arc;
use cyclops_sdk::{
Claim, CreateClaimRequest, CreatePoolRequest, CyclopsClient, CyclopsConfiguration,
- CyclopsCredentials, HttpClient, HttpError, HttpHeader, HttpRequest, HttpResponse, Pool,
- ResourceMetadata, Sandbox, SdkError,
+ CyclopsCredentials, HttpClient, HttpError, HttpHeader, HttpRequest, HttpRequestBuilder,
+ HttpResponse, Pool, ResourceMetadata, Sandbox, SdkError,
};
use cyclops_sdk_schema::{
ClaimSpec, OSGymSandboxClaimStatus, OSGymSandboxWarmPoolSpec, OSGymSandboxWarmPoolStatus,
@@ -208,6 +208,49 @@ fn http_request_distinguishes_absent_and_empty_bodies() {
assert_eq!(timed.timeout_secs, Some(75));
}
+#[test]
+fn http_request_builder_treats_optional_fields_as_skippable() {
+ let request = HttpRequestBuilder::new()
+ .method("GET".into())
+ .url("https://run.cua.ai/v1/pools".into())
+ .headers(vec![])
+ .build()
+ .unwrap();
+
+ assert_eq!(request.body, None);
+ assert_eq!(request.timeout_secs, None);
+
+ let bounded = HttpRequestBuilder::new()
+ .method("GET".into())
+ .url("https://run.cua.ai/v1/pools".into())
+ .headers(vec![])
+ .timeout_secs(30)
+ .build()
+ .unwrap();
+
+ assert_eq!(bounded.timeout_secs, Some(30));
+
+ let missing = HttpRequestBuilder::new()
+ .method("GET".into())
+ .headers(vec![])
+ .build();
+
+ assert!(missing.is_err());
+}
+
+#[test]
+fn http_request_deserializes_without_timeout_secs() {
+ let request: HttpRequest = serde_json::from_value(serde_json::json!({
+ "method": "GET",
+ "url": "https://run.cua.ai/v1/pools",
+ "headers": [],
+ "body": null,
+ }))
+ .unwrap();
+
+ assert_eq!(request.timeout_secs, None);
+}
+
#[test]
fn resource_metadata_preserves_kubernetes_creation_timestamp() {
let metadata: ResourceMetadata = serde_json::from_value(serde_json::json!({