mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-07 02:51:50 +00:00
fix: _chromium_installed() now checks AGENT_BROWSER_EXECUTABLE_PATH and system Chrome
Before this fix, _chromium_installed() only searched Playwright-style chromium-* / chromium_headless_shell-* directories, which meant users with system Chrome or AGENT_BROWSER_EXECUTABLE_PATH configured still had all browser_* tools gated. Now checks three sources in priority order: 1. AGENT_BROWSER_EXECUTABLE_PATH env var (if set and points to a real binary) 2. System Chrome/Chromium via shutil.which() (google-chrome, chromium-browser, chrome) 3. Playwright browser cache (existing logic, kept as fallback) Closes #19294
This commit is contained in:
parent
c653f5dc3f
commit
45fd45103d
1 changed files with 28 additions and 5 deletions
|
|
@ -2757,17 +2757,40 @@ def _chromium_search_roots() -> List[str]:
|
||||||
def _chromium_installed() -> bool:
|
def _chromium_installed() -> bool:
|
||||||
"""Return True when a usable Chromium (or headless-shell) build is on disk.
|
"""Return True when a usable Chromium (or headless-shell) build is on disk.
|
||||||
|
|
||||||
|
Checks, in order:
|
||||||
|
|
||||||
|
1. ``AGENT_BROWSER_EXECUTABLE_PATH`` env var — the official way to point
|
||||||
|
agent-browser at a pre-installed Chrome/Chromium.
|
||||||
|
2. System Chrome/Chromium in PATH (``google-chrome``, ``chromium-browser``,
|
||||||
|
``chrome``).
|
||||||
|
3. Playwright's browser cache (current logic) — directories containing
|
||||||
|
``chromium-*`` or ``chromium_headless_shell-*``.
|
||||||
|
|
||||||
agent-browser (0.26+) downloads Playwright's chromium / headless-shell
|
agent-browser (0.26+) downloads Playwright's chromium / headless-shell
|
||||||
builds into ``PLAYWRIGHT_BROWSERS_PATH`` and won't start without them.
|
builds into ``PLAYWRIGHT_BROWSERS_PATH`` and won't start without at least
|
||||||
When the CLI is present but no browser build is, the first browser tool
|
one of the three above being present. Without a browser binary the CLI
|
||||||
call hangs for the full command timeout (often ~30s each) before
|
hangs on first use until the command timeout fires (often ~30s). Guarding
|
||||||
surfacing a useless error. Guarding the tool behind this check prevents
|
the tool behind this check prevents advertising a capability that will
|
||||||
advertising a capability that will fail at runtime.
|
fail at runtime.
|
||||||
"""
|
"""
|
||||||
global _cached_chromium_installed
|
global _cached_chromium_installed
|
||||||
if _cached_chromium_installed is not None:
|
if _cached_chromium_installed is not None:
|
||||||
return _cached_chromium_installed
|
return _cached_chromium_installed
|
||||||
|
|
||||||
|
# 1. AGENT_BROWSER_EXECUTABLE_PATH — explicit user-configured browser
|
||||||
|
ab_path = os.environ.get("AGENT_BROWSER_EXECUTABLE_PATH", "").strip()
|
||||||
|
if ab_path:
|
||||||
|
if os.path.isfile(ab_path) or shutil.which(ab_path):
|
||||||
|
_cached_chromium_installed = True
|
||||||
|
return True
|
||||||
|
|
||||||
|
# 2. System Chrome/Chromium in PATH (common names)
|
||||||
|
system_chrome = shutil.which("google-chrome") or shutil.which("chromium-browser") or shutil.which("chrome")
|
||||||
|
if system_chrome:
|
||||||
|
_cached_chromium_installed = True
|
||||||
|
return True
|
||||||
|
|
||||||
|
# 3. Playwright browser cache (legacy — chromium-* / chromium_headless_shell-* dirs)
|
||||||
for root in _chromium_search_roots():
|
for root in _chromium_search_roots():
|
||||||
if not root or not os.path.isdir(root):
|
if not root or not os.path.isdir(root):
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue