open-codex-computer-use icon indicating copy to clipboard operation
open-codex-computer-use copied to clipboard

Locked Use fails when Karabiner-Elements is running (IOHIDManagerOpen returns kIOReturnExclusiveAccess)

Open AbdullahPesteli opened this issue 1 month ago • 2 comments

Summary

Locked Use fails with Locked Use could not observe a protected GUI session becoming unlocked whenever Karabiner-Elements is running. Guardian logs Hardware input activity monitor unavailable and aborts the unlock. With Karabiner stopped, the same test passes on the same machine.

Environment

  • macOS 26.4.1 (arm64)
  • Open Computer Use 1.1.2 (npm), Locked Use installed, all four permissions granted, clientApproved=true
  • Karabiner-Elements 16.3.0 (Karabiner-Core-Service running, DriverKit virtual keyboard)

Steps

  1. ocu locked-use enable; grant Accessibility, Screen Recording and Input Monitoring to OCU and OCU Guardian.
  2. Keep Karabiner-Elements running (it seizes the built-in keyboard, a Bluetooth Magic Keyboard and the TouchBar device).
  3. Lock the Mac and start a Locked Use turn.

Result

  • Broker reaches phase=preparing, then Guardian exits. Guardian log (~/Library/Logs/OpenComputerUse/LockedUse/*.jsonl): {"event":"error","message":"message(\"Hardware input activity monitor unavailable\")"}.
  • Client sees Locked Use could not observe a protected GUI session becoming unlocked.

Cause (from source, PhysicalInputMonitor.start())

The monitor calls IOHIDManagerOpen once for all matched keyboards/pointers and treats any non-success return as fatal. With Karabiner running, that call returns 0xe00002c5 (kIOReturnExclusiveAccess).

Same matching dictionary as Guardian, probed device by device:

Karabiner IOHIDManagerOpen per-device IOHIDDeviceOpen
stopped 0x0 13 / 13 open
running 0xe00002c5 10 / 15 open; denied: Magic Keyboard (2 interfaces), built-in keyboard/trackpad (2), TouchBarUserDevice (1)

Karabiner's own virtual keyboard is among the devices that do open, and physical key presses are re-emitted through it.

A/B evidence (same mode 755, fresh broker, displays kept awake with caffeinate -u -d)

  • Karabiner stopped: get_app_state, click, type_text and save in TextEdit all succeeded while locked; file contained the typed text. Broker phases: preparing, authorizing, permitIssued, unlocking, active, relocking, idle.
  • Karabiner running: fails every time (3 runs) with the error above.

Suggestion

Do not abort when only some devices refuse to open. For example, open devices individually and continue if at least one input source (including the virtual keyboard) is observable, or fall back to the CG event tap when the HID manager reports kIOReturnExclusiveAccess. At minimum, log which device was refused and why, and document the Karabiner conflict in docs/locked-use.en.md.

Unverified

I have not tested whether Guardian would still detect physical activity if it simply skipped the seized devices. That is the part I would like maintainers to confirm.

Side findings (separate small issues, mentioned for context)

  • When /Library/Application Support is mode 0777 (common on machines with some installers), ocu locked-use enable fails with untrusted (1) (trustedTree requires mode & 0o022 == 0), and a later chmod back to 0777 makes the broker log installationPolicyInvalidated. That flag is only cleared by restarting the broker daemon.
  • If displays are asleep while locked, CGGetActiveDisplayList returns 0 and Guardian aborts with an active-display-count error. caffeinate -u works around it.

AbdullahPesteli avatar Nov 01 '26 12:11 AbdullahPesteli

Thanks for the precise diagnosis. #143 fixes this: the Guardian input monitor now opens each keyboard, pointer and consumer-control device on its own and skips a device that another app holds with kIOReturnExclusiveAccess, instead of failing the whole open. It still requires at least one observable device in each category, so Karabiner's virtual keyboard has to be visible for a turn to start.

#143 merged on 2026-11-07, just after v1.1.4 was tagged, so it isn't in a release yet. I'll post here when it ships. A retest with Karabiner running, keyboard and pointer both, is what would let us close this.

The asleep-display side finding is handled by #187, which is also unreleased.

hyprcat avatar Nov 19 '26 09:11 hyprcat

v1.1.5 is now available and includes #143 (input monitoring when Karabiner holds devices exclusively) and #187 (asleep-display handling).

Please update and retest with Karabiner running:

  • Can Locked Use prepare and start successfully?
  • Do keyboard and mouse/trackpad activity each stop the task and return control as expected?
  • If possible, also check Secure Input, device disconnection, and a Karabiner restart.

Please include your macOS, Karabiner, and OCU versions with the results. We are keeping this issue open pending confirmation; our local checks did not cover the complete Karabiner/Secure Input setup.

iFurySt avatar Nov 19 '26 14:11 iFurySt