camoufox-rs
Pure Rust client for controlling Camoufox through the Firefox Juggler protocol.
This crate implements the full stack needed to automate a Camoufox browser process over the -juggler-pipe transport: process launch, null-delimited JSON framing, protocol request/response/event routing, and ergonomic Browser / BrowserContext / MainFrame wrappers.
Current Scope
- Library crate with a synchronous API for Juggler domains (
Browser, MainFrame, Network, Runtime, Heap)
- Optional CLI (
--features cli) with a Unix socket daemon for multi-instance management, file uploads, persistent profiles (launch --profile-dir), external subcommand plugins (camoufox-<name> on PATH), and structured error kind classifications
- Page HTTP cassette recording and deterministic offline replay with
record start/stop and replay start/stop
- Unix implementation (process + fd pipe model): Linux and macOS. Windows is not supported.
Documentation
The project's documentation follows the Diataxis framework:
Requirements
- Rust 1.85+ (
rust-version in Cargo.toml)
- Unix-like OS for full functionality (process spawning + Unix sockets)
- Camoufox binary available on disk
The CLI daemon resolves the Camoufox binary in this order:
--executable <path> passed to launch
- the
CAMOUFOX_BIN environment variable
- the install marked active in
~/.cache/camoufox/config.json (active_version), as set by the Python camoufox fetch / camoufox set commands
- the newest
~/.cache/camoufox/browsers/<repo>/<version>/camoufox
~/.cache/camoufox/camoufox, the legacy flat layout
~/.cache means $XDG_CACHE_HOME when it is set to an absolute path, else
$HOME/.cache (/root/.cache when HOME is unset). Library users get the
same lookup from camoufox::config::default_executable(). On macOS, set
CAMOUFOX_BIN or pass --executable.
Build
Library only:
cargo build
CLI binary:
cargo build --features cli --bin camoufox
CLI Quick Start
The CLI uses a daemon process and newline-delimited JSON over a Unix domain socket.
Built-in commands: serve, launch, dialog, list, stop, new-page, navigate,
evaluate, click, screenshot, shutdown, ping, cookies, text, html, links,
data, url, back, forward, reload, wait, cookie, header, fill, upload,
type, press, hover, select, scroll, tabs, close-tab, downloads, record,
replay.
External subcommands: executing camoufox <name> for any command not built-in searches for
camoufox-<name> in absolute PATH entries. Arguments, standard streams, and exit status
pass through. Put global flags before <name>; CAMOUFOX_SOCKET receives the absolute
socket path, and CAMOUFOX_JSON is set to 1 with --json or cleared otherwise.
Start daemon (run in a dedicated shell):
cargo run --features cli --bin camoufox -- serve
Launch an instance (--profile-dir specifies an optional persistent profile directory):
cargo run --features cli --bin camoufox -- launch
cargo run --features cli --bin camoufox -- launch --profile-dir /path/to/profile