From 9a6b1659fc48609ee7f95448d1fffcd2081465d0 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 12 Nov 2026 20:33:50 +0800 Subject: [PATCH] Report a sandboxed shell instead of a missing permission Inside Codex's workspace-write Seatbelt sandbox, AXIsProcessTrusted() reads false and the window list comes back empty even when the host app holds the Accessibility permission. On 2026-11-12 a Codex agent took that reading at face value and asked the user to enable a switch that was already on. status now reports `sandboxed` (sandbox_check on our own pid), Desktop refuses with "run outside the sandbox" before the permission check, and the skill tells the agent to escalate rather than ask for the permission. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- open_computer_use/axbridge.swift | 9 +++++++++ open_computer_use/desktop.py | 6 ++++++ skill/open-computer-use/SKILL.md | 11 ++++++++--- tests/test_cli.py | 2 +- 5 files changed, 25 insertions(+), 5 deletions(-) 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