Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(fleet-sdk): expose per-request HTTP timeout (#6701)
r33drichards2cb240f6cf8a
diff --git a/libs/fleet/scripts/test-generate-sdk-bindings.sh b/libs/fleet/scripts/test-generate-sdk-bindings.shindex 3999e783e7..f4683407cb 100755--- a/libs/fleet/scripts/test-generate-sdk-bindings.sh+++ b/libs/fleet/scripts/test-generate-sdk-bindings.sh@@ -407,6 +407,19 @@ grep -Fq -- "public var creationTimestamp: String?" "$swift_sdk_source" || failgrep -Fq -- "attr_reader :namespace, :name, :labels, :creation_timestamp" "$ruby_sdk_source" || fail "Ruby bindings omit creation_timestamp"grep -Fq -- "creationTimestamp?: string" "$node_sdk_source" || fail "Node bindings omit creationTimestamp"grep -Fq -- "CreationTimestamp *string" "$go_sdk_source" || fail "Go bindings omit CreationTimestamp"++for typescript_binding in "$node_sdk_source" "$browser_sdk_source"; do+ grep -Fq -- "timeoutSecs?: bigint" "$typescript_binding" || fail "TypeScript bindings omit HttpRequest.timeoutSecs: $typescript_binding"+ grep -Fq -- "timeoutSecs: FfiConverterOptionalUInt64.read(from)" "$typescript_binding" || fail "TypeScript bindings do not read HttpRequest.timeoutSecs: $typescript_binding"+ grep -Fq -- "FfiConverterOptionalUInt64.write(value.timeoutSecs, into)" "$typescript_binding" || fail "TypeScript bindings do not write HttpRequest.timeoutSecs: $typescript_binding"+ grep -Fq -- "FfiConverterOptionalUInt64.allocationSize(value.timeoutSecs)" "$typescript_binding" || fail "TypeScript bindings do not allocate HttpRequest.timeoutSecs: $typescript_binding"+ grep -Fq -- "const FfiConverterOptionalUInt64 = new FfiConverterOptional" "$typescript_binding" || fail "TypeScript bindings omit the optional UInt64 converter: $typescript_binding"+done+grep -Fq -- "TimeoutSecs *uint64" "$go_sdk_source" || fail "Go bindings omit HttpRequest.TimeoutSecs"+grep -Fq -- "FfiConverterOptionalUint64INSTANCE.Read(reader)" "$go_sdk_source" || fail "Go bindings do not read HttpRequest.TimeoutSecs"+grep -Fq -- "FfiConverterOptionalUint64INSTANCE.Write(writer, value.TimeoutSecs)" "$go_sdk_source" || fail "Go bindings do not write HttpRequest.TimeoutSecs"+grep -Fq -- "FfiDestroyerOptionalUint64{}.Destroy(r.TimeoutSecs)" "$go_sdk_source" || fail "Go bindings do not destroy HttpRequest.TimeoutSecs"+grep -Fq -- "type FfiConverterOptionalUint64 struct{}" "$go_sdk_source" || fail "Go bindings omit the optional uint64 converter"grep -Fq -- "@uniffi_handle_map = UniffiHandleMap.new" "$ruby_sdk_source" || fail "Ruby callback bindings do not retain native callback objects"grep -Fq -- "module UniffiCallbackInterfaceHttpClient" "$ruby_sdk_source" || fail "Ruby callback bindings do not register an HTTP callback vtable"grep -Fq -- "[VTableCallbackInterfaceHttpClient.by_ref]" "$ruby_sdk_source" || fail "Ruby callback vtable initializer has the wrong FFI signature"diff --git a/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.kt b/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.ktindex 0f16336ce7..173456a93b 100644--- a/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.kt+++ b/libs/fleet/sdk-bindings/examples/kotlin/AppControlled.kt@@ -53,7 +53,7 @@ fun main() = runBlocking {val pool = client.createPool(CreatePoolRequest("default", spec))val claim = client.createClaim(CreateClaimRequest(pool, ClaimSpec(SandboxTemplateRef(pool.metadata.name), null, null, null)))val sandbox = client.waitClaim(claim)- val service = client.serviceRequest(sandbox, "mcp", "/mcp", HttpRequest("POST", "https://ignored.invalid/mcp", emptyList(), "{\"offline\":true}".encodeToByteArray()))+ val service = client.serviceRequest(sandbox, "mcp", "/mcp", HttpRequest("POST", "https://ignored.invalid/mcp", emptyList(), "{\"offline\":true}".encodeToByteArray(), null))client.deleteClaim(claim)client.deletePool(pool)check(pool.metadata.name == "default" && claim.metadata.name == "default" && sandbox.name == "offline-sandbox")diff --git a/libs/fleet/sdk-bindings/examples/kotlin/LiveAppControlled.kt b/libs/fleet/sdk-bindings/examples/kotlin/LiveAppControlled.ktindex c39450910f..15472d32d8 100644--- a/libs/fleet/sdk-bindings/examples/kotlin/LiveAppControlled.kt+++ b/libs/fleet/sdk-bindings/examples/kotlin/LiveAppControlled.kt@@ -64,6 +64,7 @@ private suspend fun initializeMcp(client: CyclopsClient, sandbox: Sandbox): UShoHttpHeader("content-type", "application/json"),),body,+ null,),)if (response.status.toInt() in 200..299) return response.statusdiff --git a/libs/fleet/sdk-bindings/examples/python/live_app_controlled.py b/libs/fleet/sdk-bindings/examples/python/live_app_controlled.pyindex 1b8eae6416..73c22ac6bc 100755--- a/libs/fleet/sdk-bindings/examples/python/live_app_controlled.py+++ b/libs/fleet/sdk-bindings/examples/python/live_app_controlled.py@@ -77,6 +77,7 @@ async def initialize_mcp(client: CyclopsClient, sandbox) -> int:HttpHeader(name="content-type", value="application/json"),],body=body,+ timeout_secs=None,),)if 200 <= response.status < 300:diff --git a/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rb b/libs/fleet/sdk-bindings/examples/ruby/app_controlled.rbindex bf6dca827b..913ffd187d 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(basepool = 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))+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))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.rbindex 0073ed3dea..63022fc504 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' } }).bdeadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + 300loop 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))+ 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))return response.status if response.status.between?(200, 299)if [502, 503, 504].include?(response.status) && Process.clock_gettime(Process::CLOCK_MONOTONIC) < deadlinesleep 5diff --git a/libs/fleet/sdk-bindings/examples/swift/AppControlled.swift b/libs/fleet/sdk-bindings/examples/swift/AppControlled.swiftindex 80cbf336ea..1740a6f4e5 100644--- a/libs/fleet/sdk-bindings/examples/swift/AppControlled.swift+++ b/libs/fleet/sdk-bindings/examples/swift/AppControlled.swift@@ -27,7 +27,7 @@ actor ScriptedHttpClient: HttpClient {let pool = try await client.createPool(request: CreatePoolRequest(namespace: "default", spec: spec))let claim = try await client.createClaim(request: CreateClaimRequest(pool: pool, spec: ClaimSpec(sandboxTemplateRef: SandboxTemplateRef(name: pool.metadata.name), warmpool: nil, bindDeadline: nil, lifecycle: nil)))let sandbox = try await client.waitClaim(claim: claim)- let service = try await client.serviceRequest(sandbox: sandbox, service: "mcp", path: "/mcp", request: HttpRequest(method: "POST", url: "https://ignored.invalid/mcp", headers: [], body: Data("{\"offline\":true}".utf8)))+ let service = try await client.serviceRequest(sandbox: sandbox, service: "mcp", path: "/mcp", request: HttpRequest(method: "POST", url: "https://ignored.invalid/mcp", headers: [], body: Data("{\"offline\":true}".utf8), timeoutSecs: nil))try await client.deleteClaim(claim: claim)try await client.deletePool(pool: pool)await transport.assertExhausted()diff --git a/libs/fleet/sdk-bindings/examples/swift/LiveAppControlled.swift b/libs/fleet/sdk-bindings/examples/swift/LiveAppControlled.swiftindex d98ddd907e..ee1c1bd2b0 100644--- a/libs/fleet/sdk-bindings/examples/swift/LiveAppControlled.swift+++ b/libs/fleet/sdk-bindings/examples/swift/LiveAppControlled.swift@@ -69,7 +69,8 @@ private func initializeMcp(client: CyclopsClient, sandbox: Sandbox) async throwsHttpHeader(name: "accept", value: "application/json, text/event-stream"),HttpHeader(name: "content-type", value: "application/json"),],- body: body+ body: body,+ timeoutSecs: nil))if (200...299).contains(Int(response.status)) { return response.status }diff --git a/libs/fleet/sdk-bindings/go-uniffi/fleet_sdk/fleet_sdk.go b/libs/fleet/sdk-bindings/go-uniffi/fleet_sdk/fleet_sdk.goindex ee034f8542..8ff268d293 100644--- a/libs/fleet/sdk-bindings/go-uniffi/fleet_sdk/fleet_sdk.go+++ b/libs/fleet/sdk-bindings/go-uniffi/fleet_sdk/fleet_sdk.go@@ -2845,10 +2845,11 @@ func (_ FfiDestroyerHttpHeader) Destroy(value HttpHeader) {}type HttpRequest struct {- Method string- Url string- Headers []HttpHeader- Body *[]byte+ Method string+ Url string+ Headers []HttpHeader+ Body *[]byte+ TimeoutSecs *uint64}func (r *HttpRequest) Destroy() {@@ -2856,6 +2857,7 @@ func (r *HttpRequest) Destroy() {FfiDestroyerString{}.Destroy(r.Url)FfiDestroyerSequenceHttpHeader{}.Destroy(r.Headers)FfiDestroyerOptionalBytes{}.Destroy(r.Body)+ FfiDestroyerOptionalUint64{}.Destroy(r.TimeoutSecs)}type FfiConverterHttpRequest struct{}@@ -2872,6 +2874,7 @@ func (c FfiConverterHttpRequest) Read(reader io.Reader) HttpRequest {FfiConverterStringINSTANCE.Read(reader),FfiConverterSequenceHttpHeaderINSTANCE.Read(reader),FfiConverterOptionalBytesINSTANCE.Read(reader),+ FfiConverterOptionalUint64INSTANCE.Read(reader),}}@@ -2888,6 +2891,7 @@ func (c FfiConverterHttpRequest) Write(writer io.Writer, value HttpRequest) {FfiConverterStringINSTANCE.Write(writer, value.Url)FfiConverterSequenceHttpHeaderINSTANCE.Write(writer, value.Headers)FfiConverterOptionalBytesINSTANCE.Write(writer, value.Body)+ FfiConverterOptionalUint64INSTANCE.Write(writer, value.TimeoutSecs)}type FfiDestroyerHttpRequest struct{}@@ -4108,6 +4112,47 @@ func (_ FfiDestroyerOptionalBytes) Destroy(value *[]byte) {}}+type FfiConverterOptionalUint64 struct{}++var FfiConverterOptionalUint64INSTANCE = FfiConverterOptionalUint64{}++func (c FfiConverterOptionalUint64) Lift(rb RustBufferI) *uint64 {+ return LiftFromRustBuffer[*uint64](c, rb)+}++func (_ FfiConverterOptionalUint64) Read(reader io.Reader) *uint64 {+ if readInt8(reader) == 0 {+ return nil+ }+ temp := FfiConverterUint64INSTANCE.Read(reader)+ return &temp+}++func (c FfiConverterOptionalUint64) Lower(value *uint64) C.RustBuffer {+ return LowerIntoRustBuffer[*uint64](c, value)+}++func (c FfiConverterOptionalUint64) LowerExternal(value *uint64) ExternalCRustBuffer {+ return RustBufferFromC(LowerIntoRustBuffer[*uint64](c, value))+}++func (_ FfiConverterOptionalUint64) Write(writer io.Writer, value *uint64) {+ if value == nil {+ writeInt8(writer, 0)+ } else {+ writeInt8(writer, 1)+ FfiConverterUint64INSTANCE.Write(writer, *value)+ }+}++type FfiDestroyerOptionalUint64 struct{}++func (_ FfiDestroyerOptionalUint64) Destroy(value *uint64) {+ if value != nil {+ FfiDestroyerUint64{}.Destroy(*value)+ }+}+type FfiConverterOptionalClaimSpec struct{}var FfiConverterOptionalClaimSpecINSTANCE = FfiConverterOptionalClaimSpec{}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.ktindex 47350ea44c..9291bddfca 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@@ -5928,6 +5928,8 @@ data class HttpRequest (var `headers`: List<HttpHeader>,var `body`: kotlin.ByteArray?+ ,+ var `timeoutSecs`: kotlin.ULong?){@@ -5948,6 +5950,7 @@ public object FfiConverterTypeHttpRequest: FfiConverterRustBuffer<HttpRequest> {FfiConverterString.read(buf),FfiConverterSequenceTypeHttpHeader.read(buf),FfiConverterOptionalByteArray.read(buf),+ FfiConverterOptionalULong.read(buf),)}@@ -5955,7 +5958,8 @@ public object FfiConverterTypeHttpRequest: FfiConverterRustBuffer<HttpRequest> {FfiConverterString.allocationSize(value.`method`) +FfiConverterString.allocationSize(value.`url`) +FfiConverterSequenceTypeHttpHeader.allocationSize(value.`headers`) +- FfiConverterOptionalByteArray.allocationSize(value.`body`)+ FfiConverterOptionalByteArray.allocationSize(value.`body`) ++ FfiConverterOptionalULong.allocationSize(value.`timeoutSecs`))override fun write(value: HttpRequest, buf: ByteBuffer) {@@ -5963,6 +5967,7 @@ public object FfiConverterTypeHttpRequest: FfiConverterRustBuffer<HttpRequest> {FfiConverterString.write(value.`url`, buf)FfiConverterSequenceTypeHttpHeader.write(value.`headers`, buf)FfiConverterOptionalByteArray.write(value.`body`, buf)+ FfiConverterOptionalULong.write(value.`timeoutSecs`, buf)}}@@ -6837,6 +6842,38 @@ public object FfiConverterTypeSdkError : FfiConverterRustBuffer<SdkException> {+/**+ * @suppress+ */+public object FfiConverterOptionalULong: FfiConverterRustBuffer<kotlin.ULong?> {+ override fun read(buf: ByteBuffer): kotlin.ULong? {+ if (buf.get().toInt() == 0) {+ return null+ }+ return FfiConverterULong.read(buf)+ }++ override fun allocationSize(value: kotlin.ULong?): ULong {+ if (value == null) {+ return 1UL+ } else {+ return 1UL + FfiConverterULong.allocationSize(value)+ }+ }++ override fun write(value: kotlin.ULong?, buf: ByteBuffer) {+ if (value == null) {+ buf.put(0)+ } else {+ buf.put(1)+ FfiConverterULong.write(value, buf)+ }+ }+}++++/*** @suppress*/diff --git a/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.kt b/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.ktindex 2f5f449fee..b10b142094 100644--- a/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.kt+++ b/libs/fleet/sdk-bindings/kotlin/tests/TestAsyncClient.kt@@ -108,7 +108,7 @@ private fun configuration() = CyclopsConfiguration(2u,)-private fun serviceRequest(body: ByteArray?) = HttpRequest("POST", "https://ignored.invalid/mcp", emptyList(), body)+private fun serviceRequest(body: ByteArray?) = HttpRequest("POST", "https://ignored.invalid/mcp", emptyList(), body, null)private val sandbox = Sandbox("default", "default", "offline-sandbox", listOf("mcp"))fun main() = runBlocking {diff --git a/libs/fleet/sdk-bindings/python/contract_fixture.py b/libs/fleet/sdk-bindings/python/contract_fixture.pyindex 8f35a752a8..3aff6d44e3 100644--- a/libs/fleet/sdk-bindings/python/contract_fixture.py+++ b/libs/fleet/sdk-bindings/python/contract_fixture.py@@ -69,7 +69,7 @@ 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)+ return HttpRequest(method='POST', url='https://ignored.invalid/mcp', headers=[], body=body, timeout_secs=None)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.pyindex 5e51b03e2f..c5ecedd73d 100644--- a/libs/fleet/sdk-bindings/python/fleet_sdk/_sdk.py+++ b/libs/fleet/sdk-bindings/python/fleet_sdk/_sdk.py@@ -2581,19 +2581,45 @@ class _UniffiFfiConverterOptionalBytes(_UniffiConverterRustBuffer):else:raise InternalError("Unexpected flag byte for optional type")+class _UniffiFfiConverterOptionalUInt64(_UniffiConverterRustBuffer):+ @classmethod+ def check_lower(cls, value):+ if value is not None:+ _UniffiFfiConverterUInt64.check_lower(value)++ @classmethod+ def write(cls, value, buf):+ if value is None:+ buf.write_u8(0)+ return++ buf.write_u8(1)+ _UniffiFfiConverterUInt64.write(value, buf)++ @classmethod+ def read(cls, buf):+ flag = buf.read_u8()+ if flag == 0:+ return None+ elif flag == 1:+ return _UniffiFfiConverterUInt64.read(buf)+ else:+ raise InternalError("Unexpected flag byte for optional type")+@dataclassclass HttpRequest:- def __init__(self, *, method:str, url:str, headers:typing.List[HttpHeader], body:typing.Optional[bytes]):+ def __init__(self, *, method:str, url:str, headers:typing.List[HttpHeader], body:typing.Optional[bytes], timeout_secs:typing.Optional[int]):self.method = methodself.url = urlself.headers = headersself.body = body+ self.timeout_secs = timeout_secsdef __str__(self):- return "HttpRequest(method={}, url={}, headers={}, body={})".format(self.method, self.url, self.headers, self.body)+ return "HttpRequest(method={}, url={}, headers={}, body={}, timeout_secs={})".format(self.method, self.url, self.headers, self.body, self.timeout_secs)def __eq__(self, other):if self.method != other.method:return False@@ -2603,6 +2629,8 @@ class HttpRequest:return Falseif self.body != other.body:return False+ if self.timeout_secs != other.timeout_secs:+ return Falsereturn Trueclass _UniffiFfiConverterTypeHttpRequest(_UniffiConverterRustBuffer):@@ -2613,6 +2641,7 @@ class _UniffiFfiConverterTypeHttpRequest(_UniffiConverterRustBuffer):url=_UniffiFfiConverterString.read(buf),headers=_UniffiFfiConverterSequenceTypeHttpHeader.read(buf),body=_UniffiFfiConverterOptionalBytes.read(buf),+ timeout_secs=_UniffiFfiConverterOptionalUInt64.read(buf),)@staticmethod@@ -2621,6 +2650,7 @@ class _UniffiFfiConverterTypeHttpRequest(_UniffiConverterRustBuffer):_UniffiFfiConverterString.check_lower(value.url)_UniffiFfiConverterSequenceTypeHttpHeader.check_lower(value.headers)_UniffiFfiConverterOptionalBytes.check_lower(value.body)+ _UniffiFfiConverterOptionalUInt64.check_lower(value.timeout_secs)@staticmethoddef write(value, buf):@@ -2628,6 +2658,7 @@ class _UniffiFfiConverterTypeHttpRequest(_UniffiConverterRustBuffer):_UniffiFfiConverterString.write(value.url, buf)_UniffiFfiConverterSequenceTypeHttpHeader.write(value.headers, buf)_UniffiFfiConverterOptionalBytes.write(value.body, buf)+ _UniffiFfiConverterOptionalUInt64.write(value.timeout_secs, buf)class _UniffiFfiConverterUInt16(_UniffiConverterPrimitiveInt):CLASS_NAME = "u16"diff --git a/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rb b/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rbindex 669703ddf2..b3071eb925 100644--- a/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rb+++ b/libs/fleet/sdk-bindings/ruby/cyclops_sdk/sdk.rb@@ -349,6 +349,7 @@ private_constant :UniffiHandleMapRustBuffer.check_lower_SequenceTypeHttpHeader(v.headers)RustBuffer.check_lower_Optionalbytes(v.body)+ RustBuffer.check_lower_Optionalu64(v.timeout_secs)enddef self.alloc_from_TypeHttpRequest(v)@@ -549,6 +550,27 @@ private_constant :UniffiHandleMap+ # The Optional<T> type for u64.++ def self.check_lower_Optionalu64(v)+ if not v.nil?++ end+ end++ def self.alloc_from_Optionalu64(v)+ RustBuffer.allocWithBuilder do |builder|+ builder.write_Optionalu64(v)+ return builder.finalize()+ end+ end++ def consumeIntoOptionalu64+ consumeWithStream do |stream|+ return stream.readOptionalu64+ end+ end+# The Optional<T> type for string.def self.check_lower_Optionalstring(v)@@ -1087,7 +1109,8 @@ class RustBufferStreammethod: readString,url: readString,headers: readSequenceTypeHttpHeader,- body: readOptionalbytes+ body: readOptionalbytes,+ timeout_secs: readOptionalu64)end@@ -1306,6 +1329,20 @@ class RustBufferStreamend+ # The Optional<T> type for u64.++ def readOptionalu64+ flag = unpack_from 1, 'c'++ if flag == 0+ return nil+ elsif flag == 1+ return readU64+ else+ raise InternalError, 'Unexpected flag byte for Optionalu64'+ end+ end+# The Optional<T> type for string.def readOptionalstring@@ -1738,6 +1775,7 @@ class RustBufferBuilderself.write_String(v.url)self.write_SequenceTypeHttpHeader(v.headers)self.write_Optionalbytes(v.body)+ self.write_Optionalu64(v.timeout_secs)end# The Record type HttpResponse.@@ -1821,6 +1859,17 @@ class RustBufferBuilder+ # The Optional<T> type for u64.++ def write_Optionalu64(v)+ if v.nil?+ pack_into(1, 'c', 0)+ else+ pack_into(1, 'c', 1)+ self.write_U64(v)+ end+ end+# The Optional<T> type for string.def write_Optionalstring(v)@@ -3173,13 +3222,14 @@ end# Record type HttpRequestclass HttpRequest- attr_reader :method, :url, :headers, :body+ attr_reader :method, :url, :headers, :body, :timeout_secs- def initialize(method:, url:, headers:, body:)+ def initialize(method:, url:, headers:, body:, timeout_secs:)@method = method@url = url@headers = headers@body = body+ @timeout_secs = timeout_secsenddef ==(other)@@ -3195,6 +3245,9 @@ class HttpRequestif @body != other.bodyreturn falseend+ if @timeout_secs != other.timeout_secs+ return false+ endtrueenddiff --git a/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rb b/libs/fleet/sdk-bindings/ruby/tests/test_async_client.rbindex 3ddbca0550..568321e87f 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,7 @@ def configurationenddef service_request(body)- FleetSdk::HttpRequest.new(method: 'POST', url: 'https://ignored.invalid/mcp', headers: [], body: body)+ FleetSdk::HttpRequest.new(method: 'POST', url: 'https://ignored.invalid/mcp', headers: [], body: body, timeout_secs: nil)endsandbox = FleetSdk::Sandbox.new(namespace: 'default', claim: 'default', name: 'offline-sandbox', services: ['mcp'])diff --git a/libs/fleet/sdk-bindings/swift/CyclopsSdk.swift b/libs/fleet/sdk-bindings/swift/CyclopsSdk.swiftindex e2039323ad..f75d399d99 100644--- a/libs/fleet/sdk-bindings/swift/CyclopsSdk.swift+++ b/libs/fleet/sdk-bindings/swift/CyclopsSdk.swift@@ -3223,14 +3223,16 @@ public struct HttpRequest: Equatable, Hashable {public var url: Stringpublic var headers: [HttpHeader]public var body: Data?+ 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?) {+ public init(method: String, url: String, headers: [HttpHeader], body: Data?, timeoutSecs: UInt64?) {self.method = methodself.url = urlself.headers = headersself.body = body+ self.timeoutSecs = timeoutSecs}@@ -3252,7 +3254,8 @@ public struct FfiConverterTypeHttpRequest: FfiConverterRustBuffer {method: FfiConverterString.read(from: &buf),url: FfiConverterString.read(from: &buf),headers: FfiConverterSequenceTypeHttpHeader.read(from: &buf),- body: FfiConverterOptionData.read(from: &buf)+ body: FfiConverterOptionData.read(from: &buf),+ timeoutSecs: FfiConverterOptionUInt64.read(from: &buf))}@@ -3261,6 +3264,7 @@ public struct FfiConverterTypeHttpRequest: FfiConverterRustBuffer {FfiConverterString.write(value.url, into: &buf)FfiConverterSequenceTypeHttpHeader.write(value.headers, into: &buf)FfiConverterOptionData.write(value.body, into: &buf)+ FfiConverterOptionUInt64.write(value.timeoutSecs, into: &buf)}}@@ -4188,6 +4192,30 @@ public func FfiConverterTypeSdkError_lower(_ value: SdkError) -> RustBuffer {return FfiConverterTypeSdkError.lower(value)}+#if swift(>=5.8)+@_documentation(visibility: private)+#endif+fileprivate struct FfiConverterOptionUInt64: FfiConverterRustBuffer {+ typealias SwiftType = UInt64?++ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {+ guard let value = value else {+ writeInt(&buf, Int8(0))+ return+ }+ writeInt(&buf, Int8(1))+ FfiConverterUInt64.write(value, into: &buf)+ }++ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {+ switch try readInt(&buf) as Int8 {+ case 0: return nil+ case 1: return try FfiConverterUInt64.read(from: &buf)+ default: throw UniffiInternalError.unexpectedOptionalTag+ }+ }+}+#if swift(>=5.8)@_documentation(visibility: private)#endifdiff --git a/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swift b/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swiftindex 5084a4b17c..0c2f17465e 100644--- a/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swift+++ b/libs/fleet/sdk-bindings/swift/tests/TestAsyncClient.swift@@ -111,7 +111,7 @@ private func configuration() -> CyclopsConfiguration {private let sandbox = Sandbox(namespace: "default", claim: "default", name: "offline-sandbox", services: ["mcp"])private func serviceRequest(_ body: Data?) -> HttpRequest {- HttpRequest(method: "POST", url: "https://ignored.invalid/mcp", headers: [], body: body)+ HttpRequest(method: "POST", url: "https://ignored.invalid/mcp", headers: [], body: body, timeoutSecs: nil)}@main struct AppControlled {diff --git a/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.ts b/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.tsindex 3e7fa25061..44cd92067d 100644--- a/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.ts+++ b/libs/fleet/sdk-bindings/ts-uniffi-browser/ts/fleet_sdk.ts@@ -785,6 +785,7 @@ export type HttpRequest = {url: string;headers: Array<HttpHeader>;body?: ArrayBuffer;+ timeoutSecs?: bigint;};/**@@ -813,6 +814,7 @@ const FfiConverterTypeHttpRequest = (() => {url: FfiConverterString.read(from),headers: FfiConverterSequenceTypeHttpHeader.read(from),body: FfiConverterOptionalBytes.read(from),+ timeoutSecs: FfiConverterOptionalUInt64.read(from),};}write(value: TypeName, into: RustBuffer): void {@@ -820,13 +822,15 @@ const FfiConverterTypeHttpRequest = (() => {FfiConverterString.write(value.url, into);FfiConverterSequenceTypeHttpHeader.write(value.headers, into);FfiConverterOptionalBytes.write(value.body, into);+ FfiConverterOptionalUInt64.write(value.timeoutSecs, into);}allocationSize(value: TypeName): number {return (FfiConverterString.allocationSize(value.method) +FfiConverterString.allocationSize(value.url) +FfiConverterSequenceTypeHttpHeader.allocationSize(value.headers) +- FfiConverterOptionalBytes.allocationSize(value.body)+ FfiConverterOptionalBytes.allocationSize(value.body) ++ FfiConverterOptionalUInt64.allocationSize(value.timeoutSecs));}}@@ -5053,6 +5057,9 @@ const FfiConverterOptionalBytes = new FfiConverterOptional(FfiConverterArrayBuffer,);+// FfiConverter for bigint | undefined+const FfiConverterOptionalUInt64 = new FfiConverterOptional(FfiConverterUInt64);+// FfiConverter for Array<Claim>const FfiConverterSequenceTypeClaim = new FfiConverterArray(FfiConverterTypeClaim,diff --git a/libs/fleet/sdk-bindings/ts-uniffi/fleet_sdk.ts b/libs/fleet/sdk-bindings/ts-uniffi/fleet_sdk.tsindex ef1358c8d1..6fad0e7393 100644--- a/libs/fleet/sdk-bindings/ts-uniffi/fleet_sdk.ts+++ b/libs/fleet/sdk-bindings/ts-uniffi/fleet_sdk.ts@@ -678,7 +678,8 @@ export type HttpRequest = {method: string,url: string,headers: Array<HttpHeader>,- body?: ArrayBuffer+ body?: ArrayBuffer,+ timeoutSecs?: bigint}/**@@ -705,7 +706,8 @@ const FfiConverterTypeHttpRequest = (() => {method: FfiConverterString.read(from),url: FfiConverterString.read(from),headers: FfiConverterSequenceTypeHttpHeader.read(from),- body: FfiConverterOptionalBytes.read(from)+ body: FfiConverterOptionalBytes.read(from),+ timeoutSecs: FfiConverterOptionalUInt64.read(from)};}write(value: TypeName, into: RustBuffer): void {@@ -713,12 +715,14 @@ const FfiConverterTypeHttpRequest = (() => {FfiConverterString.write(value.url, into);FfiConverterSequenceTypeHttpHeader.write(value.headers, into);FfiConverterOptionalBytes.write(value.body, into);+ FfiConverterOptionalUInt64.write(value.timeoutSecs, into);}allocationSize(value: TypeName): number {return FfiConverterString.allocationSize(value.method) +FfiConverterString.allocationSize(value.url) +FfiConverterSequenceTypeHttpHeader.allocationSize(value.headers) +- FfiConverterOptionalBytes.allocationSize(value.body);+ FfiConverterOptionalBytes.allocationSize(value.body) ++ FfiConverterOptionalUInt64.allocationSize(value.timeoutSecs);}};@@ -3189,6 +3193,9 @@ const FfiConverterSequenceTypeHttpHeader = new FfiConverterArray(FfiConverterTyp// FfiConverter for ArrayBuffer | undefinedconst FfiConverterOptionalBytes = new FfiConverterOptional(FfiConverterArrayBuffer);+// FfiConverter for bigint | undefined+const FfiConverterOptionalUInt64 = new FfiConverterOptional(FfiConverterUInt64);+// FfiConverter for Array<Claim>const FfiConverterSequenceTypeClaim = new FfiConverterArray(FfiConverterTypeClaim);diff --git a/libs/fleet/sdk/src/claims.rs b/libs/fleet/sdk/src/claims.rsindex 675b796383..6b835a8b0b 100644--- a/libs/fleet/sdk/src/claims.rs+++ b/libs/fleet/sdk/src/claims.rs@@ -278,6 +278,7 @@ fn json_request(method: &str, url: Url, body: Option<Vec<u8>>) -> HttpRequest {},],body,+ timeout_secs: None,}}diff --git a/libs/fleet/sdk/src/namespaces.rs b/libs/fleet/sdk/src/namespaces.rsindex 7b5f2c6088..eb36704f04 100644--- a/libs/fleet/sdk/src/namespaces.rs+++ b/libs/fleet/sdk/src/namespaces.rs@@ -97,6 +97,7 @@ fn json_request(method: &str, url: url::Url, body: Option<Vec<u8>>) -> HttpReque},],body,+ timeout_secs: None,}}diff --git a/libs/fleet/sdk/src/pools.rs b/libs/fleet/sdk/src/pools.rsindex c90569fc0d..a9c640c74b 100644--- a/libs/fleet/sdk/src/pools.rs+++ b/libs/fleet/sdk/src/pools.rs@@ -220,6 +220,7 @@ fn json_request(method: &str, url: Url, body: Option<Vec<u8>>) -> HttpRequest {},],body,+ timeout_secs: None,}}diff --git a/libs/fleet/sdk/src/services.rs b/libs/fleet/sdk/src/services.rsindex 896624296c..d33f7ec275 100644--- a/libs/fleet/sdk/src/services.rs+++ b/libs/fleet/sdk/src/services.rs@@ -29,6 +29,7 @@ impl CyclopsClient {url: url.to_string(),headers: filtered_headers(request.headers),body: request.body,+ timeout_secs: request.timeout_secs,};self.execute_authenticated_service(request).await}diff --git a/libs/fleet/sdk/src/templates.rs b/libs/fleet/sdk/src/templates.rsindex cebcb6ed5c..f09a06b342 100644--- a/libs/fleet/sdk/src/templates.rs+++ b/libs/fleet/sdk/src/templates.rs@@ -143,6 +143,7 @@ fn json_request(method: &str, url: Url, body: Option<Vec<u8>>) -> HttpRequest {},],body,+ timeout_secs: None,}}diff --git a/libs/fleet/sdk/src/transport.rs b/libs/fleet/sdk/src/transport.rsindex 68146f5664..4d7dcb3175 100644--- a/libs/fleet/sdk/src/transport.rs+++ b/libs/fleet/sdk/src/transport.rs@@ -58,17 +58,36 @@ impl NativeHttpClient {})}}++#[cfg(not(target_arch = "wasm32"))]+fn apply_request_timeout(+ request: reqwest::RequestBuilder,+ timeout_secs: Option<u64>,+) -> reqwest::RequestBuilder {+ match timeout_secs {+ Some(timeout_secs) => request.timeout(Duration::from_secs(timeout_secs)),+ None => request,+ }+}+#[cfg(not(target_arch = "wasm32"))]#[async_trait::async_trait]impl HttpClient for NativeHttpClient {async fn execute(&self, request: HttpRequest) -> Result<HttpResponse, HttpError> {- let method = reqwest::Method::from_bytes(request.method.as_bytes()).map_err(|error| {+ let HttpRequest {+ method,+ url,+ headers: request_headers,+ body,+ timeout_secs,+ } = request;+ let method = reqwest::Method::from_bytes(method.as_bytes()).map_err(|error| {HttpError::Transport {reason: format!("invalid HTTP method: {error}"),}})?;let mut headers = reqwest::header::HeaderMap::new();- for header in request.headers {+ for header in request_headers {let name = reqwest::header::HeaderName::from_bytes(header.name.as_bytes()).map_err(|error| HttpError::Transport {reason: format!("invalid HTTP header name: {error}"),@@ -81,8 +100,11 @@ impl HttpClient for NativeHttpClient {})?;headers.append(name, value);}- let mut native = self.client.request(method, request.url).headers(headers);- if let Some(body) = request.body {+ let mut native = apply_request_timeout(+ self.client.request(method, url).headers(headers),+ timeout_secs,+ );+ if let Some(body) = body {native = native.body(body);}native_http_runtime()@@ -462,6 +484,7 @@ impl Transport {},],body: Some(body),+ timeout_secs: None,}).await.map_err(map_http_error)?;@@ -607,6 +630,7 @@ mod native_http_client_tests {},],body: None,+ timeout_secs: None,}).await.unwrap();@@ -650,6 +674,7 @@ mod native_http_client_tests {value: "Bearer intended-token".into(),}],body: None,+ timeout_secs: None,}).await.unwrap();@@ -659,3 +684,27 @@ mod native_http_client_tests {assert!(matches!(redirected.accept(), Err(error) if error.kind() == ErrorKind::WouldBlock));}}++#[cfg(all(test, not(target_arch = "wasm32")))]+mod native_tests {+ use super::apply_request_timeout;+ use std::time::Duration;++ #[test]+ fn applies_per_request_timeout_only_when_present() {+ let client = reqwest::Client::builder()+ .timeout(Duration::from_secs(30))+ .build()+ .unwrap();++ let default_request = apply_request_timeout(client.get("https://example.com"), None)+ .build()+ .unwrap();+ let overridden_request = apply_request_timeout(client.get("https://example.com"), Some(75))+ .build()+ .unwrap();++ assert_eq!(default_request.timeout(), None);+ assert_eq!(overridden_request.timeout(), Some(&Duration::from_secs(75)));+ }+}diff --git a/libs/fleet/sdk/src/types.rs b/libs/fleet/sdk/src/types.rsindex f152ba6325..e897f05742 100644--- a/libs/fleet/sdk/src/types.rs+++ b/libs/fleet/sdk/src/types.rs@@ -293,6 +293,7 @@ pub struct HttpRequest {pub url: String,pub headers: Vec<HttpHeader>,pub body: Option<Vec<u8>>,+ pub timeout_secs: Option<u64>,}#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, uniffi::Record)]diff --git a/libs/fleet/sdk/src/user_keys.rs b/libs/fleet/sdk/src/user_keys.rsindex d4e710bff0..33ab66fcaf 100644--- a/libs/fleet/sdk/src/user_keys.rs+++ b/libs/fleet/sdk/src/user_keys.rs@@ -75,5 +75,6 @@ fn json_request(method: &str, url: url::Url, body: Option<Vec<u8>>) -> HttpRequeurl: url.into(),headers,body,+ timeout_secs: None,}}diff --git a/libs/fleet/sdk/tests/oauth.rs b/libs/fleet/sdk/tests/oauth.rsindex ff30fe2da2..d87106ab52 100644--- a/libs/fleet/sdk/tests/oauth.rs+++ b/libs/fleet/sdk/tests/oauth.rs@@ -340,6 +340,7 @@ async fn does_not_attach_bearer_to_cross_origin_requests() {url: "https://cyclops.example/api/pools".into(),headers: vec![header("Authorization", "Basic external")],body: Some(vec![0, 1, 2]),+ timeout_secs: None,};let response = client.execute_authenticated(external).await.unwrap();@@ -430,6 +431,7 @@ fn request(url: &str) -> HttpRequest {header("x-trace", "keep"),],body: None,+ timeout_secs: None,}}diff --git a/libs/fleet/sdk/tests/public_api.rs b/libs/fleet/sdk/tests/public_api.rsindex a84631b746..95c5a3979b 100644--- a/libs/fleet/sdk/tests/public_api.rs+++ b/libs/fleet/sdk/tests/public_api.rs@@ -176,6 +176,7 @@ async fn foreign_http_client_preserves_ordered_headers_and_byte_bodies() {},],body: Some(vec![0, 255]),+ timeout_secs: None,}).await.unwrap();@@ -190,14 +191,21 @@ fn http_request_distinguishes_absent_and_empty_bodies() {url: "https://run.cua.ai/v1/pools".into(),headers: vec![],body: None,+ timeout_secs: None,};let empty = HttpRequest {body: Some(vec![]),..absent.clone()};+ let timed = HttpRequest {+ timeout_secs: Some(75),+ ..absent.clone()+ };assert_ne!(absent, empty);assert_eq!(empty.body, Some(vec![]));+ assert_ne!(absent, timed);+ assert_eq!(timed.timeout_secs, Some(75));}#[test]diff --git a/libs/fleet/sdk/tests/service_flow.rs b/libs/fleet/sdk/tests/service_flow.rsindex 7e8c18b6d8..5362700cc6 100644--- a/libs/fleet/sdk/tests/service_flow.rs+++ b/libs/fleet/sdk/tests/service_flow.rs@@ -184,6 +184,7 @@ async fn filters_hop_by_hop_and_connection_nominated_headers_without_reordering_header("Cookie", "session=kept"),],body: Some(vec![0, 255, 1]),+ timeout_secs: Some(75),};client@@ -206,6 +207,7 @@ async fn filters_hop_by_hop_and_connection_nominated_headers_without_reordering_]);assert_eq!(request.body, Some(vec![0, 255, 1]));+ assert_eq!(request.timeout_secs, Some(75));}#[tokio::test]@@ -295,6 +297,7 @@ async fn returns_service_unauthorized_once_without_refreshing_or_replaying() {url: "https://attacker.example/ignored".into(),headers: vec![header("content-type", "application/octet-stream")],body: Some(vec![0, 255, 1]),+ timeout_secs: None,};let response = client@@ -407,6 +410,7 @@ fn request(body: Option<Vec<u8>>) -> HttpRequest {url: "https://attacker.example/ignored".into(),headers: vec![],body,+ timeout_secs: None,}}