Skip to main content

glass/
lib.rs

1//! Glass — lightweight local browser control for Chrome and Chromium.
2//!
3//! Drives Chrome or Chromium directly through the Chrome DevTools Protocol
4//! (CDP), without Playwright, WebDriver, or an embedded browser runtime.
5//!
6//! # Quick start
7//!
8//! Build a session with [`SessionOptions`], start Chrome, navigate, and close
9//! the session when the work is complete:
10//!
11//! ```rust,no_run
12//! use glass::{BrowserSession, SessionOptions};
13//!
14//! # async fn run() -> glass::BrowserResult<()> {
15//! let options = SessionOptions::builder().build()?;
16//! let session = BrowserSession::start(&options).await?;
17//! let page = session.navigate("https://example.com").await?;
18//! println!("{}", page.url);
19//! session.close().await?;
20//! # Ok(())
21//! # }
22//! ```
23//!
24//! The [`browser`] module contains the reusable Rust API. The [`cli`] module
25//! backs the `glass` binary, [`mcp`] exposes the MCP stdio server, and [`tui`]
26//! provides the terminal interface. User-facing guides are available in the
27//! repository's [`docs`](https://github.com/wanazhar/glass/tree/main/docs).
28//!
29//! # Cargo features
30//!
31//! - `visual-compare` enables PNG comparison helpers for screenshot checks.
32//! - `fuzzing` enables test-oriented fuzzing hooks and is not needed by normal
33//!   applications.
34//!
35//! # Modules
36//!
37//! - [`browser`] — Chrome lifecycle, CDP client, DOM/accessibility parsing,
38//!   mouse movement, security policy, profiles, and the central
39//!   [`BrowserSession`].
40//! - [`cli`] — Clap argument definitions and command dispatch.
41//! - [`mcp`] — JSON-RPC/MCP stdio server for MCP-compatible clients.
42//! - [`tui`] — Ratatui terminal interface.
43
44/// Browser control modules and the reusable [`browser::BrowserSession`] API.
45pub mod browser;
46/// Versioned Glass protocol and capability negotiation.
47pub mod capabilities;
48/// Command-line argument definitions and dispatch helpers.
49pub mod cli;
50/// Local Unix-socket daemon lifecycle and MCP bridge.
51pub mod daemon;
52/// Validated extension metadata and permission boundaries.
53pub mod extensions;
54/// MCP stdio server, prompts, resources, and tool dispatch.
55pub mod mcp;
56/// Transport-neutral versioned request and response envelopes.
57pub mod protocol;
58/// Versioned browser-free reliability scenario contracts.
59pub mod reliability;
60/// Bounded browser execution for reliability scenarios and replay evidence.
61pub mod reliability_runner;
62/// Ratatui terminal interface.
63pub mod tui;
64
65// Keep the most common embedding types on the crate root. Lower-level and
66// capability-specific APIs remain organized under `glass::browser`.
67pub use browser::{
68    AccessibilityDiffSummary, ActionContractError, ActionFailureKind, ActionKind, ActionOutcome,
69    ActionStatus, ActionVerificationEvidence, BrowserResult, BrowserSession, KnowledgeAssessment,
70    KnowledgeAssessmentSignal, KnowledgeAssessmentStatus, KnowledgeConfidence,
71    KnowledgeInvalidation, KnowledgeLifecycleEvent, KnowledgeLookupContext, KnowledgeLookupOptions,
72    KnowledgeObservationMode, KnowledgeObservationReport, KnowledgeProfileScope,
73    KnowledgePurgeResult, KnowledgeRecord, KnowledgeRecordBuildOptions, KnowledgeRecordKind,
74    KnowledgeScope, KnowledgeSignalKind, KnowledgeSource, KnowledgeStore, KnowledgeStoreChange,
75    KnowledgeStoreError, KnowledgeStoreLimits, KnowledgeStoreSnapshot, KnowledgeStoreStats,
76    KnowledgeValidationError, NavigationOutcome, PageInfo, SessionOptions, SessionOptionsBuilder,
77    WORKFLOW_SCHEMA_VERSION, WorkflowBudgets, WorkflowCheckpoint, WorkflowCheckpointPage,
78    WorkflowCheckpointStep, WorkflowDefinition, WorkflowInput, WorkflowOutput,
79    WorkflowOutputDeclaration, WorkflowOutputSource, WorkflowResumeError, WorkflowResumePlan,
80    WorkflowRunResult, WorkflowRunStatus, WorkflowStep, WorkflowStepRecord, WorkflowStepState,
81    WorkflowTerminalProof, WorkflowTrace, WorkflowTraceEvent, WorkflowTransactionClass,
82    WorkflowValidationError, WorkflowValueType,
83};