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): name the missing AT-SPI bus in the X11 background keyboard refusal (#5070)
injaneityd7c98c1e0f66
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/health_report.rs b/libs/cua-driver/rust/crates/platform-linux/src/health_report.rsindex 1a8641f7dc..fbdf341328 100644--- a/libs/cua-driver/rust/crates/platform-linux/src/health_report.rs+++ b/libs/cua-driver/rust/crates/platform-linux/src/health_report.rs@@ -104,8 +104,7 @@ async fn check_ax_capability() -> CheckEntry {NAME_AX_CAPABILITY,"Wayland session: org.a11y.Bus is not reachable on the session bus; \AT-SPI inspection will fail.",- "Start the AT-SPI bus (`/usr/libexec/at-spi-bus-launcher`) or enable \- accessibility in your desktop's settings.",+ START_ATSPI_BUS_HINT,);}// Mirror the existing `check_permissions` Linux probe: X11@@ -426,6 +425,9 @@ fn probe_x11_connect() -> bool {false}+pub(crate) const START_ATSPI_BUS_HINT: &str = "Start the AT-SPI bus \+ (`/usr/libexec/at-spi-bus-launcher`) or enable accessibility in your desktop's settings.";+/// Probe whether `org.a11y.Bus` is reachable on the session bus — the/// canonical AT-SPI prerequisite on Wayland, where there is no X server to/// stand in. Returns false on any error (no session bus, no a11y service,diff --git a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rsindex 98fe985d5b..c226b0a4ed 100644--- a/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs+++ b/libs/cua-driver/rust/crates/platform-linux/src/tools/impl_.rs@@ -3129,10 +3129,15 @@ fn with_uinput_hint(mut refusal: ToolResult) -> ToolResult {/// Honest refusal for a background keyboard action that has no focus-free/// actuator. Carries the uinput hint whenever the MPX route is missing only/// because `/dev/uinput` is not writable (the fixable case).-fn background_keyboard_refusal() -> ToolResult {- let refusal = crate::input::delivery::background_unavailable_error(+fn background_keyboard_refusal(atspi_ok: bool) -> ToolResult {+ let mut refusal = crate::input::delivery::background_unavailable_error(crate::input::delivery::BackgroundUnavailable::FocusedInputOnly,);+ let bus = crate::health_report::START_ATSPI_BUS_HINT;+ let hint = format!("AT-SPI is unavailable. {bus} Or use delivery_mode \"foreground\".");+ refusal+ .content+ .extend((!atspi_ok).then(|| cua_driver_core::protocol::Content::text(hint)));if !crate::wayland::is_wayland() && !crate::input::uinput_accessible() {with_uinput_hint(refusal)} else {@@ -3140,6 +3145,11 @@ fn background_keyboard_refusal() -> ToolResult {}}+fn atspi_up() -> bool {+ let probe = std::thread::spawn(crate::health_report::probe_a11y_bus);+ crate::wayland::is_wayland() || probe.join().unwrap_or(false)+}+fn unavailable_gtk_keyboard_background(pid: u32,delivery: crate::input::delivery::DeliveryMode,@@ -3148,7 +3158,7 @@ fn unavailable_gtk_keyboard_background(&& is_gtk_process(pid)&& !crate::wayland::is_inject_mode()&& !crate::input::real_keyboard_input_available())- .then(background_keyboard_refusal)+ .then(|| background_keyboard_refusal(atspi_up()))}/// Outcome of one background/foreground keyboard delivery on X11, funnelled@@ -4815,6 +4825,46 @@ fn isolated_background_routes_do_not_reprobe_availability_before_primary_fallbac}}+#[cfg(test)]+#[test]+fn background_keyboard_refusal_names_missing_atspi_bus() {+ let plain = crate::input::delivery::background_unavailable_error(+ crate::input::delivery::BackgroundUnavailable::FocusedInputOnly,+ );+ let text = |refusal: &ToolResult| -> String {+ refusal+ .content+ .iter()+ .filter_map(|content| match content {+ cua_driver_core::protocol::Content::Text { text, .. } => Some(text.as_str()),+ _ => None,+ })+ .collect()+ };+ let (missing, reachable) = (+ background_keyboard_refusal(false),+ background_keyboard_refusal(true),+ );+ for needle in [+ "AT-SPI is unavailable",+ "at-spi-bus-launcher",+ "delivery_mode \"foreground\"",+ ] {+ assert!(+ text(&missing).contains(needle),+ "{needle} missing from {}",+ text(&missing)+ );+ }+ assert!(!text(&reachable).contains("AT-SPI is unavailable"));+ for refusal in [missing, reachable] {+ let structured = refusal.structured_content.unwrap();+ let expected = plain.structured_content.as_ref().unwrap();+ assert_eq!(structured["code"], expected["code"]);+ assert_eq!(structured["escalation"], expected["escalation"]);+ }+}+#[cfg(test)]#[test]fn type_text_routes_isolated_background_before_generic_wayland_refusal() {@@ -7921,7 +7971,7 @@ impl Tool for TypeTextTool {}).await;return match result {- Ok(Ok(("background_unavailable", _))) => background_keyboard_refusal(),+ Ok(Ok(("background_unavailable", _))) => background_keyboard_refusal(atspi_up()),Ok(Ok((_, Some(report)))) => type_text_mpx_result(text_len, report),Ok(Ok((path, None))) => ToolResult::text(format!("Typed {text_len} character(s) (terminal emulator: pty/XTest key events)."@@ -8051,7 +8101,7 @@ impl Tool for TypeTextTool {)).with_structured(type_text_structured("key_events", text_len, false)),Ok(Ok(Some(KeyRoute::Mpx(report)))) => type_text_mpx_result(text_len, report),- Ok(Ok(_)) => background_keyboard_refusal(),+ Ok(Ok(_)) => background_keyboard_refusal(atspi_up()),Ok(Err(e)) => input_error_result(e),Err(e) => ToolResult::error(format!("Task error: {e}")),};@@ -8191,7 +8241,7 @@ impl Tool for TypeTextTool {text_len,&format!("via X11, delivery_mode={mode_label}"),),- Ok(Ok(("background_unavailable", _))) => background_keyboard_refusal(),+ Ok(Ok(("background_unavailable", _))) => background_keyboard_refusal(atspi_up()),Ok(Ok((_, Some(report)))) => type_text_mpx_result(text_len, report),Ok(Ok((path, None))) => ToolResult::text(format!("Typed {text_len} character(s) (via X11, delivery_mode={mode_label})."