lexmount/moli

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

Moli is an open-source, production-ready headless browser built specifically for AI agents. "Headless" means it runs without a visible window — it fetches and processes web pages in the background, which is exactly what AI agents need when they browse the web, extract content, or automate tasks.

Core Idea: Structure First, Pixels on Demand

Most browser automation doesn't actually need to see the page — it needs the page's structure: the HTML, the DOM (the document's object model), text content, and JavaScript state. Traditional browsers constantly render everything visually, which is expensive. Moli flips this: it treats the DOM and style state as the single source of truth, and only performs visual layout or painting when a task genuinely requires it.

Agent request What Moli does
Extract HTML/Markdown, query the DOM, run JS Reads browser state directly — no layout or paint triggered
Read an element's position, hit-test coordinates, send mouse input Runs one layout calculation, keeps only the latest frozen layout tree
Capture a screenshot Rebuilds from current DOM/style, renders a fresh frame, discards paint state after use
Poll a screencast (video-like stream) Compares generation metadata only; unchanged state emits no frame, changed state emits one fresh frame

This design makes Moli fast (most requests skip visual work entirely) and resource-efficient (it doesn't continuously maintain a fully rendered visual state).

What It Does

  • Fetches and extracts web pages — the CLI can output HTML, Markdown, JSON, or a compact "semantic tree" (a model-friendly text representation of page structure)
  • Searches the web and automates browser tasks
  • Produces visual output on demand — screenshots (viewport or full-page PNG) and PDFs, but only when you explicitly ask with the --layout flag
  • Runs a unified automation server — one endpoint serves all three standard protocols: CDP (Chrome DevTools Protocol), WebDriver Classic, and WebDriver BiDi. No separate driver binaries needed; tools like Playwright can connect directly

How to Use It

Quick start: Give your AI agent a prompt that tells it to install the skills from the repo, download the prebuilt binary, and fetch a URL. There are also one-line installers for Linux/macOS (curl script) and Windows (PowerShell).

CLI examples:

# Extract a page as Markdown
moli fetch --dump markdown --wait done https://example.com

# Get a compact semantic tree
moli fetch --dump semantic_tree_text --wait-selector body https://example.com

# Take a screenshot (requires --layout)
moli fetch --layout --dump screenshot https://example.com > page.png

# Generate a PDF
moli fetch --layout --dump pdf https://example.com > page.pdf

Automation server:

moli serve                    # DOM-first workloads
moli serve --layout           # Adds real geometry, input, screenshots
moli serve --layout --resource  # Also fetches images, fonts, media, etc.

Cost Controls (Explicit Opt-In)

Expensive operations are never on by default. The default mode uses LayoutPolicy::Mock — deterministic placeholder geometry with no real layout or paint. You opt in with flags:

  • --layout — real layout, geometry, hit-testing, coordinate input, screenshots, screencast
  • --resource — fetch all optional visual/media resource families (or individual flags: --image, --font, --audio, --video, --media, --text-track)
  • --profile-dir, --http-cache-dir, --cookie — selectively enable persistence

Layout is an on-demand snapshot, not continuously maintained state. The first geometry request builds a working layout tree from the current DOM/style, freezes it into an immutable FrozenLayoutTree, and discards the working tree. Screenshots always rebuild fresh. Paint results are never reused.

Architecture

Moli is a standalone browser kernel written in Rust — not a Chromium wrapper. It has its own ownership and lifecycle rules and relies on:

  • libcurl — network transport
  • html5ever — HTML parsing
  • rusty_v8 / V8 — JavaScript execution
  • Servo/Stylo — selectors, CSS cascade, computed style
  • Taffy + Parley — box and text layout
  • AnyRender/Vello CPU, usvg, Rust image ecosystem — software rendering

There's no incrementally maintained layout tree, no damage graph, no retained display list, no GPU compositor, and no persistent window.

Performance (from the README's benchmarks)

Mixed public-web crawl test (192 URLs, success = meaningful content after JS runs):

Browser Success rate Median time Median memory
Moli 53.6% 1.43 s 73 MiB
Chrome Headless 52.6% 1.43 s 773 MiB
Lightpanda 44.3% 0.97 s 40 MiB
Obscura 29.7% 1.30 s 39 MiB

Lexbench-Headless-Browser (1,308 comparable tasks): Moli passed 81.88%, ahead of Kitesurf (62.08%), Lightpanda (53.29%), Obscura (44.88%); Chrome reached 99.85%. In a separate 557-task resource comparison, Moli used ~15% of Chrome's CPU time (100.6 ms vs 687 ms) and ~13% of its peak memory (92 MiB vs 697 MiB).

WPT tests: One full run passed 1.612 million tests in the current WPT selection used to validate Moli's agent-browser scope.

Current Capabilities

  • Complete web runtime — streaming HTML parsing, native DOM, V8 JavaScript, modules/timers/microtasks/events, iframes and workers, CSS cascade, Fetch/XHR/WebSocket, cookies, WebCrypto, profile-scoped storage (localStorage, IndexedDB, OPFS)
  • Extraction-optimized outputs — HTML, Markdown, JSON, semantic text trees, frame-aware serialization, with selector/script/response waits and network tracing
  • Unified automation binary — CDP, WebDriver Classic, WebDriver BiDi share the same kernel; no separate ChromeDriver, geckodriver, or browser installation needed
  • Real visual capabilities on demand — with --layout: complete box construction, Taffy layout, Parley text layout, layout-backed hit-testing/input, viewport screenshots, low-frequency CPU-rendered DevTools screencast frames
  • Controllable operational options — profiles, cookies, HTTP cache, proxies, resource families, connection limits, timeouts, private-network policy, user-agent overrides, diagnostic logging, network diagnostics

Relationship with Lexmount

Moli is Lexmount's open-source headless browser. Lexmount Browser is a separate managed cloud runtime and control plane built around it. The open-source headless browser is fully usable without Lexmount Browser.

Project Scope & Boundaries

Moli is production-ready for agent-browser scenarios and under active development. Intentional boundaries:

  • No GUI browser, persistent window, GPU compositor, or retained multi-frame paint architecture
  • Does not pursue pixel-for-pixel parity with Chrome; no high-fidelity Canvas/WebGL/media playback
  • --layout supports software screenshots and native CDP/CLI PDF with embedded fonts, but not every Chrome screenshot or print mode
  • Unsupported protocol paths return explicit errors — Moli never pretends an action, event, or visual result occurred when it didn't

License

Dual-licensed under Apache License 2.0 or MIT License, at your option (unless a file/directory states otherwise). Third-party components remain under their own licenses; machine-readable metadata is in license-metadata.json.

Related

  • Project
  • Project
  • Project
  • Project
  • Project