Skip to main content

dravr_browser/
lib.rs

1// ABOUTME: Headless-Chrome automation primitives shared across dravr crates
2// ABOUTME: Launch, persistent profiles, stealth, CDP input, cookie sessions, streaming capture, vision seam
3//
4// SPDX-License-Identifier: MIT OR Apache-2.0
5// Copyright (c) 2026 dravr.ai
6
7#![deny(unsafe_code)]
8
9//! # dravr-browser
10//!
11//! Reusable headless-Chrome automation primitives extracted so multiple dravr
12//! crates share one battle-tested browser stack instead of each re-rolling it.
13//!
14//! ## What's here
15//!
16//! - [`launch`] — launch Chrome with a **persistent profile** (cookies survive
17//!   across runs) or attach to an external Chrome via CDP.
18//! - [`stealth`] — inject anti-detection + an optional network-capture hook,
19//!   including a streaming ([`stealth::StealthOptions::capture_stream`]) variant
20//!   that tees SSE bodies as they arrive.
21//! - [`capture`] — read the capture buffer and parse SSE `data:` payloads.
22//! - [`input`] — CDP mouse/keyboard input and DOM helpers.
23//! - [`session`] — capture/inject cookie sessions ([`session::AuthSession`]).
24//! - [`vision`] — the [`vision::VisionAnalyzer`] seam consumers implement to
25//!   supply screenshot analysis without this crate depending on any LLM.
26//!
27//! This crate is intentionally LLM-agnostic: it never depends on a concrete
28//! model crate, so consumers (which may *be* LLM crates) avoid a dependency
29//! cycle.
30
31/// Error type for browser automation.
32pub mod error;
33
34/// Chrome launch + persistent-profile management.
35pub mod launch;
36
37/// Anti-detection stealth + optional network capture hook.
38pub mod stealth;
39
40/// Reading the capture buffer and parsing SSE bodies.
41pub mod capture;
42
43/// CDP-based input and DOM helpers.
44pub mod input;
45
46/// Cookie-based session capture/injection.
47pub mod session;
48
49/// The vision-LLM seam.
50pub mod vision;
51
52/// JavaScript string-escaping utilities for CDP evaluate calls.
53pub mod js_utils;
54
55/// Process-wide browser-teardown signal for WS-reset log suppression.
56pub mod teardown_signal;
57
58// Re-export the underlying chromiumoxide handles so consumers can name them
59// without taking a direct chromiumoxide dependency (keeping versions in lockstep).
60pub use chromiumoxide::{Browser, Page};
61
62pub use capture::{parse_sse_data, read_last_capture, CaptureState};
63pub use error::{BrowserError, BrowserResult};
64pub use input::{
65    cdp_click_at, cdp_insert_text, cdp_select_all_delete, click_element, element_exists,
66    fill_input_field, get_element_center, read_visible_text,
67};
68pub use launch::{
69    connect_browser, launch_browser, open_page_with_stealth, BrowserLaunchConfig, CONNECT_URL_ENV,
70};
71pub use session::{capture_session, generate_session_id, inject_cookies, AuthSession, CookieData};
72pub use stealth::{apply_stealth, StealthOptions, CAPTURE_GLOBAL};
73pub use teardown_signal::{is_in_progress as is_browser_teardown_in_progress, TeardownGuard};
74pub use vision::{VisionAnalyzer, VisionError};