qwen-code/packages/cua-driver/python
顾盼 9605bcc25f
feat(cua-driver): sync vendored cua-driver 0.6.8 → 0.7.0 (#6212)
* feat(cua-driver): sync vendored cua-driver from 0.6.8 to 0.7.0

Upstream 0.7.0 brings action-time modality (get_window_state always
returns AX tree + screenshot, capture_mode retired), honest verification
(every action returns verified/path/effect/escalation), browser page
(CDP) tools, desktop-scope (capture_scope=window|desktop,
get_desktop_state, screen-absolute click/scroll), and Rust-only
consolidation (Swift backend retired).

Cherry-pick patch changes:
- #2025 (X11 synthetic click): retired — superseded by 0.7.0
  honest-verification
- #2035 (session revive): retired — superseded by 0.7.0
  revive_session/loud-reject/is_session_lifecycle_tool
- #2036 (EAGAIN socket write retry): re-injected — merged upstream
  post-0.7.0 tag, EAGAIN os error 35 is not acceptable
- #2021 (null/empty-title windows + resolve_uwp_host_window): retained,
  adapted to 0.7.0's new is_listable_top_level and window_title helpers

Shim extensions:
- coord_norm: desktop-scope support — denormalize_args falls back to
  screen basis when no window cache (desktop-scope click),
  normalize_result handles get_desktop_state, ingest_screen_size reads
  get_desktop_state's screen_width/height
- serve.rs: rewrite_coord_desc re-injected at both tools/list sites

Install scripts simplified to Rust-only (Swift backend retired upstream).

Fix platform-linux cross-compilation: cfg-gate wayland::PORTAL_LIBEI_ENABLED
reference in health_report.rs for non-linux hosts.

* fix(cua-driver): distinguish desktop-scope from window cache miss in denormalize_args

When screenshot_w == 0 (no cached window size), check whether the call
has a pid/window_id target before falling back to screen-size basis.
Window-scoped clicks with a cache miss now correctly leave coordinates
as-is instead of mapping them against the screen dimensions.

* fix(cua-driver): use screenshot pixels not logical points for desktop-scope coord basis

ingest_screen_size was reading screen_width/height (logical display
points from CGDisplayBounds) for get_desktop_state, but the model
operates on the screenshot PNG whose dimensions are physical pixels.
On Retina displays (2x) this caused every desktop-scope click to land
at half the intended position.

Read screenshot_width/height instead — the same basis normalize_result
rewrites to 1000. Updated test to use realistic Retina values
(screen 1920, screenshot 3840) to catch 1:1 masking.

* fix(cua-driver): split screen cache into logical (move_cursor) and physical (desktop-scope)

The single screen_cache was being written by both get_screen_size
(logical points, e.g. 1920x1080) and get_desktop_state (physical
pixels, e.g. 3840x2160). Since move_cursor operates in CGEvent screen
points (logical) while desktop-scope clicks operate in screenshot
pixels (physical), whichever tool ran last would corrupt the other's
denormalization basis — causing 2x overshoot or 1/2 offset on Retina.

Split into:
- SCREEN_SIZE: logical points, written by get_screen_size, consumed by
  move_cursor (screen_basis=true)
- DESKTOP_SCREENSHOT_SIZE: physical pixels, written by get_desktop_state,
  consumed by desktop-scope click fallback (screenshot_w==0, no pid)

Added cross-contamination isolation tests.

---------

Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
2026-07-03 06:27:00 +00:00
..
src/cua_driver feat(cua-driver): vendor qwen-cua-driver with opt-in 0–1000 relative coordinates (#5896) 2026-06-26 13:06:43 +00:00
tests feat(cua-driver): vendor qwen-cua-driver with opt-in 0–1000 relative coordinates (#5896) 2026-06-26 13:06:43 +00:00
.gitignore feat(cua-driver): vendor qwen-cua-driver with opt-in 0–1000 relative coordinates (#5896) 2026-06-26 13:06:43 +00:00
build_wheel.py feat(cua-driver): vendor qwen-cua-driver with opt-in 0–1000 relative coordinates (#5896) 2026-06-26 13:06:43 +00:00
MANIFEST.in feat(cua-driver): vendor qwen-cua-driver with opt-in 0–1000 relative coordinates (#5896) 2026-06-26 13:06:43 +00:00
pyproject.toml feat(cua-driver): vendor qwen-cua-driver with opt-in 0–1000 relative coordinates (#5896) 2026-06-26 13:06:43 +00:00
README.md feat(cua-driver): sync vendored cua-driver 0.6.8 → 0.7.0 (#6212) 2026-07-03 06:27:00 +00:00

cua-driver

Python wrapper for cua-driver - a cross-platform MCP (Model Context Protocol) server for computer-use automation.

Installation

Install and usage docs live at https://cua.ai/docs/how-to-guides/driver/install and https://cua.ai/docs/reference/cua-driver/mcp-tools.

Usage

The package provides a cua-driver command that wraps the native Rust binary. See the canonical tool reference at https://cua.ai/docs/reference/cua-driver/mcp-tools.

Python API

You can also use the Python API directly:

from cua_driver import run_cua_driver, get_binary_path

# Run with custom args
exit_code = run_cua_driver(["mcp"])

# Get path to bundled binary
binary_path = get_binary_path()

Features

  • Cross-platform: Works on macOS (universal), Linux (x86_64), and Windows (x86_64/ARM64)
  • Zero dependencies: Pure Python wrapper with no external dependencies
  • Stdio passthrough: Transparent piping for MCP protocol communication
  • Bundled binary: No separate installation required - the Rust binary is included in the wheel

Platform Support

Platform Architecture Status
macOS Universal (ARM64 + x86_64) Supported
Linux x86_64 Supported
Windows x86_64 Supported
Windows ARM64 Supported

License

MIT License - see LICENSE