👾 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
feat(cli): add read-only doctor --json permission diagnostics
ifuryst3cfe4b1e52ca
diff --git a/README.md b/README.mdindex db69823..45a5582 100644--- a/README.md+++ b/README.md@@ -155,6 +155,9 @@ open-computer-use call --calls-file examples/textedit-overlay-seq.json --sleep 0# Check permissions; onboarding only opens when something is missingopen-computer-use doctor+# macOS: query permission JSON without opening onboarding+ocu doctor --json+# Run local validation from a source checkoutmake smokeOPEN_COMPUTER_USE_STRESS_LOOPS=20 make stress@@ -185,6 +188,8 @@ The npm launcher itself currently requires Node.js 18 or newer. Its help alwaysadapter/kernel, and the native runtime are available. Once started, it reusesthe current Node executable instead of looking up another `node` on PATH.+`ocu doctor --json` (macOS only) returns `platform`, `accessibilityTrusted`, `screenCaptureGranted`, `allGranted`, and `missingPermissions`. Missing permissions still exit with code 0; hosts should check `allGranted` and query again after authorization. The snapshot uses existing system API/TCC diagnostics and does not prove an operation succeeded; some permission changes may still require a process restart.+## Cursor MotionCursor Motion is an open-source cursor motion system for macOS, based on public information shared by members of the Software.Inc team. You can download the app from the [Releases page](https://github.com/iFurySt/open-codex-computer-use/releases).diff --git a/README.zh-CN.md b/README.zh-CN.mdindex 0508228..d40193c 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -135,11 +135,16 @@ open-computer-use call --calls-file examples/textedit-overlay-seq.json --sleep 0# 检查权限;只有缺失时才会拉起引导,已全部授权则只打印状态并退出open-computer-use doctor+# macOS:只查询权限 JSON,不弹引导界面+ocu doctor --json+# 查看帮助open-computer-use -hocu -h```+`ocu doctor --json`(仅 macOS)返回 `platform`、`accessibilityTrusted`、`screenCaptureGranted`、`allGranted` 和 `missingPermissions`。缺权限仍返回退出码 0;宿主应检查 `allGranted`,并在用户授权后再次查询。状态复用现有系统 API/TCC 检测,不代表实际操作已经成功;某些权限变更仍可能需要重启进程。+## Cursor MotionCursor Motion 是一个面向 macOS 的开源光标运动系统,基于 Software.Inc 几位大佬的公开信息实现的开源版本,也可以到 [Releases 页面](https://github.com/iFurySt/open-codex-computer-use/releases) 下载 app 运行。diff --git a/apps/OpenComputerUse/Sources/OpenComputerUse/MacOSAppAgentProxy.swift b/apps/OpenComputerUse/Sources/OpenComputerUse/MacOSAppAgentProxy.swiftindex b79b96b..6e6060b 100644--- a/apps/OpenComputerUse/Sources/OpenComputerUse/MacOSAppAgentProxy.swift+++ b/apps/OpenComputerUse/Sources/OpenComputerUse/MacOSAppAgentProxy.swift@@ -389,14 +389,14 @@ private final class AppAgentConnection: @unchecked Sendable {}return CLIProxyResponse(stdout: "", stderr: "", exitCode: EXIT_SUCCESS)- case .doctor:+ case let .doctor(json):let permissions = PermissionDiagnostics.current()- if !permissions.missingPermissions.isEmpty {+ if !json && !permissions.missingPermissions.isEmpty {Task { @MainActor inPermissionOnboardingApp.present()}}- return CLIProxyResponse(stdout: permissions.summary + "\n", stderr: "", exitCode: EXIT_SUCCESS)+ return CLIProxyResponse(stdout: (try json ? permissions.jsonText() : permissions.summary) + "\n", stderr: "", exitCode: EXIT_SUCCESS)case .listApps:let service = ComputerUseService()diff --git a/apps/OpenComputerUse/Sources/OpenComputerUse/OpenComputerUseMain.swift b/apps/OpenComputerUse/Sources/OpenComputerUse/OpenComputerUseMain.swiftindex a323e02..60f0129 100644--- a/apps/OpenComputerUse/Sources/OpenComputerUse/OpenComputerUseMain.swift+++ b/apps/OpenComputerUse/Sources/OpenComputerUse/OpenComputerUseMain.swift@@ -48,10 +48,10 @@ enum OpenComputerUseMain {} else {try server.run()}- case .doctor:+ case let .doctor(json):let permissions = PermissionDiagnostics.current()- print(permissions.summary)- if !permissions.missingPermissions.isEmpty {+ print(try json ? permissions.jsonText() : permissions.summary)+ if !json && !permissions.missingPermissions.isEmpty {PermissionOnboardingApp.launch()}case .listApps:diff --git a/apps/OpenComputerUseLinux/main.go b/apps/OpenComputerUseLinux/main.goindex fdad2aa..25ef0c2 100644--- a/apps/OpenComputerUseLinux/main.go+++ b/apps/OpenComputerUseLinux/main.go@@ -1366,6 +1366,9 @@ func runCLI(args []string, stdout io.Writer) error {case "mcp":return runMCP(os.Stdin, stdout)case "doctor":+ if len(args) > 1 && args[1] == "--json" {+ return errors.New("doctor --json permission diagnostics are only supported on macOS")+ }fmt.Fprintln(stdout, "Linux runtime: AT-SPI2 and GDK run against the signed-in desktop user's accessibility session. When Codex starts without XDG_RUNTIME_DIR, DBUS_SESSION_BUS_ADDRESS, or display variables, open-computer-use tries to discover the same user's session from /run/user/<uid> and desktop processes.")return nilcase "list-apps":diff --git a/apps/OpenComputerUseLinux/main_test.go b/apps/OpenComputerUseLinux/main_test.goindex 4039d71..210d471 100644--- a/apps/OpenComputerUseLinux/main_test.go+++ b/apps/OpenComputerUseLinux/main_test.go@@ -434,3 +434,13 @@ func TestLinuxWindowPlacementSchemaAndUnsupportedAgentDisplay(t *testing.T) {t.Fatalf("agent_display result = %#v", result)}}++func TestDoctorJSONRejectsUnsupportedPermissionDiagnostics(t *testing.T) {+ var out bytes.Buffer+ if err := runCLI([]string{"doctor", "--json"}, &out); err == nil {+ t.Fatal("expected unsupported permission diagnostics error")+ }+ if out.Len() != 0 {+ t.Fatal("unsupported JSON mode must not emit text on stdout")+ }+}diff --git a/apps/OpenComputerUseWindows/main.go b/apps/OpenComputerUseWindows/main.goindex c2acb00..f5cdb2a 100644--- a/apps/OpenComputerUseWindows/main.go+++ b/apps/OpenComputerUseWindows/main.go@@ -1010,6 +1010,9 @@ func runCLI(args []string, stdout io.Writer) error {case "mcp":return runMCP(os.Stdin, stdout)case "doctor":+ if len(args) > 1 && args[1] == "--json" {+ return errors.New("doctor --json permission diagnostics are only supported on macOS")+ }fmt.Fprintln(stdout, "Windows runtime: UI Automation and Win32 window-message bridge are available when this process runs in the signed-in desktop session.")return nilcase "list-apps":diff --git a/apps/OpenComputerUseWindows/main_test.go b/apps/OpenComputerUseWindows/main_test.goindex 8600c61..909315f 100644--- a/apps/OpenComputerUseWindows/main_test.go+++ b/apps/OpenComputerUseWindows/main_test.go@@ -455,3 +455,13 @@ func TestWindowsWindowPlacementSchemaAndUnsupportedAgentDisplay(t *testing.T) {t.Fatalf("agent_display result = %#v", result)}}++func TestDoctorJSONRejectsUnsupportedPermissionDiagnostics(t *testing.T) {+ var out bytes.Buffer+ if err := runCLI([]string{"doctor", "--json"}, &out); err == nil {+ t.Fatal("expected unsupported permission diagnostics error")+ }+ if out.Len() != 0 {+ t.Fatal("unsupported JSON mode must not emit text on stdout")+ }+}diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.mdindex f3a7df0..4fef697 100644--- a/docs/ARCHITECTURE.md+++ b/docs/ARCHITECTURE.md@@ -175,3 +175,6 @@macOS screenshot 在每轮捕获读取用户 JSON 配置,优先级为 ENV > 文件 > 默认值。npm launcher 提供 `ocu config` 查看、set、reset 和 path;支持 PNG/JPG/WebP、JPEG 质量、最大长边/超限缩小策略、最小总像素数丢弃与 SCK 超时,保留 hardware capture 优先路径。app-agent 按请求转发解析后的配置路径并清除未提供的 image 环境,防止常驻值污染。见[中文配置说明](configuration.zh-CN.md)与[English](configuration.md)。截图像素丢弃门槛按 width×height 计算,低于(不含等于)门槛不返回 image,但保留 AX 和原因;配置省略截图后拒绝坐标输入。WebP 无损编码通过固定版本 libwebp 静态链接,随 app/npm 制品带上许可文本。+## 结构化权限查询++macOS `doctor --json` 在 CLI 和 app-agent proxy 路径复用 `PermissionDiagnostics`,只输出一份 JSON 快照,不打开 onboarding。字段为 `platform: "macos"`、`accessibilityTrusted`、`screenCaptureGranted`、`allGranted` 和 `missingPermissions`(`accessibility` / `screenRecording`)。缺权限仍退出 0,宿主应读取 `allGranted` 并重新查询授权变化。此状态延续系统 API/TCC 合并诊断语义,并非操作成功证明;Linux/Windows 明确拒绝该权限查询模式。普通 `doctor` 保留文本输出与权限引导。diff --git a/docs/histories/2026-10/20261010-2024-doctor-json-permissions.md b/docs/histories/2026-10/20261010-2024-doctor-json-permissions.mdnew file mode 100644index 0000000..749a504--- /dev/null+++ b/docs/histories/2026-10/20261010-2024-doctor-json-permissions.md@@ -0,0 +1,11 @@+# 结构化权限查询++用户要求为 OCU 增加 `--json` 权限状态并提交 PR。++- macOS `doctor --json` 输出权限 JSON,不打开引导,支持宿主轮询。+- CLI 和 app-agent proxy 共用 PermissionDiagnostics 序列化,普通 doctor 行为保持一致。+- 字段:platform、accessibilityTrusted、screenCaptureGranted、allGranted、missingPermissions。缺权限仍退出 0;状态沿用现有系统 API/TCC 诊断语义。+- Linux/Windows 明确拒绝不支持的权限 JSON 查询。+- 更新双语 README、架构说明、功能发布记录,补充参数、四种权限组合和代理路由测试。++验证:Swift 测试、Node contract 测试、Linux/Windows Go 测试、文档检查与 CLI JSON 手工查询(结果见 PR)。diff --git a/docs/releases/feature-release-notes.md b/docs/releases/feature-release-notes.mdindex 5dd76d5..4cc6485 100644--- a/docs/releases/feature-release-notes.md+++ b/docs/releases/feature-release-notes.md@@ -5,6 +5,7 @@| 日期 | 功能域 | 用户价值 | 变更摘要 || --- | --- | --- | --- || 2026-10-10 | macOS 截图配置 | 普通用户可用 `ocu config` 持久化截图偏好,无需维护 shell ENV。 | 新增用户 JSON、ENV 覆盖、PNG/JPG/WebP 格式、明确的超大缩小/丢弃开关、最小总像素数过滤、质量/SCK 超时;取消字节预算缩小,支持关闭长边上限,省略截图时说明原因,保留 #65 捕获路径与坐标映射。 |+| 2026-10-10 | 结构化权限查询 | 宿主可以读取和轮询 macOS 授权状态,无需解析文本或重复弹引导。 | 新增 `ocu doctor --json`,输出权限布尔值、`allGranted` 和缺失权限列表;普通 `doctor` 保留权限引导,Linux/Windows 明确返回不支持。 || 2026-10-10 | 1.0.0 正式发布 | 用户可通过 npm 或直接下载使用跨平台桌面自动化,并以持久 JavaScript 会话编排操作。 | 基于当前 main 发布 `1.0.0`:统一所有版本源,交付 macOS 后台键盘、遮挡/其他 Space 窗口读取及显式 agent display,包含 Linux 快捷键与 Windows 无效截图修复;Linux / Windows runtime 继续标为实验性。 || 2026-10-09 | Linux 按键 | Linux 上 `press_key` 的 Enter、Tab、Escape、方向键和 `ctrl+a` 等快捷键会送达正确的按键,Agent 可以提交表单、切换焦点和使用快捷键。 | Linux bridge 改用 `KeySynthType.SYM` 发送具名键 keysym,并以 `LOCKMODIFIERS` / `UNLOCKMODIFIERS` 保持修饰键;此前 keysym 被当作 keycode,Enter 会输入 `4`,修饰键不生效。 || 2026-10-09 | Windows 截图可靠性 | 极小、最小化、隐藏、cloaked 或离屏窗口不会再向模型返回不可用的 PNG;极端情况下仍可读取 accessibility tree,并明确限制依赖截图坐标的操作。 | Windows bridge 在截图前校验窗口状态、virtual screen 交集和最小尺寸,Go 层再次解码 PNG header 复核;无有效截图时省略 image block,coordinate click / drag fail closed,不做放大、补边或占位图。 |diff --git a/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/OpenComputerUseCLI.swift b/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/OpenComputerUseCLI.swiftindex 183b067..a64bd0e 100644--- a/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/OpenComputerUseCLI.swift+++ b/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/OpenComputerUseCLI.swift@@ -3,7 +3,7 @@ import Foundationpublic enum OpenComputerUseCLICommand: Equatable {case launchOnboardingcase mcp- case doctor+ case doctor(json: Bool = false)case listAppscase snapshot(app: String, textLimit: SnapshotTextLimit = .defaults, treeLimits: AccessibilityTreeLimits = .defaults)case call(OpenComputerUseCallInvocation)@@ -77,7 +77,10 @@ public func parseOpenComputerUseCLI(arguments: [String]) throws -> OpenComputerUcase "mcp":return try parseSimpleCommand(name: "mcp", arguments: Array(arguments.dropFirst()), result: .mcp)case "doctor":- return try parseSimpleCommand(name: "doctor", arguments: Array(arguments.dropFirst()), result: .doctor)+ if Array(arguments.dropFirst()) == ["--json"] {+ return .doctor(json: true)+ }+ return try parseSimpleCommand(name: "doctor", arguments: Array(arguments.dropFirst()), result: .doctor())case "list-apps":return try parseSimpleCommand(name: "list-apps", arguments: Array(arguments.dropFirst()), result: .listApps)case "call":@@ -133,10 +136,12 @@ public func openComputerUseHelpText(command: String? = nil) -> String {case "doctor":return """Usage:- open-computer-use doctor+ open-computer-use doctor [--json]Print the current Accessibility and Screen Recording permission state.If permissions are missing, this also launches the onboarding app.+ --json prints a permission snapshot without launching onboarding (macOS only).+ Read allGranted to determine readiness; missing permissions still exit successfully."""case "list-apps":return """diff --git a/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/Permissions.swift b/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/Permissions.swiftindex b1ca888..298bb9d 100644--- a/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/Permissions.swift+++ b/packages/OpenComputerUseKit/Sources/OpenComputerUseKit/Permissions.swift@@ -89,6 +89,19 @@ public struct PermissionDiagnostics: Sendable {"Permissions: accessibility=\(accessibilityTrusted ? "granted" : "missing"), screenRecording=\(screenCaptureGranted ? "granted" : "missing")"}+ /// A read-only snapshot for host integrations; does not request permissions.+ public func jsonText() throws -> String {+ let payload: [String: Any] = [+ "platform": "macos",+ "accessibilityTrusted": accessibilityTrusted,+ "screenCaptureGranted": screenCaptureGranted,+ "allGranted": allGranted,+ "missingPermissions": missingPermissions.map(\.rawValue),+ ]+ let data = try JSONSerialization.data(withJSONObject: payload, options: [.sortedKeys])+ return String(decoding: data, as: UTF8.self)+ }+public var missingPermissions: [SystemPermissionKind] {SystemPermissionKind.allCases.filter { !isGranted($0) }}diff --git a/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift b/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swiftindex 952acfa..8388001 100644--- a/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift+++ b/packages/OpenComputerUseKit/Tests/OpenComputerUseKitTests/OpenComputerUseKitTests.swift@@ -27,6 +27,33 @@ final class OpenComputerUseKitTests: XCTestCase {XCTAssertEqual(try parseOpenComputerUseCLI(arguments: ["--version"]), .version)}+ func testDoctorJSONContract() throws {+ XCTAssertEqual(try parseOpenComputerUseCLI(arguments: ["doctor"]), .doctor())+ XCTAssertEqual(try parseOpenComputerUseCLI(arguments: ["doctor", "--json"]), .doctor(json: true))+ XCTAssertThrowsError(try parseOpenComputerUseCLI(arguments: ["doctor", "--json", "--json"]))+ XCTAssertThrowsError(try parseOpenComputerUseCLI(arguments: ["doctor", "--unknown"]))+ XCTAssertTrue(shouldUseMacOSAppAgentProxy(+ command: .doctor(json: true), proxyDisabled: false,+ appBundleAvailable: true, runningFromLaunchServicesAppInstance: false+ ))+ for accessibility in [false, true] {+ for screenCapture in [false, true] {+ let diagnostics = PermissionDiagnostics(+ accessibilityTrusted: accessibility, screenCaptureGranted: screenCapture+ )+ let payload = try XCTUnwrap(JSONSerialization.jsonObject(+ with: Data(try diagnostics.jsonText().utf8)+ ) as? [String: Any])+ XCTAssertEqual(payload["platform"] as? String, "macos")+ XCTAssertEqual(payload["accessibilityTrusted"] as? Bool, accessibility)+ XCTAssertEqual(payload["screenCaptureGranted"] as? Bool, screenCapture)+ XCTAssertEqual(payload["allGranted"] as? Bool, accessibility && screenCapture)+ XCTAssertEqual(payload["missingPermissions"] as? [String],+ diagnostics.missingPermissions.map(\.rawValue))+ }+ }+ }+func testCLIRecognizesCommandSpecificHelp() throws {XCTAssertEqual(try parseOpenComputerUseCLI(arguments: ["help", "snapshot"]), .help(command: "snapshot"))XCTAssertEqual(try parseOpenComputerUseCLI(arguments: ["snapshot", "--help"]), .help(command: "snapshot"))@@ -346,7 +373,7 @@ final class OpenComputerUseKitTests: XCTestCase {func testMacOSAppAgentProxyDecisionRoutesAutomationCommandsThroughAppBundle() {for command in [OpenComputerUseCLICommand.mcp,- .doctor,+ .doctor(),.listApps,.snapshot(app: "TextEdit"),.call(.single(toolName: "list_apps", argumentsJSON: nil, argumentsFile: nil)),@@ -412,13 +439,13 @@ final class OpenComputerUseKitTests: XCTestCase {func testMacOSAppAgentProxyDecisionHonorsDisableAndMissingBundle() {XCTAssertFalse(shouldUseMacOSAppAgentProxy(- command: .doctor,+ command: .doctor(),proxyDisabled: true,appBundleAvailable: true,runningFromLaunchServicesAppInstance: false))XCTAssertFalse(shouldUseMacOSAppAgentProxy(- command: .doctor,+ command: .doctor(),proxyDisabled: false,appBundleAvailable: false,runningFromLaunchServicesAppInstance: false