feat(computer_use): enable Windows via cua-driver-rs

The cua-driver backend was gated to macOS only:

    # tools/computer_use/tool.py
    def check_computer_use_requirements() -> bool:
        if sys.platform != "darwin":
            return False
        ...

But cua-driver itself has been Windows-feature-complete since cua-driver-rs
(the cross-platform Rust port) shipped its Windows backend. Every action
tool — click, type_text, hotkey, drag, scroll, screenshot, launch_app,
list_apps, list_windows, get_window_state, move_cursor, wait — is marked
VERIFIED on Windows in the cross-platform PARITY matrix:
https://github.com/trycua/cua/blob/main/libs/cua-driver-rs/PARITY.md

This PR widens the gate to `sys.platform in ("darwin", "win32")`. No new
code paths — the existing MCP stdio integration in cua_backend.py works
identically against cua-driver on Windows because cua-driver's tool
surface is uniform across OSes.

Linux is not in scope. cua-driver-rs Linux support exists in tree but is
alpha (most Linux rows in PARITY are OPEN, not VERIFIED) — keeping it gated
off here until upstream flips those to VERIFIED. The plumbing is
OS-agnostic so flipping the gate later is one-line.

Empirical verification on Windows 11 24H2 (2026-05-22 dogfood):

  - Built-in Administrator (RID 500) at High IL via cua-driver-rs
    RunLevel=Highest autostart task:
      `cua-driver call get_window_state` for Calculator UWP
      → element_count: 41

  - Regular admin (UAC-split, Medium IL primary token) running
    `cua-driver call` directly from PowerShell:
      `cua-driver call get_window_state` for Calculator UWP
      → element_count: 41

UWP / AppContainer UIA works at any IL for any user. No EV cert, no
uiAccess="true" manifest, no Program Files install requirement.

## Changes

- tools/computer_use/tool.py: replace `sys.platform != "darwin"`
  early-return with `sys.platform not in ("darwin", "win32")`. Update
  top-of-file docstring + vision-prompt phrasing ("macOS application" →
  "desktop application") so the model isn't told to expect a Mac UI when
  it's looking at a Windows screen.
- tools/computer_use/cua_backend.py: rewrite top-of-file docstring to
  cover macOS + Windows + the Linux-alpha caveat. `is_available()`
  matches the same `darwin/win32` allowlist. `cua_driver_install_hint()`
  returns the Windows installer (irm | iex) on Windows, the bash
  installer on macOS.
- tools/computer_use_tool.py: update registry description from "macOS
  desktop control" to "desktop control (macOS, Windows; Linux alpha)".

The macOS-specific bits in `cua_backend.py` (the `_is_arm_mac` helper, the
"macOS reports localized app names" warning) stay as-is — they're macOS
runtime details that are conditionally taken when running on macOS, not
gates that block other OSes.

## Install

Same one-liner story, OS-specific installer:

  macOS:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh)"

  Windows (PowerShell):
    irm https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.ps1 | iex

After install, `cua-driver` is on $PATH and Hermes's check_fn sees it.

## Related

Replies to @teknium1's question on #20660 about whether cua-driver-rs
ships Windows + Linux backends and whether @Abd0r's per-OS Python work
should be absorbed into cua-driver as a starting point. Short answer:
the cua-driver-rs Rust impl is months ahead of a fresh Python port on
Windows. Linux is alpha and will get there. Several pieces of #20660
(kill-switch, JSONL audit log, screenshot redact_regions, the per-OS
SKILL.md docs) are worth absorbing into cua-driver as follow-up work —
separate from this PR.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Francesco Bonacci 2026-05-23 02:00:21 +02:00 • committed by Teknium
parent bee13817f0
commit d3c34e0126
No known key found for this signature in database
3 changed files with 55 additions and 18 deletions

View file

@ -1,18 +1,35 @@
"""Cua-driver backend (macOS only).
"""Cua-driver backend (macOS + Windows).
Speaks MCP over stdio to `cua-driver`. The Python `mcp` SDK is async, so we
run a dedicated asyncio event loop on a background thread and marshal sync
calls through it.
Install: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh)"`
The same `cua-driver call <tool>` surface (click, type_text, hotkey, drag,
scroll, screenshot, launch_app, list_apps, list_windows, get_window_state,
move_cursor, wait) works identically across macOS + Windows — cua-driver's
PARITY matrix marks every action tool VERIFIED on Windows in the
cross-platform Rust port (`cua-driver-rs`).
Linux support exists in cua-driver-rs but is alpha today — Linux PARITY
rows are mostly OPEN, not VERIFIED — so it's gated off in
`check_computer_use_requirements` until that flips upstream. The plumbing
in this file is OS-agnostic, so flipping that gate later is one-line.
Install:
- **macOS**:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh)"
- **Windows** (PowerShell):
irm https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.ps1 | iex
After install, `cua-driver` is on $PATH and supports `cua-driver mcp` (stdio
transport) which is what we invoke.
The private SkyLight SPIs cua-driver uses (SLEventPostToPid, SLPSPostEvent-
RecordTo, _AXObserverAddNotificationAndCheckRemote) are not Apple-public and
can break on OS updates. Pin the installed version via `HERMES_CUA_DRIVER_
VERSION` if you want reproducibility across an OS bump.
The macOS path uses private SkyLight SPIs (SLEventPostToPid,
SLPSPostEventRecordTo, _AXObserverAddNotificationAndCheckRemote) that aren't
Apple-public and can break on OS updates. The Windows path in cua-driver-rs
uses stable Win32 APIs (SendInput + UI Automation) — not subject to the
same SPI breakage class. Pin the installed version via
HERMES_CUA_DRIVER_VERSION if you want reproducibility across an OS bump.
"""
from __future__ import annotations
@ -84,12 +101,22 @@ def cua_driver_binary_available() -> bool:
def cua_driver_install_hint() -> str:
if sys.platform == "win32":
installer = (
' irm https://raw.githubusercontent.com/trycua/cua/main/'
'libs/cua-driver/scripts/install.ps1 | iex'
)
else:
installer = (
' /bin/bash -c "$(curl -fsSL '
'https://raw.githubusercontent.com/trycua/cua/main/'
'libs/cua-driver/scripts/install.sh)"'
)
return (
"cua-driver is not installed. Install with one of:\n"
" hermes computer-use install\n"
"Or run the upstream installer directly:\n"
' /bin/bash -c "$(curl -fsSL '
'https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh)"\n'
f"{installer}\n"
"Or run `hermes tools` and enable the Computer Use toolset to install it automatically."
)
@ -396,7 +423,7 @@ def _extract_tool_result(mcp_result: Any) -> Dict[str, Any]:
# ---------------------------------------------------------------------------
class CuaDriverBackend(ComputerUseBackend):
"""Default computer-use backend. macOS-only via cua-driver MCP."""
"""Default computer-use backend. Cross-platform via cua-driver MCP (macOS + Windows)."""
def __init__(self) -> None:
self._bridge = _AsyncBridge()
@ -417,7 +444,10 @@ class CuaDriverBackend(ComputerUseBackend):
self._bridge.stop()
def is_available(self) -> bool:
if not _is_macos():
# cua-driver itself is cross-platform; we constrain Hermes to
# macOS + Windows because cua-driver-rs Linux is alpha (most rows
# in its PARITY matrix are OPEN). Flip when Linux goes VERIFIED.
if sys.platform not in ("darwin", "win32"):
return False
return cua_driver_binary_available()

View file

@ -1,9 +1,12 @@
"""Entry point for the `computer_use` tool.
Universal (any-model) macOS desktop control via cua-driver's background
computer-use primitive. Replaces #4562's Anthropic-native `computer_20251124`
approach — the schema here is standard OpenAI function-calling so every
tool-capable model can drive it.
Universal (any-model) desktop control across macOS + Windows via
cua-driver's background computer-use primitive. Replaces #4562's
Anthropic-native `computer_20251124` approach — the schema here is standard
OpenAI function-calling so every tool-capable model can drive it.
Linux support exists in cua-driver-rs (alpha — PARITY rows are mostly
OPEN today, not VERIFIED) and is gated off here until it flips upstream.
Return contract
---------------
@ -693,7 +696,7 @@ def _route_capture_through_aux_vision(
temp_image_path.write_bytes(raw)
prompt = (
"Describe what is visible in this macOS application screenshot in "
"Describe what is visible in this desktop application screenshot in "
"concise but specific terms. Mention the app name and window "
"title if visible, the overall layout, any labelled buttons, "
"menus or text fields, and any prominent text content the user "
@ -810,9 +813,13 @@ def _element_to_dict(e: UIElement) -> Dict[str, Any]:
def check_computer_use_requirements() -> bool:
"""Return True iff computer_use can run on this host.
Conditions: macOS + cua-driver binary installed (or override via env).
Conditions: macOS or Windows + cua-driver binary installed (or override
via env). cua-driver-rs (the cross-platform Rust port) has every action
tool marked VERIFIED on Windows in its PARITY matrix. Linux is alpha
today — Linux rows in PARITY are mostly OPEN — so it's gated off until
that flips to VERIFIED upstream.
"""
if sys.platform != "darwin":
if sys.platform not in ("darwin", "win32"):
return False
from tools.computer_use.cua_backend import cua_driver_binary_available
return cua_driver_binary_available()

View file

@ -24,7 +24,7 @@ registry.register(
check_fn=check_computer_use_requirements,
requires_env=[],
description=(
"Universal macOS desktop control via cua-driver. Works with any "
"Universal desktop control via cua-driver (macOS, Windows; Linux alpha). Works with any "
"tool-capable model (Anthropic, OpenAI, OpenRouter, local vLLM, "
"etc.). Background computer-use: does NOT steal the user's cursor "
"or keyboard focus."