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.

feat(cua-driver): advertise native Wayland build features (#2669)

Tony Simons31c61dd161ea
diff --git a/libs/cua-driver/rust/crates/cua-driver/src/cli.rs b/libs/cua-driver/rust/crates/cua-driver/src/cli.rs
index 8f68e01566..cb90944c49 100644
--- a/libs/cua-driver/rust/crates/cua-driver/src/cli.rs
+++ b/libs/cua-driver/rust/crates/cua-driver/src/cli.rs
@@ -1731,6 +1731,18 @@ pub fn run_manifest(pretty: bool) {
println!("{out}");
}
+fn manifest_feature_flags(
+ target_is_linux: bool,
+ portal_input_enabled: bool,
+ portal_capture_enabled: bool,
+) -> (bool, bool, bool) {
+ (
+ target_is_linux,
+ target_is_linux && portal_input_enabled,
+ target_is_linux && portal_capture_enabled,
+ )
+}
+
/// Build the JSON manifest document. Pure function — surfaced separately
/// from `run_manifest` so tests can introspect the shape without going
/// through stdout.
@@ -1743,6 +1755,12 @@ pub fn build_manifest() -> serde_json::Value {
.and_then(|p| p.to_str().map(str::to_owned))
.unwrap_or_else(|| "cua-driver".to_owned());
+ let (wayland_native, portal_input, portal_capture) = manifest_feature_flags(
+ cfg!(target_os = "linux"),
+ cfg!(feature = "portal-input"),
+ cfg!(feature = "portal-capture"),
+ );
+
serde_json::json!({
// `schema_version` is bumped only on a breaking change to the
// manifest shape itself. Additive field changes don't bump it.
@@ -1750,6 +1768,15 @@ pub fn build_manifest() -> serde_json::Value {
"schema_version": "1",
"binary_version": env!("CARGO_PKG_VERSION"),
"binary_path": binary,
+ // A release version cannot prove which optional Linux features were
+ // compiled into this artifact. Downstream hosts use this additive,
+ // machine-readable map to decide whether native Wayland may be
+ // auto-enabled safely.
+ "features": {
+ "wayland_native": wayland_native,
+ "portal_input": portal_input,
+ "portal_capture": portal_capture,
+ },
"mcp_invocation": {
"command": binary,
"args": ["mcp"]
@@ -4929,6 +4956,31 @@ mod tests {
.expect("binary_version present and a string");
assert_eq!(bv, env!("CARGO_PKG_VERSION"));
+ // Explicit build-time capability claims let integrations decide whether
+ // a Linux artifact can safely auto-enable native Wayland.
+ let features = obj
+ .get("features")
+ .and_then(|v| v.as_object())
+ .expect("features is an object");
+ for key in ["wayland_native", "portal_input", "portal_capture"] {
+ assert!(
+ features.get(key).and_then(|v| v.as_bool()).is_some(),
+ "features.{key} must be a boolean"
+ );
+ }
+ assert_eq!(
+ features.get("wayland_native").and_then(|v| v.as_bool()),
+ Some(cfg!(target_os = "linux"))
+ );
+ assert_eq!(
+ features.get("portal_input").and_then(|v| v.as_bool()),
+ Some(cfg!(all(target_os = "linux", feature = "portal-input")))
+ );
+ assert_eq!(
+ features.get("portal_capture").and_then(|v| v.as_bool()),
+ Some(cfg!(all(target_os = "linux", feature = "portal-capture")))
+ );
+
// mcp_invocation — { command: <bin path>, args: ["mcp"] }
let inv = obj
.get("mcp_invocation")
@@ -4971,6 +5023,17 @@ mod tests {
}
}
+ #[test]
+ fn manifest_never_advertises_linux_portal_features_on_non_linux_targets() {
+ // Simulate a non-Linux build with both Cargo features enabled. This
+ // runs on every CI host, so the exact cross-target regression is
+ // covered even when Windows only compiles the broader test suite.
+ assert_eq!(
+ manifest_feature_flags(false, true, true),
+ (false, false, false)
+ );
+ }
+
/// Every subcommand entry has the same JSON shape — name + description
/// + args[] — so consumers can render the catalog uniformly without
///