//! The Browser abstraction — the whole product sits behind this trait.
/// One click/type/navigation step. The mock implements it; a real
/// Chromium/CDP adapter lands later behind the same contract.
pub trait Browser: Send {
fn goto(&mut self, url: &str) -> Result<Page, BrowserError>;
fn click(&mut self, selector: &str) -> Result<Page, BrowserError>;
fn typing(&mut self, selector: &str, text: &str) -> Result<Page, BrowserError>;
fn screenshot(&mut self) -> Result<Vec<u8>, BrowserError>;
/// Naive text snapshot for the agent's working memory.
fn text(&self) -> String;
}
#[derive(Debug, Clone)]
pub struct Page {
pub url: String,
pub title: String,
pub links: Vec<String>,
pub screenshot: Option<Vec<u8>>,
}
#[derive(Debug, Clone)]
pub enum BrowserError {
// Failures are variants, never strings: agents act on what they can match.
Navigation(String),
NoSuchElement(String),
Budget,
}