mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-26 11:49:36 +00:00
Adds bidi_client.py — a WebDriver BiDi client over WebSocket to Firefox 129+ / Chrome 124+ at --remote-debugging-port=9222. This is the "trusted input" backend that complements the existing WebExtension scripting backend (the cdp_bridge_server WS to the extension). The extension produces synthetic events with isTrusted=false, which strict frameworks (Drupal AJAX, certain React libraries, security-aware sites) reject. BiDi via input.performActions produces real browser input with isTrusted=true that ALL frameworks honor because they ARE the real browser events. Methods implemented: - probe() auto-detect at /json/version - connect() / close() WebSocket session lifecycle - list_contexts() browsingContext.getTree - find_context_by_url() locate tab by URL substring - navigate(ctx, url) browsingContext.navigate - capture_screenshot(ctx) browsingContext.captureScreenshot - script_evaluate(ctx, js) script.evaluate in page context - input_mouse_click(ctx,x,y) input.performActions — TRUSTED click - input_double_click double-click composite - input_key_press input.performActions key - input_insert_text trusted keyboard typing - click_selector(ctx, sel) composite: eval rect + trusted click Architecture: decomplected, three layers. Layer 1 = wire transport (WebSocket JSON-RPC). Layer 2 = canonical primitives (input.performActions / browsingContext.* / script.evaluate). Layer 3 = ergonomic aliases (click_selector composite). Integration into cdp_bridge_server.py — auto-detect on startup, route BiDi.* methods, optionally route Input.dispatchMouseEvent and hanzo.click to BiDi backend when available — is the next step. To enable BiDi in a Firefox session: open -a "Firefox Developer Edition" --args --remote-debugging-port=9222 The bridge will probe http://localhost:9222/json/version on startup; if BiDi is available it advertises BiDi.* in its capabilities.
hanzo-tools-browser
Browser automation tools for Hanzo MCP using Playwright.
Installation
pip install hanzo-tools-browser
Tools
browser - Complete Playwright API
70+ browser actions for full automation.
Navigation:
browser(action="navigate", url="https://example.com")
browser(action="go_back")
browser(action="reload")
Input:
browser(action="click", selector="button.submit")
browser(action="fill", selector="input[name=email]", text="[email protected]")
browser(action="type", selector="textarea", text="Hello")
Touch/Mobile:
browser(action="tap", selector=".button")
browser(action="swipe", selector=".carousel", direction="left")
browser(action="emulate", device="mobile") # or tablet, laptop
Assertions:
browser(action="expect_visible", selector=".modal")
browser(action="expect_text", selector="h1", expected="Welcome")
browser(action="expect_url", expected="*/dashboard*")
Content:
browser(action="get_text", selector=".content")
browser(action="screenshot", full_page=True)
browser(action="pdf")
Parallel Agents:
# Each agent gets isolated session
browser(action="new_context") # Separate cookies/storage
Device Presets:
mobile- iPhone-like (390x844, touch)tablet- iPad-like (1024x1366, touch)laptop- MacBook-like (1440x900)iphone_14,pixel_7,ipad_pro, etc.
License
MIT