字节笔记本
2026年7月5日
cua · 开源 Computer-Use Agent 基础设施,沙盒+SDK+驱动+基准
本文介绍 cua,一个开源的 Computer-Use Agent 基础设施项目。它把"AI 操作整台电脑"这件事拆成沙盒、SDK、驱动、基准测试四块基础设施,让你能给任何 AI agent 配上一台完整的 macOS / Linux / Windows 桌面,让它真的"看到屏幕、点击按钮、完成任务"。
项目简介
cua(读作 "coo-ah")是 trycua 团队开源的一套基础设施,目标是让 AI agent 拥有操作完整桌面的能力。截至目前,该项目在 GitHub 上已获得 19.4k stars,84 位贡献者,主要使用 HTML、Python、Rust、Swift、TypeScript 编写。
整套设施包含四个核心组件:
- Cua Drivers — 后台驱动 macOS / Windows / Linux 桌面,AI 点击、输入、验证都不抢你的鼠标焦点
- Cua Sandbox — 一套统一 API,管理任何 OS 或 runtime 的沙盒(VM 或容器)
- Cua Bench — 在 OSWorld、ScreenSpot、Windows Arena 等基准上评估 computer-use agent,可导出轨迹用于训练
- Lume — 基于 Apple Virtualization.Framework 的 macOS/Linux 虚拟化,Apple Silicon 上接近原生性能
无论你是想自己写 agent、给编程 agent 接一台电脑、还是要评测/训练模型,cua 都提供了对应层的工具。
核心特性
- 后台 computer-use — Driver 在后台驱动原生桌面应用,不抢鼠标、不抢焦点;同一个 CLI 和 MCP server 在 macOS 和 Windows 通用
- 任意 OS 沙盒 — 一套 Sandbox API 抽象掉底层差异,Linux 容器、Linux VM、macOS、Windows、Android、自带镜像(BYOI)统一接口
- 云或本地 — Linux / macOS / Windows / Android 沙盒可在云端(cua.ai)或本地(QEMU)启动;BYOI 镜像本地启动
- MCP 集成 — Claude Code、Cursor、Codex、OpenClaw 等客户端通过
cua-driver mcp一行接入 - 基准评测 — 内置 OSWorld、ScreenSpot、Windows Arena 等数据集,支持并行评测、轨迹导出
- Apple Silicon 优化 — Lume 用 Apple 自家 Virtualization.Framework 跑 macOS VM,接近原生速度
- MIT 协议 — 主仓库 MIT,第三方组件各自许可(Kasm/OmniParser 等)
技术栈
- Python — 主语言,所有 SDK、CLI、基准测试都是 Python 3.11+
- Rust — 核心驱动与虚拟化层
- Swift — macOS 端 Lume 与驱动
- TypeScript — 部分前端与工具链
- Apple Virtualization.Framework — Lume 的 macOS/Linux VM 后端
- QEMU — 本地沙盒的跨平台 VM 后端
安装指南
前置要求
- Python 3.11 或更高版本(用 Sandbox / Bench 时)
- macOS(用 Lume 时,需 Apple Silicon)
- Windows 10/11(用 Windows Driver 时)
- Linux(用 Linux Driver / Lume 容器时)
Cua Drivers(macOS / Linux)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.sh)"Cua Drivers(Windows,PowerShell)
irm https://raw.githubusercontent.com/trycua/cua/main/libs/cua-driver/scripts/install.ps1 | iexCua Sandbox(Python 包)
pip install cua
# 需 Python 3.11+Lume(macOS/Linux 虚拟化)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh)"Cua Bench
git clone https://github.com/trycua/cua && cd cua/cua-bench
uv tool install -e . && cb image create linux-docker快速开始
把 Driver 接入 Claude Code 作为 MCP
最常用的一行命令,把 cua-driver 注册为 Claude Code 的 MCP server,agent 立刻就能后台驱动桌面:
claude mcp add --transport stdio cua-driver -- cua-driver mcp用 Sandbox API 控制任意 OS
同一份代码,换一行就能切换 OS,API 完全一致:
from cua import Sandbox, Image
# 换成 .macos() / .windows() / .android() 即可切换沙盒类型
async with Sandbox.ephemeral(Image.linux()) as sb:
result = await sb.shell.run("echo hello")
screenshot = await sb.screenshot()
await sb.mouse.click(100, 200)
await sb.keyboard.type("Hello from Cua!")
await sb.mobile.gesture((100, 500), (100, 200)) # 多点触控手势拉起一台 macOS VM(Lume)
# 拉取并启动 macOS Sequoia 镜像
lume run macos-sequoia-vanilla:latest跑一次基准评测(Cua Bench)
cb run dataset datasets/cua-bench-basic --agent cua-agent --max-parallel 4使用示例
场景 1:让 Claude Code 后台操作你的 Mac
把 cua-driver 注册成 MCP 后,Claude Code 里就能调用 driver 工具,在后台点开应用、填表单、复制数据,而你的鼠标键盘完全不受影响——这正是"background computer-use"的核心价值。
场景 2:Windows Agent 跨客户端复用
同一套 cua-driver CLI 也跑在 Windows 上,可以接 Cursor、Codex、OpenClaw 或自定义客户端,驱动 Windows 原生桌面应用。
场景 3:用 Lume 给 CI 跑 macOS 测试
Lume 在 Apple Silicon 上以接近原生的速度跑 macOS VM,可以给 CI 流水线提供干净的 macOS 测试环境,无需物理 Mac 集群。
API 参考
Sandbox 核心方法
| 方法 | 说明 |
|---|---|
Sandbox.ephemeral(image) | 创建一次性沙盒(async context manager) |
sb.shell.run(cmd) | 在沙盒内执行 shell 命令 |
sb.screenshot() | 截屏,返回当前画面 |
sb.mouse.click(x, y) | 模拟鼠标点击 |
sb.keyboard.type(text) | 模拟键盘输入文本 |
sb.mobile.gesture(start, end) | 多点触控手势(Android) |
Image 选项
| 方法 | 说明 |
|---|---|
Image.linux() | Linux 沙盒(容器或 VM) |
Image.macos() | macOS 沙盒 |
Image.windows() | Windows 沙盒 |
Image.android() | Android 沙盒 |
Image.custom(path) | BYOI 自定义镜像(.qcow2 / .iso) |
包与功能矩阵
| Package | 说明 |
|---|---|
cua-driver | 后台 computer-use agent(macOS / Windows / Linux) |
cua-agent | computer-use 任务 AI agent 框架 |
cua-sandbox | 沙盒创建与控制 SDK |
cua-computer-server | 沙盒内 UI 交互与代码执行驱动 |
cua-bench | computer-use agent 的基准与 RL 环境 |
lume | Apple Silicon 上的 macOS/Linux VM 管理 |
lumier | Lume VM 的 Docker 兼容接口 |
注意事项
- Linux Driver 仍是 pre-release — 平台测试还在进行中,生产环境暂以 macOS / Windows 为准
- Android BYOI 在云端 —
cua.ai云端 Android 沙盒标记为"即将到来",目前本地 QEMU 可用 - OmniParser 许可证 — 可选的
cua-agent[omni]包含 ultralytics(AGPL-3.0),企业使用需注意 - Apple Silicon 限制 — Lume 的 macOS VM 仅在 Apple Silicon 上接近原生,Intel Mac 不支持
- 遥测可关闭 —
cuameta 包提供 telemetry opt-out,可一键禁用 - 不是官方产品 — Apple / macOS / Microsoft / Ubuntu 等都是各自公司商标,本项目与这些公司无附属或认可关系
项目链接
- GitHub 仓库:https://github.com/trycua/cua
- 官方文档:https://docs.cua.ai
- 官方站点:https://cua.ai
- 社区 Discord:cua.ai Discord(README 内链接)