roboticus-browser 0.11.3

Headless browser automation via Chrome DevTools Protocol
Documentation
//! Browser backend abstraction.
//!
//! Enables pluggable browser backends — the native CDP implementation and
//! external CLI tools (e.g., `agent-browser`) both implement this trait.
//!
//! The trait operates at the `BrowserAction` level: callers dispatch actions
//! without knowing whether they're executed via CDP WebSocket, an external
//! process, or a mock.

use async_trait::async_trait;

use crate::actions::{ActionResult, BrowserAction};

/// A pluggable browser backend that can execute `BrowserAction` variants.
///
/// Implementations:
/// - `CdpBackend` — native Chrome DevTools Protocol (existing behavior)
/// - `AgentBrowserBackend` — external `agent-browser` CLI with `--json` mode
#[async_trait]
pub trait BrowserBackend: Send + Sync {
    /// Execute a browser action and return the result.
    async fn execute(&self, action: &BrowserAction) -> ActionResult;

    /// Human-readable backend name for provenance/logging.
    fn name(&self) -> &str;

    /// Whether the backend is currently available (process running, connection alive).
    fn is_available(&self) -> bool;
}