chore: update agent-browser dependency and clean up stale daemon processes

- Upgraded the agent-browser dependency from version 0.7.6 to 0.13.0 in package.json.
- Added functionality to kill stale agent-browser daemon processes in browser_tool.py to prevent orphaned instances from previous runs.
This commit is contained in:
teknium1
2026-02-20 23:40:42 -08:00
parent 70dd3a16dc
commit c48817f69b
2 changed files with 31 additions and 1 deletions

View File

@@ -16,7 +16,7 @@
}, },
"homepage": "https://github.com/NousResearch/Hermes-Agent#readme", "homepage": "https://github.com/NousResearch/Hermes-Agent#readme",
"dependencies": { "dependencies": {
"agent-browser": "^0.7.6" "agent-browser": "^0.13.0"
}, },
"engines": { "engines": {
"node": ">=18.0.0" "node": ">=18.0.0"

View File

@@ -642,11 +642,39 @@ def _get_browserbase_config() -> Dict[str, str]:
} }
_stale_daemons_cleaned = False
def _kill_stale_agent_browser_daemons():
"""Kill any orphaned agent-browser daemon processes from previous runs."""
global _stale_daemons_cleaned
if _stale_daemons_cleaned:
return
_stale_daemons_cleaned = True
try:
result = subprocess.run(
["pgrep", "-f", "agent-browser.*daemon"],
capture_output=True, text=True, timeout=5
)
pids = result.stdout.strip().split()
if pids and pids[0]:
for pid in pids:
try:
os.kill(int(pid), signal.SIGTERM)
except (ProcessLookupError, ValueError, PermissionError):
pass
if not os.getenv("HERMES_QUIET"):
print(f"[browser_tool] Cleaned up {len(pids)} stale daemon process(es)", file=sys.stderr)
except Exception:
pass
def _find_agent_browser() -> str: def _find_agent_browser() -> str:
""" """
Find the agent-browser CLI executable. Find the agent-browser CLI executable.
Checks in order: PATH, local node_modules/.bin/, npx fallback. Checks in order: PATH, local node_modules/.bin/, npx fallback.
Also kills any stale daemon processes from prior runs on first call.
Returns: Returns:
Path to agent-browser executable Path to agent-browser executable
@@ -654,6 +682,8 @@ def _find_agent_browser() -> str:
Raises: Raises:
FileNotFoundError: If agent-browser is not installed FileNotFoundError: If agent-browser is not installed
""" """
_kill_stale_agent_browser_daemons()
# Check if it's in PATH (global install) # Check if it's in PATH (global install)
which_result = shutil.which("agent-browser") which_result = shutil.which("agent-browser")
if which_result: if which_result: