Sessions
Every Libretto session gets its own isolated directory under.libretto/sessions/<name>/. Sessions are git-ignored by default — they contain runtime state and machine-local data that should not be committed.
You can run multiple sessions simultaneously. Each session targets a specific browser instance and has its own log files, network capture, and snapshot history.
Starting and ending sessions
Treat exploration sessions as disposable unless you explicitly need to keep a session open for continued investigation. Use
close --all before starting a fresh automation run to avoid stale browser state.Session state file
Each session writes astate.json file with metadata about the running browser process:
| Field | Type | Description |
|---|---|---|
version | number | State file schema version |
session | string | Session name |
port | number | Chrome DevTools Protocol debug port |
pid | number (optional) | Browser process ID |
startedAt | string | ISO 8601 timestamp when the session started |
status | string | active, paused, completed, failed, or exited |
Session logs
Each session directory contains several log files you can query directly withjq:
logs.jsonl
Structured CLI and system logs. Contains debug output from Libretto itself — command execution, errors, and internal events.actions.jsonl
Recorded user and agent actions. Each line is a JSON object representing one interaction — a click, fill, navigation, or other Playwright action. Libretto records both actions you perform manually in the browser (source: "user") and actions the agent performs programmatically (source: "agent").
Key fields:
| Field | Description |
|---|---|
ts | ISO timestamp |
source | "user" for captured DOM events, "agent" for Playwright calls |
action | Action type: click, fill, goto, reload, etc. |
selector | Selector or locator hint (agent entries) |
bestSemanticSelector | Canonical selector for user DOM events |
success | true if the action completed, false on failure |
value | Typed, selected, or submitted value when the action had one |
url | Navigation target for goto-style actions |
error | Error message when the action failed |
network.jsonl
Captured HTTP requests and responses. Each line represents one request/response pair. Key fields:| Field | Description |
|---|---|
ts | ISO timestamp |
method | HTTP method: GET, POST, etc. |
url | Request URL |
status | HTTP status code |
contentType | Response content type |
responseBody | Response body string (may be null) |
snapshots/
Thesnapshots/ directory contains paired PNG screenshots and HTML files captured by npx libretto snapshot. Each snapshot produces:
snapshot-NNN.png— a full-page screenshotsnapshot-NNN.html— the full DOM at capture time, used by the AI analysis model
Profiles
Profiles save browser sessions — cookies and localStorage — so you can reuse authenticated state across multiple runs without logging in every time.Creating a profile
.libretto/profiles/app.example.com.json. It contains:
- The full cookie jar for the domain
- localStorage contents for the domain
Using a profile
Pass--auth-profile when running a workflow to inject the saved browser state:
Profile storage
Profiles are:- Stored at
.libretto/profiles/<domain>.json - Machine-local — not shared between machines
- Git-ignored — never committed to version control
Sessions can expire. If a profile stops working, repeat the manual login flow and run
npx libretto save <domain> again to refresh it.Best practices
- Give sessions meaningful names. Use names like
debug-login,scrape-run-1, ortest-checkoutinstead of the default. Meaningful names make it easier to identify which browser is which when runningnpx libretto pagesor reading log files. - Use profiles to avoid repeated logins. Save authenticated state once and reuse it across runs. This reduces friction during development and avoids login rate limits on the target site.
- Keep exploration sessions disposable. Unless you explicitly need to return to a browser state, close sessions when you’re done. Stale sessions consume resources and can interfere with fresh runs.
- Clean up before fresh starts. Run
npx libretto close --allbefore beginning a new automation run to ensure you’re starting with a clean state. - Don’t commit profile files. Profiles contain session cookies that are effectively credentials. The
.libretto/directory is already git-ignored, but double-check your.gitignoreif you’re storing Libretto state in a non-standard location.
Related pages
Automation approaches
Compare the four integration strategies and their detection risk profiles.
Bot detection
Understand how sites detect automation and choose approaches that minimize risk.