The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui): lead slash_worker PATH with Hermes' managed bin dir
Tekniumf92accd05d17
diff --git a/tests/gateway/test_tui_slash_worker_path.py b/tests/gateway/test_tui_slash_worker_path.pyindex 546fa66d4d7..d0770cc4588 100644--- a/tests/gateway/test_tui_slash_worker_path.py+++ b/tests/gateway/test_tui_slash_worker_path.py@@ -18,25 +18,31 @@ from tui_gateway import server as tui_serverclass TestPrependToolPaths:- def test_prepends_venv_and_user_bin(self):+ def test_prepends_managed_venv_and_user_bin(self, monkeypatch, tmp_path):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hh"))env = {"PATH": "/usr/bin"}result = tui_server._prepend_tool_paths(env)parts = result["PATH"].split(os.pathsep)- # venv bin first, then user-local bin, then the original PATH preserved- assert parts[0] == str(Path(sys.executable).parent)+ # managed bin first (managed-first policy), then venv bin, then+ # user-local bin, then the original PATH preserved+ assert parts[0] == str(tmp_path / "hh" / "bin")+ assert parts[1] == str(Path(sys.executable).parent)assert str(Path.home() / ".local" / "bin") in partsassert parts[-1] == "/usr/bin"- def test_preserves_existing_path_when_empty(self):+ def test_preserves_existing_path_when_empty(self, monkeypatch, tmp_path):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hh"))env = {}result = tui_server._prepend_tool_paths(env)parts = result["PATH"].split(os.pathsep)- assert parts[0] == str(Path(sys.executable).parent)+ assert parts[0] == str(tmp_path / "hh" / "bin")+ assert str(Path(sys.executable).parent) in partsassert str(Path.home() / ".local" / "bin") in parts- def test_venv_bin_points_at_sys_executable_dir(self):+ def test_managed_bin_leads_path(self, monkeypatch, tmp_path):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "hh"))env = {"PATH": "/bin"}result = tui_server._prepend_tool_paths(env)- assert result["PATH"].split(os.pathsep)[0] == str(Path(sys.executable).parent)+ assert result["PATH"].split(os.pathsep)[0] == str(tmp_path / "hh" / "bin")diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex b6589ec8b49..3d0b8f7129c 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -369,15 +369,25 @@ _detached_ws_transport = _DropTransport()def _prepend_tool_paths(env: dict[str, str]) -> dict[str, str]:- """Prepend the Hermes venv bin dir and the user-local bin dir to PATH- so slash_worker child processes can resolve Hermes-managed CLIs- (browser-use, uvx) even when the parent gateway was launched with a- minimal PATH (e.g. by the Desktop/Dashboard app)."""+ """Prepend Hermes' managed bin, the venv bin dir, and the user-local+ bin dir to PATH so slash_worker child processes can resolve+ Hermes-managed CLIs (browser-use, uvx, uv) even when the parent+ gateway was launched with a minimal PATH (e.g. by the+ Desktop/Dashboard app). Managed bin leads, matching the managed-first+ resolution policy for the Browser Use CLI."""+ managed_bin = ""+ try:+ from hermes_constants import get_hermes_home++ managed_bin = str(Path(get_hermes_home()) / "bin")+ except Exception:+ passvenv_bin = str(Path(sys.executable).parent) # <venv>/bin (POSIX) or <venv>/Scripts (Windows)user_bin = str(Path.home() / ".local" / "bin")existing = env.get("PATH") or ""env["PATH"] = os.pathsep.join(- [p for p in (venv_bin, user_bin) if p] + ([existing] if existing else [])+ [p for p in (managed_bin, venv_bin, user_bin) if p]+ + ([existing] if existing else []))return env