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(cua-driver): drop the boolean enum from verify_state for Gemini clients (#4229)
Shobhit agnihotri919f1d517b50
diff --git a/libs/cua-driver/contract/manifest.json b/libs/cua-driver/contract/manifest.jsonindex b786ceef35..4a942079ea 100644--- a/libs/cua-driver/contract/manifest.json+++ b/libs/cua-driver/contract/manifest.json@@ -5036,9 +5036,6 @@},"exists": {"description": "Assert that at least one trusted element matches the selector.\n\nElement walks are not yet exhaustive on every platform, so absence\ncannot be proven. `false` is rejected instead of returning an\nindefinitely-unknown predicate.",- "enum": [- true- ],"type": "boolean"},"selected": {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.rsindex 0cdde7377d..2e07c54b92 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@@ -409,8 +409,15 @@ mod tests {);assert_eq!(contract.input_schema["properties"]["expect"]["items"]["properties"]["element"]- ["properties"]["exists"]["enum"],- serde_json::json!([true])+ ["properties"]["exists"]["type"],+ serde_json::json!("boolean")+ );+ assert!(+ contract.input_schema["properties"]["expect"]["items"]["properties"]["element"]+ ["properties"]["exists"]+ .get("enum")+ .is_none(),+ "verify_state element.exists should not specify enum (must remain plain boolean for Gemini function-calling compatibility)");}diff --git a/libs/cua-driver/rust/crates/cua-driver-contract/src/verification.rs b/libs/cua-driver/rust/crates/cua-driver-contract/src/verification.rsindex acba4dbb6b..72ed6462e5 100644--- a/libs/cua-driver/rust/crates/cua-driver-contract/src/verification.rs+++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/verification.rs@@ -51,8 +51,8 @@ fn nonempty_string_schema(_: &mut SchemaGenerator) -> Schema {json_schema!({ "type": "string", "minLength": 1 })}-fn true_only_boolean_schema(_: &mut SchemaGenerator) -> Schema {- json_schema!({ "type": "boolean", "enum": [true] })+fn boolean_schema(_: &mut SchemaGenerator) -> Schema {+ json_schema!({ "type": "boolean" })}fn nullable_string_schema(_: &mut SchemaGenerator) -> Schema {@@ -125,7 +125,7 @@ pub struct ElementPredicate {/// cannot be proven. `false` is rejected instead of returning an/// indefinitely-unknown predicate.#[serde(default, skip_serializing_if = "Option::is_none")]- #[schemars(schema_with = "true_only_boolean_schema")]+ #[schemars(schema_with = "boolean_schema")]pub exists: Option<bool>,#[serde(default, skip_serializing_if = "Option::is_none")]pub value_equals: Option<String>,diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/protocol_schema_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/protocol_schema_test.rsindex 0cde058c7b..713a5c09d8 100644--- a/libs/cua-driver/rust/crates/cua-driver/tests/protocol_schema_test.rs+++ b/libs/cua-driver/rust/crates/cua-driver/tests/protocol_schema_test.rs@@ -1,16 +1,47 @@//! Pure `tools/list` schema-shape assertions.//!-//! These never invoke a tool — they only inspect the advertised inputSchemas:-//! that every tool keeps its top-level schema provider-compatible, that-//! `type_text_chars` is hidden, the `list_windows.on_screen_only` knob, the-//! `set_agent_cursor_motion` Bezier knobs, delivery and scope enums, and the-//! `set_config.capture_mode` enum and the per-session capture-scope contract.+//! These never invoke a tool — they only inspect the advertised schemas: that+//! every tool keeps its top-level schema provider-compatible, that every+//! advertised `enum` is string-only, that `type_text_chars` is hidden, the+//! `list_windows.on_screen_only` knob, the `set_agent_cursor_motion` Bezier+//! knobs, delivery and scope enums, and the `set_config.capture_mode` enum and+//! the per-session capture-scope contract.#![cfg(any(target_os = "linux", target_os = "macos", target_os = "windows"))]use cua_driver_testkit::{Driver, McpDriver, RawDriver};use std::collections::BTreeSet;+/// Gemini function calling accepts `enum` only on string schemas and rejects+/// the whole request otherwise, so one boolean or numeric enum in any+/// advertised schema breaks every call from that client (#4220).+fn assert_string_enums(value: &serde_json::Value, path: &str) {+ match value {+ serde_json::Value::Object(map) => {+ if let Some(values) = map.get("enum") {+ let values = values+ .as_array()+ .unwrap_or_else(|| panic!("{path}.enum must be an array: {values}"));+ for (index, item) in values.iter().enumerate() {+ assert!(+ item.is_string(),+ "{path}.enum[{index}] must be a string for Gemini-compatible clients: {item}"+ );+ }+ }+ for (key, child) in map {+ assert_string_enums(child, &format!("{path}.{key}"));+ }+ }+ serde_json::Value::Array(items) => {+ for (index, item) in items.iter().enumerate() {+ assert_string_enums(item, &format!("{path}[{index}]"));+ }+ }+ _ => {}+ }+}+#[test]fn tools_list_schema_shape() {//! `type_text_chars` is an accepted-but-deprecated invoke alias that stays@@ -49,6 +80,9 @@ fn tools_list_schema_shape() {"{name} top-level {unsupported} is rejected by Bedrock: {schema}");}+ for field in ["inputSchema", "outputSchema"] {+ assert_string_enums(&tool[field], &format!("{name}.{field}"));+ }}let enum_contains = |schema: &serde_json::Value, expected: &str| {schema["enum"]