👾 Open Computer Use – Open-Source Alternative to Codex Computer Use
Swift accessibilityai-agentai-agentsclaude-codecodexcodex-computer-usecomputer-usecomputer-use-agentcross-platformcuadesktop-automationgemini-cligui-automationmacosmcpmodel-context-protocolopen-computer-useopen-computer-use-mcpopenai-codexopencode
[2026-05-03 17:31] | Task: 修复 macOS 终端权限归属
Execution Context
- Agent ID:
Codex - Base Model:
GPT-5 - Runtime:
local macOS workspace
User Query
open-computer-use doctor能打开权限页面,但从终端执行时权限似乎要求的是 iTerm/Terminal,而不是Open Computer Use.app;需要保证 iTerm 没有 Accessibility / Screen Recording 权限时,只给 Open Computer Use 授权也能工作。
Changes Overview
Scope: apps/OpenComputerUse, packages/OpenComputerUseKit, docs
Key Actions:
- [App agent proxy]: 新增隐藏 app-agent 启动模式;终端 CLI 对
mcp、doctor、call、snapshot和list-apps通过 Unix domain socket 转发到 LaunchServices 启动的.app进程。 - [Onboarding reuse]: 将权限 onboarding 拆出可复用的
present()路径,让 doctor 可以在 app agent 已运行的 NSApplication 内显示授权窗口,而不是在终端子进程内直接跑 UI。 - [Decision tests]: 将 app-agent 代理选择规则下沉为 Kit 内纯函数,并补单测覆盖 automation 命令代理、非 automation 命令本地执行、LaunchServices 打开 app 不递归代理、禁用开关和缺少 bundle fallback。
- [Launch mode guard]: 对无参数启动区分 LaunchServices 打开的
.app和终端直接执行的 bundle executable,避免双击 app 时留下多余后台 agent,同时让终端入口仍走 app 身份代理。 - [Socket permissions]: app-agent Unix socket 创建后收紧为当前用户读写,维持本地-only 权限边界。
- [Permission relaunch]: app-agent 内完成授权后仍会终止当前 app 进程,确保下一次命令用重新启动后的授权进程执行 ScreenCaptureKit / AX 路径。
- [Permission wording]: 更新权限错误和文档口径,明确 macOS 授权目标是
Open Computer Use.app,不是宿主终端。 - [Swift 6.2 build fix]: 适配 Swift 6.2 并发检查,将 cursor reference
NSImage静态缓存显式标记为nonisolated(unsafe),保持当前 AppKit 主线程绘制路径可编译。
Design Intent (Why)
macOS TCC 对 Accessibility 和 Screen Recording 的责任归属取决于真正调用系统 API 的进程。终端直接启动 native runtime 时,系统可能要求 iTerm/Terminal 获得权限;把真实 automation 放到通过 LaunchServices 启动的 app bundle 进程内,可以让用户只授权 Open Computer Use.app,终端负责 stdio/命令代理。
Files Modified
apps/OpenComputerUse/Sources/OpenComputerUse/MacOSAppAgentProxy.swiftapps/OpenComputerUse/Sources/OpenComputerUse/OpenComputerUseMain.swiftapps/OpenComputerUse/Sources/OpenComputerUse/PermissionOnboardingApp.swiftpackages/OpenComputerUseKit/Sources/OpenComputerUseKit/OpenComputerUseCLI.swiftpackages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swiftpackages/OpenComputerUseKit/Sources/OpenComputerUseKit/AccessibilitySnapshot.swiftpackages/OpenComputerUseKit/Sources/OpenComputerUseKit/SoftwareCursorGlyphRenderer.swiftdocs/ARCHITECTURE.mddocs/SECURITY.mddocs/RELIABILITY.md
Verification
- Passed:
git diff --check - Passed:
./scripts/check-docs.sh - Passed:
xcrun swiftc -parse apps/OpenComputerUse/Sources/OpenComputerUse/MacOSAppAgentProxy.swift - Passed:
xcrun swiftc -parse packages/OpenComputerUseKit/Sources/OpenComputerUseKit/OpenComputerUseCLI.swift - Passed:
xcrun swiftc -parse packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift - Passed:
PATH="$HOME/.swiftly/bin:$PATH" swift build --product OpenComputerUsewith Swift6.2.4. - Passed:
PATH="$HOME/.swiftly/bin:$PATH" ./scripts/build-open-computer-use-app.sh debug --arch native. - Passed:
.build/arm64-apple-macosx/debug/OpenComputerUse doctorreturned missing permission status while launchingdist/Open Computer Use (Dev).app/Contents/MacOS/OpenComputerUse __open-computer-use-app-agent ..., confirming the terminal command hands off to the app bundle process. - Passed: the app-agent socket was created as
srw-------, current-user read/write only. - Passed: after granting the dev app both macOS permissions,
OpenComputerUse doctorreportedaccessibility=granted, screenRecording=granted. - Passed:
OpenComputerUse call get_app_state --args '{"app":"Finder"}'returnedisError=falsewith bothtextandimagecontent while iTerm did not hold the permissions. - Passed: Codex MCP integration via
codex execwith the bundled officialcomputer-useplugin disabled calledserver="open-computer-use"forlist_appsandget_app_state. - Passed: Codex-driven action smoke covered
click,scroll,set_value,press_key,drag, andtype_text; Finder, Calendar, and the local fixture succeeded, while TextEditclickexposed an existing window-bounds edge case but TextEdit typing still succeeded. - Blocked locally:
PATH="$HOME/.swiftly/bin:$PATH" swift testcannot importXCTestfrom the Swift.org toolchain in this CLT-only environment.