fix(browser): auto-start CDP bridge on BrowserTool init

The CDP bridge server (ws://localhost:9223 + http://localhost:9224)
was never starting because the entrypoint loader instantiates
BrowserTool directly, bypassing the package-level register_tools()
which called start_cdp_bridge().

Now BrowserTool.__init__() auto-starts the bridge when backend is
not "playwright", ensuring the browser extension can connect and
be used as the preferred backend over headless Playwright.
This commit is contained in:
2026-03-06 00:32:42 -08:00
parent d2c6d50557
commit 237c801a7b
@@ -672,6 +672,17 @@ class BrowserTool(BaseTool):
self.backend = backend or get_backend()
self.timeout = 30000
# Auto-start CDP bridge for browser extension integration.
# This enables the extension (Chrome/Firefox/Safari) to connect
# and be preferred over Playwright when backend != "playwright".
if self.backend != "playwright":
try:
from hanzo_tools.browser import start_cdp_bridge, CDP_BRIDGE_AVAILABLE
if CDP_BRIDGE_AVAILABLE:
start_cdp_bridge()
except Exception:
pass
@property
def description(self) -> str:
return """Complete browser automation with full Playwright API.