Skip to content

feat(browser): /browser connect — attach browser tools to live Chrome via CDP#1549

Merged
teknium1 merged 4 commits intomainfrom
hermes/hermes-6360cdf9
Mar 16, 2026
Merged

feat(browser): /browser connect — attach browser tools to live Chrome via CDP#1549
teknium1 merged 4 commits intomainfrom
hermes/hermes-6360cdf9

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

Summary

Adds a /browser slash command that lets users connect the browser tools to their live Chrome browser via Chrome DevTools Protocol (CDP). Inspired by OpenClaw's browser profile system.

Usage

/browser connect             # Connect to Chrome on localhost:9222
/browser connect ws://h:port # Custom CDP endpoint
/browser disconnect          # Revert to default mode
/browser status              # Show current mode + connectivity test

What happens on /browser connect

  1. Sets the browser backend to the user's live Chrome
  2. Shows platform-specific instructions for launching Chrome with --remote-debugging-port=9222
  3. Tests port connectivity immediately (✓ reachable / ⚠ not reachable)
  4. Injects a context message so the model knows it's controlling a live browser ("be mindful of open tabs, ask before navigating away")

How it works

  • BROWSER_CDP_URL env var overrides the backend selection in browser_tool.py
  • New _create_cdp_session() creates sessions using the CDP URL
  • _get_cdp_override() is checked before local/Browserbase selection
  • The existing agent-browser --cdp flag handles the actual CDP connection — no new dependencies

Files Changed

  • tools/browser_tool.py — CDP override helpers + session creator
  • cli.py_handle_browser_command() with connect/disconnect/status
  • hermes_cli/commands.py/browser command definition
  • tests/hermes_cli/test_commands.py — updated expected commands set

Test Plan

pytest tests/hermes_cli/test_commands.py tests/tools/test_browser*.py -n0 -q  # 41 passed
… via CDP

Add /browser slash command for connecting browser tools to the user's
live Chrome instance via Chrome DevTools Protocol:

  /browser connect       — connect to Chrome on localhost:9222
  /browser connect ws://host:port  — custom CDP endpoint
  /browser disconnect    — revert to default (headless/Browserbase)
  /browser status        — show current browser mode + connectivity

When connected:
- All browser tools (navigate, snapshot, click, etc.) control the
  user's real Chrome — logged-in sessions, cookies, open tabs
- Platform-specific Chrome launch instructions are shown
- Port connectivity is tested immediately
- A context message is injected so the model knows it's controlling
  a live browser and should be mindful of user's open tabs

Implementation:
- BROWSER_CDP_URL env var drives the backend selection in browser_tool.py
- New _create_cdp_session() creates sessions using the CDP override
- _get_cdp_override() checked before local/Browserbase selection
- Existing agent-browser --cdp flag handles the actual CDP connection

Inspired by OpenClaw's browser profile system.
…gger

When /browser connect detects that port 9222 isn't open, it now:
1. Finds Chrome/Chromium/Brave/Edge on the system (macOS app bundles
   or Linux PATH lookup)
2. Launches it with --remote-debugging-port=9222 (detached)
3. Waits up to 5 seconds for the port to come up
4. Falls back to manual instructions if auto-launch fails

This means GUI-only users can just type /browser connect without
needing to know about terminal flags or Chrome launch commands.
Updated the injected context message to tell the model to await the
user's instruction before operating the browser. Typical flow is:
user opens Chrome → logs into sites → /browser connect → tells the
agent what to do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant