Documentation Index
Fetch the complete documentation index at: https://docs.monolex.ai/llms.txt
Use this file to discover all available pages before exploring further.
How MonoSurf Works
The Engine
MonoSurf is a Rust binary that controls Chrome directly through the Chrome DevTools Protocol (CDP) via chromiumoxide — a Rust-native CDP client. No subprocess, no Node.js, no Playwright dependency.Profile Management
MonoSurf manages isolated Chrome instances per profile:| Command | Purpose |
|---|---|
monosurf start --profile work | Launch Chrome with CDP (visible) |
monosurf start --profile work --headless | Launch headless (no window) |
monosurf stop --profile work | Stop Chrome |
monosurf profiles | List all profiles + status |
monosurf browsers | Discover available browser engines |
--user-data-dir and CDP port. On macOS, open -n ensures MonoSurf Chrome doesn’t conflict with the user’s regular Chrome.
Connection Flow
- Resolve profile name → CDP port from
profiles.json - TCP connect check: is port alive?
- If not, launch Chrome (visible or headless, system or Playwright/Puppeteer)
Browser::connect_with_config()→ WebSocket to Chrome CDP- Get or create a page
- All subsequent commands go through this page
Cookie Management
v0.4 uses CDPNetwork.setCookies / Network.getCookies instead of JavaScript document.cookie. This means:
- HttpOnly cookies — accessible (JS-based approach couldn’t see these)
- Full metadata — domain, path, expiry, secure flag
- Cross-origin — can set cookies for any domain
Navigate with Fallback
Some sites (especially in headless mode) don’t complete the CDPPage.navigate event. MonoSurf uses a timeout fallback:
Write Operations
For commands withintent: "write", MonoSurf executes a sequence of JS actions:
js type — DOM queries and element.click(). The pw (Playwright script) action type from v0.2 is removed since there is no Playwright subprocess.
Multiline text is supported — line breaks in the type action are preserved.
For anti-bot sites that strip CSS selectors, JS actions use accessibility attributes:
Why JS element.click() Instead of CDP Mouse Events
All JS click operations useelement.click() instead of CDP mouse events. This avoids scroll_into_view() which breaks modal dialogs (discovered through React source code analysis). JS clicks work on regular pages, modals, React SPAs, and any framework.
Browser Selection
MonoSurf discovers browsers at runtime from 3 sources:| Source | Stealth | Best For |
|---|---|---|
| System Chrome | No | Visible mode, login |
| Playwright Chromium | Yes | Headless automation |
| Puppeteer Chrome | Yes | Headless automation |
navigator.webdriver spoofing and other stealth features built into the binary.
Install Chromium for headless use: