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/// Experimental bounded browser-evidence extraction contracts.
55pub mod extraction;
56/// MCP stdio server, prompts, resources, and tool dispatch.
57pub mod mcp;
58/// Transport-neutral versioned request and response envelopes.
59pub mod protocol;
60/// Versioned browser-free reliability scenario contracts.
61pub mod reliability;
62/// Bounded browser execution for reliability scenarios and replay evidence.
63pub mod reliability_runner;
64/// Bounded agent-facing response projections and local result artifacts.
65pub mod results;
66/// Browser-free deterministic Task Protocol execution-plan compiler.
67pub mod task_compiler;
68/// Strict, bounded authored Task Protocol v1 inputs.
69pub mod task_protocol;
70/// Ratatui terminal interface.
71pub mod tui;
72/// Experimental draft Web IR reconciliation and validation.
73pub mod web_ir;
74
75// Keep the most common embedding types on the crate root. Lower-level and
76// capability-specific APIs remain organized under `glass::browser`.
77pub use browser::{
78    AccessibilityDiffSummary, ActionContractError, ActionFailureKind, ActionKind, ActionOutcome,
79    ActionStatus, ActionVerificationEvidence, BrowserResult, BrowserSession, KnowledgeAssessment,
80    KnowledgeAssessmentSignal, KnowledgeAssessmentStatus, KnowledgeConfidence,
81    KnowledgeInvalidation, KnowledgeLifecycleEvent, KnowledgeLookupContext, KnowledgeLookupOptions,
82    KnowledgeObservationMode, KnowledgeObservationReport, KnowledgeProfileScope,
83    KnowledgePurgeResult, KnowledgeRecord, KnowledgeRecordBuildOptions, KnowledgeRecordKind,
84    KnowledgeScope, KnowledgeSignalKind, KnowledgeSource, KnowledgeStore, KnowledgeStoreChange,
85    KnowledgeStoreError, KnowledgeStoreLimits, KnowledgeStoreSnapshot, KnowledgeStoreStats,
86    KnowledgeValidationError, NavigationOutcome, PageInfo, SessionOptions, SessionOptionsBuilder,
87    WORKFLOW_SCHEMA_VERSION, WorkflowBudgets, WorkflowCheckpoint, WorkflowCheckpointPage,
88    WorkflowCheckpointStep, WorkflowDefinition, WorkflowInput, WorkflowOutput,
89    WorkflowOutputDeclaration, WorkflowOutputSource, WorkflowResumeError, WorkflowResumePlan,
90    WorkflowRunResult, WorkflowRunStatus, WorkflowStep, WorkflowStepRecord, WorkflowStepState,
91    WorkflowTerminalProof, WorkflowTrace, WorkflowTraceEvent, WorkflowTransactionClass,
92    WorkflowValidationError, WorkflowValueType,
93};
94
95pub use task_protocol::{
96    GlassTask, TASK_PROTOCOL_SCHEMA_VERSION, TaskAmbiguityPolicy, TaskKind, TaskLimits,
97    TaskPostcondition, TaskPostconditionKind, TaskProtocolError, TaskRevisionPolicy, TaskRiskClass,
98    TaskScope,
99};
100
101pub use task_compiler::{
102    TASK_PLAN_SCHEMA_VERSION, TaskCompilationError, TaskExecutionPlan, TaskPlanOperation,
103    TaskPlanStep, compile_task,
104};
105
106pub use protocol::{
107    TASK_COMPILE_OPERATION, TaskCompilePayload, TaskCompileResult, TaskValidationResult,
108    compile_task_request, compile_task_result,
109};
110
111/// Re-export the experimental bounded extraction contract for embedding callers.
112pub use extraction::{
113    EXTRACTION_CONTRACT_SCHEMA_VERSION, EvidenceCoverage, EvidenceFact, EvidenceQuality,
114    EvidenceRelationshipHint, EvidenceSource, ExtractionBudgets, ExtractionContractError,
115    ExtractionEvidence, ExtractionEvidenceLimits, ExtractionRequest, ExtractionScope,
116    MAX_EXTRACTION_DEPTH, MAX_EXTRACTION_DURATION_MS, MAX_EXTRACTION_NODES,
117    MAX_EXTRACTION_OUTPUT_BYTES, MAX_EXTRACTION_TEXT_BYTES, extract_page_context,
118};
119
120/// Re-export the experimental Web IR draft types for embedding callers.
121pub use web_ir::{
122    DraftChangeKind, DraftEntity, DraftEntityChange, DraftEntityContinuity,
123    DraftEntityContinuityStatus, DraftEntityKind, DraftFixtureExpectation, DraftRelationship,
124    DraftRelationshipChange, DraftRelationshipHintDiagnostic, DraftRelationshipKind,
125    GlassWebIrDiff, GlassWebIrDraft, RelationshipHintDiagnosticStatus, WEB_IR_DRAFT_SCHEMA_VERSION,
126    WebIrValidationError, reconcile_evidence,
127};