The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(config): v52 drops browser.backend and moves AGENT_BROWSER_* settings to browser.* keys
Tekniuma9f890f4a68f
diff --git a/cli-config.yaml.example b/cli-config.yaml.exampleindex 5343b2acf7c..bb85f798629 100644--- a/cli-config.yaml.example+++ b/cli-config.yaml.example@@ -7,7 +7,7 @@# Schema version of this file. The installers copy it to seed config.yaml, and# `hermes update` uses it to know which one-time migrations the file already# has. Hermes manages it: do not copy it into another config.-_config_version: 51+_config_version: 52# =============================================================================# Database Configuration@@ -620,19 +620,13 @@ browser:extension_control:enabled: false- # Maximum characters of snapshot content before truncate-and-store.- # Increase for long pages (for example, documentation or financial reports),- # or decrease to reduce context usage. Minimum: 1000; default: 15000- # (same per-page budget as web_extract).- # snapshot_threshold: 15000-- # JavaScript evaluation guardrails (both default false). restrict_evaluate- # opts into a denylist that blocks sensitive primitives (cookies, storage,- # clipboard, network, form values) in browser_console(expression=...) — use- # it when the agent drives a logged-in profile. allow_unsafe_evaluate is the- # legacy override that switches the denylist back off even when restrict is on.- # restrict_evaluate: false- # allow_unsafe_evaluate: false+ # Local Chromium for browser_exec. Empty executable_path = pm's chromium+ # (`hermes pm install chromium`), the Docker image's build, or a system+ # chromium where pm builds none (Termux). user_data_dir keeps one persistent+ # profile for every local session (empty = a throwaway profile per session).+ # executable_path: ""+ # user_data_dir: ""+ # chromium_args: ["--lang=de"]# =============================================================================# Tool Loop Guardrails@@ -1526,9 +1520,8 @@ platform_toolsets:# search - web_search only (no scraping)# terminal - terminal, process# file - read_file, write_file, patch, search-# browser - browser_navigate, browser_snapshot, browser_click, browser_type,-# browser_scroll, browser_back, browser_press,-# browser_get_images, browser_vision (requires BROWSERBASE_API_KEY)+# browser - browser_exec, browser_cdp, browser_dialog, browser_vault+# (local Chromium, or a cloud browser with its API key)# vision - vision_analyze (requires OPENROUTER_API_KEY)# image_gen - image_generate (requires FAL_KEY)# skills - skills_list, skill_view@@ -1554,7 +1547,7 @@ platform_toolsets:# search - Web search only, no scraping (web_search)# terminal - Command execution and process management (terminal, process)# file - File operations: read, write, patch, search-# browser - Full browser automation (navigate, click, type, screenshot, etc.)+# browser - Browser automation over CDP (browser_exec drives a real Chromium)# vision - Image analysis (vision_analyze)# image_gen - Image generation with FLUX (image_generate)# skills - Load skill documents (skills_list, skill_view)diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.pyindex 63ff490ee73..885aebceb04 100644--- a/hermes_cli/config_defaults.py+++ b/hermes_cli/config_defaults.py@@ -421,24 +421,29 @@ DEFAULT_CONFIG = {},"browser": {- # "" = Browser Use mode when the browser-use CLI (or uvx) is available, else built-in tools- # (Camofox setups always keep built-in tools: no CDP surface); "browser-use" = force one- # browser_exec tool driving the Browser Use CLI over any CDP backend (local Chrome, cloud);- # "off" = force the built-in browser_navigate/browser_click/... tools.- "backend": "",+ # REMOVAL NOTE: `backend` (built-in browser_* tools vs browser_exec), `snapshot_threshold`,+ # `record_sessions`, `allow_unsafe_evaluate` and `restrict_evaluate` left with the built-in+ # browser tools; browser_exec is the only core browser. Config v52 drops `backend` (an `off`+ # gets a one-time notice) and copies AGENT_BROWSER_* from .env to the keys below; other+ # user values stay untouched."inactivity_timeout": 120,- "command_timeout": 30, # seconds per browser command (screenshot, navigate, etc.)- "snapshot_threshold": 15000, # max chars before snapshot truncate-and-store (min 1000)- "record_sessions": False, # auto-record browser sessions as WebM videos+ # Seconds a local Chromium launch may take to open its DevTools port; a launch always waits+ # at least 120 s (a cold first start unpacks the profile).+ "command_timeout": 30,# headed: visible Chromium window (local); skips per-turn cleanup, idle reaper still applies"headed": False,"allow_private_urls": False, # allow private/internal IPs (localhost, 192.168.x.x, ...)- # Local browser engine for both drivers. "auto" = Chrome; "lightpanda" = faster navigation,- # no screenshots (Browser Use mode spawns `lightpanda serve` per session; built-in tools- # pass `--engine <value>` to agent-browser with Chrome fallback); "chrome" = explicit.- # Ignored while a cloud provider, Camofox, cdp_url or use_real_profile is active. Also- # settable via AGENT_BROWSER_ENGINE.+ # Local browser engine. "auto" = Chromium; "lightpanda" = `lightpanda serve` per session+ # (faster navigation, no screenshots); "chrome" is read as "auto". Ignored while a cloud+ # provider, cdp_url or use_real_profile is active."engine": "auto",+ # Chromium binary for local sessions. "" = pm's chromium (`hermes pm install chromium`), the+ # Docker image's build, else a system chromium where pm builds none (Termux).+ "executable_path": "",+ # Persistent Chromium profile directory shared by local sessions; "" = a fresh throwaway+ # profile per session.+ "user_data_dir": "",+ "chromium_args": [], # extra Chromium flags for local sessions, e.g. ["--lang=de"]# With a cloud provider, auto-spawn local Chromium for LAN/localhost URLs instead"auto_local_for_private_urls": True,"cdp_url": "", # persistent CDP endpoint for attaching to an existing Chromium/Chrome@@ -462,33 +467,18 @@ DEFAULT_CONFIG = {# agent the wrong identity. A pin naming a missing directory never falls back to another# profile: the session gets a fresh browser without the user's logins."real_profile_pin": "",- # restrict_evaluate: opt-in denylist blocking sensitive JS primitives (cookies/storage/- # clipboard/network/form values) in browser_console(expression=...); allow_unsafe_evaluate- # is the legacy override that bypasses that denylist entirely.- "allow_unsafe_evaluate": False,- "restrict_evaluate": False,# CDP supervisor: dialog + frame detection over a persistent WebSocket; active only with a# CDP-capable backend (Browserbase, or local Chrome via /browser connect). See# website/docs/developer-guide/browser-supervisor.md."dialog_policy": "must_respond", # must_respond | auto_dismiss | auto_accept"dialog_timeout_s": 300, # safety auto-dismiss after N seconds under must_respond- "camofox": {- # true = send a stable profile-scoped userId so Camofox maps it to a persistent Firefox- # profile; false = random ephemeral userId per session.- "managed_persistence": False,- # Externally managed Camofox identity, for when another app owns the visible browser.- "user_id": "",- "session_key": "",- "adopt_existing_tab": False, # rehydrate tab_id from Camofox before creating a tab- # Docker Camofox opens page URLs from inside the container: rewrite loopback page URLs- # (localhost/127.0.0.1/::1) to the host alias; CAMOFOX_URL itself is unchanged.- "rewrite_loopback_urls": False,- "loopback_host_alias": "host.docker.internal",- },+ # Read by the `camofox` catalog plugin (Camofox left core). An empty free-form mapping, so+ # `hermes config set browser.camofox.<key>` is accepted and user values are never stripped.+ "camofox": {},# Authenticated browser-extension controller lane: a registered extension can become the- # exact controller for a session's browser_* tools (fail-closed once bound). Local API+ # exact controller for a session's browser_cdp calls (fail-closed once bound). Local API# registration also requires the API server bearer key. developer_mode gates the privileged- # browser_cdp / browser_evaluate capabilities.+ # browser_cdp capabilities."extension_control": {"enabled": False, "developer_mode": False},},# Stale git worktree lifecycle (`hermes -w`, `/worktree new`, subagent isolation, Desktop). The@@ -2728,7 +2718,7 @@ DEFAULT_CONFIG = {# Extra ports detection probes for an external llama-server (besides 8080)."detect_ports": [],},- "_config_version": 51, # Config schema version - bump this when adding new required fields+ "_config_version": 52, # Config schema version - bump this when adding new required fields}@@ -2902,33 +2892,19 @@ OPTIONAL_ENV_VARS = {"BROWSERBASE_API_KEY": _tool("Browserbase API key for cloud browser (optional — local browser works without this)","Browserbase API key", "https://browserbase.com/",- tools=["browser_navigate", "browser_click"]),+ tools=["browser_exec"]),"BROWSERBASE_PROJECT_ID": _tool("Browserbase project ID (optional — only needed for cloud browser)","Browserbase project ID", "https://browserbase.com/",- tools=["browser_navigate", "browser_click"], password=False),+ tools=["browser_exec"], password=False),"BROWSER_USE_API_KEY": _tool("Browser Use API key for cloud browser (optional — local browser works without this)","Browser Use API key", "https://browser-use.com/",- tools=["browser_navigate", "browser_click"]),+ tools=["browser_exec"]),"FIRECRAWL_BROWSER_TTL": _tool("Firecrawl browser session TTL in seconds (optional, default 300)",- "Browser session TTL (seconds)", tools=["browser_navigate", "browser_click"],+ "Browser session TTL (seconds)", tools=["browser_exec"],password=False),- "AGENT_BROWSER_ENGINE": _env(- "Local browser engine: auto (default Chrome), lightpanda (faster, no screenshots; Browser Use mode "- "spawns lightpanda serve), chrome", "Browser engine (auto/lightpanda/chrome)",- url="https://lightpanda.io/docs/run-locally/installation/one-liner",- tools=["browser_exec", "browser_navigate", "browser_snapshot", "browser_click", "browser_vision"],- password=False, category="tool", advanced=True),- "CAMOFOX_URL": _tool(- "Camofox browser server URL for local anti-detection browsing (e.g. http://localhost:9377)",- "Camofox server URL", "https://github.com/jo-inc/camofox-browser",- tools=["browser_navigate", "browser_click"], password=False),- "CAMOFOX_API_KEY": _tool(- "Optional bearer token sent as Authorization header to a remote/authenticated Camofox "- "server", "Camofox API key", "https://github.com/jo-inc/camofox-browser",- tools=["browser_navigate", "browser_click"], advanced=True),"FAL_KEY": _tool("FAL API key for image and video generation", "FAL API key", "https://fal.ai/",tools=["image_generate", "video_generate"]),"KREA_API_KEY": _tool("Krea API key for Krea 3 and Krea 2 image generation",diff --git a/hermes_cli/config_migrations.py b/hermes_cli/config_migrations.pyindex 260d09a14dd..893f8161a89 100644--- a/hermes_cli/config_migrations.py+++ b/hermes_cli/config_migrations.py@@ -702,6 +702,104 @@ def _migrate_to_50(results: dict[str, Any], quiet: bool) -> None:" ✓ Removed security.tirith_* — the tirith scanner is no longer bundled with Hermes.")+# AGENT_BROWSER_* (read by agent-browser, which left Hermes) -> the browser.* key Hermes reads now.+_AGENT_BROWSER_ENV_KEYS = (+ ("AGENT_BROWSER_EXECUTABLE_PATH", "executable_path"),+ ("AGENT_BROWSER_PROFILE", "user_data_dir"),+ ("AGENT_BROWSER_ARGS", "chromium_args"),+ ("AGENT_BROWSER_HEADED", "headed"),+ ("AGENT_BROWSER_ENGINE", "engine"),+)+++def _agent_browser_env(home) -> dict[str, str]:+ """AGENT_BROWSER_* as *home* set them: its dotenv layers, then the process env for the launch home+ only (a served profile's env is the launch profile's, not its own)."""+ import os++ from hermes_cli.env_loader import resolve_home_dotenv+ from hermes_constants import get_routing_process_hermes_home, hermes_home_key++ dotenv = resolve_home_dotenv(home)+ launch = hermes_home_key(home) == hermes_home_key(get_routing_process_hermes_home())+ found = {}+ for name, _key in _AGENT_BROWSER_ENV_KEYS:+ value = (dotenv.get(name) or (os.environ.get(name) if launch else None) or "").strip()+ if value:+ found[name] = value+ return found+++def _inside_pm_store(value: str) -> bool:+ """pm (and the Docker image, from pm) exported its own Chromium as AGENT_BROWSER_EXECUTABLE_PATH:+ that is the default now, and a copied versioned store path would break at the next Chromium bump."""+ from pathlib import Path++ from pm import paths++ try:+ resolved = Path(value).expanduser().resolve()+ roots = {paths.store_root().resolve(), paths.writable_store_root().resolve()}+ except (OSError, RuntimeError):+ return False+ return any(resolved.is_relative_to(root) for root in roots)+++def _browser_value_from_env(key: str, value: str) -> Any:+ """The ``browser.<key>`` value an AGENT_BROWSER_* value meant, or None when it carries nothing."""+ if key == "chromium_args":+ return [arg.strip() for arg in re.split(r"[,\n]", value) if arg.strip()] or None+ if key == "headed":+ return True if value.lower() in ("1", "true", "yes", "on") else None+ if key == "engine":+ return value.lower() if value.lower() in ("auto", "lightpanda", "chrome") else None+ if key == "executable_path" and _inside_pm_store(value):+ return None+ return value+++def _migrate_to_52(results: dict[str, Any], quiet: bool) -> None:+ # 51 -> 52: agent-browser and the built-in browser_* tools left Hermes; browser_exec is the only+ # browser. `browser.backend` chose between the two, so it is dropped (an `off`, the opt-out of+ # browser_exec, gets a notice saying how to turn browsing off now). The AGENT_BROWSER_* settings+ # this home's .env gave agent-browser move to the browser.* keys the launcher reads, never over+ # a value already set. .env itself is left alone.+ from pathlib import Path++ from hermes_constants import get_hermes_home++ config = read_raw_config()+ browser = config.get("browser") if isinstance(config.get("browser"), dict) else {}+ added, messages = [], []+ if "backend" in browser:+ backend = browser.pop("backend")+ added.append("removed browser.backend")+ if isinstance(backend, str) and backend.strip().lower() == "off":+ messages.append(+ " ✓ Removed browser.backend: off — the built-in browser tools are gone and browser_exec is the "+ "browser now. To turn browsing off, disable the `browser` toolset in `hermes tools`.")+ moved = []+ for name, value in _agent_browser_env(Path(get_hermes_home())).items():+ key = dict(_AGENT_BROWSER_ENV_KEYS)[name]+ if browser.get(key) not in (None, "", []):+ continue+ new = _browser_value_from_env(key, value)+ if new is not None:+ browser[key] = new+ moved.append(f"{name} → browser.{key}")+ if moved:+ added.append(f"browser: {', '.join(moved)}")+ messages.append(f" ✓ Moved agent-browser settings from .env to config.yaml: {', '.join(moved)}")+ if not added:+ return+ config["browser"] = browser+ _persist_migration(config)+ results["config_added"].extend(added)+ if not quiet:+ for message in messages:+ print(message)++MIGRATIONS: tuple[tuple[int, Callable[[dict[str, Any], bool], None]], ...] = ((12, _migrate_to_12),(13, _migrate_to_13),@@ -847,6 +945,8 @@ MIGRATIONS: tuple[tuple[int, Callable[[dict[str, Any], bool], None]], ...] = ("admitted to the target profile's running gateway and tracked by receipt, so cron no ""longer runs (or times out) a Bot Chat turn of its own."),extra_guard=lambda raw: "bot_chat_delivery_timeout_seconds" in raw)),+ # 51 -> 52: browser.backend dropped, AGENT_BROWSER_* .env settings -> browser.* (see _migrate_to_52).+ (52, _migrate_to_52),)#: Steps triggered by a legacy key or identifier (a renamed or retired key, a removed plugin or@@ -858,7 +958,7 @@ MIGRATIONS: tuple[tuple[int, Callable[[dict[str, Any], bool], None]], ...] = (#: out: it clears OPENAI_MODEL from .env, a generic name Hermes never reads but the user's tools may.#: v41 is left out too: it rewrites profile SOUL.md on a heading match, an artifact whose#: provenance the config stamp says nothing about.-LEGACY_KEY_STEPS = frozenset({12, 14, 16, 17, 29, 33, 38, 39, 42, 43, 46, 50, 51})+LEGACY_KEY_STEPS = frozenset({12, 14, 16, 17, 29, 33, 38, 39, 42, 43, 46, 50, 51, 52})#: Legacy-key steps that run on every migration pass whatever the stamp says, because a stamp at#: or past their version does not prove they ran: unreleased builds of the gateway-runtime branchdiff --git a/tests/hermes_cli/test_config_migration_52_browser.py b/tests/hermes_cli/test_config_migration_52_browser.pynew file mode 100644index 00000000000..cba8e3effd4--- /dev/null+++ b/tests/hermes_cli/test_config_migration_52_browser.py@@ -0,0 +1,137 @@+"""Config v52: agent-browser and the built-in browser tools left Hermes.++browser.backend is dropped (``off`` gets a one-time notice); AGENT_BROWSER_* from a profile's own+.env (plus the process env for the launch home only) moves to browser.* keys that are still unset.+"""++import hermes_yaml as yaml+import pytest++from hermes_constants import reset_hermes_home_override, set_hermes_home_override++_AB_ENV = ("AGENT_BROWSER_EXECUTABLE_PATH", "AGENT_BROWSER_PROFILE", "AGENT_BROWSER_ARGS",+ "AGENT_BROWSER_HEADED", "AGENT_BROWSER_ENGINE")++[email protected](autouse=True)+def _clean_env(monkeypatch):+ for name in _AB_ENV:+ monkeypatch.delenv(name, raising=False)+++def _home(path, config, env=""):+ path.mkdir(parents=True, exist_ok=True)+ (path / "config.yaml").write_text(yaml.safe_dump(config), encoding="utf-8")+ (path / ".env").write_text(env, encoding="utf-8")+ return path+++def _raw(home):+ return yaml.safe_load((home / "config.yaml").read_text(encoding="utf-8"))+++def _migrate(home, *, quiet=False):+ from hermes_cli.config import migrate_config++ token = set_hermes_home_override(home)+ try:+ return migrate_config(interactive=False, quiet=quiet)+ finally:+ reset_hermes_home_override(token)+++def test_backend_off_is_dropped_with_a_notice(tmp_path, monkeypatch, capsys):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "launch"))+ home = _home(tmp_path / "a", {"_config_version": 51, "browser": {"backend": "off", "inactivity_timeout": 60}})+ _migrate(home)+ out = capsys.readouterr().out+ assert _raw(home)["browser"] == {"inactivity_timeout": 60}+ assert _raw(home)["_config_version"] == 52+ assert "browser_exec is the browser now" in out and "`browser` toolset in `hermes tools`" in out+ # Once: a second pass at v52 has nothing left to say.+ _migrate(home)+ assert "browser_exec" not in capsys.readouterr().out++[email protected]("value", ["", "browser-use", "Browser-Use", None])+def test_other_backend_values_are_dropped_silently(tmp_path, monkeypatch, capsys, value):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "launch"))+ home = _home(tmp_path / "a", {"_config_version": 51, "browser": {"backend": value, "headed": True}})+ _migrate(home)+ assert _raw(home)["browser"] == {"headed": True}+ assert "browser_exec" not in capsys.readouterr().out+++def test_unversioned_config_still_loses_backend(tmp_path, monkeypatch):+ """The installer seeds config.yaml without a stamp; a legacy key is legacy however old the file."""+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "launch"))+ home = _home(tmp_path / "a", {"browser": {"backend": "off"}})+ _migrate(home, quiet=True)+ assert "backend" not in (_raw(home).get("browser") or {})+++def test_dotenv_settings_move_to_unset_keys_only(tmp_path, monkeypatch):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "launch"))+ env = ("AGENT_BROWSER_EXECUTABLE_PATH=/opt/chrome/chrome\n"+ "AGENT_BROWSER_PROFILE=/data/profile\n"+ "AGENT_BROWSER_ARGS=--no-sandbox, --lang=de\n"+ "AGENT_BROWSER_HEADED=true\n"+ "AGENT_BROWSER_ENGINE=lightpanda\n")+ home = _home(tmp_path / "a", {"_config_version": 51, "browser": {"user_data_dir": "/mine"}}, env)+ results = _migrate(home, quiet=True)+ browser = _raw(home)["browser"]+ assert browser == {+ "executable_path": "/opt/chrome/chrome",+ "user_data_dir": "/mine", # already set: the user's value wins+ "chromium_args": ["--no-sandbox", "--lang=de"],+ "headed": True,+ "engine": "lightpanda",+ }+ assert any("AGENT_BROWSER_ARGS → browser.chromium_args" in item for item in results["config_added"])+ # .env is left as it was.+ assert (home / ".env").read_text(encoding="utf-8") == env+++def test_falsy_headed_and_unknown_engine_carry_nothing(tmp_path, monkeypatch):+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "launch"))+ home = _home(tmp_path / "a", {"_config_version": 51},+ "AGENT_BROWSER_HEADED=0\nAGENT_BROWSER_ENGINE=webkit\n")+ _migrate(home, quiet=True)+ assert not _raw(home).get("browser")+++def test_pm_store_chromium_path_is_not_pinned(tmp_path, monkeypatch):+ """pm (and the Docker image) exported its own Chromium under AGENT_BROWSER_EXECUTABLE_PATH; that is the+ default now, and a copied versioned store path would break at the next Chromium update."""+ from pm import paths++ store = tmp_path / "tools"+ monkeypatch.setenv("HERMES_RUNTIME_DIR", str(store))+ pm_binary = paths.store_root() / "chromium-1208" / "chrome-linux64" / "chrome"+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / "a"))+ home = _home(tmp_path / "a", {"_config_version": 51})+ monkeypatch.setenv("AGENT_BROWSER_EXECUTABLE_PATH", str(pm_binary))+ _migrate(home, quiet=True)+ assert "executable_path" not in (_raw(home).get("browser") or {})+++def test_profiles_are_islands_a_b_a(tmp_path, monkeypatch, capsys):+ """Each home is decided by its own files; the process env counts for the launch home only."""+ a = _home(tmp_path / "a", {"_config_version": 51, "browser": {"backend": "off"}},+ "AGENT_BROWSER_EXECUTABLE_PATH=/opt/a/chrome\n")+ b = _home(tmp_path / "b", {"_config_version": 51, "browser": {"inactivity_timeout": 300}})+ monkeypatch.setenv("HERMES_HOME", str(a)) # A is the launch home+ monkeypatch.setenv("AGENT_BROWSER_HEADED", "1") # e.g. a systemd unit for A++ _migrate(a)+ out_a = capsys.readouterr().out+ _migrate(b)+ out_b = capsys.readouterr().out+ _migrate(a)+ out_a2 = capsys.readouterr().out++ assert _raw(a)["browser"] == {"executable_path": "/opt/a/chrome", "headed": True}+ assert "browser_exec is the browser now" in out_a+ assert _raw(b)["browser"] == {"inactivity_timeout": 300}+ assert "browser_exec" not in out_b and "agent-browser" not in out_b+ assert "browser_exec" not in out_a2 and "agent-browser" not in out_a2