The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): defer interactive CUA installs on Windows
Royalaid0c23bf19af44
diff --git a/hermes_cli/tools_config.py b/hermes_cli/tools_config.pyindex d37d58f1e16..b0587504d19 100644--- a/hermes_cli/tools_config.py+++ b/hermes_cli/tools_config.py@@ -1005,7 +1005,9 @@ def install_cua_driver(``_CUA_INSTALLER_TIMEOUT`` and install.ps1's concurrency lock can adda further ~600s wait on Windows). ``hermes computer-use install--upgrade`` leaves it False — an explicit upgrade request should still- reinstall when the check is indeterminate.+ reinstall when the check is indeterminate. On Windows this flag also+ prevents every installer run, because install.ps1 may require console or+ UAC consent; automatic updates instead point at the explicit command.``show_installer_progress`` controls the installer's own progress line.``hermes update`` already prints a contextual line before its update@@ -1123,6 +1125,16 @@ def install_cua_driver("the override and run: hermes computer-use install --upgrade")return False+ if is_windows and require_confirmed_update:+ _print_info(+ " Automatic Windows updates cannot safely run cua-driver's "+ "interactive repair installer."+ )+ _print_info(+ " Repair it from an interactive terminal with: "+ "hermes computer-use install --upgrade"+ )+ return False_print_info(" Repairing it with the current upstream installer.")# upgrade=True path — refresh to the latest upstream release.@@ -1177,6 +1189,18 @@ def install_cua_driver()return Trueif _state is not None and _state.get("update_available"):+ if is_windows and require_confirmed_update:+ _latest = _state.get("latest_version") or "a newer version"+ _print_info(+ f" {driver_cmd} {_latest} is available; keeping the "+ "installed version because its Windows installer may "+ "require interactive consent."+ )+ _print_info(+ " Update it from an interactive terminal with: "+ "hermes computer-use install --upgrade"+ )+ return True# Pin the installer to the release check-update just confirmed.# `latest_version` comes from the GitHub Releases API, so its# assets are published — unlike the installer script's bakeddiff --git a/hermes_cli/update_cmd.py b/hermes_cli/update_cmd.pyindex e9d630defda..5e9b5e6172f 100644--- a/hermes_cli/update_cmd.py+++ b/hermes_cli/update_cmd.py@@ -7522,7 +7522,10 @@ def _cmd_update_impl(args, gateway_mode: bool):# An indeterminate check (offline, rate-limited, old# driver) keeps the installed version — `hermes update`# must stay fast; `hermes computer-use install --upgrade`- # remains the force path.+ # remains the force path. Windows also defers confirmed+ # updates and contract repairs to that explicit command+ # because the upstream installer may prompt for console/UAC+ # consent that this hidden updater cannot provide.install_cua_driver(upgrade=True,require_confirmed_update=True,diff --git a/tests/hermes_cli/test_install_cua_driver.py b/tests/hermes_cli/test_install_cua_driver.pyindex 39b997323d0..85da84c96ec 100644--- a/tests/hermes_cli/test_install_cua_driver.py+++ b/tests/hermes_cli/test_install_cua_driver.py@@ -6,8 +6,9 @@ must:* Be supported-platform-only — no-op silently elsewhere so ``hermes update``can call it unconditionally without warning unsupported-platform users.-* Re-run the installer even when the binary is already on PATH (this is the- fix for the "we only pulled cua-driver once on enable" complaint).+* Re-run the installer for explicit upgrades even when the binary is already+ on PATH (this is the fix for the "we only pulled cua-driver once on enable"+ complaint). Automatic Windows updates defer because the installer can prompt.* For ``upgrade=False``, keep compatible installations, repair old orincomplete installations, and install when missing.@@ -439,7 +440,7 @@ class TestRequireConfirmedUpdate:still reinstall when the check can't answer."""- def _install(self, check_state, require_confirmed):+ def _install(self, check_state, require_confirmed, contract_status=None):"""Drive ``install_cua_driver`` on the host, whatever it is.The old signature took a ``system`` string and faked@@ -463,7 +464,11 @@ class TestRequireConfirmedUpdate:patch.object(tools_config,"_cua_driver_contract_status",- return_value={"ready": True, "version": "0.20.0", "reason": ""},+ return_value=contract_status or {+ "ready": True,+ "version": "0.20.0",+ "reason": "",+ },), \patch("tools.computer_use.cua_backend.cua_driver_update_check",return_value=check_state), \@@ -497,13 +502,50 @@ class TestRequireConfirmedUpdate:for call in info.call_args_list)- def test_confirmed_update_still_runs_installer(self):+ @pytest.mark.skipif(+ sys.platform == "win32",+ reason="automatic Windows updates must not launch an interactive installer",+ )+ def test_confirmed_update_still_runs_installer_on_posix(self):state = {"current_version": "0.5.0", "latest_version": "0.6.0","update_available": True}ok, runner, _ = self._install(state, require_confirmed=True)assert ok is Truerunner.assert_called_once()+ @pytest.mark.windows_only+ def test_windows_confirmed_update_defers_interactive_installer(self):+ state = {"current_version": "0.5.0", "latest_version": "0.6.0",+ "update_available": True}+ ok, runner, info = self._install(state, require_confirmed=True)++ assert ok is True+ runner.assert_not_called()+ assert any(+ "computer-use install --upgrade" in call.args[0]+ for call in info.call_args_list+ )++ @pytest.mark.windows_only+ def test_windows_incompatible_driver_defers_interactive_repair(self):+ incompatible = {+ "ready": False,+ "version": "0.19.3",+ "reason": "Hermes computer use requires cua-driver 0.20.0 or newer",+ }+ ok, runner, info = self._install(+ None,+ require_confirmed=True,+ contract_status=incompatible,+ )++ assert ok is False+ runner.assert_not_called()+ assert any(+ "computer-use install --upgrade" in call.args[0]+ for call in info.call_args_list+ )+def test_up_to_date_short_circuits(self):state = {"current_version": "0.6.0", "latest_version": "0.6.0","update_available": False}@@ -518,7 +560,11 @@ class TestRequireConfirmedUpdate:assert ok is Truerunner.assert_called_once()- def test_incompatible_driver_repairs_despite_indeterminate_check(self):+ @pytest.mark.skipif(+ sys.platform == "win32",+ reason="automatic Windows updates must not launch an interactive repair",+ )+ def test_incompatible_driver_repairs_on_posix_despite_indeterminate_check(self):"""Hermes' own version floor is the confirmation. When the installeddriver fails the runtime contract, the `hermes update` refresh mustrepair it even though ``check-update`` can't confirm a newer release@@ -1106,13 +1152,7 @@ class TestConfirmedVersionPinning:"""def _install(self, check_state):- """Host-agnostic: version pinning is string handling, not an OS branch.-- The old ``platform.system`` → "Windows" fake was incidental — the- pin flows into ``CUA_DRIVER_RS_VERSION`` identically on every host- (both upstream installers honour it), and this test never reaches the- installer anyway because ``_run_cua_driver_installer`` is mocked.- """+ """Version pinning also applies to explicit installer runs."""from unittest.mock import MagicMockfrom hermes_cli import tools_config@@ -1139,7 +1179,7 @@ class TestConfirmedVersionPinning:patch.object(tools_config, "_print_warning"), \patch.object(tools_config, "_print_info"):ok = tools_config.install_cua_driver(- upgrade=True, require_confirmed_update=True+ upgrade=True, require_confirmed_update=False)return ok, runner