mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +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.