feat(browser): /browser connect — attach browser tools to live Chrome via CDP#1549
Merged
feat(browser): /browser connect — attach browser tools to live Chrome via CDP#1549
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
/browserslash 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
What happens on
/browser connect--remote-debugging-port=9222How it works
BROWSER_CDP_URLenv var overrides the backend selection inbrowser_tool.py_create_cdp_session()creates sessions using the CDP URL_get_cdp_override()is checked before local/Browserbase selectionagent-browser --cdpflag handles the actual CDP connection — no new dependenciesFiles Changed
tools/browser_tool.py— CDP override helpers + session creatorcli.py—_handle_browser_command()with connect/disconnect/statushermes_cli/commands.py—/browsercommand definitiontests/hermes_cli/test_commands.py— updated expected commands setTest Plan