Module browser_api

Module browser_api 

Source
Expand description

Browser-pane DOM API (/agentmux/browser/*).

External clients (test harnesses, automation scripts) use these endpoints to query and mutate the DOM inside a running browser pane without depending on screen-pixel geometry. Implemented as a thin proxy over CEF’s Chrome DevTools Protocol (CDP) server on remote_debugging_port (9223 dev / 9222 release).

Phase 1 implements only browser.query — a CSS-selector lookup that returns matching elements with their tag, text, attrs, and bounding rect. Subsequent phases layer on focus_info, eval, screenshot, and the write methods (click_element, dispatch_key, …). See docs/specs/SPEC_BROWSER_DOM_API.md and docs/specs/PLAN_BROWSER_DOM_API.md.

All routes require Authorization: Bearer <ipc_token> — same scheme as the existing /ipc route in crate::ipc.

Modules§

cdp
Minimal Chrome DevTools Protocol (CDP) WebSocket client.
resolver
Resolve block_id → CDP target id.
routes
Axum route handlers for /agentmux/browser/*.
types
Request/response types for the browser DOM API.

Structs§

BrowserApiState
Shared state for the browser API — primarily the CDP target cache (block_id → target_id). Lives inside AppState and is lazily populated on first resolve per block.

Functions§

register_routes
Register /agentmux/browser/* routes on the given axum Router. Called from ipc::start_ipc_server alongside the existing /ipc + /health routes.