The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(computer-use): doctor names the stale TCC row on the health_report path too
kshitijk4poordb1f3f4564eb
diff --git a/hermes_cli/subcommands/computer_use.py b/hermes_cli/subcommands/computer_use.pyindex 82c9472196a..f1e2709f512 100644--- a/hermes_cli/subcommands/computer_use.py+++ b/hermes_cli/subcommands/computer_use.py@@ -89,7 +89,7 @@ def _cu_doctor(args) -> None:def _cu_perms_status(args) -> None:import json as _json- from tools.computer_use.permissions import computer_use_status, stale_tcc_grant_hint+ from tools.computer_use.permissions import TCC_FIELDS, computer_use_status, stale_tcc_grant_hintst = computer_use_status()if bool(getattr(args, "json", False)):print(_json.dumps(st, indent=2, sort_keys=True))@@ -107,9 +107,8 @@ def _cu_perms_status(args) -> None:print(f" {glyph(st['screen_recording'])} Screen Recording")if not st["ready"]:print(" Grant: hermes computer-use permissions grant")- missing = [f for f in ("accessibility", "screen_recording") if st[f] is False]- if missing:- print(f" {stale_tcc_grant_hint(*missing)}")+ if hint := stale_tcc_grant_hint(*(f for f in TCC_FIELDS if st[f] is False)):+ print(f" {hint}")else: # no TCC model — readiness is driver healthprint(f" {glyph(st['ready'])} driver health (no permission toggles on {st['platform']})")for c in st["checks"]:diff --git a/tests/computer_use/test_doctor.py b/tests/computer_use/test_doctor.pyindex 5cf1b09f20f..ae95a94f39c 100644--- a/tests/computer_use/test_doctor.py+++ b/tests/computer_use/test_doctor.py@@ -442,15 +442,26 @@ class TestDoctorVersionIdentity:-def test_fallback_tcc_row_hint_names_the_stale_row_reset_for_that_service():- """The fallback ``tcc_*`` fail row must carry the stale-grant recovery for its own TCC service (Screen Recording- is the ``ScreenCapture`` row), because System Settings can show the toggle ON while the daemon is denied."""+def test_failed_tcc_row_from_health_report_names_the_stale_row_reset_for_that_service():+ """A failed ``tcc_*`` row from the driver's own health_report (0.22+, not only the 0.10 fallback probes) must+ carry the stale-grant recovery for its own TCC service, because System Settings can show the toggle ON while+ the daemon is denied (trycua/cua#3170)."""from tools.computer_use import doctor- ctx = {"perms": {"accessibility": True, "screen_recording": False}, "perm_err": None, "plat": "darwin"}- status, message, extra = doctor._tcc_row("screen_recording", "Screen Recording", True, ctx)-- assert status == "fail"- assert "tccutil reset ScreenCapture com.trycua.driver" in extra["hint"]- assert "reset Accessibility" not in extra["hint"]- assert extra["data"] == {"screen_recording": False}+ report = _ok_report()+ report["checks"] = [{"name": "tcc_screen_recording", "status": "fail", "message": "Screen Recording is not granted.",+ "hint": "Grant it in System Settings."},+ {"name": "tcc_accessibility", "status": "pass", "message": "granted"}]+ proc = _fake_proc_with_responses(+ {"jsonrpc": "2.0", "id": 1, "result": {}},+ {"jsonrpc": "2.0", "id": 2, "result": {"structuredContent": report}},+ )+ with patch("shutil.which", return_value="/fake/cua-driver"), patch("subprocess.Popen", return_value=proc), \+ patch("sys.stdout", new_callable=StringIO) as out:+ doctor.run_doctor(json_output=True)+ checks = {c["name"]: c for c in json.loads(out.getvalue())["checks"]}++ assert checks["tcc_screen_recording"]["hint"].startswith("Grant it in System Settings.")+ assert "tccutil reset ScreenCapture com.trycua.driver" in checks["tcc_screen_recording"]["hint"]+ assert "reset Accessibility" not in checks["tcc_screen_recording"]["hint"]+ assert "tccutil" not in checks["tcc_accessibility"].get("hint", "")diff --git a/tools/computer_use/cua_backend_daemon.py b/tools/computer_use/cua_backend_daemon.pyindex 3f9bab5deeb..8c90e9e27be 100644--- a/tools/computer_use/cua_backend_daemon.py+++ b/tools/computer_use/cua_backend_daemon.py@@ -17,12 +17,13 @@ from collections import dequefrom typing import Any, Dict, List, Optional, Tuplefrom tools.computer_use import cua_backend_driver as _driver+from tools.computer_use.permissions import CUA_DRIVER_BUNDLE_IDlogger = logging.getLogger("tools.computer_use.cua_backend")# The only bundle identity the private daemon may launch through, and the teams that sign official# releases. Exact matches only: a suffixed identifier or other team is an impostor.-_CUA_DRIVER_BUNDLE_ID = "com.trycua.driver"+_CUA_DRIVER_BUNDLE_ID = CUA_DRIVER_BUNDLE_ID_CUA_DRIVER_TEAM_IDS = ("4YEC26S9KF", "YCK386LBJ7")_QUIET_ERRORS = (OSError, subprocess.SubprocessError)diff --git a/tools/computer_use/doctor.py b/tools/computer_use/doctor.pyindex 62d322e730d..e653a1e17ff 100644--- a/tools/computer_use/doctor.py+++ b/tools/computer_use/doctor.py@@ -208,7 +208,7 @@ def _tcc_row(field: str, label: str, platform_bound: bool, ctx: Report) -> _Row:off_platform = platform_bound and ctx["plat"] != "darwin"return "skip", f"not applicable on {ctx['plat']}" if off_platform else f"{field} field absent from check_permissions", {}if not granted:- return "fail", f"{label} is not granted.", {"hint": f"{_TCC_HINT.format(label)} {stale_tcc_grant_hint(field)}", "data": {field: False}}+ return "fail", f"{label} is not granted.", {"hint": _TCC_HINT.format(label), "data": {field: False}}data = {field: True, **({"screen_recording_capturable": perms.get("screen_recording_capturable")} if field == "screen_recording" else {})}if data.get("screen_recording_capturable") is False: # the granted-but-not-capturable row wins over plain passreturn "fail", "Screen Recording granted but not capturable.", {"hint": (@@ -273,6 +273,19 @@ def _compose_fallback_report(binary: str, *, reason: str = "", timeout: float ="overall": _overall_from(checks), "checks": checks,"fallback": True, "fallback_reason": reason or "health_report unavailable"}+_TCC_CHECK_FIELDS = {"tcc_accessibility": "accessibility", "tcc_screen_recording": "screen_recording"}++def _apply_stale_tcc_guard(report: Report) -> Report:+ """Append the stale-row recovery to every failed ``tcc_*`` check. Applied at the report seam so the driver's+ own health_report rows (0.22+) get it too, not only the 0.10 fallback probes — the users hit by a stale row+ are on current drivers (trycua/cua#3170)."""+ checks = report.get("checks")+ for check in (c for c in (checks if isinstance(checks, list) else ()) if isinstance(c, dict)):+ field = _TCC_CHECK_FIELDS.get(check.get("name"))+ if field and check.get("status") == "fail":+ check["hint"] = f"{check.get('hint') or ''} {stale_tcc_grant_hint(field)}".strip()+ return report+def _apply_display_count_guard(report: Report) -> Report:"""Fail an 'ok' screen_capture_capability with ``display_count=0``: macOS ScreenCaptureKit reports 0 on headless/ asleep panels — TCC fine, health_report ok, yet every capture is 0x0. Turns a silent failure actionable; applied@@ -442,6 +455,7 @@ def run_doctor(driver_cmd: Optional[str] = None, *, include: Sequence[str] = (),print(f"cua-driver health_report failed: {e}", file=sys.stderr)return 2report = _apply_display_count_guard(report)+ report = _apply_stale_tcc_guard(report)report = _apply_stale_unit_guard(report)report = _apply_daemon_liveness_guard(report, binary)identity = _build_identity(binary, report)diff --git a/tools/computer_use/permissions.py b/tools/computer_use/permissions.pyindex 9a19cf0c9b9..b7d6b1a699f 100644--- a/tools/computer_use/permissions.py+++ b/tools/computer_use/permissions.py@@ -18,22 +18,23 @@ from hermes_cli._subprocess_compat import windows_hide_flags_RUNTIME_PLATFORMS = frozenset({"darwin", "win32", "linux"}) # mirrors the toolset platform_gate_BOOLS = ("accessibility", "screen_recording", "screen_recording_capturable")+CUA_DRIVER_BUNDLE_ID = "com.trycua.driver" # the only identity TCC rows and the private daemon are keyed to_TCC_SERVICES = {"accessibility": "Accessibility", "screen_recording": "ScreenCapture"} # status field -> tccutil service+TCC_FIELDS = tuple(_TCC_SERVICES)def stale_tcc_grant_hint(*missing: str) -> str:"""Recovery text for grants the daemon reports missing while System Settings shows the CuaDriver toggle ON.TCC keys each row to the app's code-signing requirement, so a row written for an earlier CuaDriver build canstop matching after a driver update: the toggle stays ON, the daemon is denied, and flipping the toggle does- not rewrite the requirement (trycua/cua#3170; the cua-driver >= 0.22 installer repairs this on update). Only a- reset + re-grant recovers it, so the hint names the exact rows for the *missing* status fields.+ not rewrite the requirement (trycua/cua#3170). Only a reset + re-grant recovers it, so the hint names the+ exact rows for the *missing* status fields."""- resets = " && ".join(f"tccutil reset {_TCC_SERVICES[f]} com.trycua.driver" for f in missing if f in _TCC_SERVICES)+ resets = " && ".join(f"tccutil reset {_TCC_SERVICES[f]} {CUA_DRIVER_BUNDLE_ID}" for f in missing if f in _TCC_SERVICES)if not resets:return ""return ("If System Settings already shows CuaDriver ON, the stored grant is stale (it no longer matches the installed "- f"driver's signature): run `{resets}`, then `hermes computer-use permissions grant`. "- "`hermes computer-use install --upgrade` moves to a driver whose installer repairs stale rows on update.")+ f"driver's signature): run `{resets}`, then `hermes computer-use permissions grant`.")def _child_env() -> Dict[str, str]:"""cua-driver child env (telemetry policy + provider secrets stripped); ``os.environ`` on import error.@@ -117,7 +118,7 @@ def request_permissions_grant(driver_cmd: Optional[str] = None) -> int:print("cua-driver: not installed. Run: hermes computer-use install")return 2print("Requesting Accessibility + Screen Recording for CuaDriver.\n"- "macOS will show a dialog attributed to CuaDriver (com.trycua.driver) — approve it, then return here.")+ f"macOS will show a dialog attributed to CuaDriver ({CUA_DRIVER_BUNDLE_ID}) — approve it, then return here.")try:return int(subprocess.run([binary, "permissions", "grant"], env=_child_env(), stdin=subprocess.DEVNULL).returncode)except KeyboardInterrupt: # pragma: no cover - interactivediff --git a/website/docs/user-guide/features/computer-use.md b/website/docs/user-guide/features/computer-use.mdindex 8d382de99af..b41c478361c 100644--- a/website/docs/user-guide/features/computer-use.md+++ b/website/docs/user-guide/features/computer-use.md@@ -623,9 +623,6 @@ tccutil reset ScreenCapture com.trycua.driverhermes computer-use permissions grant```-cua-driver 0.22+ installers repair this automatically on update, so-`hermes computer-use install --upgrade` prevents a recurrence.-**Element indices are stale** — SOM indices are only valid until thenext `capture`. Re-capture after any state-changing action. Thewrapper carries opaque `element_token`s for stale detection — you'll