The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): restore managed-node-path and PATHEXT-aware fallback rungs
Zak B. Elepf4d3592b65f7
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.pyindex 735b685866a..5289cabce07 100644--- a/hermes_cli/nous_subscription.py+++ b/hermes_cli/nous_subscription.py@@ -178,14 +178,30 @@ def _has_agent_browser() -> bool:# (prior behaviour) rather than crashing the setup/status surface.# Validate the resolved binary actually runs — a dangling global# symlink (issue #48521) is reported by ``which`` but fails at exec.- # Fall through to the local node_modules copy, which the validator- # also checks.if agent_browser_runnable(shutil.which("agent-browser")):return True- local_bin = (- Path(__file__).parent.parent / "node_modules" / ".bin" / "agent-browser"- )- return agent_browser_runnable(str(local_bin)) if local_bin.exists() else False++ # Hermes-managed Node dirs (Windows installer / POSIX $HERMES_HOME/node)+ # are prepended to PATH at runtime but usually absent from the *probe*+ # process's PATH. Without this rung a successful install keeps+ # reporting "needs setup" on Windows.+ from hermes_constants import with_hermes_node_path+ managed_path = with_hermes_node_path().get("PATH", "")+ if managed_path:+ managed_hit = shutil.which("agent-browser", path=managed_path)+ if managed_hit and agent_browser_runnable(managed_hit):+ return True++ # Local node_modules/.bin: resolve via PATHEXT-aware ``shutil.which`` so+ # Windows picks the executable ``.cmd`` shim — probing the+ # extensionless POSIX shim directly fails exec (WinError 193) even+ # right after a successful ``npm install``.+ local_bin_dir = Path(__file__).parent.parent / "node_modules" / ".bin"+ if local_bin_dir.is_dir():+ local_which = shutil.which("agent-browser", path=str(local_bin_dir))+ if local_which and agent_browser_runnable(local_which):+ return True+ return Falsetry:browser_cmd = _find_agent_browser(validate=False)diff --git a/tests/hermes_cli/test_nous_subscription.py b/tests/hermes_cli/test_nous_subscription.pyindex 6397cc9179e..b71a0fb2842 100644--- a/tests/hermes_cli/test_nous_subscription.py+++ b/tests/hermes_cli/test_nous_subscription.py@@ -298,6 +298,41 @@ def test_has_agent_browser_import_failure_falls_back_to_path_check(monkeypatch):assert ns._has_agent_browser() is True+def test_has_agent_browser_import_failure_falls_back_to_hermes_managed_node_path(+ monkeypatch, tmp_path+):+ """If tools.browser_tool cannot be imported, the managed-Node rung must+ still find a runnable agent-browser under the Hermes Node dir even when+ it's absent from the probe process's PATH — the Windows installer shape+ where install succeeded but the GUI still said needs setup."""+ monkeypatch.setitem(sys.modules, "tools.browser_tool", None)+ managed_dir = tmp_path / "node"+ managed_dir.mkdir()+ managed_bin = managed_dir / "agent-browser"+ managed_bin.write_text("#!/bin/sh\nexit 0\n")+ managed_bin.chmod(0o755)++ real_which = shutil.which+ monkeypatch.setattr(+ shutil,+ "which",+ lambda cmd, *args, **kwargs: (+ None+ if cmd == "agent-browser" and not kwargs.get("path")+ else real_which(cmd, *args, **kwargs)+ ),+ )+ monkeypatch.setattr(+ "hermes_constants.with_hermes_node_path", lambda: {"PATH": str(managed_dir)}+ )+ monkeypatch.setattr(+ "hermes_constants.agent_browser_runnable",+ lambda p: bool(p) and str(p) == str(managed_bin),+ )++ assert ns._has_agent_browser() is True++def test_has_agent_browser_import_failure_and_no_binary_is_false(monkeypatch):monkeypatch.setitem(sys.modules, "tools.browser_tool", None)_block_legacy_agent_browser_checks(monkeypatch)