How bunwv architecture works
mainbunwv operates using a client-server model designed for high-performance browser automation via Bun:
- CLI Client: The
bunwvCLI sends HTTP requests to a background daemon via a Unix socket (located at/tmp/bunwv-*.sock, restricted tochmod 0600). - Daemon: A background process that manages a single
Bun.WebViewinstance. It listens for requests and manages the browser lifecycle. - Browser Engine: Uses
Bun.WebViewto drive WebKit on macOS, Chrome on Linux, or the native Windows engine.
Key Technical Features:
- Native Events: All selector and coordinate-based inputs are dispatched as native events (
isTrusted: true). - Auto-waiting: Selector-based methods automatically wait for elements to be attached, visible, stable, and unobscured before acting.
- Event Buffering: Navigation and CDP (Chrome DevTools Protocol) events are buffered using monotonic
seqcursors, allowing agents to poll for new events since their last interaction.