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): keep background input working on macOS windows in other Spaces (#4068)
Francesco Bonacci9f5fb906ca8a
diff --git a/.github/scripts/tests/test_macos_hosted_e2e_workflow.py b/.github/scripts/tests/test_macos_hosted_e2e_workflow.pyindex 30b1d65238..e4514935c4 100644--- a/.github/scripts/tests/test_macos_hosted_e2e_workflow.py+++ b/.github/scripts/tests/test_macos_hosted_e2e_workflow.py@@ -30,12 +30,14 @@ def test_hosted_macos_probe_is_manual_exact_sha_and_least_privilege() -> None:assert "github.run_id }}-${{ github.run_attempt" in workflowassert "CUA_MACOS_HOSTED_PROBE_DIR: ${{ runner.temp" not in workflowassert 'echo "CUA_MACOS_HOSTED_PROBE_DIR=${artifact_dir}" >> "${GITHUB_ENV}"' in workflow- assert "matrix:\n lane: [shared, native, capture]" in workflow+ assert "matrix:\n lane: [shared, native, capture, browser]" in workflowassert "fail-fast: false" in workflowassert "needs: probe" in workflowassert "scripts/ci/macos/run-hosted-rust-e2e.sh" in workflowassert "path: artifacts/cua-driver" in workflowassert "needs: [probe, matrix]" in workflow+ assert 'lanes: ["shared", "native", "capture", "browser"]' in workflow+ assert "standalone_browser: true" in workflowassert "cua-driver/macos-hosted-certification@v1" in workflowassert "workflow_ref: $workflow_ref" in workflowassert "workflow_sha: $workflow_sha" in workflow@@ -202,3 +204,43 @@ def test_hosted_macos_runner_is_strict_and_uses_the_canonical_matrix() -> None:assert "cleanup-status.txt" in runnerassert "permissions grant" not in runnerassert "cleanup-targets.txt" in runner+++def test_hosted_macos_browser_lane_mirrors_the_lume_standalone_browser_matrix() -> None:+ runner = read("scripts/ci/macos/run-hosted-rust-e2e.sh")+ lume = read("libs/cua-driver/tests/runners/macos-lume/run-all.sh")+ matrix_runner = read("scripts/ci/macos/run-rust-e2e.sh")++ assert "shared|native|capture|browser) ;;" in runner+ # The repo-local matrix runner keeps its own partitions; only the hosted+ # wrapper routes the browser lane to the standalone browser suite.+ assert "shared|native|capture|all) ;;" in matrix_runner+ assert 'STANDALONE_BROWSER_PRODUCTS="chrome,edge"' in runner+ assert '"/Applications/Google Chrome.app|com.google.Chrome|EQHXZ8M8AV"' in runner+ assert '"/Applications/Microsoft Edge.app|com.microsoft.edgemac|UBF8T346G9"' in runner+ assert "--test-requirement \"${browser_requirement}\"" in runner+ platform = read("libs/cua-driver/rust/crates/platform-macos/src/browser/platform.rs")+ for identity in ('"com.google.Chrome"', '"EQHXZ8M8AV"', '"com.microsoft.edgemac"', '"UBF8T346G9"'):+ assert identity in platform+ assert "missing hosted standalone browser" in runner+ assert "hosted standalone browser signature is not valid" in runner+ assert "standalone-browsers.txt" in runner+ # Only Finder detritus is normalized; the vendor requirement still decides.+ assert "-xattrname com.apple.FinderInfo" in runner+ assert "xattr -d com.apple.FinderInfo" in runner+ assert "xattr -c" not in runner+ assert runner.index("xattr -d com.apple.FinderInfo") < runner.index(+ '--test-requirement "${browser_requirement}"'+ )+ assert 'CUA_E2E_BROWSER_PRODUCTS="${STANDALONE_BROWSER_PRODUCTS}"' in runner+ assert 'CUA_TEST_DRIVER_BIN="${CARGO_TARGET_DIR}/release/cua-driver"' in runner+ assert "artifacts/cua-driver/macos-standalone-browser" in runner+ assert "artifacts/cua-driver/macos-standalone-browser" in lume+ assert 'CUA_E2E_ARTIFACT_DIR="${BROWSER_ARTIFACT_DIR}"' in runner+ assert "scripts/ci/run-rust-standalone-browser-e2e.sh" in runner+ assert "scripts/ci/run-rust-standalone-browser-e2e.sh" in lume+ # The browser rows run only after the same bootstrap and daemon checks.+ dispatch = runner.index('bash "${REPO_ROOT}/scripts/ci/run-rust-standalone-browser-e2e.sh"')+ assert runner.index('.source.attribution == "driver-daemon"') < dispatch+ assert runner.index("WATCHDOG_PID=$!") < dispatch+ assert "never shrinks" in runnerdiff --git a/.github/workflows/e2e-rust-macos.yml b/.github/workflows/e2e-rust-macos.ymlindex db84a09bd2..7883436306 100644--- a/.github/workflows/e2e-rust-macos.yml+++ b/.github/workflows/e2e-rust-macos.yml@@ -116,7 +116,7 @@ jobs:strategy:fail-fast: falsematrix:- lane: [shared, native, capture]+ lane: [shared, native, capture, browser]env:CUA_E2E_SOURCE_SHA: ${{ inputs.source_sha }}CUA_E2E_WORKFLOW_SHA: ${{ github.sha }}@@ -217,6 +217,8 @@ jobs:github: {run_id: $run_id, run_attempt: $run_attempt,workflow_ref: $workflow_ref, workflow_sha: $workflow_sha},jobs: {probe: $probe, matrix: $matrix},+ lanes: ["shared", "native", "capture", "browser"],+ standalone_browser: true,passed: ($probe == "success" and $matrix == "success")}' \| tee certification.jsonjq -e '.passed == true' certification.json >/dev/nulldiff --git a/docs/content/docs/concepts/how-cua-driver-is-validated.mdx b/docs/content/docs/concepts/how-cua-driver-is-validated.mdxindex c3c8e54024..2286196449 100644--- a/docs/content/docs/concepts/how-cua-driver-is-validated.mdx+++ b/docs/content/docs/concepts/how-cua-driver-is-validated.mdx@@ -39,8 +39,9 @@ keys, scrolling, dragging, child windows, controls, and editor behavior. Thismakes a failure reproducible without depending on the changing state of aninstalled third-party application.-The optional standalone-browser lane launches installed Chrome, Edge, or-Chromium with a fresh repo-owned profile and one exact source-built driver. Its+The standalone-browser lane launches installed Chrome, Edge, or Chromium with+a fresh repo-owned profile and one exact source-built driver. Every macOS Lume+run includes it; Windows and Linux run it as a separate workflow. Itsrows cover binding and ambiguous active-tab evidence, semantic snapshots,frames, inactive tabs, JavaScript dialogs, file assignment, extended pointeractions, and approval-scoped downloads. The target stays fully occluded behinddiff --git a/docs/content/docs/reference/cua-driver/limits.mdx b/docs/content/docs/reference/cua-driver/limits.mdxindex 45d4d9bc28..cca43cc4a6 100644--- a/docs/content/docs/reference/cua-driver/limits.mdx+++ b/docs/content/docs/reference/cua-driver/limits.mdx@@ -118,6 +118,16 @@ does not imply arbitrary raw background PX delivery on Wayland.---+## Off-Space windows keep background input and hide the agent cursor++**Behavior:** macOS omits windows on other Spaces from an application's `AXWindows` list. Cua Driver recovers the requested window by its exact CGWindowID, so `get_window_state`, element actions, and background pixel actions keep working while the window stays on its Space. The user's current Space, frontmost application, and keyboard focus do not change.++**Agent cursor:** the overlay does not paint while an action targets a window on another Space, so the cursor never animates over the user's Space at that window's coordinates. It reappears with the next action on a current-Space window.++**Platform scope:** macOS only. Windows virtual desktops and Linux workspaces do not yet suppress the cursor for off-workspace targets.++---+## Off-Space SwiftUI windows strip their AX tree**Symptom:** `get_window_state({pid, window_id})` on a window on a different Space (e.g. System Settings parked on Space 2 while on Space 1) returns a minimal tree that contains only the menu bar, or just the `AXApplication` root.diff --git a/docs/content/docs/reference/cua-driver/mcp-tools.mdx b/docs/content/docs/reference/cua-driver/mcp-tools.mdxindex 24313af43c..18f7715827 100644--- a/docs/content/docs/reference/cua-driver/mcp-tools.mdx+++ b/docs/content/docs/reference/cua-driver/mcp-tools.mdx@@ -71,7 +71,7 @@ Always returns BOTH the element tree AND a screenshot — ground on both and croThe mirror image: pass `include_accessibility_tree:false` to SKIP the AX walk entirely (the expensive part, bounded by timeout_ms) and return just the screenshot plus window metadata — `window_bounds`, `screenshot_scale`, `screenshot_width`/`screenshot_height`, `app_name`, and `window_title` — the capture-only path for rendering a live window preview / picture-in-picture without paying for perception. Setting BOTH `include_accessibility_tree:false` and `include_screenshot:false` is an error (nothing to return). Optional `max_image_dimension` overrides the configured screenshot long-edge limit for this call; use 0 for native resolution. The legacy `max_dimension` remains a tighter cap for compatibility.-The snapshot is SCOPED to `window_id`: a window_id that no longer exists is refused with `window_id_not_found`, and one owned by another process is refused with `window_owner_pid_mismatch` naming the real `owner_pid` to retry with (macOS hosts a sandboxed app's Open/Save panel out-of-process, so its window belongs to the panel service, not the app). If the window is live under this pid but its accessibility surface can't be resolved, the tree comes back EMPTY with `degraded_reason: ax_window_unresolved` and the screenshot of the requested window — act by pixel there. This tool never returns another surface's elements under your window_id. Before exposing a screenshot, its raw dimensions are validated as a coherent 1x/2x representation of the requested WindowServer bounds. `px_frame_mismatch` or `px_capture_unavailable` omits an unprovable screenshot/pixel frame instead of guessing a transform; the truthful AX payload remains available.+The snapshot is SCOPED to `window_id`: a window_id that no longer exists is refused with `window_id_not_found`, and one owned by another process is refused with `window_owner_pid_mismatch` naming the real `owner_pid` to retry with (macOS hosts a sandboxed app's Open/Save panel out-of-process, so its window belongs to the panel service, not the app). If the window is live under this pid but its accessibility surface can't be resolved, the tree comes back EMPTY with `degraded_reason: ax_window_unresolved` and the screenshot of the requested window; background input is refused until it resolves, so re-snapshot or act with `delivery_mode:"foreground"`. A window on another Space still resolves by its exact CGWindowID. This tool never returns another surface's elements under your window_id. Before exposing a screenshot, its raw dimensions are validated as a coherent 1x/2x representation of the requested WindowServer bounds. `px_frame_mismatch` or `px_capture_unavailable` omits an unprovable screenshot/pixel frame instead of guessing a transform; the truthful AX payload remains available.Optional `query` projects both tree_markdown and structured `elements` to matching lines plus their ancestor chain (case-insensitive substring). The element_index values are unchanged, the complete snapshot remains actionable, and `element_count` continues to report its total size; `filtered_element_count` reports the projected response size.diff --git a/libs/cua-driver/docs/test-harnesses-guide.md b/libs/cua-driver/docs/test-harnesses-guide.mdindex cade349248..acdf424cbb 100644--- a/libs/cua-driver/docs/test-harnesses-guide.md+++ b/libs/cua-driver/docs/test-harnesses-guide.md@@ -41,9 +41,9 @@ Windows and Linux use the repository's GitHub-hosted workflows when theirstrict environment preflights pass. Windows Azure RDP runs are optionalenvironment-parity replays or a fallback when the hosted preflight cannot provea required capability. macOS uses the logged-in Lume maintainer wrapper.-For browser-facing changes or browser-use release certification, also run the-standalone Chrome/Edge matrix: the macOS wrapper accepts-`--standalone-browser`, while the Windows and Linux workflow is+The macOS wrapper always runs the standalone Chrome/Edge matrix after the+repo-local matrix. For browser-facing changes or browser-use release+certification on Windows and Linux, also run`.github/workflows/e2e-rust-standalone-browsers.yml`.Historical `*-plan.md`, `*-journal.md`, and release evidence documents record@@ -285,12 +285,14 @@ Canonical runner: `libs/cua-driver/tests/runners/macos-lume/run-all.sh`Canonical Actions wrapper: manually dispatch`.github/workflows/e2e-rust-macos.yml` in `lume` mode at the exact source SHA. It runs the-logged-in Lume wrapper with `--standalone-browser` and emits the certification+logged-in Lume wrapper, including its standalone browser matrix, and emits the certificationartifact consumed by protected evidence workflows.Supplemental hosted runner: manually dispatch`.github/workflows/e2e-rust-macos.yml` with an exact 40-character source SHA.-Its probe must pass before independent shared, native, and capture jobs run.+Its probe must pass before independent shared, native, capture, and browser+jobs run. The browser job runs the standalone installed Chrome/Edge matrix that+the Lume gate runs after its repo-local matrix.| Runner area | Rust test | Real harness or app || ------------------------- | -------------------------------------- | --------------------------------------- |@@ -302,6 +304,7 @@ Its probe must pass before independent shared, native, and capture jobs run.| Installed app AX delivery | `installed_app_textedit_macos_test.rs` | TextEdit || Capture contract | `capture_contract_test.rs` | Installed driver and macOS capture APIs || Desktop scope | `desktop_scope_macos_test.rs` | macOS window and desktop scope |+| Standalone browsers | `standalone_browser_behavior_test.rs` | Installed Google Chrome and Edge |The WKWebView host runs the same typed shared-web catalog as Electron andTauri. Calculator and TextEdit add typed supporting rows for built-in app@@ -316,7 +319,9 @@ It requires the GitHub-hosted Aqua session and SIP-off VirtualMac environment,creates a temporary code-signing Keychain, installs a certificate-signed localapp, seeds only Accessibility and Screen Capture for that app's exact csreq, andverifies that permission status is attributed to the driver daemon before any-test begins. The temporary certificate trust is removed during job cleanup.+test begins. The browser lane additionally requires the image's vendor-signed+Google Chrome and Microsoft Edge and fails closed when either is missing. The+temporary certificate trust is removed during job cleanup.Hosted results remain supplemental until the image and signingidentity provide the same release-parity guarantees as the maintained Lumeseed.diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/README.md b/libs/cua-driver/rust/crates/cua-driver/tests/README.mdindex eb2184b325..eb6847ecd4 100644--- a/libs/cua-driver/rust/crates/cua-driver/tests/README.md+++ b/libs/cua-driver/rust/crates/cua-driver/tests/README.md@@ -146,5 +146,5 @@ desktop state outside the repo-local fixtures:foreground sentinel when needed and opts pure Wayland runs into the nativebackend. Non-macOS runs prove that standard mode refuses existing-profileattachment before running the authorized success rows with a disposable- unrestricted daemon. macOS Lume maintainers can add the success rows to the- VM acceptance run with `run-all.sh --standalone-browser`.+ unrestricted daemon. The macOS Lume `run-all.sh` acceptance run always+ includes the success rows.diff --git a/libs/cua-driver/rust/crates/cua-driver/tests/standalone_browser_behavior_test.rs b/libs/cua-driver/rust/crates/cua-driver/tests/standalone_browser_behavior_test.rsindex 645dabc990..b8e7ca8201 100644--- a/libs/cua-driver/rust/crates/cua-driver/tests/standalone_browser_behavior_test.rs+++ b/libs/cua-driver/rust/crates/cua-driver/tests/standalone_browser_behavior_test.rs@@ -3762,6 +3762,51 @@ fn browser_chrome_changed_pixel_center(})}+/// Screen-point center of the pixels that changed in the top browser chrome of+/// two captures of the same window. Window captures exclude other processes'+/// windows, so a system notification banner over the toolbar cannot move the+/// result the way it can in a desktop capture.+fn window_chrome_changed_pixel_center(+ before: &image::RgbaImage,+ after: &image::RgbaImage,+ bounds: (f64, f64, f64, f64),+) -> Option<(f64, f64)> {+ assert_eq!(before.dimensions(), after.dimensions());+ let scale_x = f64::from(before.width()) / bounds.2;+ let scale_y = f64::from(before.height()) / bounds.3;+ // Browser permission indicators live in the top chrome, as in+ // `browser_chrome_changed_pixel_center`.+ let bottom = (bounds.3.min(120.0) * scale_y)+ .round()+ .min(f64::from(before.height())) as u32;+ let mut changed = 0_u64;+ let mut x_sum = 0_u64;+ let mut y_sum = 0_u64;+ for y in 0..bottom {+ for x in 0..before.width() {+ let before = before.get_pixel(x, y);+ let after = after.get_pixel(x, y);+ if before+ .0+ .iter()+ .zip(after.0.iter())+ .take(3)+ .any(|(before, after)| before.abs_diff(*after) >= 32)+ {+ changed += 1;+ x_sum += u64::from(x);+ y_sum += u64::from(y);+ }+ }+ }+ (changed > 0).then(|| {+ (+ bounds.0 + (x_sum as f64 / changed as f64) / scale_x,+ bounds.1 + (y_sum as f64 / changed as f64) / scale_y,+ )+ })+}+fn run_browser_owned_permission_prompt(spec: &BrowserSpec) {let scenario = format!("{}-{}-standalone-browser-owned-permission",@@ -3959,19 +4004,37 @@ fn run_browser_owned_permission_prompt(spec: &BrowserSpec) {// Edge can collapse the notification request to a quiet indicator in// browser chrome. Expand the region that actually changed, then assess// the resulting browser-owned surface with the same pixel oracle.- if cfg!(target_os = "windows")- && spec.name == "edge"+ // macOS locates the indicator in the window capture and gates on its+ // change count: a system notification banner can cover the toolbar in+ // the desktop capture.+ let quiet_indicator = if spec.name != "edge" {+ None+ } else if cfg!(target_os = "windows")&& initial_desktop_changed_pixels < minimum_prompt_pixels{let full_desktop_before = load_capture(&desktop_before_path);let full_desktop_after = load_capture(&desktop_after_path);- let (x, y) = browser_chrome_changed_pixel_center(+ Some(browser_chrome_changed_pixel_center(&full_desktop_before,&full_desktop_after,&desktop,bounds,- )- .expect("quiet permission indicator did not produce a changed browser chrome region");+ ))+ } else if cfg!(target_os = "macos")+ && changed_pixel_count(&window_before, &window_after) < minimum_prompt_pixels+ {+ Some(window_chrome_changed_pixel_center(+ &window_before,+ &window_after,+ bounds,+ ))+ } else {+ None+ };+ if let Some(indicator) = quiet_indicator {+ let (x, y) = indicator.expect(+ "quiet permission indicator did not produce a changed browser chrome region",+ );quiet_prompt_indicator = Some((x, y));let expanded = fixture.driver.call("click",diff --git a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rsindex cb1e393962..d217c09e6a 100644--- a/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs+++ b/libs/cua-driver/rust/crates/cursor-overlay/src/render_state.rs@@ -76,6 +76,11 @@ pub struct RenderStateCore {pub theme_fallback: Option<String>,/// User-controlled visibility.pub visible: bool,+ /// The pinned target window is on another workspace (macOS Space), so the+ /// cursor must not paint over the user's current workspace at that+ /// window's coordinates. Platform adapters set it when handling+ /// `PinAbove`; `false` when membership is unknown.+ pub pinned_target_off_workspace: bool,/// Idle-hide: elapsed seconds since last activity.pub idle_secs: f64,/// Idle-hide fade: 1.0 = fully visible, 0.0 = fully hidden.@@ -138,6 +143,7 @@ impl RenderStateCore {idle_secs: 0.0,idle_alpha: 1.0,pinned_wid: None,+ pinned_target_off_workspace: false,session_label: None,session_badge_secs: SESSION_BADGE_HOLD_SECS + SESSION_BADGE_FADE_SECS,session_badge_hovered: false,@@ -810,7 +816,11 @@ pub fn paint_cursor(focus_rect: Option<FocusRect>,backing_scale: f32,) {- if !core.visible || core.pos.0 < -100.0 || core.idle_alpha < 0.004 {+ if !core.visible+ || core.pinned_target_off_workspace+ || core.pos.0 < -100.0+ || core.idle_alpha < 0.004+ {return;}@@ -1292,6 +1302,22 @@ mod backing_scale_tests {pm}+ #[test]+ fn cursor_pinned_to_an_off_workspace_window_paints_nothing() {+ let mut core = RenderStateCore::new(CursorConfig::default());+ core.pos = (32.0, 32.0);+ core.idle_alpha = 1.0;+ core.visible = true;+ core.pinned_target_off_workspace = true;+ let mut pm = tiny_skia::Pixmap::new(64, 64).unwrap();+ paint_cursor(&mut pm, &core, 0.0, 0.0, None, 1.0);+ assert_eq!(visible_pixel_count(&pm), 0);++ core.pinned_target_off_workspace = false;+ paint_cursor(&mut pm, &core, 0.0, 0.0, None, 1.0);+ assert!(visible_pixel_count(&pm) > 0);+ }+/// The compiled artifact contains vector geometry. Skia must rasterize it/// at the destination backing scale, so linear dimensions grow 1:2:3 and/// strongly visible coverage grows approximately with the square.diff --git a/libs/cua-driver/rust/crates/platform-macos/src/ax/bindings.rs b/libs/cua-driver/rust/crates/platform-macos/src/ax/bindings.rsindex 02ba09c01c..6b5cbcf445 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/ax/bindings.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/ax/bindings.rs@@ -94,6 +94,13 @@ extern "C" {/// Private SPI: maps an AX window element to its CGWindowID./// Stable since macOS 10.9; used by yabai, Hammerspoon, Accessibility Inspector.pub fn _AXUIElementGetWindow(element: AXUIElementRef, window_id: *mut u32) -> AXError;++ /// Private SPI: materializes an AX element from its 20-byte remote token+ /// (pid, 0, `'coco'`, element id). Reaches windows on other Spaces, which+ /// `AXWindows` omits. Used by alt-tab-macos for the same purpose.+ pub fn _AXUIElementCreateWithRemoteToken(+ token: core_foundation::data::CFDataRef,+ ) -> AXUIElementRef;}/// Hit-test one process's accessibility tree at a screen point. The returned@@ -748,11 +755,98 @@ pub unsafe fn copy_ax_windows(element: AXUIElementRef) -> Vec<AXUIElementRef> {.collect()}+/// Highest AX element id probed when looking for an off-Space window.+/// Window elements are allocated early in an app's lifetime (Calculator's+/// main window is id 42); alt-tab-macos probes the same order of magnitude.+const MAX_REMOTE_TOKEN_ELEMENT_ID: u64 = 2_000;++/// Wall-clock ceiling for one remote-token probe, so an unresponsive app+/// cannot stall a snapshot or an action decision.+const REMOTE_TOKEN_PROBE_DEADLINE: std::time::Duration = std::time::Duration::from_millis(300);++/// Per-candidate AX messaging timeout during the probe, in seconds.+const REMOTE_TOKEN_CANDIDATE_TIMEOUT_SECONDS: f32 = 0.05;++/// The 20-byte remote token AX uses to identify one element of `pid`.+fn remote_token_bytes(pid: i32, element_id: u64) -> [u8; 20] {+ const COCOA_TOKEN_MAGIC: i32 = 0x636f_636f; // 'coco'+ let mut token = [0u8; 20];+ token[0..4].copy_from_slice(&pid.to_ne_bytes());+ token[8..12].copy_from_slice(&COCOA_TOKEN_MAGIC.to_ne_bytes());+ token[12..20].copy_from_slice(&element_id.to_ne_bytes());+ token+}++/// Find the `AXWindow` element for `window_id` when `AXWindows` omits it —+/// macOS drops windows on other Spaces from that list. Probes the app's AX+/// element ids through `_AXUIElementCreateWithRemoteToken` and returns only an+/// element whose role is `AXWindow` AND whose `_AXUIElementGetWindow` equals+/// `window_id`, so the result is exactly as strong as an `AXWindows` match.+/// Returns a retained element the caller must release.+///+/// # Safety+///+/// The caller must release any returned element exactly once with `CFRelease`.+pub unsafe fn copy_ax_window_by_remote_token(pid: i32, window_id: u32) -> Option<AXUIElementRef> {+ let started = std::time::Instant::now();+ for element_id in 0..MAX_REMOTE_TOKEN_ELEMENT_ID {+ if started.elapsed() > REMOTE_TOKEN_PROBE_DEADLINE {+ return None;+ }+ let token =+ core_foundation::data::CFData::from_buffer(&remote_token_bytes(pid, element_id));+ let element = _AXUIElementCreateWithRemoteToken(token.as_concrete_TypeRef());+ if element.is_null() {+ continue;+ }+ AXUIElementSetMessagingTimeout(element, REMOTE_TOKEN_CANDIDATE_TIMEOUT_SECONDS);+ if copy_string_attr(element, "AXRole").as_deref() == Some("AXWindow")+ && ax_get_window_id(element) == Some(window_id)+ {+ return Some(element);+ }+ CFRelease(element as CFTypeRef);+ }+ None+}++/// `AXWindows` of `pid`'s application element, plus the requested window when+/// `AXWindows` does not list it (it is on another Space). Returns retained+/// elements the caller must release.+///+/// # Safety+///+/// `app` must be the valid application element of `pid`, and the caller must+/// release every returned element.+pub unsafe fn copy_ax_windows_including(+ app: AXUIElementRef,+ pid: i32,+ window_id: u32,+) -> Vec<AXUIElementRef> {+ let mut windows = copy_ax_windows(app);+ if !windows+ .iter()+ .any(|&window| ax_get_window_id(window) == Some(window_id))+ {+ windows.extend(copy_ax_window_by_remote_token(pid, window_id));+ }+ windows+}+#[cfg(test)]mod tests {use super::*;use core_foundation::{boolean::CFBoolean, number::CFNumber};+ #[test]+ fn remote_token_layout_is_pid_zero_coco_element_id() {+ let token = remote_token_bytes(0x0102_0304, 42);+ assert_eq!(&token[0..4], &0x0102_0304i32.to_ne_bytes());+ assert_eq!(&token[4..8], &[0, 0, 0, 0]);+ assert_eq!(&token[8..12], &0x636f_636fi32.to_ne_bytes());+ assert_eq!(&token[12..20], &42u64.to_ne_bytes());+ }+#[test]fn binary_value_accepts_booleans_and_exact_zero_or_one() {let true_value = CFBoolean::true_value();diff --git a/libs/cua-driver/rust/crates/platform-macos/src/ax/exact_target.rs b/libs/cua-driver/rust/crates/platform-macos/src/ax/exact_target.rsindex c07f19b981..5713df0061 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/ax/exact_target.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/ax/exact_target.rs@@ -13,8 +13,8 @@ use cua_driver_core::background_input::{};use super::bindings::{- ax_get_window_id, copy_ax_windows, copy_bool_attr, copy_element_attr, copy_string_attr,- focused_element_of_pid, AXUIElementCreateApplication, AXUIElementRef,+ ax_get_window_id, copy_ax_windows_including, copy_bool_attr, copy_element_attr,+ copy_string_attr, focused_element_of_pid, AXUIElementCreateApplication, AXUIElementRef,};use crate::windows::{all_windows, resolve_window_owner, WindowOwner};@@ -97,11 +97,12 @@ struct AxWindowRecord {minimized: Option<bool>,}-/// Map the application's fresh `AXWindows` through `_AXUIElementGetWindow`.-/// Windows whose id the SPI cannot resolve are omitted: an unmappable window-/// can never satisfy an exact-target requirement.-unsafe fn ax_window_records(app: AXUIElementRef) -> Vec<AxWindowRecord> {- copy_ax_windows(app)+/// Map the application's fresh `AXWindows` — plus the requested window when it+/// is on another Space — through `_AXUIElementGetWindow`. Windows whose id the+/// SPI cannot resolve are omitted: an unmappable window can never satisfy an+/// exact-target requirement.+unsafe fn ax_window_records(app: AXUIElementRef, pid: i32, window_id: u32) -> Vec<AxWindowRecord> {+ copy_ax_windows_including(app, pid, window_id).into_iter().filter_map(|window| {let record = ax_get_window_id(window).map(|window_id| AxWindowRecord {@@ -173,7 +174,7 @@ pub fn gather_background_facts(// Electron/Chromium apps may need per-process-lifetime enablement// before their AX windows and subtrees are materialized.super::enablement::ensure_chromium_ax_enabled(pid, app);- let records = ax_window_records(app);+ let records = ax_window_records(app, pid, window_id);let app_hidden = copy_bool_attr(app, "AXHidden");let element = element_ptr.map(|ptr| match element_window_id(ptr as AXUIElementRef) {Some(id) if id == window_id => ElementAncestry::ProvenDescendant,diff --git a/libs/cua-driver/rust/crates/platform-macos/src/ax/tree.rs b/libs/cua-driver/rust/crates/platform-macos/src/ax/tree.rsindex ab41962bdb..84d6aa0d9a 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/ax/tree.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/ax/tree.rs@@ -245,7 +245,12 @@ pub fn walk_tree_budgeted(// AXChildren omits windows when the app isn't frontmost (AppKit limitation).// AXWindows returns the window list regardless of activation state.let from_children = copy_children(app_elem);- let from_windows = copy_ax_windows(app_elem);+ // A requested window on another Space is absent from AXWindows; the+ // `_including` variant recovers it by exact CGWindowID.+ let from_windows = match window_id {+ Some(wid) => copy_ax_windows_including(app_elem, pid, wid),+ None => copy_ax_windows(app_elem),+ };let mut top_level = from_children;for w in from_windows {diff --git a/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs b/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rsindex 5d74dddf50..4159449b9c 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/cursor/overlay.rs@@ -546,6 +546,16 @@ impl RenderState {self.focus_rect = rect;self.focus_rect_t = 0.0; // reset fade to fully visible}+ OverlayCommand::PinAbove(wid) => {+ // The overlay window joins every Space, so a target on another+ // Space would otherwise animate over the user's current one at+ // that window's coordinates. Unknown membership keeps painting.+ self.core.pinned_target_off_workspace = u32::try_from(wid)+ .ok()+ .and_then(crate::windows::window_on_current_space_by_id)+ == Some(false);+ let _ = self.core.apply_command_base(cmd, true, true);+ }other => {let _ = self.core.apply_command_base(other, true, true);}diff --git a/libs/cua-driver/rust/crates/platform-macos/src/input/skylight.rs b/libs/cua-driver/rust/crates/platform-macos/src/input/skylight.rsindex 6fd7c4c647..ef72ab9d65 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/input/skylight.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/input/skylight.rs@@ -550,6 +550,81 @@ pub fn activate_without_raise(target_pid: pid_t, target_wid: u32) -> bool {defocus_ok && focus_ok}+/// Reverse [`activate_without_raise`] once a background click is delivered:+/// defocus `target_wid` and hand key focus back to `previous_pid`'s key window.+///+/// The no-raise recipe posts a defocus record to the user's front process.+/// That process stays frontmost as far as NSWorkspace reports, but its key+/// window stops receiving keyboard input until the user clicks it again, so+/// the activation-based restore never fires. Returns `true` when both posts+/// succeeded.+pub fn restore_focus_after_without_raise(+ previous_pid: pid_t,+ target_pid: pid_t,+ target_wid: u32,+) -> bool {+ let Some(post_fn) = post_event_record_to_fn() else {+ return false;+ };+ let Some(previous_wid) = key_window_of_pid(previous_pid) else {+ return false;+ };+ let mut previous_psn = [0u8; 8];+ let mut target_psn = [0u8; 8];+ if !get_process_psn_for_window(previous_wid, previous_pid, &mut previous_psn)+ || !get_process_psn_for_window(target_wid, target_pid, &mut target_psn)+ {+ return false;+ }++ let mut buf = focus_record(target_wid);+ buf[0x8A] = 0x02;+ let defocus_ok = unsafe { post_fn(target_psn.as_ptr() as *const c_void, buf.as_ptr()) == 0 };++ let mut buf = focus_record(previous_wid);+ buf[0x8A] = 0x01;+ let focus_ok = unsafe { post_fn(previous_psn.as_ptr() as *const c_void, buf.as_ptr()) == 0 };++ defocus_ok && focus_ok+}++/// The 248-byte focus/defocus event record with `wid` stamped little-endian at+/// bytes 0x3c–0x3f. The caller sets the direction byte at 0x8a.+fn focus_record(wid: u32) -> [u8; 0xF8] {+ let mut buf = [0u8; 0xF8];+ buf[0x04] = 0xF8;+ buf[0x08] = 0x0D;+ buf[0x3C..0x40].copy_from_slice(&wid.to_le_bytes());+ buf+}++/// The CGWindowID of `pid`'s key window: its `AXFocusedWindow`, else its+/// frontmost on-screen layer-0 window.+fn key_window_of_pid(pid: pid_t) -> Option<u32> {+ use crate::ax::bindings::{ax_get_window_id, copy_element_attr, AXUIElementCreateApplication};+ let focused = unsafe {+ let app = AXUIElementCreateApplication(pid);+ if app.is_null() {+ None+ } else {+ let window = copy_element_attr(app, "AXFocusedWindow");+ core_foundation::base::CFRelease(app as _);+ window.and_then(|window| {+ let wid = ax_get_window_id(window);+ core_foundation::base::CFRelease(window as _);+ wid+ })+ }+ };+ focused.or_else(|| {+ crate::windows::visible_windows()+ .into_iter()+ .filter(|w| w.pid == pid && w.layer == 0 && w.is_on_screen)+ .max_by_key(|w| w.z_index)+ .map(|w| w.window_id)+ })+}+// ── NSMenu shortcut activation ────────────────────────────────────────────────/// Gets the PSN for the process that owns `window_id`.diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rsindex 628792c3e1..222c1fc85c 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/click.rs@@ -976,6 +976,27 @@ impl Tool for ClickTool {None};+ // Pin the overlay above the target window BEFORE animating so+ // the cursor is already sandwiched correctly while it glides in.+ // Both PX deliveries below (AX hit-test and routed events) share+ // this glide, so the cursor shows whichever one lands the click.+ if let Some(wid) = window_id {+ crate::cursor::overlay::send_command(+ cursor_key.clone(),+ cursor_overlay::OverlayCommand::PinAbove(wid as u64),+ );+ }+ // Animate the visual cursor to the click point and wait for it to+ // arrive — mirrors Swift's `AgentCursor.shared.animateAndWait(to:)`.+ crate::cursor::overlay::animate_cursor_to(cursor_key.clone(), screen_x, screen_y).await;+ // Keep the registry in sync with the overlay (see AX path above).+ self.state+ .cursor_registry+ .update_position(&cursor_key, screen_x, screen_y);+ self.state+ .cursor_registry+ .note_press(&cursor_key, screen_x, screen_y);+// A background PX action can still use an accessibility delivery// backend after resolving the requested screen point. This keeps// targeting (PX) orthogonal to delivery (AX) and avoids making a@@ -1014,6 +1035,13 @@ impl Tool for ClickTool {.await;match ax_result {Ok(Ok(true)) => {+ crate::cursor::overlay::send_command(+ cursor_key.clone(),+ cursor_overlay::OverlayCommand::ClickPulse {+ x: screen_x,+ y: screen_y,+ },+ );let label = if focus_only { "focused" } else { "pressed" };return ToolResult::text(format!("✅ PX hit-test {label} the background element via AX."@@ -1048,25 +1076,6 @@ impl Tool for ClickTool {let fg = delivery_mode.is_foreground() && window_id.is_some();let activation_policy = pixel_activation_policy(&button_str, fg, window_id.is_some());- // Pin the overlay above the target window BEFORE animating so- // the cursor is already sandwiched correctly while it glides in.- if let Some(wid) = window_id {- crate::cursor::overlay::send_command(- cursor_key.clone(),- cursor_overlay::OverlayCommand::PinAbove(wid as u64),- );- }- // Animate the visual cursor to the click point and wait for it to- // arrive — mirrors Swift's `AgentCursor.shared.animateAndWait(to:)`.- crate::cursor::overlay::animate_cursor_to(cursor_key.clone(), screen_x, screen_y).await;- // Keep the registry in sync with the overlay (see AX path above).- self.state- .cursor_registry- .update_position(&cursor_key, screen_x, screen_y);- self.state- .cursor_registry- .note_press(&cursor_key, screen_x, screen_y);-// ── Focus-suppression wrap (Swift WindowChangeDetector + FocusGuard) ──// A pixel click can land on a "Sign In" button that opens a sheet// or a Safari link that activates a new tab — same side-effect@@ -1234,6 +1243,20 @@ impl Tool for ClickTool {apps::frontmost_pid(),) {let _ = apps::activate_pid(previous_pid);+ } else if let (Some(previous_pid), Some(wid)) = (prior_front, window_id) {+ // The prior app is still frontmost, but the no-raise+ // recipe posted it a defocus record: hand its key window+ // focus back so the user's typing keeps landing there.+ if focus_without_raise && apps::frontmost_pid() == Some(previous_pid) {+ let _ = tokio::task::spawn_blocking(move || {+ crate::input::skylight::restore_focus_after_without_raise(+ previous_pid,+ pid,+ wid,+ )+ })+ .await;+ }}}diff --git a/libs/cua-driver/rust/crates/platform-macos/src/tools/get_window_state.rs b/libs/cua-driver/rust/crates/platform-macos/src/tools/get_window_state.rsindex 945efa9a65..72c3d105f1 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/tools/get_window_state.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/tools/get_window_state.rs@@ -70,7 +70,9 @@ fn def() -> &'static ToolDef {window belongs to the panel service, not the app). If the window is live under \this pid but its accessibility surface can't be resolved, the tree comes back \EMPTY with `degraded_reason: ax_window_unresolved` and the screenshot of the \- requested window — act by pixel there. This tool never returns another \+ requested window; background input is refused until it resolves, so \+ re-snapshot or act with `delivery_mode:\"foreground\"`. A window on another \+ Space still resolves by its exact CGWindowID. This tool never returns another \surface's elements under your window_id. Before exposing a screenshot, \its raw dimensions are validated as a coherent 1x/2x representation of \the requested WindowServer bounds. `px_frame_mismatch` or \diff --git a/libs/cua-driver/rust/crates/platform-macos/src/windows.rs b/libs/cua-driver/rust/crates/platform-macos/src/windows.rsindex 64fdf2641c..cc849c5be7 100644--- a/libs/cua-driver/rust/crates/platform-macos/src/windows.rs+++ b/libs/cua-driver/rust/crates/platform-macos/src/windows.rs@@ -332,6 +332,15 @@ pub fn window_info_by_id(window_id: u32) -> Option<WindowInfo> {.find(|w| w.window_id == window_id)}+/// Whether `window_id` is on the current Space of its display. `None` when+/// WindowServer does not know the window or Space membership is unreadable.+pub fn window_on_current_space_by_id(window_id: u32) -> Option<bool> {+ all_windows()+ .into_iter()+ .find(|w| w.window_id == window_id)?+ .on_current_space+}+/// Look up a window's bounds by its CGWindowID.////// Returns `None` if the window is not currently known to WindowServerdiff --git a/libs/cua-driver/scripts/tests/test_macos_lume_runner.py b/libs/cua-driver/scripts/tests/test_macos_lume_runner.pyindex e9fa98ccb4..eabcf824c9 100644--- a/libs/cua-driver/scripts/tests/test_macos_lume_runner.py+++ b/libs/cua-driver/scripts/tests/test_macos_lume_runner.py@@ -626,7 +626,6 @@ REPORT_OPTIONS = ('printf "harness=%s\\n" "$RETRY_HARNESS"\n''printf "attempts=%s\\n" "$RETRY_ATTEMPTS"\n''printf "only=%s\\n" "$RETRY_ONLY"\n'- 'printf "standalone=%s\\n" "$RUN_STANDALONE_BROWSER"\n''printf "nobuild=%s\\n" "$NO_BUILD"\n''printf "lane=%s\\n" "$RETRY_INTERNAL_LANE"\n')@@ -643,7 +642,6 @@ def test_default_invocation_runs_the_full_matrix() -> None:assert fields["status"] == "0"assert fields["cell"] == ""assert fields["only"] == "0"- assert fields["standalone"] == "0"assert fields["nobuild"] == "0"@@ -737,10 +735,7 @@ def test_native_swiftui_selector_matches_exactly_one_owned_cell() -> None:pytest.param(["--retry-cell", "cell", "--retry-harness", "Electron!"], id="bad-harness"),pytest.param(["--retry-cell"], id="missing-cell-value"),pytest.param(["--retry-cell", "--retry-only"], id="flag-as-cell-value"),- pytest.param(- ["--retry-cell", "cell", "--retry-only", "--standalone-browser"],- id="retry-only-with-standalone-browser",- ),+ pytest.param(["--standalone-browser"], id="removed-standalone-browser-flag"),pytest.param(["--unknown"], id="unknown-argument"),],)diff --git a/libs/cua-driver/tests/perception-demo/README.md b/libs/cua-driver/tests/perception-demo/README.mdindex dd8e5da752..5ab19940df 100644--- a/libs/cua-driver/tests/perception-demo/README.md+++ b/libs/cua-driver/tests/perception-demo/README.md@@ -143,7 +143,7 @@ for a new run. Do not attach the cache, staged envelopes, or plaintext to a PR.Native macOS certification remains separate from the Windows/Linux candidateworkflow. This proof runs directly in a logged-in, TCC-authorized Lume guest. A maintainerdispatches `.github/workflows/e2e-rust-macos.yml` in `lume` mode, whose exact-SHA gate runs-`libs/cua-driver/tests/runners/macos-lume/run-all.sh --standalone-browser` and+`libs/cua-driver/tests/runners/macos-lume/run-all.sh` andpublishes a certification artifact without live-provider credentials. Thecandidate workflow does not schedule macOS execution, and no GitHub Actionsworkflow represents the macOS gate. macOS recordings remain private on thediff --git a/libs/cua-driver/tests/runners/macos-lume/README.md b/libs/cua-driver/tests/runners/macos-lume/README.mdindex c737fa0242..5a66e2326a 100644--- a/libs/cua-driver/tests/runners/macos-lume/README.md+++ b/libs/cua-driver/tests/runners/macos-lume/README.md@@ -387,13 +387,9 @@ cd ~/cualibs/cua-driver/tests/runners/macos-lume/run-all.sh```-When Chrome or Edge is installed in the disposable worker, include the optional-standalone browser-tool matrix in the same exact-source run:--```bash-cd ~/cua-libs/cua-driver/tests/runners/macos-lume/run-all.sh --standalone-browser-```+Every complete run also executes the standalone installed-browser matrix after+the repo-local harness matrix, so the worker must have Chrome and Edge+installed.After a successful run, `artifacts/cua-driver/macos/direct-result.json` recordsthe exact source SHA and run ID. Preserve the private artifacts and register@@ -414,10 +410,10 @@ Also pass the one-line base64 value of `direct-result.json`. The protectedGitHub-hosted job validates and records the result; it does not rerun the guestor require a self-hosted runner.-This adds the declared adversarial installed-browser rows and writes their-separate typed results and MP4 evidence under+The standalone browser matrix runs the declared adversarial installed-browser+rows and writes their separate typed results and MP4 evidence under`artifacts/cua-driver/macos-standalone-browser/`. Missing external browsers are-a hard failure for this option; they never shrink the reported matrix. On a+a hard failure; they never shrink the reported matrix. On arepeat run, the entrypoint preserves the previous standalone-browser evidencein a temporary archive before creating a fresh artifact directory. Theentrypoint temporarily restarts the disposable worker daemon in unrestricted@@ -427,7 +423,7 @@ standard autostart daemon even when a browser row fails.On macOS Tahoe, first-use Chrome can present a native local-network discoveryprompt over `chrome://inspect/#remote-debugging`. The standalone-browser laneuses loopback DevTools and does not need LAN discovery. Before freezing a seed-that will run this optional lane, complete Chrome's welcome screen without+that will run this lane, complete Chrome's welcome screen withoutsigning in and leave the default-browser and usage-reporting choices disabled.Launch Chrome on that exact page in the VM display, choose **Don't Allow**, quitChrome, then relaunch the page and require that the prompt does not return. Do@@ -544,7 +540,7 @@ Pull evidence before deleting the worker, even after a failed run:REMOTE_ARTIFACT_DIR=artifacts/cua-driver/macos \libs/cua-driver/scripts/sync-vm-worktree.sh pull-artifacts \"lume@${VM_IP}" '~/cua'-# Also retrieve this directory when --standalone-browser was used.+# Standalone browser evidence.REMOTE_ARTIFACT_DIR=artifacts/cua-driver/macos-standalone-browser \libs/cua-driver/scripts/sync-vm-worktree.sh pull-artifacts \"lume@${VM_IP}" '~/cua'diff --git a/libs/cua-driver/tests/runners/macos-lume/run-all.sh b/libs/cua-driver/tests/runners/macos-lume/run-all.shindex ca857ece33..62135cdc09 100755--- a/libs/cua-driver/tests/runners/macos-lume/run-all.sh+++ b/libs/cua-driver/tests/runners/macos-lume/run-all.sh@@ -46,7 +46,7 @@ RETRYABLE_LANES=(usage() {cat <<'EOF'-Usage: run-all.sh [--no-build] [--standalone-browser]+Usage: run-all.sh [--no-build][--retry-cell <cell-id> [--retry-harness <harness>][--retry-attempts <1-3>] [--retry-only]]@@ -54,8 +54,8 @@ Run the canonical cua-driver macOS GUI E2E matrix in a disposable clone ofthe maintainer Lume golden image. Start this command from Terminal in the VM'slogged-in desktop session, not over SSH.---standalone-browser also runs the optional installed Chrome/Edge browser-tool-matrix after the canonical repo-local harness matrix.+Every complete run also executes the installed Chrome/Edge browser-tool matrix+after the canonical repo-local harness matrix.--retry-cell authorizes exactly one bounded retry selection. After a failingfull matrix the runner retries that single cell only when it was the matrix's@@ -71,7 +71,6 @@ unrestricted worker daemon first.EOF}-RUN_STANDALONE_BROWSER=0NO_BUILD=0RETRY_CELL=""RETRY_HARNESS=""@@ -79,7 +78,6 @@ RETRY_ATTEMPTS=""RETRY_ONLY=0parse_arguments() {- RUN_STANDALONE_BROWSER=0NO_BUILD=0RETRY_CELL=""RETRY_HARNESS=""@@ -88,7 +86,10 @@ parse_arguments() {while (($#)); docase "$1" in--no-build) NO_BUILD=1 ;;- --standalone-browser) RUN_STANDALONE_BROWSER=1 ;;+ --standalone-browser)+ echo "--standalone-browser was removed; every complete run includes the standalone browser matrix" >&2+ return 2+ ;;--retry-only) RETRY_ONLY=1 ;;--retry-cell=*) RETRY_CELL="${1#*=}" ;;--retry-harness=*) RETRY_HARNESS="${1#*=}" ;;@@ -148,10 +149,6 @@ validate_arguments() {echo "--retry-attempts must be between 1 and ${RETRY_ATTEMPTS_LIMIT}" >&2return 2fi- if [[ "${RETRY_ONLY}" == 1 && "${RUN_STANDALONE_BROWSER}" == 1 ]]; then- echo "--retry-only cannot be combined with --standalone-browser" >&2- return 2- fiif [[ "${RETRY_CELL}" == macos-swiftui-* ]]; thenif [[ -n "${RETRY_HARNESS}" && "${RETRY_HARNESS}" != swiftui ]]; then@@ -1104,25 +1101,23 @@ elif [[ -n "${RETRY_CELL}" ]]; thenecho "[RETRY] The full matrix passed; no retry of ${RETRY_CELL} was needed"fi-if [[ "${RUN_STANDALONE_BROWSER}" == 1 ]]; then- echo "[E2E] Running the optional standalone browser matrix"- BROWSER_ARTIFACT_DIR="${REPO_ROOT}/artifacts/cua-driver/macos-standalone-browser"- if [[ -d "${BROWSER_ARTIFACT_DIR}" ]] \- && [[ -n "$(find "${BROWSER_ARTIFACT_DIR}" -mindepth 1 -print -quit)" ]]; then- BROWSER_ARTIFACT_ARCHIVE="$(mktemp -d "${TMPDIR:-/tmp}/cua-macos-browser-e2e.XXXXXX")"- mv "${BROWSER_ARTIFACT_DIR}" "${BROWSER_ARTIFACT_ARCHIVE}/macos-standalone-browser"- echo "Previous standalone-browser evidence preserved at ${BROWSER_ARTIFACT_ARCHIVE}/macos-standalone-browser"- fi- ensure_unrestricted_daemon- set +e- CUA_E2E_ARTIFACT_DIR="${BROWSER_ARTIFACT_DIR}" \- "${REPO_ROOT}/scripts/ci/run-rust-standalone-browser-e2e.sh"- BROWSER_STATUS=$?- set -e-- if [[ "${BROWSER_STATUS}" != 0 ]]; then- exit "${BROWSER_STATUS}"- fi+echo "[E2E] Running the standalone browser matrix"+BROWSER_ARTIFACT_DIR="${REPO_ROOT}/artifacts/cua-driver/macos-standalone-browser"+if [[ -d "${BROWSER_ARTIFACT_DIR}" ]] \+ && [[ -n "$(find "${BROWSER_ARTIFACT_DIR}" -mindepth 1 -print -quit)" ]]; then+ BROWSER_ARTIFACT_ARCHIVE="$(mktemp -d "${TMPDIR:-/tmp}/cua-macos-browser-e2e.XXXXXX")"+ mv "${BROWSER_ARTIFACT_DIR}" "${BROWSER_ARTIFACT_ARCHIVE}/macos-standalone-browser"+ echo "Previous standalone-browser evidence preserved at ${BROWSER_ARTIFACT_ARCHIVE}/macos-standalone-browser"+fi+ensure_unrestricted_daemon+set +e+CUA_E2E_ARTIFACT_DIR="${BROWSER_ARTIFACT_DIR}" \+ "${REPO_ROOT}/scripts/ci/run-rust-standalone-browser-e2e.sh"+BROWSER_STATUS=$?+set -e++if [[ "${BROWSER_STATUS}" != 0 ]]; then+ exit "${BROWSER_STATUS}"fijq -n \@@ -1130,9 +1125,8 @@ jq -n \--arg source_sha "${SOURCE_SHA}" \--arg run_id "${RUN_ID}" \--arg completed_at "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \- --argjson standalone_browser "${RUN_STANDALONE_BROWSER}" \'{schema: $schema, source_sha: $source_sha, run_id: $run_id,- completed_at: $completed_at, standalone_browser: ($standalone_browser == 1),+ completed_at: $completed_at, standalone_browser: true,passed: true}' > "${ARTIFACT_DIR}/direct-result.json"echo "macOS direct Lume run passed: ${RUN_ID}"diff --git a/scripts/ci/README.md b/scripts/ci/README.mdindex 8b3127d08b..eed53c12ca 100644--- a/scripts/ci/README.md+++ b/scripts/ci/README.md@@ -223,8 +223,9 @@ with each measurement.Use the command without a selector for the canonical complete run. CI sets theprivate `CUA_E2E_INTERNAL_LANE` partition to `shared`, `native`, or `capture`-when it fans the same matrix into independent jobs. Those values are not public-alternate suites.+when it fans the same matrix into independent jobs. The hosted macOS wrapper+also accepts `browser`, which it routes to the standalone browser suite instead+of the repo-local matrix. Those values are not public alternate suites.The complete harness result at the exact source SHA is the behavioral gate.Manual app smokes, standalone videos, legacy runners, and environment-parity@@ -235,13 +236,12 @@ complete repo-local matrix.The maintainer-facing macOS command is`libs/cua-driver/tests/runners/macos-lume/run-all.sh`. It verifies the privateLume seed, installs the exact committed source, and then delegates to the thin-`macos/run-rust-e2e.sh` matrix runner above. Pass `--standalone-browser` to run-the optional installed Chrome/Edge browser matrix after the canonical repo-local-harness matrix.+`macos/run-rust-e2e.sh` matrix runner above. It then always runs the installed+Chrome/Edge browser matrix after the canonical repo-local harness matrix.Run the canonical logged-in Lume gate directly from Terminal in the disposableguest; do not install or register a GitHub Actions runner in that guest. After a-successful `run-all.sh --standalone-browser` invocation, bundle the private+successful `run-all.sh` invocation, bundle the privateartifact directories, calculate their SHA-256 digest, and dispatch`.github/workflows/e2e-rust-macos.yml` in `lume` mode at the exact candidate SHAwith the harness run ID and digest. That protected `ubuntu-latest` job only@@ -257,14 +257,21 @@ exact source SHA. Probe permission checks describe only the temporary probeprocess. Dispatch only a reviewed commit SHA; the selected source is executabletest code and the bootstrap uses the hosted runner's passwordless sudo policy.-After that prerequisite passes, three fresh hosted runners execute the shared,-native, and capture partitions through `macos/run-hosted-rust-e2e.sh`. Each+After that prerequisite passes, four fresh hosted runners execute the shared,+native, capture, and browser lanes through `macos/run-hosted-rust-e2e.sh`. Eachrunner refuses unexpected hosts or pre-existing app state, creates a temporarycertificate-backed identity and Keychain, installs the exact source as`CuaDriverLocal.app`, seeds only its Accessibility and Screen Capture TCC rows,records the app's separate `replayd` approval before its first direct capture,verifies the daemon-attributed permission result, and delegates to-`macos/run-rust-e2e.sh`. GitHub's image-level approval covers the hosted runner+`macos/run-rust-e2e.sh`. The browser lane instead runs+`run-rust-standalone-browser-e2e.sh` against the same unrestricted installed+daemon for the image's Google Chrome and Microsoft Edge, writing evidence to+`artifacts/cua-driver/macos-standalone-browser/` like the Lume gate. It fails+before bootstrap when either browser is missing or fails the driver's vendor+code-signing requirement, and it never shrinks the product set. The image's Edge+carries a stray `com.apple.FinderInfo` attribute that strict verification+rejects; the lane removes only that unsigned attribute and records each path. The `certify` job requires every lane. GitHub's image-level approval covers the hosted runneragent, while the bundled driver is its own responsible ScreenCaptureKit clientand would otherwise show the private-window-picker reminder over the headedtest. The lane uploads bootstrap, structured result, log, and video evidencediff --git a/scripts/ci/macos/run-hosted-rust-e2e.sh b/scripts/ci/macos/run-hosted-rust-e2e.shindex 999e70f08d..d797501e5e 100755--- a/scripts/ci/macos/run-hosted-rust-e2e.sh+++ b/scripts/ci/macos/run-hosted-rust-e2e.sh@@ -1,5 +1,8 @@#!/usr/bin/env bash# Prepare a fresh GitHub-hosted macOS 26 runner and run one canonical E2E lane.+# The shared, native, and capture lanes partition the repo-local matrix. The+# browser lane runs the standalone installed Chrome/Edge matrix, which the Lume+# gate runs after its repo-local matrix.set -euo pipefailSCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"@@ -10,6 +13,15 @@ INSTALLED_BIN="${LOCAL_APP}/Contents/MacOS/cua-driver-local"TCC_SEEDER="${DRIVER_ROOT}/tests/runners/macos-lume/seed-tcc-guest.sh"LANE="${CUA_E2E_INTERNAL_LANE:-}"BOOTSTRAP_DIR="${REPO_ROOT}/artifacts/cua-driver/macos-hosted-bootstrap"+BROWSER_ARTIFACT_DIR="${REPO_ROOT}/artifacts/cua-driver/macos-standalone-browser"+# The browser lane certifies every installed product the Lume seed carries.+STANDALONE_BROWSER_PRODUCTS="chrome,edge"+# app path|code-signing identifier|vendor team, matching the driver's pid-free+# isolated-launch attestation in platform-macos/src/browser/platform.rs.+STANDALONE_BROWSER_APPS=(+ "/Applications/Google Chrome.app|com.google.Chrome|EQHXZ8M8AV"+ "/Applications/Microsoft Edge.app|com.microsoft.edgemac|UBF8T346G9"+)KEYCHAIN="${RUNNER_TEMP:-}/cua-driver-hosted-signing.keychain-db"DAEMON_SOCKET="${HOME}/Library/Caches/cua-driver-local/cua-driver-local.sock"SCREEN_CAPTURE_APPROVALS="${HOME}/Library/Group Containers/group.com.apple.replayd/ScreenCaptureApprovals.plist"@@ -163,8 +175,8 @@ capture_command_output() {[[ -z "${SSH_CONNECTION:-}" && -z "${SSH_TTY:-}" ]] \|| fail "SSH sessions cannot seed or certify hosted TCC state"case "${LANE}" in- shared|native|capture) ;;- *) fail "CUA_E2E_INTERNAL_LANE must be shared, native, or capture" ;;+ shared|native|capture|browser) ;;+ *) fail "CUA_E2E_INTERNAL_LANE must be shared, native, capture, or browser" ;;esacCURRENT_USER="$(id -un)"@@ -198,6 +210,44 @@ done|| fail "refusing a runner with a pre-existing signing keychain"sudo -n -v >/dev/null 2>&1 \|| fail "requires the hosted runner's noninteractive sudo policy"+if [[ "${LANE}" == browser ]]; then+ # A missing or unsigned vendor browser must fail the lane; it never shrinks+ # the certified product set.+ mkdir -p "${BOOTSTRAP_DIR}"+ : > "${BOOTSTRAP_DIR}/standalone-browser-finderinfo-removed.txt"+ for browser_entry in "${STANDALONE_BROWSER_APPS[@]}"; do+ IFS='|' read -r browser_app browser_identifier browser_team <<< "${browser_entry}"+ browser_executable="${browser_app}/Contents/MacOS/$(basename "${browser_app}" .app)"+ [[ -x "${browser_executable}" ]] \+ || fail "missing hosted standalone browser: ${browser_app}"+ # The hosted image provisions Edge with a stray com.apple.FinderInfo xattr+ # on a framework directory. Extended attributes are not signed content, and+ # strict verification (like the driver's own attestation) rejects that+ # Finder detritus. Remove only that attribute, record each path, and still+ # require the full strict vendor requirement below.+ # The attribute can sit on a framework symlink, so clear it from both the+ # link (-s) and its target; the strict requirement check is the judge.+ finderinfo_paths=()+ while IFS= read -r -d '' finderinfo_path; do+ finderinfo_paths+=("${finderinfo_path}")+ done < <(find "${browser_app}" -xattrname com.apple.FinderInfo -print0)+ for finderinfo_path in ${finderinfo_paths[@]+"${finderinfo_paths[@]}"}; do+ printf '%s\n' "${finderinfo_path}" \+ >> "${BOOTSTRAP_DIR}/standalone-browser-finderinfo-removed.txt"+ run_bounded 20 sudo -n /usr/bin/xattr -s -d com.apple.FinderInfo \+ "${finderinfo_path}" >/dev/null 2>&1 || true+ run_bounded 20 sudo -n /usr/bin/xattr -d com.apple.FinderInfo \+ "${finderinfo_path}" >/dev/null 2>&1 || true+ done+ browser_requirement="=anchor apple generic and certificate leaf[subject.OU] = \"${browser_team}\" and identifier \"${browser_identifier}\""+ if ! browser_verify_output="$(codesign --verify --strict -vvvv \+ --test-requirement "${browser_requirement}" "${browser_executable}" 2>&1)"; then+ printf '%s\n' "${browser_verify_output}" >&2+ codesign -dvvv "${browser_executable}" >&2 2>&1 || true+ fail "hosted standalone browser signature is not valid: ${browser_executable}"+ fi+ done+fiSOURCE_SHA="$(git -C "${REPO_ROOT}" rev-parse HEAD)"[[ "${CUA_E2E_SOURCE_SHA:-}" =~ ^[0-9a-fA-F]{40}$ ]] \@@ -226,6 +276,22 @@ mkdir -p "${BOOTSTRAP_DIR}"ffprobe -version 2>&1 | sed -n '1p'jq --version} > "${BOOTSTRAP_DIR}/environment.txt"+if [[ "${LANE}" == browser ]]; then+ {+ printf 'standalone_browser_products=%s\n' "${STANDALONE_BROWSER_PRODUCTS}"+ for browser_entry in "${STANDALONE_BROWSER_APPS[@]}"; do+ browser_app="${browser_entry%%|*}"+ printf '%s version=%s\n' "${browser_app}" \+ "$(defaults read "${browser_app}/Contents/Info" CFBundleShortVersionString)"+ codesign -dv "${browser_app}" 2>&1 \+ | grep -E '^(Identifier|TeamIdentifier)='+ # Informational only: the driver attests the main executable, and the+ # hosted image's Edge bundle does not pass a whole-bundle strict check.+ printf 'bundle_strict_verify: '+ codesign --verify --strict "${browser_app}" 2>&1 && printf 'ok\n'+ done+ } > "${BOOTSTRAP_DIR}/standalone-browsers.txt"+ficat > "${BOOTSTRAP_DIR}/cleanup-targets.txt" <<EOFInstaller recursive cleanup is limited to source-derived task-owned paths:@@ -405,7 +471,19 @@ export CUA_E2E_FRESH_FIXTURE_STATE=1mark_phase "matrix-${LANE}"echo "[E2E] Running hosted macOS ${LANE} lane"MATRIX_STATUS=0-bash "${SCRIPT_DIR}/run-rust-e2e.sh" || MATRIX_STATUS=$?+if [[ "${LANE}" == browser ]]; then+ # Mirror the Lume gate: the standalone matrix runs against the same+ # unrestricted installed daemon, with a fresh evidence directory and a+ # repo-owned isolated profile per browser row.+ CUA_TEST_DRIVER_BIN="${CARGO_TARGET_DIR}/release/cua-driver" \+ CUA_E2E_BROWSER_PRODUCTS="${STANDALONE_BROWSER_PRODUCTS}" \+ CUA_E2E_BROWSER_STDERR=1 \+ CUA_E2E_ARTIFACT_DIR="${BROWSER_ARTIFACT_DIR}" \+ bash "${REPO_ROOT}/scripts/ci/run-rust-standalone-browser-e2e.sh" \+ || MATRIX_STATUS=$?+else+ bash "${SCRIPT_DIR}/run-rust-e2e.sh" || MATRIX_STATUS=$?+fikill "${WATCHDOG_PID}" >/dev/null 2>&1 || truewait "${WATCHDOG_PID}" 2>/dev/null || trueWATCHDOG_PID=""