Open Computer Use 开发者指南:源码构建、smoke 测试与 agent 冒烟验证完整流程
【免费下载链接】open-codex-computer-use👾 Open Computer Use – Open-Source Alternative to Codex Computer Use项目地址: https://gitcode.com/gh_mirrors/op/open-codex-computer-use
Open Computer Use 是一个把 Computer Use 能力封装成 MCP 服务的开源项目(Codex Computer Use 的开源替代版),支持 macOS、Linux 与 Windows。本文面向新手开发者,带你走通三条核心验证链路:源码构建、smoke 测试、agent 冒烟验证,并附压力测试与推送前检查清单。
1. 环境准备:构建 Computer Use 源码的前置条件
| 工具 | 用途 | 最低版本 |
|---|---|---|
| Swift + Xcode CLI | 编译 macOS 运行时与测试套件 | 随 Xcode 提供 |
| Node.js | 运行 agent 冒烟验证脚本 | 18+ |
| make | 一键调度构建/测试命令 | 系统自带 |
⚠️ macOS 运行时要求 macOS 14.0 或更高版本;首次使用需授予「辅助功能」与「屏幕录制」权限(可用
open-computer-use doctor检查)。
获取源码:
git clone https://gitcode.com/gh_mirrors/op/open-codex-computer-use cd open-codex-computer-use2. 源码构建:make build 一键编译
所有命令都集中在根目录的 Makefile 里,常用入口如下:
make build # swift build,产出 .build/debug 下的可执行文件 make test # swift test + Node REPL 单元测试swift build会编译出 4 个关键产物(定义在 Package.swift 中):
- OpenComputerUse:MCP 服务主程序,提供 9 个 Computer Use 工具(
list_apps、click、type_text等) - OpenComputerUseFixture:冒烟测试用的「靶场」应用,内置计数器按钮、文本框、按键捕获区、滚动区与拖拽区
- OpenComputerUseSmokeSuite:端到端 smoke 测试执行器
- OpenComputerUseKit:底层能力库(可访问性快照、输入模拟、MCP 服务等)
构建成功后,可执行文件位于.build/debug/,可用open-computer-use capabilities或ocu capabilities --json查看运行时能力。
3. smoke 测试:make smoke 全流程冒烟验证
smoke 测试是本项目最核心的质量门禁,入口是 scripts/run-tool-smoke-tests.sh,它会先swift build,然后跑两轮OpenComputerUseSmokeSuite:
第一轮:完整工具链冒烟(见 OpenComputerUseSmokeSuite/main.swift)
- 启动
OpenComputerUseFixture靶场应用(支持 headless 模式) - 通过 JSON-RPC 启动 MCP 服务,断言工具数量恰好为 9
- 依次执行并逐一断言:
list_apps→get_app_state→ 按元素索引点击(计数器 +1)→ 按坐标点击(计数器 +2)→ 窗口Raise次级操作 →set_value写文本 →type_text追加文本 →press_key捕获 Return →scroll滚动 →drag拖拽
第二轮:光标 idle 冒烟(--cursor-idle-only)
开启视觉光标(OPEN_COMPUTER_USE_VISUAL_CURSOR=1)并写入观察文件,验证空闲光标「锚点稳定 + 微小旋转晃动」的官方对齐行为,防止视觉光标在无人操作时乱漂。
make smoke想加大力度就做压力测试:循环执行 N 轮完整冒烟,每轮含 10 个 fixture 操作,并输出 JSON 汇总(见 scripts/run-tool-stress-tests.sh):
OPEN_COMPUTER_USE_STRESS_LOOPS=20 make stress4. agent 冒烟验证:让真实 AI Agent 执行 Computer Use 任务
这是项目特色:不只看「工具返回对不对」,而是让真实 Agent(Claude / Codex / Hermes)通过 MCP 完整跑一遍 Computer Use 工作流。脚本是 scripts/run-agent-smoke-tests.mjs,三种场景由浅入深:
| 场景 | 参数 | Agent 需要做的事 |
|---|---|---|
| 列表应用 | list-apps | 只调一次list_apps |
| 基础 fixture | fixture | 读状态 +set_value+ 点击按钮 |
| 完整 fixture | fixture-full | 额外完成type_text、press_key、次级操作、scroll、drag共 8 类操作 |
验证是「双重确认」:既要求 Agent 回复约定的OPEN_CU_AGENT_OK,又独立复查 fixture 的真实状态(文本值精确匹配、计数器恰好为 1、滚动偏移与拖拽状态都已变化),杜绝 Agent「嘴上说完成、实际没生效」。
# 最常用:claude + codex 双 Agent 跑 list-apps make agent-smoke # 指定更完整的场景 make agent-smoke SCENARIO=fixture-full # 直接调脚本可换 Agent、换命令 node ./scripts/run-agent-smoke-tests.mjs --scenario=fixture --agents=claude,codex --command=open-computer-useHermes 需要额外指定 provider/model,参考 README.md 中的make agent-smoke AGENTS=hermes示例。
5. 推送前检查清单:make ci 与文档门禁
按 CONTRIBUTING.md 的要求,发起 Pull Request 前请跑完:
make check-docs # 文档检查 make check-repo # 文档 + 仓库卫生检查 make ci # 完整 CI:文档、脚本语法、Node 测试、Linux/Go 测试等make ci对应 scripts/ci.sh,覆盖文档校验、全部 shell/Node 脚本语法检查、Node REPL 单测、Linux runtime 单测以及 Windows/Linux 的 Go 测试,与 CI 流水线(见 docs/CICD.md)保持一致。
6. 速查表:开发者指南一张图
| 目标 | 命令 | 关键文件 |
|---|---|---|
| 源码构建 | make build | Makefile |
| 单元测试 | make test | Package.swift |
| smoke 测试 | make smoke | scripts/run-tool-smoke-tests.sh |
| 压力测试 | make stress | scripts/run-tool-stress-tests.sh |
| agent 冒烟验证 | make agent-smoke | scripts/run-agent-smoke-tests.mjs |
| 推送前检查 | make ci | scripts/ci.sh |
🎯 推荐的新手验证顺序:make build→make test→make smoke→make agent-smoke→make ci。走完这条链路,你就完整掌握了 Open Computer Use 从源码到上线的全套验证方法。
【免费下载链接】open-codex-computer-use👾 Open Computer Use – Open-Source Alternative to Codex Computer Use项目地址: https://gitcode.com/gh_mirrors/op/open-codex-computer-use
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考