feat: wire ensure_dependency into TUI and browser tool call sites

Before: missing node → hard exit; missing browser → FileNotFoundError.
After: both try ensure_dependency() first, which prompts interactively
and delegates installation to install.sh --ensure.

ripgrep and ffmpeg already degrade gracefully (grep fallback, skip
conversion) so they don't need wiring.

Also documents the design rationale in dep_ensure.py: detection and
prompting live in Python (portable, instant, UX-integrated); only
the actual installation delegates to install.sh (1900 lines of
battle-tested OS/package-manager logic).
This commit is contained in:
alt-glitch 2026-05-15 13:28:21 +00:00 committed by Teknium
parent e38a478c05
commit c57709a3d6
3 changed files with 36 additions and 3 deletions

View file

@ -1703,7 +1703,23 @@ def _find_agent_browser() -> str:
_agent_browser_resolved = True
return _cached_agent_browser
# Nothing found — cache the failure so subsequent calls don't re-scan.
# Nothing found — try lazy installation before giving up.
try:
from hermes_cli.dep_ensure import ensure_dependency
if ensure_dependency("browser"):
recheck = shutil.which("agent-browser")
if not recheck and extended_path:
recheck = shutil.which("agent-browser", path=extended_path)
if not recheck:
hermes_nm = str(get_hermes_home() / "node_modules" / ".bin")
recheck = shutil.which("agent-browser", path=hermes_nm)
if recheck:
_cached_agent_browser = recheck
_agent_browser_resolved = True
return recheck
except Exception:
pass
_agent_browser_resolved = True
raise FileNotFoundError(
"agent-browser CLI not found. Install it with: "