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(cua-driver): drop schemars uint/float formats from contract schema (#3462)

Michael Neeleyefd75df76f2c
diff --git a/libs/cua-driver/contract/manifest.json b/libs/cua-driver/contract/manifest.json
index a85ec9fc57..ebeb1c25c7 100644
--- a/libs/cua-driver/contract/manifest.json
+++ b/libs/cua-driver/contract/manifest.json
@@ -118,12 +118,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -176,7 +174,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -549,12 +546,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -612,7 +607,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -957,39 +951,30 @@
"motion": {
"properties": {
"arc_flow": {
- "format": "double",
"type": "number"
},
"arc_size": {
- "format": "double",
"type": "number"
},
"dwell_after_click_ms": {
- "format": "double",
"type": "number"
},
"end_handle": {
- "format": "double",
"type": "number"
},
"glide_duration_ms": {
- "format": "double",
"type": "number"
},
"idle_hide_ms": {
- "format": "double",
"type": "number"
},
"spring": {
- "format": "double",
"type": "number"
},
"start_handle": {
- "format": "double",
"type": "number"
},
"turn_radius": {
- "format": "double",
"type": "number"
}
},
@@ -1011,11 +996,9 @@
{
"properties": {
"x": {
- "format": "double",
"type": "number"
},
"y": {
- "format": "double",
"type": "number"
}
},
@@ -1075,7 +1058,6 @@
"visual_state": {
"properties": {
"frame": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -1089,7 +1071,6 @@
"type": "string"
},
"preempted_count": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -1434,12 +1415,10 @@
"type": "boolean"
},
"expires_in_seconds": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
"idle_seconds": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -1695,7 +1674,6 @@
]
},
"element_count": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -1715,12 +1693,10 @@
]
},
"depth": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"element_index": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -1739,19 +1715,15 @@
"frame": {
"properties": {
"h": {
- "format": "double",
"type": "number"
},
"w": {
- "format": "double",
"type": "number"
},
"x": {
- "format": "double",
"type": "number"
},
"y": {
- "format": "double",
"type": "number"
}
},
@@ -1779,21 +1751,18 @@
]
},
"max": {
- "format": "double",
"type": [
"number",
"null"
]
},
"min": {
- "format": "double",
"type": [
"number",
"null"
]
},
"parent_index": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -1841,7 +1810,6 @@
]
},
"filtered_element_count": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -1849,12 +1817,10 @@
]
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"returned_element_count": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -1874,7 +1840,6 @@
]
},
"screenshot_height": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -1888,14 +1853,12 @@
]
},
"screenshot_scale": {
- "format": "double",
"type": [
"number",
"null"
]
},
"screenshot_width": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -1909,7 +1872,6 @@
]
},
"total_element_count": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -1937,19 +1899,15 @@
"window_bounds": {
"properties": {
"height": {
- "format": "double",
"type": "number"
},
"width": {
- "format": "double",
"type": "number"
},
"x": {
- "format": "double",
"type": "number"
},
"y": {
- "format": "double",
"type": "number"
}
},
@@ -1965,7 +1923,6 @@
]
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -2035,12 +1992,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -2089,7 +2044,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -2293,7 +2247,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -2498,7 +2451,6 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
@@ -2553,7 +2505,6 @@
},
"limit": {
"description": "Maximum number of content-free summaries to return (default 50, max\n100). Ordinary agent transports are scoped to their own lease.",
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -2594,12 +2545,10 @@
"type": "boolean"
},
"expires_in_seconds": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
"idle_seconds": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -2699,7 +2648,6 @@
"additionalProperties": true,
"properties": {
"current_space_id": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -2715,19 +2663,15 @@
"bounds": {
"properties": {
"height": {
- "format": "double",
"type": "number"
},
"width": {
- "format": "double",
"type": "number"
},
"x": {
- "format": "double",
"type": "number"
},
"y": {
- "format": "double",
"type": "number"
}
},
@@ -2740,7 +2684,6 @@
"type": "object"
},
"current_space_id": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -2779,7 +2722,6 @@
},
"space_ids": {
"items": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -2792,7 +2734,6 @@
"type": "string"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -2870,12 +2811,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -2932,7 +2871,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -3172,27 +3110,21 @@
"type": "string"
},
"m11": {
- "format": "double",
"type": "number"
},
"m12": {
- "format": "double",
"type": "number"
},
"m21": {
- "format": "double",
"type": "number"
},
"m22": {
- "format": "double",
"type": "number"
},
"tx": {
- "format": "double",
"type": "number"
},
"ty": {
- "format": "double",
"type": "number"
}
},
@@ -3258,12 +3190,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -3434,7 +3364,6 @@
]
},
"reading_order": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -3471,12 +3400,10 @@
"timing": {
"properties": {
"duration_ms": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
"inference_ms": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -3484,7 +3411,6 @@
]
},
"preprocess_ms": {
- "format": "uint64",
"minimum": 0,
"type": [
"integer",
@@ -3631,12 +3557,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -3685,7 +3609,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -3893,12 +3816,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -3955,7 +3876,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -4169,42 +4089,36 @@
"additionalProperties": false,
"properties": {
"arc_flow": {
- "format": "double",
"type": [
"number",
"null"
]
},
"arc_size": {
- "format": "double",
"type": [
"number",
"null"
]
},
"dwell_after_click_ms": {
- "format": "double",
"type": [
"number",
"null"
]
},
"end_handle": {
- "format": "double",
"type": [
"number",
"null"
]
},
"glide_duration_ms": {
- "format": "double",
"type": [
"number",
"null"
]
},
"idle_hide_ms": {
- "format": "double",
"type": [
"number",
"null"
@@ -4214,21 +4128,18 @@
"type": "string"
},
"spring": {
- "format": "double",
"type": [
"number",
"null"
]
},
"start_handle": {
- "format": "double",
"type": [
"number",
"null"
]
},
"turn_radius": {
- "format": "double",
"type": [
"number",
"null"
@@ -4246,39 +4157,30 @@
"motion": {
"properties": {
"arc_flow": {
- "format": "double",
"type": "number"
},
"arc_size": {
- "format": "double",
"type": "number"
},
"dwell_after_click_ms": {
- "format": "double",
"type": "number"
},
"end_handle": {
- "format": "double",
"type": "number"
},
"glide_duration_ms": {
- "format": "double",
"type": "number"
},
"idle_hide_ms": {
- "format": "double",
"type": "number"
},
"spring": {
- "format": "double",
"type": "number"
},
"start_handle": {
- "format": "double",
"type": "number"
},
"turn_radius": {
- "format": "double",
"type": "number"
}
},
@@ -4472,7 +4374,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -4801,12 +4702,10 @@
"type": "string"
},
"pid": {
- "format": "uint32",
"minimum": 0,
"type": "integer"
},
"window_id": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
}
@@ -4858,7 +4757,6 @@
"additionalProperties": false,
"properties": {
"delivered_count": {
- "format": "uint32",
"minimum": 0,
"type": [
"integer",
@@ -5178,7 +5076,6 @@
"additionalProperties": true,
"properties": {
"elapsed_ms": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -5186,7 +5083,6 @@
"items": {
"properties": {
"index": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
@@ -5239,7 +5135,6 @@
"type": "array"
},
"samples": {
- "format": "uint64",
"minimum": 0,
"type": "integer"
},
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
index b4d780099e..b9636d508a 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/inputs.rs
@@ -6,7 +6,7 @@
//! These types are transport-free. The contract generator derives JSON Schema
//! from them, and live Rust handlers deserialize the same types before acting.
-use crate::CursorThemeSelection;
+use crate::{schema_settings, CursorThemeSelection};
use schemars::{json_schema, JsonSchema, Schema, SchemaGenerator};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::Value;
@@ -19,11 +19,9 @@ pub trait ToolInput: Serialize + DeserializeOwned + JsonSchema {
}
fn input_schema() -> Value {
- let settings = schemars::generate::SchemaSettings::draft2020_12().with(|settings| {
- settings.meta_schema = None;
- settings.inline_subschemas = true;
- });
- let schema = settings.into_generator().into_root_schema_for::<Self>();
+ let schema = schema_settings()
+ .into_generator()
+ .into_root_schema_for::<Self>();
let mut value = serde_json::to_value(schema).expect("tool input schema serializes");
normalize_schema(&mut value);
value
@@ -226,11 +224,7 @@ pub enum ActionTarget {
}
pub fn action_target_schema() -> Value {
- let settings = schemars::generate::SchemaSettings::draft2020_12().with(|settings| {
- settings.meta_schema = None;
- settings.inline_subschemas = true;
- });
- let schema = settings
+ let schema = schema_settings()
.into_generator()
.into_root_schema_for::<ActionTarget>();
let mut value = serde_json::to_value(schema).expect("action target schema serializes");
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
index 2e07c54b92..5dceca8495 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs
@@ -8,6 +8,7 @@
//! typed inputs/results and versioned declarations used by the live runtime
//! and to generate experimental client SDKs.
+use schemars::{generate::SchemaSettings, transform::RecursiveTransform, Schema};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::{BTreeMap, BTreeSet};
@@ -25,6 +26,24 @@ mod visual;
mod windows;
pub use windows::*;
+pub(crate) fn schema_settings() -> SchemaSettings {
+ SchemaSettings::draft2020_12()
+ .with(|settings| {
+ settings.meta_schema = None;
+ settings.inline_subschemas = true;
+ })
+ .with_transform(RecursiveTransform(drop_schemars_numeric_format))
+}
+
+fn drop_schemars_numeric_format(schema: &mut Schema) {
+ if matches!(
+ schema.get("format").and_then(Value::as_str),
+ Some("uint32" | "uint64" | "double")
+ ) {
+ schema.remove("format");
+ }
+}
+
pub use cursor::{
classify_cursor_semantics, CursorAction, CursorDelivery, CursorPlayback, CursorReducedMotion,
CursorSemantics, CursorTarget, CursorThemeSelection,
@@ -334,6 +353,72 @@ pub fn validate_success_output(name: &str, value: Value) -> Result<bool, String>
mod tests {
use super::*;
+ #[derive(Serialize, Deserialize)]
+ struct NumericFormatFixture;
+
+ impl schemars::JsonSchema for NumericFormatFixture {
+ fn schema_name() -> std::borrow::Cow<'static, str> {
+ "NumericFormatFixture".into()
+ }
+
+ fn json_schema(_: &mut schemars::SchemaGenerator) -> Schema {
+ schemars::json_schema!({
+ "type": "object",
+ "properties": {
+ "count": {"type": "integer", "format": "uint32"},
+ "frame": {"type": "integer", "format": "uint64"},
+ "ratio": {"type": "number", "format": "double"},
+ "created_at": {"type": "string", "format": "date-time"},
+ "format": {"type": "string"},
+ "annotation": {
+ "const": {"format": "uint32"},
+ "default": {"format": "uint64"},
+ "examples": [{"format": "double"}]
+ }
+ },
+ "required": ["format"]
+ })
+ }
+ }
+
+ impl ToolInput for NumericFormatFixture {
+ const TOOL_NAME: &'static str = "numeric_format_fixture";
+ }
+
+ impl ToolOutput for NumericFormatFixture {}
+
+ #[test]
+ fn input_and_output_schemas_drop_only_schemars_numeric_formats() {
+ let schemas = [
+ <NumericFormatFixture as ToolInput>::input_schema(),
+ <NumericFormatFixture as ToolOutput>::output_schema(),
+ ];
+
+ for schema in schemas {
+ for property in ["count", "frame", "ratio"] {
+ assert!(schema["properties"][property].get("format").is_none());
+ }
+ assert_eq!(schema["properties"]["created_at"]["format"], "date-time");
+ assert_eq!(
+ schema["properties"]["format"],
+ serde_json::json!({"type": "string"})
+ );
+ assert_eq!(schema["required"], serde_json::json!(["format"]));
+ assert_eq!(
+ schema["properties"]["annotation"]["const"],
+ serde_json::json!({"format": "uint32"})
+ );
+ assert_eq!(
+ schema["properties"]["annotation"]["default"],
+ serde_json::json!({"format": "uint64"})
+ );
+ assert_eq!(
+ schema["properties"]["annotation"]["examples"],
+ serde_json::json!([{"format": "double"}])
+ );
+ }
+ }
+
#[test]
fn manifest_is_sorted_and_versioned() {
let manifest = manifest();
diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
index 5066c98a65..fdd0619fa3 100644
--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2026 Cua AI, Inc.
-use crate::{CaptureScope, EscalationReason, Platform};
-use schemars::{generate::SchemaSettings, JsonSchema};
+use crate::{schema_settings, CaptureScope, EscalationReason, Platform};
+use schemars::JsonSchema;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_json::{Map, Value};
use std::collections::BTreeMap;
@@ -113,11 +113,12 @@ pub fn advertised_output_schema(success: Value) -> Value {
pub(crate) fn output_schema_with_additional_properties<T: JsonSchema>(
additional_properties: bool,
) -> Value {
- let mut settings = SchemaSettings::draft2020_12();
- settings.inline_subschemas = true;
- settings.meta_schema = None;
- let mut schema = serde_json::to_value(settings.into_generator().into_root_schema_for::<T>())
- .expect("JSON Schema serializes");
+ let mut schema = serde_json::to_value(
+ schema_settings()
+ .into_generator()
+ .into_root_schema_for::<T>(),
+ )
+ .expect("JSON Schema serializes");
strip_schema_titles(&mut schema);
if let Some(object) = schema.as_object_mut() {
object.insert(