mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user