mirror of
https://github.com/epiral/bb-browser.git
synced 2026-09-14 13:45:45 +08:00
94c94b7c4e
Monitoring commands (network, console, errors, trace) are broken in direct CDP mode because each CLI invocation is a new short-lived process that cannot accumulate events over time. This introduces a long-running background monitor process that maintains a persistent CDP connection and collects events: - cdp-monitor-state.ts: MonitorState class extracted from cdp-client.ts event handling logic (Network.*, Runtime.*, trace) - cdp-monitor.ts: standalone Node.js process that connects to Chrome via CDP, attaches to all page targets, and serves an HTTP API on 127.0.0.1 with bearer-token auth - monitor-manager.ts: CLI-side lifecycle management (spawn, health check, shutdown, command forwarding) - client.ts: routes monitor actions (network/console/errors/trace) through the monitor with graceful fallback to direct CDP - tsup.config.ts: adds cdp-monitor as a build entry point The monitor auto-discovers new tabs, writes PID/port/token files to ~/.bb-browser/, and auto-exits after 30 minutes of inactivity. cdp-client.ts is intentionally left untouched to avoid regressions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>