Skip to content

The agent that grows with you

fix(browser): ship the Browser Use CLI engine in every install, Desktop included

teknium11d287d5375c5
diff --git a/hermes_cli/tools_config_post_setup.py b/hermes_cli/tools_config_post_setup.py
index cc33a4541f5..bd3727647e0 100644
--- a/hermes_cli/tools_config_post_setup.py
+++ b/hermes_cli/tools_config_post_setup.py
@@ -21,27 +21,20 @@ def _info_lines(*lines: str) -> None:
_print_info(f" {line}")
-def _ensure_browser_use_cli(*, verbose_hints: bool = False, timeout_s: int = 600) -> None:
- """Install the Browser Use CLI if it isn't already runnable.
- Primary driver engine for EVERY browser backend except Camofox (Firefox-based, no CDP surface).
- A browser-use on the user's PATH does not satisfy this check; PM owns the
- selected isolated tool environment. ``timeout_s`` bounds the install (the update
- step passes a tighter bound so one optional download cannot stall the update)."""
- _print_info(" Ensuring browser-use CLI (managed install)...")
- try:
- from tools.browser_use_cli import install_cli
- ok, message = install_cli(timeout_s=timeout_s)
- except Exception as exc: # pragma: no cover — defensive
- ok, message = False, f"install failed: {exc}"
- if ok:
- _print_success(f" {message}")
+def _ensure_browser_use_cli(*, verbose_hints: bool = False) -> None:
+ """Confirm the Browser Use CLI engine is runnable. It is browser-harness, a core dependency of
+ Hermes's own venv, so there is nothing to download; a miss means the venv needs a re-sync.
+ Primary driver engine for EVERY browser backend except Camofox (Firefox-based, no CDP surface)."""
+ from tools.browser_use_cli import _find_cli
+
+ if _find_cli() is not None:
+ _print_success(" Browser Use CLI ready (browser-harness, bundled with Hermes)")
else:
- for line in str(message).splitlines():
- _print_warning(f" {line[:200]}")
- _print_info(" Retry with: hermes tools post-setup browser_use_cli")
+ _print_warning(" browser-harness is missing from Hermes's Python environment")
+ _print_info(" Re-sync it with: hermes update")
if verbose_hints:
_info_lines("Local Chrome needs remote debugging: chrome://inspect/#remote-debugging",
- "Cloud browsers: browser-use auth login (or set BROWSER_USE_API_KEY)")
+ "Cloud browsers: set BROWSER_USE_API_KEY")
def _post_setup_lightpanda() -> None:
diff --git a/hermes_cli/update_cmd_maint.py b/hermes_cli/update_cmd_maint.py
index 368fe52638c..8869b2d0d6a 100644
--- a/hermes_cli/update_cmd_maint.py
+++ b/hermes_cli/update_cmd_maint.py
@@ -888,34 +888,9 @@ def _refresh_cua_driver_after_update() -> None:
pm.ensure("cua-driver", explicit=True)
-#: Bound for the Browser Use CLI provision inside install/update (well under the
-#: 600s interactive default - an update must not stall on one optional download).
-_BROWSER_USE_CLI_UPDATE_TIMEOUT_S = 180
-
-
-def _ensure_browser_use_cli_after_update() -> None:
- """Provision the Browser Use CLI, the default browser driver.
-
- It is a PM tool environment, not a store package, so ``Package.default`` cannot
- carry it; without this step an unset ``browser.backend`` silently downgrades to
- the built-in tools. ``off`` and Camofox never use it, and declining the browser
- tools (``--skip-browser``) declines it too.
- """
- from pm.defaults import declined
- from tools.browser_use_cli import _BACKEND_KEY, _camofox_active, _find_cli, get_browser_backend
-
- if "agent-browser" in declined() or get_browser_backend() not in ("", _BACKEND_KEY):
- return
- if _camofox_active() or _find_cli() is not None:
- return
- from hermes_cli.tools_config_post_setup import _ensure_browser_use_cli
-
- _ensure_browser_use_cli(timeout_s=_BROWSER_USE_CLI_UPDATE_TIMEOUT_S)
-
-
def _install_default_tools_after_update() -> None:
"""Give the install its optional default tools: the PM defaults (agent-browser +
- Chromium, cua-driver) and the Browser Use CLI.
+ Chromium, cua-driver). The Browser Use CLI engine (browser-harness) is a venv dependency.
Runs at the end of both the installers (via the source completion) and
``hermes update``: a source update re-syncs only the venv, so a tool that became
@@ -941,7 +916,6 @@ def _install_default_tools_after_update() -> None:
except (pm.InstallError, OSError) as exc:
print(f" ⚠ {name} was not installed: {exc}")
print(f" Retry with: hermes pm install {name}")
- _ensure_browser_use_cli_after_update()
def _print_checkpoint_footprint_notice() -> None:
diff --git a/pyproject.toml b/pyproject.toml
index 3380055aa40..6c0d1248afb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -127,6 +127,11 @@ dependencies = [
# Browser CDP supervisor + browser_dialog import this directly. Keep core
# so browser tool discovery doesn't fail on lean installs.
"websockets==15.0.1; python_version >= '3.14'",
+ # Engine of the default browser_exec tool (the `browser-use` CLI is a thin
+ # wrapper over it). Pure Python, and its pins match Pillow/websockets above,
+ # so it rides in the main venv and every install, Desktop bundle included,
+ # ships it without a separate tool environment.
+ "browser-harness==0.1.13; python_version >= '3.14'",
# .gitignore-aware file matching for desktop build stamp.
"pathspec==1.1.1; python_version >= '3.14'",
"fastapi>=0.104.0,<1; python_version >= '3.14'",
@@ -697,6 +702,7 @@ asyncpg = false
azure-identity = false
boto3 = false
brotlicffi = false
+browser-harness = false
certifi = false
concurrent-log-handler = false
croniter = false
diff --git a/scripts/install.ps1 b/scripts/install.ps1
index 37c20c999ed..7ab82037d1f 100644
--- a/scripts/install.ps1
+++ b/scripts/install.ps1
@@ -8,7 +8,7 @@
# -IncludeDesktop add the desktop build stage
# -ProtocolVersion print the stage protocol version
# -SkipBrowser do not install the browser tools (agent-browser +
-# Chromium, Browser Use CLI); remembered by later
+# Chromium); remembered by later
# installs and `hermes update`, undone by
# `hermes pm install agent-browser`
# -SkipComputerUse do not install the computer-use driver (cua-driver);
diff --git a/scripts/install.sh b/scripts/install.sh
index b2a4bb30068..b6a1d2da176 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -65,8 +65,8 @@ while [ $# -gt 0 ]; do
echo " [--non-interactive] [--include-desktop] [--verbose]"
echo " [--skip-browser] [--skip-computer-use]"
echo
- echo " --skip-browser Do not install the browser tools (agent-browser + Chromium,"
- echo " Browser Use CLI). Alias: --no-playwright. Remembered by later"
+ echo " --skip-browser Do not install the browser tools (agent-browser + Chromium)."
+ echo " Alias: --no-playwright. Remembered by later"
echo " installs and 'hermes update'; undo with 'hermes pm install agent-browser'."
echo " --skip-computer-use"
echo " Do not install the computer-use driver (cua-driver). Remembered"
diff --git a/tests/hermes_cli/test_tools_config.py b/tests/hermes_cli/test_tools_config.py
index bd71059ebca..93813f26e4b 100644
--- a/tests/hermes_cli/test_tools_config.py
+++ b/tests/hermes_cli/test_tools_config.py
@@ -449,35 +449,18 @@ class TestBrowserUseCliInstalledForAllNonCamofoxBackends:
_run_post_setup("camofox")
ensure.assert_not_called()
- def test_ensure_helper_always_delegates_to_install_cli(self):
- """MANAGED-FIRST: a browser-use on PATH must not short-circuit the
- helper — install_cli() owns the managed-copy check and provisions
- $HERMES_HOME/bin when only side installs exist."""
- with patch(
- "hermes_cli.tools_config_post_setup.shutil.which", return_value="/usr/bin/browser-use"
- ), patch(
- "tools.browser_use_cli.install_cli",
- return_value=(True, "browser-use CLI already installed (/managed/bin/browser-use)"),
- ) as install:
- from hermes_cli.tools_config import _ensure_browser_use_cli
-
- _ensure_browser_use_cli()
- install.assert_called_once()
-
- def test_ensure_helper_install_failure_is_non_fatal(self):
- """A failed install must warn and fall back, never raise — the
- uvx zero-install path and the built-in tools remain available."""
+ def test_ensure_helper_missing_harness_is_non_fatal(self):
+ """A missing harness must warn and point at `hermes update`, never raise — the built-in
+ tools remain available."""
from hermes_cli.tools_config import _ensure_browser_use_cli
- with patch(
- "hermes_cli.tools_config_post_setup.shutil.which", return_value=None
- ), patch(
- "tools.browser_use_cli.install_cli",
- return_value=(False, "`uv tool install browser-use` failed:\nboom"),
- ), patch("hermes_cli.tools_config_post_setup._print_warning") as warn:
+ with patch("tools.browser_use_cli._find_cli", return_value=None), patch(
+ "hermes_cli.tools_config_post_setup._print_warning"
+ ) as warn, patch("hermes_cli.tools_config_post_setup._print_info") as info:
_ensure_browser_use_cli() # must not raise
- assert any("failed" in c.args[0] for c in warn.call_args_list)
+ assert any("browser-harness" in c.args[0] for c in warn.call_args_list)
+ assert any("hermes update" in c.args[0] for c in info.call_args_list)
class TestImagegenBackendRegistry:
diff --git a/tests/hermes_cli/test_tools_config_post_setup.py b/tests/hermes_cli/test_tools_config_post_setup.py
index 67451f022d0..1e4108ddc32 100644
--- a/tests/hermes_cli/test_tools_config_post_setup.py
+++ b/tests/hermes_cli/test_tools_config_post_setup.py
@@ -21,7 +21,7 @@ from hermes_cli.tools_config_post_setup import _run_post_setup
])
def test_browser_setup_respects_provider_and_native_owner(monkeypatch, capsys, provider, docker, playwright):
with (
- patch('tools.browser_use_cli.install_cli', return_value=(True, 'ready')) as install,
+ patch('tools.browser_use_cli._find_cli', return_value=['harness']) as install,
patch('tools.browser_tool_install._running_in_docker', return_value=docker),
patch('tools.browser_tool_install._find_agent_browser', return_value='/image/agent-browser'),
patch('tools.browser_tool_install._chromium_installed', return_value=False) as chromium,
diff --git a/tests/hermes_cli/test_update_browser_use_cli_provision.py b/tests/hermes_cli/test_update_browser_use_cli_provision.py
deleted file mode 100644
index 0a687fd179c..00000000000
--- a/tests/hermes_cli/test_update_browser_use_cli_provision.py
+++ /dev/null
@@ -1,39 +0,0 @@
-"""Install and update provision the Browser Use CLI, the default browser driver."""
-
-from unittest.mock import Mock
-
-import pytest
-
-import pm.defaults
-import pm.install
-import pm.lock
-import pm.paths
-import tools.browser_use_cli as browser_use_cli
-from hermes_cli import tools_config_post_setup as post_setup
-from hermes_cli import update_cmd_maint as update
-
-
[email protected]("backend,declined,expected", [
- ("", frozenset(), True), # default backend: provision
- ("browser-use", frozenset(), True), # explicit Browser Use mode needs it too
- ("off", frozenset(), False), # built-in tools chosen
- ("", frozenset({"agent-browser"}), False), # --skip-browser declines the CLI as well
-])
-def test_default_tool_step_provisions_browser_use_cli(monkeypatch, backend, declined, expected):
- monkeypatch.setattr(pm.install, "sealed", lambda: False)
- monkeypatch.setattr(pm.install, "lazy_installs_allowed", lambda: True)
- monkeypatch.setattr(pm.defaults, "default_packages", lambda names: [])
- monkeypatch.setattr(pm.defaults, "declined", lambda: declined)
- monkeypatch.setattr(pm.paths, "lockfile_path", lambda: None)
- monkeypatch.setattr(pm.lock, "Lockfile", lambda path: Mock(names=Mock(return_value=[])))
- monkeypatch.setattr(browser_use_cli, "get_browser_backend", lambda: backend)
- monkeypatch.setattr(browser_use_cli, "_camofox_active", lambda *a, **k: False)
- monkeypatch.setattr(browser_use_cli, "_find_cli", lambda: None)
- ensure = Mock()
- monkeypatch.setattr(post_setup, "_ensure_browser_use_cli", ensure)
-
- update._install_default_tools_after_update()
-
- assert ensure.called is expected
- if expected:
- assert 0 < ensure.call_args.kwargs["timeout_s"] <= 600
diff --git a/tests/tools/test_browser_use_cli.py b/tests/tools/test_browser_use_cli.py
index 64f1dfafd4c..a99cf7521d7 100644
--- a/tests/tools/test_browser_use_cli.py
+++ b/tests/tools/test_browser_use_cli.py
@@ -137,11 +137,9 @@ class TestSubprocessEnvironment:
env = bu_cli._base_subprocess_env()
assert env["ANONYMIZED_TELEMETRY"] == "false"
- def test_subprocess_env_strips_parent_python_import_paths(self, monkeypatch):
- """#83427/#84841/#86006/#86104: the browser-use CLI runs under its
- own Python — inherited PYTHONPATH/PYTHONHOME pointing at Hermes's
- venv make it import wrong-ABI C-extensions (pydantic_core) and
- crash. Both must be stripped; unrelated vars survive."""
+ def test_subprocess_env_replaces_parent_python_import_paths(self, monkeypatch):
+ """#83427/#84841/#86006/#86104: an inherited PYTHONPATH/PYTHONHOME must never reach the
+ harness child; PYTHONPATH is replaced by the harness's own site dir, unrelated vars survive."""
import sys
from types import ModuleType
@@ -152,10 +150,11 @@ class TestSubprocessEnvironment:
"KEEP_ME": "yes",
}
monkeypatch.setitem(sys.modules, "tools.browser_tool", browser_tool)
+ monkeypatch.setattr(bu_cli, "_harness_site_dir", lambda: "/harness-site")
env = bu_cli._base_subprocess_env()
- assert "PYTHONPATH" not in env
+ assert env["PYTHONPATH"] == "/harness-site"
assert "PYTHONHOME" not in env
assert env["KEEP_ME"] == "yes"
diff --git a/tests/tools/test_browser_use_harness.py b/tests/tools/test_browser_use_harness.py
new file mode 100644
index 00000000000..6397703cbba
--- /dev/null
+++ b/tests/tools/test_browser_use_harness.py
@@ -0,0 +1,67 @@
+"""Browser Use caller -> browser-harness on Hermes's own interpreter -> actual child."""
+import importlib.metadata
+import json
+import subprocess
+import sys
+
+import pytest
+
+from tools import browser_use_cli as bu
+
+
[email protected]("posix", "windows")
+def test_harness_runs_on_an_interpreter_without_its_own_site_packages(monkeypatch):
+ """The Desktop bundle boots its store interpreter with no venv to activate (``-S`` emulates
+ that); the harness and its daemon must import from the PYTHONPATH the tool env supplies,
+ never from what the agent process inherited."""
+ monkeypatch.setattr(bu, "_find_cli", bu._find_cli_unpatched)
+ monkeypatch.setenv("PYTHONPATH", "/wrong-abi")
+ monkeypatch.setenv("PYTHONHOME", "/wrong-python")
+ cmd = bu._find_cli()
+ assert cmd == [sys.executable, "-m", "browser_harness.run"]
+ result = subprocess.run([cmd[0], "-S", *cmd[1:], "--version"], env=bu._base_subprocess_env(),
+ capture_output=True, text=True, timeout=120)
+ assert result.returncode == 0, result.stderr
+ assert result.stdout.strip() == importlib.metadata.version("browser-harness")
+
+
[email protected]("posix", "windows")
+def test_browser_exec_child_environment(tmp_path, monkeypatch):
+ from tools import browser_tool_session, browser_supervisor
+
+ probe = tmp_path / "probe.py"
+ probe.write_text("import json, os, sys\n"
+ "print(json.dumps({'argv': sys.argv, 'stdin': sys.stdin.read(), 'env': dict(os.environ)}))\n",
+ encoding="utf-8")
+ monkeypatch.setattr(bu, "_find_cli", lambda: [sys.executable, str(probe)])
+ monkeypatch.setattr("hermes_cli.config.read_raw_config", lambda: {"browser": {"backend": "browser-use"}})
+ monkeypatch.setattr("tools.browser_tool_cdp._get_cdp_override", lambda: "")
+ monkeypatch.setattr("tools.browser_tool_cdp._resolve_cdp_override", lambda url: url)
+ monkeypatch.setattr("tools.browser_tool_cloud._get_cloud_provider", lambda: None)
+ monkeypatch.setattr("tools.browser_tool_lightpanda_fallback._using_lightpanda_engine", lambda: False)
+ def local_browser(task_id, command, args, **kwargs):
+ assert (task_id, command, args) == ("bu-named-research", "get", ["cdp-url"])
+ return {"success": True, "data": {"cdpUrl": "ws://127.0.0.1:47000/private"}}
+ monkeypatch.setattr(browser_tool_session, "_run_browser_command", local_browser)
+ attached = []
+ monkeypatch.setattr(browser_supervisor.SUPERVISOR_REGISTRY, "get_or_start",
+ lambda task_id, cdp_url, **kw: attached.append((task_id, cdp_url)))
+ monkeypatch.setenv("PYTHONPATH", "/wrong-abi")
+ monkeypatch.setenv("PYTHONHOME", "/wrong-python")
+ monkeypatch.setenv("OPENAI_API_KEY", "must-not-leak")
+ monkeypatch.setenv("BROWSERBASE_API_KEY", "browser-key")
+ monkeypatch.setenv("KEEP_BROWSER_PROBE", "kept")
+ monkeypatch.delenv("ANONYMIZED_TELEMETRY", raising=False)
+ result = json.loads(bu.browser_exec("print('payload')", session="research", task_id="owner"))
+ assert result["success"], result
+ child = json.loads(result["output"])
+ assert child["stdin"] == "print('payload')"
+ for key in ("PYTHONHOME", "OPENAI_API_KEY", "_HERMES_BU_PRIVATE_BROWSER"):
+ assert key not in child["env"]
+ assert child["env"].get("PYTHONPATH") == bu._harness_site_dir()
+ assert child["env"]["BU_NAME"] == "research"
+ assert child["env"]["BU_CDP_WS"] == "ws://127.0.0.1:47000/private"
+ assert child["env"]["ANONYMIZED_TELEMETRY"] == "false"
+ assert child["env"]["BROWSERBASE_API_KEY"] == "browser-key"
+ assert child["env"]["KEEP_BROWSER_PROBE"] == "kept"
+ assert attached == [("owner", "ws://127.0.0.1:47000/private")]
diff --git a/tests/tools/test_browser_use_pm.py b/tests/tools/test_browser_use_pm.py
deleted file mode 100644
index 2567dde89b4..00000000000
--- a/tests/tools/test_browser_use_pm.py
+++ /dev/null
@@ -1,84 +0,0 @@
-"""Browser Use caller -> real PM worker -> locally built CLI -> actual child."""
-import json
-import os
-from pathlib import Path
-import zipfile
-
-import pytest
-
-import pm
-from tests.pm._fixtures import _wheel, build_worker, client, isolated_python # noqa: F401
-from tools import browser_use_cli as bu
-
-
[email protected]("posix", "windows")
-def test_installed_cli_selection_and_child_environment(build_worker, tmp_path, monkeypatch):
- from tools import browser_tool_session, browser_supervisor
-
- wheel = _wheel(tmp_path, "browser_use_probe")
- with zipfile.ZipFile(wheel, "a") as archive:
- archive.writestr("browser_use_probe/cli.py", """import json, os, sys
-def main():
- print(json.dumps({'argv': sys.argv, 'stdin': sys.stdin.read(), 'env': dict(os.environ)}))
-""")
- archive.writestr("browser_use_probe-1.0.dist-info/entry_points.txt",
- "[console_scripts]\nbrowser-use = browser_use_probe.cli:main\n")
- monkeypatch.setattr(bu, "_CLI_REQUIREMENTS", (f"browser-use-probe @ {wheel.as_uri()}",))
- monkeypatch.setattr(bu, "_find_cli", bu._find_cli_unpatched)
- monkeypatch.setattr("hermes_cli.config.read_raw_config", lambda: {"browser": {"backend": "browser-use"}})
- monkeypatch.setattr("tools.browser_tool_cdp._get_cdp_override", lambda: "")
- monkeypatch.setattr("tools.browser_tool_cdp._resolve_cdp_override", lambda url: url)
- monkeypatch.setattr("tools.browser_tool_cloud._get_cloud_provider", lambda: None)
- monkeypatch.setattr("tools.browser_tool_lightpanda_fallback._using_lightpanda_engine", lambda: False)
- def local_browser(task_id, command, args, **kwargs):
- assert (task_id, command, args) == ("bu-named-research", "get", ["cdp-url"])
- return {"success": True, "data": {"cdpUrl": "ws://127.0.0.1:47000/private"}}
- monkeypatch.setattr(browser_tool_session, "_run_browser_command", local_browser)
- attached = []
- monkeypatch.setattr(browser_supervisor.SUPERVISOR_REGISTRY, "get_or_start",
- lambda task_id, cdp_url, **kw: attached.append((task_id, cdp_url)))
- # A PATH binary must never substitute for missing or corrupted PM selection.
- ambient = tmp_path / "ambient"
- ambient.mkdir()
- (ambient / "browser-use").write_text("#!/bin/sh\nexit 99\n", encoding="utf-8")
- (ambient / "browser-use").chmod(0o755)
- monkeypatch.setenv("PATH", str(ambient) + os.pathsep + os.environ["PATH"])
- assert bu._find_cli() is None
- assert "hermes tools" in json.loads(bu.browser_exec("print(1)"))["error"]
- ok, message = bu.install_cli(timeout_s=120)
- assert ok, message
- binary = pm.python_tool("browser-use", "browser-use")
- assert binary is not None and bu._find_cli() == [str(binary)]
- assert str(binary) in message
- assert bu.install_cli(timeout_s=120)[0]
- assert pm.python_tool("browser-use", "browser-use") == binary
- monkeypatch.setenv("PYTHONPATH", "/wrong-abi")
- monkeypatch.setenv("PYTHONHOME", "/wrong-python")
- monkeypatch.setenv("OPENAI_API_KEY", "must-not-leak")
- monkeypatch.setenv("BROWSERBASE_API_KEY", "browser-key")
- monkeypatch.setenv("KEEP_BROWSER_PROBE", "kept")
- monkeypatch.delenv("ANONYMIZED_TELEMETRY", raising=False)
- result = json.loads(bu.browser_exec("print('payload')", session="research", task_id="owner"))
- assert result["success"], result
- child = json.loads(result["output"])
- # Windows console-script launchers report sys.argv[0] without the .exe suffix.
- assert Path(child["argv"][0]).with_suffix("") == binary.with_suffix("")
- assert child["stdin"] == "print('payload')"
- for key in ("PYTHONPATH", "PYTHONHOME", "OPENAI_API_KEY", "_HERMES_BU_PRIVATE_BROWSER"):
- assert key not in child["env"]
- assert child["env"]["BU_NAME"] == "research"
- assert child["env"]["BU_CDP_WS"] == "ws://127.0.0.1:47000/private"
- assert child["env"]["ANONYMIZED_TELEMETRY"] == "false"
- assert child["env"]["BROWSERBASE_API_KEY"] == "browser-key"
- assert child["env"]["KEEP_BROWSER_PROBE"] == "kept"
- assert attached == [("owner", "ws://127.0.0.1:47000/private")]
- # Invalid wheel reaches real worker/uv failure, and leaves the old CLI selected.
- monkeypatch.delenv("PYTHONPATH")
- monkeypatch.delenv("PYTHONHOME")
- monkeypatch.setattr(bu, "_CLI_REQUIREMENTS", (f"browser-use-probe @ {(tmp_path / 'missing.whl').as_uri()}",))
- ok, message = bu.install_cli(timeout_s=120)
- assert not ok and "Could not install browser-use CLI" in message
- assert "missing.whl" in message
- assert bu._find_cli() == [str(binary)]
- binary.unlink()
- assert bu._find_cli() is None
diff --git a/tools/browser_use_cli.py b/tools/browser_use_cli.py
index 09e693cf993..10cfbcb9a68 100644
--- a/tools/browser_use_cli.py
+++ b/tools/browser_use_cli.py
@@ -6,15 +6,17 @@ instead of default browser tools
import contextlib
import importlib
+import importlib.util
import json
import logging
import os
import re
import signal
import subprocess
+import sys
import time
from pathlib import Path
-from typing import Any, Callable, Dict, List, Optional, Tuple
+from typing import Any, Callable, Dict, List, Optional
from hermes_constants import get_hermes_home
from utils import is_truthy_value
@@ -141,15 +143,16 @@ def _blocked_url_in_code(code: str) -> Optional[str]:
def _base_subprocess_env() -> dict:
from tools.browser_tool import _build_browser_env
env = _build_browser_env()
- # The CLI runs under its own PM-managed Python; an inherited PYTHONPATH/PYTHONHOME
- # (Hermes's venv) wins over its site-packages → wrong-ABI C-extensions and a crash.
- # PYTHONPATH/PYTHONHOME inherited from the agent process point at Hermes's venv site-packages, and a
- # child interpreter honors them ahead of its own site-packages — so the CLI imports compiled
- # C-extensions (e.g. pydantic_core) built for the wrong interpreter and crashes on ABI mismatch (#83427,
- # #84841, #86006, #86104). Strip both — the CLI manages its own environment and never needs Hermes's
- # import path.
- env.pop("PYTHONPATH", None)
+ # The harness runs on Hermes's own interpreter, but a bundled Desktop install boots that
+ # interpreter with its site dir on PYTHONPATH (no venv to activate), and the harness's daemon
+ # re-runs sys.executable. Point PYTHONPATH at the harness's site dir, replacing whatever the
+ # agent process inherited, so both the CLI and its daemon import the same packages.
env.pop("PYTHONHOME", None)
+ site_dir = _harness_site_dir()
+ if site_dir:
+ env["PYTHONPATH"] = site_dir
+ else:
+ env.pop("PYTHONPATH", None)
env["PATH"] = _floor_subprocess_path(env.get("PATH", ""))
env.setdefault("ANONYMIZED_TELEMETRY", "false")
return env
@@ -218,7 +221,7 @@ def is_legacy_browser_use_cloud_config(browser_cfg: dict) -> bool:
def is_browser_use_cli_mode() -> bool:
"""True when the Browser Use CLI replaces the built-in browser stack. Browser Use mode is the DEFAULT:
- unset ``browser.backend`` ("") enables it whenever the PM-managed CLI is installed;
+ unset ``browser.backend`` ("") enables it whenever browser-harness is importable (a core dependency);
``browser.backend: off`` keeps the built-in browser_* tools. Camofox always falls back to the built-in
tools (Firefox, custom HTTP API, no CDP surface for the harness)."""
if _camofox_active():
@@ -242,35 +245,27 @@ def default_downgrade_notice() -> Optional[str]:
stamp.parent.mkdir(parents=True, exist_ok=True)
stamp.touch()
os.utime(stamp, (now, now))
- return ("Browser Use CLI not found — using the built-in browser tools. Run `hermes tools` "
- "(Browser Automation → Browser Use) to install it, or `browser.backend: off` in config.yaml to silence this.")
+ return ("browser-harness is missing from Hermes's Python environment — using the built-in browser tools. "
+ "Run `hermes update` to re-sync it, or set `browser.backend: off` in config.yaml to silence this.")
except Exception as e: # pragma: no cover — a notice must never break startup
logger.debug("browser-use downgrade notice failed: %s", e)
return None
-_CLI_REQUIREMENTS = ("browser-use==0.13.10",)
+def _harness_site_dir() -> Optional[str]:
+ """The site dir Hermes's interpreter imports ``browser_harness`` from, or None."""
+ spec = importlib.util.find_spec("browser_harness")
+ if spec is None or not spec.origin:
+ return None
+ return str(Path(spec.origin).resolve().parent.parent)
def _find_cli() -> Optional[List[str]]:
- """Read PM's selected CLI without installing anything during discovery."""
- import pm
-
- binary = pm.python_tool("browser-use", "browser-use")
- return [str(binary)] if binary is not None else None
-
-
-def install_cli(timeout_s: int = 600) -> Tuple[bool, str]:
- """Provision the pinned CLI in PM's isolated environment; never raises."""
- try:
- import pm
-
- binary = pm.ensure_python_tool(
- "browser-use", _CLI_REQUIREMENTS, "browser-use", explicit=True, timeout=timeout_s,
- )
- except Exception as exc:
- return False, f"Could not install browser-use CLI: {exc}"
- return True, f"browser-use CLI installed ({binary})"
+ """The Browser Use CLI's engine (browser-harness) is a core dependency of Hermes's own venv,
+ so every install, the Desktop bundle included, runs it on the current interpreter."""
+ if _harness_site_dir() is None:
+ return None
+ return [sys.executable, "-m", "browser_harness.run"]
def _workspace_dir(task_id: Optional[str]) -> Optional[str]:
@@ -583,8 +578,8 @@ def browser_exec(code: str, session: str = "", timeout_s: int = _DEFAULT_TIMEOUT
cmd = _find_cli()
if not cmd:
- return tool_error("The PM-managed browser-use CLI is not installed. "
- "Run `hermes tools` (Browser Automation → Browser Use) to install it.")
+ return tool_error("browser-harness is missing from Hermes's Python environment. "
+ "Run `hermes update` to re-sync it.")
env = _base_subprocess_env()
if session:
diff --git a/uv.lock b/uv.lock
index 953221d85bd..15b66d901f9 100644
--- a/uv.lock
+++ b/uv.lock
@@ -75,6 +75,7 @@ aiohttp-socks = false
sentencepiece = false
opentelemetry-exporter-otlp-proto-http = false
croniter = false
+browser-harness = false
azure-identity = false
lark-oapi = false
firecrawl-anydoc = false
@@ -773,6 +774,21 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/4e/17/17c22d48819001ca08cadab63b09b00e0c56a7579478aa7c2623f4280de6/brotlicffi-1.2.0.2-pp311-pypy311_pp73-win_amd64.whl", hash = "sha256:5eb5563173afb92c9111b180349ff17d7c83c79febabadca5de983b552565c3c", size = 378395, upload-time = "2026-08-21T17:29:16.857Z" },
]
+[[package]]
+name = "browser-harness"
+version = "0.1.13"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "cdp-use" },
+ { name = "fetch-use" },
+ { name = "pillow" },
+ { name = "websockets" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/7f/fe/59ab493e7cf76731a7f5aabae3821eea6ea82a628c14c30e7aed48adc362/browser_harness-0.1.13.tar.gz", hash = "sha256:284dc547a042c309feafd9a9f4a74b2a8651b7963ea3ac6cb2f2d64889f6a8f3", size = 114905, upload-time = "2026-09-04T02:53:23.133Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/4a/bd/f166cf9a465eff436048d25851ab28b0d798af02b56998127a4165227fc4/browser_harness-0.1.13-py3-none-any.whl", hash = "sha256:2491459e4bfc0ee8aea22dc6c4680fc0f791b7ba553446323c50d2883449d769", size = 121123, upload-time = "2026-09-04T02:53:21.841Z" },
+]
+
[[package]]
name = "catalogue"
version = "2.0.10"
@@ -830,6 +846,20 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/29/5f/ff2c6da83553a692219a0a62a21b57a27ded4405200e50db758a17fbaf15/cbor2-6.1.4-cp314-cp314t-win_arm64.whl", hash = "sha256:164ca22b509408435b2d8236c80c964e4fc77c085ab034569cd04c40d5cc8883", size = 298386, upload-time = "2026-08-01T20:41:38.392Z" },
]
+[[package]]
+name = "cdp-use"
+version = "1.4.5"
+source = { registry = "https://pypi.org/simple" }
+dependencies = [
+ { name = "httpx" },
+ { name = "typing-extensions" },
+ { name = "websockets" },
+]
+sdist = { url = "https://files.pythonhosted.org/packages/f7/7a/c549417e8c5e4dface6d5d828cd7dc72502dcea33a99f5324abf5a853ce9/cdp_use-1.4.5.tar.gz", hash = "sha256:0da3a32df46336a03ff5a22bc6bc442cd7d2f2d50a118fd4856f29d37f6d26a0", size = 193961, upload-time = "2026-02-22T04:32:50.574Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/56/12/386d8c6bf0448c43674e24d6194c3b57d62e5361e90bca3d58108819ad32/cdp_use-1.4.5-py3-none-any.whl", hash = "sha256:8f8e2435e3a20e4009d2974144192cf3c132f6c2971338e156198814d9b91ecb", size = 350504, upload-time = "2026-02-22T04:32:49.22Z" },
+]
+
[[package]]
name = "certifi"
version = "2026.5.20"
@@ -1841,6 +1871,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/05/99/49ee85903dee060d9f08297b4a342e5e0bcfca2f027a07b4ee0a38ab13f9/faster_whisper-1.2.1-py3-none-any.whl", hash = "sha256:79a66ad50688c0b794dd501dc340a736992a6342f7f95e5811be60b5224a26a7", size = 1118909, upload-time = "2025-10-31T11:35:47.794Z" },
]
+[[package]]
+name = "fetch-use"
+version = "0.4.0"
+source = { registry = "https://pypi.org/simple" }
+sdist = { url = "https://files.pythonhosted.org/packages/5d/2d/66784fa8b66a04f170ad8f6598688b30b3a194dad4185b36d53da4ae1505/fetch_use-0.4.0.tar.gz", hash = "sha256:9511987d4907ec6dac501e21d66946d10098f66b5d21bc2aba4189cd81ba189a", size = 8974, upload-time = "2026-04-09T04:02:44.384Z" }
+wheels = [
+ { url = "https://files.pythonhosted.org/packages/57/97/d4104692aa5c99a30fea22b5adffd2ce35b1ad86ae5236766cfc1ae468f1/fetch_use-0.4.0-py3-none-any.whl", hash = "sha256:b7885f2907e7920373fa75dcdb00afd6e603a25a9ee2151aa2881f5465e1a2c0", size = 9468, upload-time = "2026-04-09T04:02:43.458Z" },
+]
+
[[package]]
name = "filelock"
version = "3.32.4"
@@ -2307,6 +2346,7 @@ name = "hermes-agent"
version = "0.0.0"
source = { editable = "." }
dependencies = [
+ { name = "browser-harness" },
{ name = "certifi" },
{ name = "concurrent-log-handler", marker = "sys_platform == 'win32'" },
{ name = "croniter" },
@@ -2634,6 +2674,7 @@ requires-dist = [
{ name = "azure-identity", marker = "extra == 'azure-identity'", specifier = "==1.25.3" },
{ name = "boto3", marker = "extra == 'bedrock'", specifier = "==1.42.89" },
{ name = "brotlicffi", marker = "extra == 'messaging'", specifier = "==1.2.0.2" },
+ { name = "browser-harness", marker = "python_full_version >= '3.14'", specifier = "==0.1.13" },
{ name = "certifi", marker = "python_full_version >= '3.14'", specifier = "==2026.5.20" },
{ name = "concurrent-log-handler", marker = "python_full_version >= '3.14' and sys_platform == 'win32'", specifier = "==0.9.29" },
{ name = "croniter", marker = "python_full_version >= '3.14'", specifier = "==6.0.0" },
diff --git a/website/docs/getting-started/installation.md b/website/docs/getting-started/installation.md
index b26e26b2c06..c15289d75b9 100644
--- a/website/docs/getting-started/installation.md
+++ b/website/docs/getting-started/installation.md
@@ -69,9 +69,11 @@ The scripts clone the source, bootstrap uv, and delegate dependency preparation
to PM. PM provides pinned Python, Node.js, npm, ripgrep, and FFmpeg. The source
installation selects the `all` Python extra, not every optional extra.
PM also installs the browser and computer-use tools by default: `agent-browser`
-and its pinned Chromium, the Browser Use CLI (the default browser driver), and
-`cua-driver` (the computer-use driver, on macOS, Windows and glibc Linux). If a
-download fails, the install still completes and prints the command to retry.
+and its pinned Chromium, and `cua-driver` (the computer-use driver, on macOS,
+Windows and glibc Linux). If a download fails, the install still completes and
+prints the command to retry. The default browser driver (browser-harness, the
+engine of the Browser Use CLI) is a regular Python dependency, so every install,
+the Desktop app included, already has it.
Other optional tools use their feature-specific installation paths.
To leave the browser tools out, pass `--skip-browser` on POSIX or `-SkipBrowser`
diff --git a/website/docs/user-guide/features/browser.md b/website/docs/user-guide/features/browser.md
index adf24bb06f0..f2867da33a3 100644
--- a/website/docs/user-guide/features/browser.md
+++ b/website/docs/user-guide/features/browser.md
@@ -73,7 +73,7 @@ The `.env` keys above supply **credentials only**. The active cloud browser is c
Browser Use mode uses the [Browser Use CLI 3.0](https://github.com/browser-use/browser-use) instead of the built-in browser tools. The agent writes and executes Python in the browser to click, type, drag, scrape, and interact with webpages.
-**This is the default browser mode**: when `browser.backend` is unset and the `browser-use` CLI is runnable (installed, or available through `uvx`), the agent gets the single `browser_exec` tool. The installers and `hermes update` install the pinned CLI into a Hermes-managed environment unless you passed `--skip-browser` / `-SkipBrowser` or chose `backend: "off"`; `hermes tools post-setup browser_use_cli` retries a failed download. If the CLI can't run, Hermes falls back to the built-in browser tools automatically.
+**This is the default browser mode**: when `browser.backend` is unset, the agent gets the single `browser_exec` tool. Its engine is browser-harness (the Browser Use CLI is a thin wrapper around it), a regular Python dependency of Hermes, so every install ships it, including the Desktop app, with no separate download. If it is ever missing from Hermes's environment, Hermes falls back to the built-in browser tools and `hermes update` restores it.
The mode is a **driver** that composes with your configured browser backend: it drives Hermes' own headless Chromium, a Nous-subscription cloud browser, Browserbase, Firecrawl, or Browser Use cloud browsers — whichever browser source is selected in `hermes tools` → Browser Automation. The one exception is Camofox, which has no CDP endpoint for the harness to attach to; Camofox setups automatically keep the built-in browser tools.
@@ -91,7 +91,7 @@ browser:
(`backend: "browser-use"` remains valid to force the mode explicitly.)
-Browser Use's own cloud browsers need `browser-use auth login` or `BROWSER_USE_API_KEY`; other browser sources use their existing credentials unchanged.
+Browser Use's own cloud browsers need `BROWSER_USE_API_KEY`; other browser sources use their existing credentials unchanged.
:::note
Because Browser Use mode executes model-written Python on your machine, the