<br>
<a href="https://trendshift.io/repositories/13685" target="_blank"><img src="https://trendshift.io/api/badge/repositories/113685" alt="trycua%2Fcua | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
Cua ("koo-ah") 是一个开源框架,用于计算机使用代理(Computer-Use Agents)——使AI系统能够通过视觉理解和动作执行自主操作计算机。它被用于研究、评估以及桌面、浏览器和移动自动化代理的生产部署。
计算机使用代理(CUAs)是能够通过视觉理解和动作执行自主与计算机界面交互的AI系统。与依赖脆弱选择器或API的传统自动化工具不同,CUAs使用视觉语言模型来感知屏幕内容并推理界面交互,使其能够适应UI变化并处理跨应用的复杂多步骤工作流。
<div align="center"> <video src="https://github.com/user-attachments/assets/c619b4ea-bb8e-4382-860e-f3757e36af20" width="600" controls></video> </div>使用 计算机SDK,你可以:
使用 代理SDK,你可以:
ComputerAgent(model="openai/computer-use-preview"))openai/,openrouter/,ollama/,huggingface-local/,mlx/,等)使用API或本地推理代理<br /> 用于自动化的AI代理框架
</td> <td width="25%" align="center" valign="top">计算机<br /> 控制Cua环境的TypeScript/Python SDK
</td> <td width="25%" align="center" valign="top">MCP服务器<br /> 用于使用Cua代理和计算机的MCP服务器
</td> <td width="25%" align="center" valign="top">计算机服务器<br /> 运行于Cua环境中的服务器组件
</td> </tr> </table> <table> <tr> <td width="25%" align="center" valign="top">Lume<br /> macOS虚拟机管理
</td> <td width="25%" align="center" valign="top">Lumier<br /> macOS/Linux虚拟机的Docker接口
</td> <td width="25%" align="center" valign="top">SOM<br /> 代理的Mark集合库
</td> <td width="25%" align="center" valign="top">核心<br /> Cua的核心实用程序
</td> </tr> </table>安装代理SDK:
pip install cua-agent[all]
使用 模型配置字符串 和 计算机实例 初始化一个计算机代理:
from agent import ComputerAgent
# ComputerAgent 可以与使用 Computer SDK 初始化的任何计算机一起工作
agent = ComputerAgent(
model="anthropic/claude-sonnet-4-5-20250929",
tools=[computer],
max_trajectory_budget=5.0
)
messages = [{"role": "user", "content": "截屏并告诉我你看到了什么"}]
async for result in agent.run(messages):
for item in result["output"]:
if item["type"] == "message":
print(item["content"][0]["text"])
Cua 使用 OpenAI 代理响应格式。
<details> <summary>示例</summary>{
"output": [
{
"role": "user",
"content": "去 GitHub 上找 trycua"
},
{
"summary": [
{
"text": "在 Firefox 中搜索 Trycua GitHub",
"type": "summary_text"
}
],
"type": "reasoning"
},
{
"action": {
"text": "Trycua GitHub",
"type": "type"
},
"call_id": "call_QI6OsYkXxl6Ww1KvyJc4LKKq",
"status": "completed",
"type": "computer_call"
},
{
"type": "computer_call_output",
"call_id": "call_QI6OsYkXxl6Ww1KvyJc4LKKq",
"output": {
"type": "input_image",
"image_url": "data:image/png;base64,..."
}
},
{
"type": "message",
"role": "assistant",
"content": [
{
"text": "成功!已打开 Trycua GitHub 页面。",
"type": "output_text"
}
]
}
],
"usage": {
"prompt_tokens": 150,
"completion_tokens": 75,
"total_tokens": 225,
"response_cost": 0.01
}
}
</details>
这些是 ComputerAgent(model="...") 的有效模型配置:
| 配置 | 描述 |
|---|---|
{computer-use-model} | 执行所有计算机使用任务的单一模型 |
{grounding-model}+{any-vlm-with-tools} | 组合 使用 VLM 进行描述和定位 LLM 进行元素检测 |
moondream3+{any-llm-with-tools} | 组合 使用 Moondream3 进行描述和UI元素检测 |
human/human | 代替模型的 人机循环 |
下表显示了每个模型支持的能力:
| 模型 | 计算机使用 | 定位 | 工具 | 视觉语言 |
|---|---|---|---|---|
| Claude Sonnet/Haiku | 🖥️ | 🎯 | 🛠️ | 👁️ |
| OpenAI CU Preview | 🖥️ | 🎯 | 👁️ | |
| Qwen3 VL | 🖥️ | 🎯 | 🛠️ | 👁️ |
| GLM-V | 🖥️ | 🎯 | 🛠️ | 👁️ |
| Gemini CU Preview | 🖥️ | 🎯 | 👁️ | |
| InternVL | 🖥️ | 🎯 | 🛠️ | 👁️ |
| UI-TARS | 🖥️ | 🎯 | 🛠️ | 👁️ |
| UI-TARS-2 | 🖥️ | 🎯 | 🛠️ | 👁️ |
| OpenCUA | 🎯 | |||
| GTA | 🎯 | |||
| Holo | 🎯 | |||
| Moondream | 🎯 | |||
| OmniParser | 🎯 |
图例:
组合示例:
更多组合示例,请参阅我们的 组合文档。
# 使用OpenAI的GPT-5进行规划,结合专门的定位
agent = ComputerAgent(model="huggingface-local/HelloKKMe/GTA1-7B+openai/gpt-5")
# 通过OmniParser进行组合
agent = ComputerAgent(model="omniparser+openai/gpt-4o")
# 结合最先进的定位和强大的推理
agent = ComputerAgent(model="huggingface-local/HelloKKMe/GTA1-7B+anthropic/claude-sonnet-4-5-20250929")
# 结合两种不同的视觉模型以增强功能
agent = ComputerAgent(model="huggingface-local/ByteDance-Seed/UI-TARS-1.5-7B+openai/gpt-4o")
# 使用内置的Moondream3定位与任何规划模式。
agent = ComputerAgent(model="moondream3+openai/gpt-4o")
| 模型 | 模型ID |
|---|---|
| Claude Sonnet/Haiku | anthropic/claude-sonnet-4-5, anthropic/claude-haiku-4-5 |
| OpenAI CU Preview | openai/computer-use-preview |
| GLM-V | openrouter/z-ai/glm-4.5v, huggingface-local/zai-org/GLM-4.5V |
| Qwen3 VL | openrouter/qwen/qwen3-vl-235b-a22b-instruct |
| Gemini CU Preview | gemini-2.5-computer-use-preview |
| InternVL | huggingface-local/OpenGVLab/InternVL3_5-{1B,2B,4B,8B,...} |
| UI-TARS | huggingface-local/ByteDance-Seed/UI-TARS-1.5-7B |
| UI-TARS-2 | cua/bytedance/ui-tars-2 |
| OpenCUA | huggingface-local/xlangai/OpenCUA-{7B,32B} |
| GTA | huggingface-local/HelloKKMe/GTA1-{7B,32B,72B} |
| Holo | huggingface-local/Hcompany/Holo1.5-{3B,7B,72B} |
| Moondream | moondream3 |
| OmniParser | omniparser |
了解更多,请参阅 代理SDK文档。
安装计算机SDK:
pip install cua-computer
初始化一台计算机:
from computer import Computer
computer = Computer(
os_type="linux", # 或 "macos", "windows"
provider_type="cloud", # 或 "lume", "docker", "windows_sandbox"
name="your-sandbox-name",
api_key="your-api-key" # 仅适用于云
# 或 use_host_computer_server=True 用于主机桌面
)
try:
await computer.run()
# 截屏
screenshot = await computer.interface.screenshot()
# 点击并输入文本
await computer.interface.left_click(100, 100)
await computer.interface.type_text("你好!")
finally:
await computer.close()
了解更多,请参阅 计算机SDK文档。
安装MCP服务器:
pip install cua-mcp-server
了解更多,请参阅 MCP服务器文档。
安装计算机服务器:
pip install cua-computer-server
python -m computer_server
了解更多,请参阅 计算机服务器文档。
安装Lume:
curl -fsSL https://raw.githubusercontent.com/trycua/cua/main/libs/lume/scripts/install.sh | bash
了解更多,请参阅 Lume文档。
安装Lumier:
docker pull trycua/lumier:latest
了解更多,请参阅 Lumier文档。
安装SOM:
pip install cua-som
了解更多,请参阅 SOM文档。