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
feat(python): Add cua-driver PyPI wrapper with bundled binaries (#1849)
ddupont6294a3620d6f
diff --git a/.github/workflows/cd-py-cua-driver.yml b/.github/workflows/cd-py-cua-driver.ymlnew file mode 100644index 0000000000..23b1079246--- /dev/null+++ b/.github/workflows/cd-py-cua-driver.yml@@ -0,0 +1,151 @@+name: "CD: Python cua-driver"++# Triggered after cua-driver-rs releases to build platform-specific wheels+# with bundled binaries and publish to PyPI.++on:+ workflow_dispatch:+ inputs:+ version:+ description: "cua-driver-rs version to package (without v prefix)"+ required: true+ default: "0.5.1"+ # Auto-trigger when cua-driver-rs releases (after CD workflow completes)+ workflow_run:+ workflows: ["CD: Cua Driver (cross-platform)"]+ types:+ - completed+ branches:+ - main++permissions:+ contents: read++jobs:+ # Extract version from the triggering workflow or input+ get-version:+ runs-on: ubuntu-latest+ if: |+ github.event_name == 'workflow_dispatch' ||+ (github.event.workflow_run.conclusion == 'success' &&+ github.event.workflow_run.head_branch == 'main')+ outputs:+ version: ${{ steps.version.outputs.version }}+ should_publish: ${{ steps.version.outputs.should_publish }}+ steps:+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2++ - name: Determine version+ id: version+ run: |+ if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then+ VERSION="${{ inputs.version }}"+ SHOULD_PUBLISH="true"+ else+ # Extract from the tag that triggered the workflow_run+ # Validate SHA format to prevent injection+ HEAD_SHA="${{ github.event.workflow_run.head_sha }}"+ if ! echo "$HEAD_SHA" | grep -qE '^[0-9a-f]{40}$'; then+ echo "Invalid SHA format: $HEAD_SHA"+ VERSION="0.0.0"+ SHOULD_PUBLISH="false"+ else+ git fetch --tags+ TAG=$(git tag --points-at "$HEAD_SHA" | grep '^cua-driver-rs-v' | head -1 || echo "")+ if [ -n "$TAG" ]; then+ VERSION="${TAG#cua-driver-rs-v}"+ SHOULD_PUBLISH="true"+ else+ # No matching tag, skip+ VERSION="0.0.0"+ SHOULD_PUBLISH="false"+ fi+ fi+ fi+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"+ echo "should_publish=$SHOULD_PUBLISH" >> "$GITHUB_OUTPUT"+ echo "Detected version: $VERSION (publish: $SHOULD_PUBLISH)"++ # Build wheels for each platform (with bundled binaries)+ build-wheels:+ needs: get-version+ if: needs.get-version.outputs.should_publish == 'true'+ runs-on: ${{ matrix.os }}+ strategy:+ fail-fast: false+ matrix:+ include:+ - os: macos-latest+ platform: macos+ - os: ubuntu-latest+ platform: linux+ - os: windows-latest+ platform: windows+ steps:+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2++ - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a20 # v5.3.0+ with:+ python-version: "3.12"++ - name: Install build dependencies+ run: |+ python -m pip install --upgrade pip+ pip install build hatchling++ - name: Update version in pyproject.toml and __init__.py+ shell: bash+ run: |+ VERSION="${{ needs.get-version.outputs.version }}"+ cd libs/cua-driver/python+ # Portable sed: use temp file approach for all platforms+ sed "s/^version = .*/version = \"$VERSION\"/" pyproject.toml > pyproject.toml.tmp+ mv pyproject.toml.tmp pyproject.toml+ sed "s/^__version__ = .*/__version__ = \"$VERSION\"/" src/cua_driver/__init__.py > __init__.py.tmp+ mv __init__.py.tmp src/cua_driver/__init__.py+ echo "Updated versions:"+ grep "^version = " pyproject.toml+ grep "^__version__ = " src/cua_driver/__init__.py++ - name: Build wheel with bundled binary+ shell: bash+ run: |+ cd libs/cua-driver/python+ python build_wheel.py --version "${{ needs.get-version.outputs.version }}"++ - name: List built artifacts+ shell: bash+ run: |+ ls -lh libs/cua-driver/python/dist/++ - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0+ with:+ name: wheel-${{ matrix.platform }}+ path: libs/cua-driver/python/dist/*.whl+ if-no-files-found: error++ # Publish all wheels to PyPI+ publish-pypi:+ needs: [get-version, build-wheels]+ runs-on: ubuntu-latest+ environment: pypi+ permissions:+ id-token: write # For trusted publishing+ steps:+ - name: Download all wheels+ uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8+ with:+ pattern: wheel-*+ path: dist+ merge-multiple: true++ - name: List wheels to publish+ run: |+ ls -lh dist/++ - name: Publish to PyPI+ uses: pypa/gh-action-pypi-publish@67339c736fd9354cd4f8cb0b744f2b82a74b5c70 # v1.12.2+ with:+ packages-dir: dist/+ skip-existing: true+ verbose: truediff --git a/libs/cua-driver/python/.gitignore b/libs/cua-driver/python/.gitignorenew file mode 100644index 0000000000..be583c0539--- /dev/null+++ b/libs/cua-driver/python/.gitignore@@ -0,0 +1,16 @@+# Build artifacts+dist/+build/+*.egg-info/+__pycache__/+*.pyc+*.pyo++# Downloaded binaries and archives+downloads/+src/cua_driver/bin/++# Virtual environments+venv/+.venv/+env/diff --git a/libs/cua-driver/python/MANIFEST.in b/libs/cua-driver/python/MANIFEST.innew file mode 100644index 0000000000..0d09f8ae2b--- /dev/null+++ b/libs/cua-driver/python/MANIFEST.in@@ -0,0 +1,2 @@+include README.md+recursive-include src/cua_driver/bin *diff --git a/libs/cua-driver/python/README.md b/libs/cua-driver/python/README.mdnew file mode 100644index 0000000000..5440a2e289--- /dev/null+++ b/libs/cua-driver/python/README.md@@ -0,0 +1,74 @@+# cua-driver++Python wrapper for [cua-driver](https://github.com/trycua/cua/tree/main/libs/cua-driver) - a cross-platform MCP (Model Context Protocol) server for computer-use automation.++## Installation++```bash+pip install cua-driver+```++## Usage++The package provides a `cua-driver` command that wraps the native Rust binary:++```bash+# Start MCP server over stdio+cua-driver mcp++# Check version+cua-driver --version++# View help+cua-driver --help+```++### Python API++You can also use the Python API directly:++```python+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++## What is cua-driver?++`cua-driver` is a cross-platform MCP server that provides 40+ tools for:+- Screen capture and window management+- Mouse and keyboard automation+- Accessibility tree interaction+- Application launching and control++It enables AI agents to interact with desktop applications through the Model Context Protocol.++## 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](https://github.com/trycua/cua/blob/main/LICENSE.md)++## Links++- [GitHub Repository](https://github.com/trycua/cua)+- [Documentation](https://github.com/trycua/cua/tree/main/libs/cua-driver)+- [Issue Tracker](https://github.com/trycua/cua/issues)diff --git a/libs/cua-driver/python/build_wheel.py b/libs/cua-driver/python/build_wheel.pynew file mode 100644index 0000000000..cf03d758b0--- /dev/null+++ b/libs/cua-driver/python/build_wheel.py@@ -0,0 +1,253 @@+#!/usr/bin/env python3+"""Build script to download platform-specific cua-driver binary and create wheel.++This script:+1. Detects the current platform+2. Downloads the appropriate cua-driver-rs binary from GitHub releases+3. Places it in src/cua_driver/bin/+4. Builds the wheel with hatchling++Usage:+ python build_wheel.py [--version VERSION]+"""++import argparse+import hashlib+import os+import platform+import shutil+import subprocess+import sys+import tarfile+import urllib.request+import zipfile+from pathlib import Path+++def get_platform_info():+ """Determine platform and architecture for binary selection."""+ system = platform.system().lower()+ machine = platform.machine().lower()++ # Normalize architecture names+ if machine in ("x86_64", "amd64"):+ arch = "x86_64"+ elif machine in ("arm64", "aarch64"):+ arch = "arm64"+ else:+ raise ValueError(f"Unsupported architecture: {machine}")++ # Map to cua-driver-rs release naming+ if system == "darwin":+ # macOS uses universal binary+ return "darwin", "universal"+ elif system == "linux":+ return "linux", arch+ elif system == "windows":+ return "windows", arch+ else:+ raise ValueError(f"Unsupported platform: {system}")+++def get_release_url(version: str, platform_name: str, arch: str) -> tuple[str, str]:+ """Get the GitHub release URL and binary name for the platform.++ Returns:+ Tuple of (download_url, binary_name_in_archive)+ """+ base_url = f"https://github.com/trycua/cua/releases/download/cua-driver-rs-v{version}"++ if platform_name == "darwin":+ # Universal binary tarball+ filename = f"cua-driver-rs-{version}-darwin-universal-binary.tar.gz"+ binary_name = "cua-driver"+ elif platform_name == "linux":+ filename = f"cua-driver-rs-{version}-linux-{arch}-binary.tar.gz"+ binary_name = "cua-driver"+ elif platform_name == "windows":+ filename = f"cua-driver-rs-{version}-windows-{arch}-binary.zip"+ binary_name = "cua-driver.exe"+ else:+ raise ValueError(f"Unknown platform: {platform_name}")++ return f"{base_url}/{filename}", binary_name+++def verify_sha256(file_path: Path, expected_sha256: str) -> None:+ """Verify file matches expected SHA256 hash."""+ h = hashlib.sha256()+ with open(file_path, "rb") as f:+ for chunk in iter(lambda: f.read(8192), b""):+ h.update(chunk)+ actual = h.hexdigest()+ if actual != expected_sha256:+ raise ValueError(+ f"SHA256 mismatch for {file_path.name}: expected {expected_sha256}, got {actual}"+ )+++def get_expected_sha256(version: str, archive_name: str) -> str:+ """Fetch and parse checksums.txt from GitHub release."""+ checksums_url = f"https://github.com/trycua/cua/releases/download/cua-driver-rs-v{version}/checksums.txt"+ print(f"Fetching checksums from {checksums_url}...")++ try:+ with urllib.request.urlopen(checksums_url) as response:+ content = response.read().decode("utf-8")++ for line in content.splitlines():+ line = line.strip()+ # Skip empty lines, comments, and headers+ if not line or line.startswith("#") or "Checksums" in line or line.startswith("```"):+ continue+ # Parse "SHA256 filename" format+ parts = line.split()+ if len(parts) >= 2:+ sha, name = parts[0], parts[-1]+ if name == archive_name:+ return sha++ raise ValueError(f"SHA256 for {archive_name} not found in checksums.txt")+ except Exception as e:+ raise RuntimeError(f"Failed to fetch or parse checksums: {e}")+++def download_file(url: str, dest: Path, expected_sha256: str) -> None:+ """Download a file with progress indication and SHA256 verification."""+ print(f"Downloading {url}...")+ try:+ with urllib.request.urlopen(url) as response:+ total_size = int(response.headers.get("content-length", 0))+ dest.parent.mkdir(parents=True, exist_ok=True)++ with open(dest, "wb") as f:+ downloaded = 0+ block_size = 8192+ while True:+ chunk = response.read(block_size)+ if not chunk:+ break+ f.write(chunk)+ downloaded += len(chunk)+ if total_size > 0:+ percent = (downloaded / total_size) * 100+ print(f" {percent:.1f}% ({downloaded}/{total_size} bytes)", end="\r")++ print(f"\nDownloaded to {dest}")++ # Verify SHA256+ print("Verifying SHA256 checksum...")+ verify_sha256(dest, expected_sha256)+ print("✓ Checksum verified")++ except Exception as e:+ if dest.exists():+ dest.unlink()+ raise RuntimeError(f"Failed to download {url}: {e}")+++def extract_binary(archive_path: Path, binary_name: str, dest_dir: Path) -> Path:+ """Extract the binary from the archive."""+ dest_dir.mkdir(parents=True, exist_ok=True)+ dest_path = dest_dir / binary_name++ if archive_path.suffix == ".zip":+ with zipfile.ZipFile(archive_path, "r") as zf:+ # Find the binary in the zip (exact match or ends with /<binary_name>)+ for name in zf.namelist():+ # Match exact name or path ending with /binary_name+ if name == binary_name or name.endswith(f"/{binary_name}"):+ with zf.open(name) as src, open(dest_path, "wb") as dst:+ shutil.copyfileobj(src, dst)+ break+ else:+ raise ValueError(f"Binary {binary_name} not found in {archive_path}")+ else:+ # .tar.gz+ with tarfile.open(archive_path, "r:gz") as tf:+ # The -binary tarballs have the binary at the root+ tf.extract(binary_name, dest_dir)++ # Make executable on Unix+ if sys.platform != "win32":+ os.chmod(dest_path, 0o755)++ print(f"Extracted binary to {dest_path}")+ return dest_path+++def build_wheel(package_dir: Path) -> None:+ """Build the wheel using hatchling."""+ print("\nBuilding wheel...")+ subprocess.run(+ [sys.executable, "-m", "build", "--wheel"],+ cwd=package_dir,+ check=True,+ )+ print("Wheel built successfully!")+++def main():+ parser = argparse.ArgumentParser(description="Build cua-driver Python wheel with bundled binary")+ parser.add_argument(+ "--version",+ default="0.5.1",+ help="cua-driver-rs version to download (default: 0.5.1)",+ )+ parser.add_argument(+ "--skip-download",+ action="store_true",+ help="Skip download and use existing binary in bin/ (for local testing)",+ )+ args = parser.parse_args()++ # Determine paths+ script_dir = Path(__file__).parent+ bin_dir = script_dir / "src" / "cua_driver" / "bin"+ download_dir = script_dir / "downloads"++ if not args.skip_download:+ # Get platform info and download URL+ platform_name, arch = get_platform_info()+ print(f"Building for {platform_name}-{arch}")++ url, binary_name = get_release_url(args.version, platform_name, arch)+ archive_name = url.split("/")[-1]+ archive_path = download_dir / archive_name++ # Get expected SHA256 from checksums.txt+ expected_sha256 = get_expected_sha256(args.version, archive_name)++ # Download the release archive (or verify cached)+ if not archive_path.exists():+ download_file(url, archive_path, expected_sha256)+ else:+ print(f"Using cached archive: {archive_path}")+ # Verify cached archive too+ print("Verifying cached archive SHA256...")+ verify_sha256(archive_path, expected_sha256)+ print("✓ Cached archive checksum verified")++ # Extract binary+ extract_binary(archive_path, binary_name, bin_dir)+ else:+ print("Skipping download (using existing binary)")++ # Verify binary exists+ expected_binary = "cua-driver.exe" if sys.platform == "win32" else "cua-driver"+ binary_path = bin_dir / expected_binary+ if not binary_path.exists():+ raise FileNotFoundError(+ f"Binary not found at {binary_path}. "+ f"Run without --skip-download or place binary manually."+ )++ print(f"Binary ready at: {binary_path}")+ print(f"Binary size: {binary_path.stat().st_size / 1024 / 1024:.2f} MB")++ # Build the wheel+ build_wheel(script_dir)+++if __name__ == "__main__":+ main()diff --git a/libs/cua-driver/python/pyproject.toml b/libs/cua-driver/python/pyproject.tomlnew file mode 100644index 0000000000..5695ddbe19--- /dev/null+++ b/libs/cua-driver/python/pyproject.toml@@ -0,0 +1,52 @@+[build-system]+requires = ["hatchling"]+build-backend = "hatchling.build"++[project]+name = "cua-driver"+version = "0.5.1"+description = "Python wrapper for cua-driver - cross-platform MCP server for computer-use automation"+readme = "README.md"+license = "MIT"+authors = [+ { name = "TryCua", email = "[email protected]" }+]+keywords = [+ "mcp",+ "computer-use",+ "automation",+ "accessibility",+ "screen-capture",+]+classifiers = [+ "Development Status :: 4 - Beta",+ "Intended Audience :: Developers",+ "License :: OSI Approved :: MIT License",+ "Operating System :: MacOS",+ "Operating System :: Microsoft :: Windows",+ "Operating System :: POSIX :: Linux",+ "Programming Language :: Python :: 3",+ "Programming Language :: Python :: 3.10",+ "Programming Language :: Python :: 3.11",+ "Programming Language :: Python :: 3.12",+ "Programming Language :: Python :: 3.13",+ "Topic :: Software Development :: Libraries :: Python Modules",+]+requires-python = ">=3.10"++dependencies = []++[project.urls]+Homepage = "https://github.com/trycua/cua"+Documentation = "https://github.com/trycua/cua/tree/main/libs/cua-driver"+Repository = "https://github.com/trycua/cua"+Issues = "https://github.com/trycua/cua/issues"++[project.scripts]+cua-driver = "cua_driver.__main__:main"++[tool.hatch.build.targets.wheel]+packages = ["src/cua_driver"]+artifacts = [+ "src/cua_driver/bin/*",+]diff --git a/libs/cua-driver/python/src/cua_driver/__init__.py b/libs/cua-driver/python/src/cua_driver/__init__.pynew file mode 100644index 0000000000..118b2bf79c--- /dev/null+++ b/libs/cua-driver/python/src/cua_driver/__init__.py@@ -0,0 +1,11 @@+"""Python wrapper for cua-driver - cross-platform MCP server.++This package provides a thin Python wrapper around the cua-driver Rust binary,+enabling pip-installable access to the MCP server for computer-use automation.+"""++__version__ = "0.5.1"++from .wrapper import run_cua_driver, get_binary_path++__all__ = ["run_cua_driver", "get_binary_path", "__version__"]diff --git a/libs/cua-driver/python/src/cua_driver/__main__.py b/libs/cua-driver/python/src/cua_driver/__main__.pynew file mode 100644index 0000000000..68a154a8c1--- /dev/null+++ b/libs/cua-driver/python/src/cua_driver/__main__.py@@ -0,0 +1,20 @@+"""CLI entry point for cua-driver Python wrapper.++This module is invoked when running:+ python -m cua_driver [args...]+or via the installed script:+ cua-driver [args...]+"""++import sys+from .wrapper import run_cua_driver+++def main() -> None:+ """Main entry point for the cua-driver CLI."""+ exit_code = run_cua_driver()+ sys.exit(exit_code)+++if __name__ == "__main__":+ main()diff --git a/libs/cua-driver/python/src/cua_driver/wrapper.py b/libs/cua-driver/python/src/cua_driver/wrapper.pynew file mode 100644index 0000000000..f91a202571--- /dev/null+++ b/libs/cua-driver/python/src/cua_driver/wrapper.py@@ -0,0 +1,71 @@+"""Subprocess wrapper for cua-driver binary with stdio passthrough."""++import os+import sys+import subprocess+from pathlib import Path+from typing import Optional+++def get_binary_path() -> Path:+ """Get the path to the bundled cua-driver binary.++ Returns:+ Path to the cua-driver executable.++ Raises:+ FileNotFoundError: If the binary is not found in the package.+ """+ # Binary is bundled in the package at: cua_driver/bin/cua-driver[.exe]+ package_dir = Path(__file__).parent++ if sys.platform == "win32":+ binary_name = "cua-driver.exe"+ else:+ binary_name = "cua-driver"++ binary_path = package_dir / "bin" / binary_name++ if not binary_path.exists():+ raise FileNotFoundError(+ f"cua-driver binary not found at {binary_path}. "+ f"This package may not have been built correctly for {sys.platform}."+ )++ # Ensure binary is executable on Unix+ if sys.platform != "win32":+ os.chmod(binary_path, 0o755)++ return binary_path+++def run_cua_driver(args: Optional[list[str]] = None) -> int:+ """Execute cua-driver binary with stdio passthrough.++ Args:+ args: Command-line arguments to pass to cua-driver.+ If None, uses sys.argv[1:].++ Returns:+ Exit code from the cua-driver process.+ """+ if args is None:+ args = sys.argv[1:]++ binary_path = get_binary_path()++ try:+ # Run with direct stdio inheritance - no buffering, no capturing+ result = subprocess.run(+ [str(binary_path), *args],+ stdin=sys.stdin,+ stdout=sys.stdout,+ stderr=sys.stderr,+ )+ return result.returncode+ except KeyboardInterrupt:+ # Standard SIGINT exit code+ return 130+ except Exception as e:+ print(f"Error executing cua-driver: {e}", file=sys.stderr)+ return 1diff --git a/libs/cua-driver/python/tests/test_wrapper.py b/libs/cua-driver/python/tests/test_wrapper.pynew file mode 100644index 0000000000..d0d8b7518b--- /dev/null+++ b/libs/cua-driver/python/tests/test_wrapper.py@@ -0,0 +1,85 @@+"""Tests for the cua-driver Python wrapper."""++import subprocess+import sys+from pathlib import Path+from unittest.mock import Mock, patch++import pytest+++def test_get_binary_path():+ """Test that get_binary_path returns a valid path."""+ from cua_driver.wrapper import get_binary_path++ # This will raise FileNotFoundError if binary doesn't exist+ # In CI, we need to build the package first for this to pass+ try:+ binary_path = get_binary_path()+ assert binary_path.exists()+ assert binary_path.name in ("cua-driver", "cua-driver.exe")+ except FileNotFoundError:+ # Expected in development without building+ pytest.skip("Binary not bundled yet (run build_wheel.py first)")+++def test_run_cua_driver_version(monkeypatch):+ """Test running cua-driver --version through the wrapper."""+ from cua_driver.wrapper import run_cua_driver, get_binary_path++ try:+ binary_path = get_binary_path()+ except FileNotFoundError:+ pytest.skip("Binary not bundled yet")++ # Run with --version+ exit_code = run_cua_driver(["--version"])+ assert exit_code == 0+++def test_wrapper_preserves_exit_code():+ """Test that the wrapper preserves the binary's exit code."""+ from cua_driver.wrapper import run_cua_driver, get_binary_path++ try:+ binary_path = get_binary_path()+ except FileNotFoundError:+ pytest.skip("Binary not bundled yet")++ # Invalid command should return non-zero+ exit_code = run_cua_driver(["--this-flag-does-not-exist"])+ assert exit_code != 0+++@patch("cua_driver.wrapper.subprocess.run")+@patch("cua_driver.wrapper.get_binary_path")+def test_subprocess_args(mock_get_binary, mock_run):+ """Test that subprocess is called with correct arguments."""+ from cua_driver.wrapper import run_cua_driver++ mock_binary = Path("/fake/path/cua-driver")+ mock_get_binary.return_value = mock_binary+ mock_run.return_value = Mock(returncode=0)++ run_cua_driver(["mcp", "--help"])++ mock_run.assert_called_once()+ call_args = mock_run.call_args+ assert call_args[0][0] == [str(mock_binary), "mcp", "--help"]+ assert call_args[1]["stdin"] == sys.stdin+ assert call_args[1]["stdout"] == sys.stdout+ assert call_args[1]["stderr"] == sys.stderr+++@patch("cua_driver.wrapper.subprocess.run")+@patch("cua_driver.wrapper.get_binary_path")+def test_keyboard_interrupt_handling(mock_get_binary, mock_run):+ """Test that KeyboardInterrupt returns exit code 130."""+ from cua_driver.wrapper import run_cua_driver++ mock_binary = Path("/fake/path/cua-driver")+ mock_get_binary.return_value = mock_binary+ mock_run.side_effect = KeyboardInterrupt()++ exit_code = run_cua_driver(["mcp"])+ assert exit_code == 130