diff --git a/README.md b/README.md index 5c4734a..e4a6703 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ open-computer-use/install.sh ```console $ open-computer-use status -{"accessibility": true, "frontmost": "Otty", "frontmost_pid": 2544, "locked": false} +{"accessibility": true, "frontmost": "Otty", "frontmost_pid": 2544, "locked": false, "sandboxed": false} ``` The loop is observe, act, read back: diff --git a/open_computer_use/axbridge.swift b/open_computer_use/axbridge.swift index 53a3a56..8cf7cc3 100644 --- a/open_computer_use/axbridge.swift +++ b/open_computer_use/axbridge.swift @@ -1462,9 +1462,18 @@ func freshPermissions() throws -> [String: Any] { return status } +/// libsystem_sandbox's check, which has no public header. With no operation it +/// answers whether the process runs under Seatbelt at all. +@_silgen_name("sandbox_check") +private func sandbox_check(_ pid: pid_t, _ operation: UnsafePointer?, _ type: Int32) -> Int32 + func statusJSON() -> [String: Any] { let front = frontmostApp() return [ + // A sandbox denies the accessibility and window-server lookups, so inside + // one `accessibility` reads false even when the host app has the permission + // (Codex's workspace-write shell, 2026-11-12). + "sandboxed": sandbox_check(getpid(), nil, 0) != 0, "accessibility": AXIsProcessTrusted(), "locked": screenLocked(), "frontmost": front?.localizedName ?? "", diff --git a/open_computer_use/desktop.py b/open_computer_use/desktop.py index 1aff860..f2ae384 100644 --- a/open_computer_use/desktop.py +++ b/open_computer_use/desktop.py @@ -206,6 +206,12 @@ class Desktop: def __init__(self, app, *, menus=True, limit=250, machine_wide=False): self.bridge = Bridge() status = self.bridge.call("status") + if status["sandboxed"]: + self.close() + raise RuntimeError( + "This shell runs inside a sandbox, which hides the accessibility tree whatever " + "System Settings says. Run open-computer-use outside it (in Codex, request escalation)." + ) if not status["accessibility"]: self.close() raise RuntimeError( diff --git a/skill/open-computer-use/SKILL.md b/skill/open-computer-use/SKILL.md index ae0157b..8493b2c 100644 --- a/skill/open-computer-use/SKILL.md +++ b/skill/open-computer-use/SKILL.md @@ -26,9 +26,14 @@ another app the whole time. open-computer-use status ``` -`accessibility: false` means the app running this shell lacks the -Accessibility permission: tell the user which System Settings switch to turn on -and stop; never trigger the prompt yourself. `locked: true` means the screen is +`sandboxed: true` means this shell runs inside a sandbox, which hides the +accessibility tree and makes `accessibility` read false whatever System Settings +says: run every `open-computer-use` command outside it (in Codex, request +escalation for it) and check `status` again; never ask the user for a permission +because of a sandboxed reading. Outside a sandbox, `accessibility: false` means +the app running this shell lacks the Accessibility permission: tell the user +which System Settings switch to turn on and stop; never trigger the prompt +yourself. `locked: true` means the screen is locked and every table comes back empty: stop. The target app must be running. Start one without bringing it forward with diff --git a/tests/test_cli.py b/tests/test_cli.py index 891498b..c108316 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -53,7 +53,7 @@ class MachineWideContracts(unittest.TestCase): def desktop(self, **options): bridge = Mock() bridge.call.side_effect = lambda method, **_: ( - {"accessibility": True, "locked": False} if method == "status" + {"sandboxed": False, "accessibility": True, "locked": False} if method == "status" else {"disposition": disposition("delivered_unverified")}) with patch("open_computer_use.desktop.Bridge", return_value=bridge): return Desktop("System Settings", **options), bridge