Skip to main content
The palyra-browserd daemon provides a managed, secure environment for browser automation using headless Chromium. It abstracts complex browser interactions into a gRPC service layer, handling session persistence, sandboxed downloads, and fine-grained action budgets.

Chromium Engine Integration

Palyra integrates with the Chromium engine via the headless_chrome crate. The daemon manages the lifecycle of Chromium instances, ensuring they are launched with appropriate security flags and resource constraints.

Execution Modes

The engine supports two primary modes defined in BrowserEngineMode:
  1. Chromium: Launches a real headless Chromium process. The path is resolved via the PALYRA_CHROMIUM_PATH environment variable or falls back to the system default crates/palyra-browserd/src/support/tests.rs#73-78.
  2. Simulated: A mock engine used for testing and validation that does not require a Chromium binary crates/palyra-browserd/src/support/tests.rs#95-95.

Session Proxying

To enforce network security, each session can be associated with a ChromiumSessionProxy. This is a SOCKS5 proxy spawned specifically for a session to intercept and validate outgoing requests, allowing or blocking private network targets based on session configuration crates/palyra-browserd/src/engine/chromium.rs#71-97. Browser Engine Architecture Sources: crates/palyra-browserd/src/transport/grpc/service.rs#9-11, crates/palyra-browserd/src/engine/chromium.rs#71-97, crates/palyra-browserd/src/lib.rs#39-43

Session Lifecycle and Persistence

Sessions in palyra-browserd are identified by ULIDs and governed by a SessionBudget that restricts lifetimes, memory usage, and action counts crates/palyra-browserd/src/transport/grpc/service.rs#93-161.

State Persistence

When persistence_enabled is set, the daemon utilizes a PersistedStateStore to save and restore session snapshots.

Download Handling

Downloads are isolated in a DownloadSandboxSession. Sources: crates/palyra-browserd/src/transport/grpc/service.rs#75-91, crates/palyra-browserd/src/domain/downloads.rs#20-44, crates/palyra-browserd/src/domain/downloads.rs#105-173

gRPC Service Layer

The BrowserServiceImpl implements the BrowserService gRPC contract, providing the primary interface for both the palyra-daemon and the CLI.
MethodPurposeKey Parameters
CreateSessionInitializes a new browser contextprincipal, persistence_id, budget
NavigateDirects the active tab to a URLurl, allow_redirects, timeout_ms
ClickSimulates a mouse clickselector, max_retries
TypeInputs text into an elementselector, text, clear_existing
SnapshotCaptures DOM/Accessibility stateinclude_dom_snapshot, max_bytes
CaptureScreenshotReturns a PNG/JPEG of the pagemax_bytes, format
Sources: crates/palyra-browserd/src/transport/grpc/service.rs#29-161, crates/palyra-cli/src/args/browser.rs#4-230

Browser Actions

The engine supports high-level actions that combine low-level Chrome DevTools Protocol (CDP) commands with Palyra-specific logic.

Interaction

  • Select/Highlight: Used for identifying and visually marking elements for the operator or LLM.
  • Console: Aggregates BrowserPageDiagnostics, including warning and error counts from the browser’s internal console log crates/palyra-browserd/src/domain/actions.rs#21-45.
Action Execution Flow Sources: crates/palyra-browserd/src/transport/grpc/service.rs#15-27, crates/palyra-browserd/src/domain/actions.rs#3-19, crates/palyra-cli/src/commands/browser.rs#219-238