Manage named browser sessions and control session access modes.
--session flag--session <name> to target a specific browser session. When you omit --session on commands that support auto-generation (open, run), Libretto creates a unique name automatically..libretto/sessions/<session>/:12345678.libretto/ sessions/ <session>/ state.json logs.jsonl network.jsonl actions.jsonl snapshots/
close command closes a browser session and cleans up its state.12npx libretto close --session debug-example npx libretto close --all
closeconnect to attach to an external CDP endpoint, close clears the
Libretto session record but does not terminate the remote browser process.path --sessionstring--all is passed.path --allbooleanpath --forceboolean--all.12345678# Close a named session npx libretto close --session debug-example # Close all sessions in the workspace npx libretto close --all # Close all sessions, force-killing any that are unresponsive npx libretto close --all --force
--read-only to open, connect, or run:123npx libretto open https://example.com --read-only --session diag npx libretto connect ws://localhost:9222 --read-only --session remote-diag npx libretto run ./workflow.ts --read-only --session test-run
sessionMode in .libretto/config.json to change the default for all new sessions:1234{ "version": 1, "sessionMode": "read-only" }
--write-access to open, connect, or run to override a read-only config default when creating a session.session-mode:12345678# View current mode npx libretto session-mode --session my-session # Switch to read-only npx libretto session-mode read-only --session my-session # Switch back to write-access npx libretto session-mode write-access --session my-session
| Command | Allowed |
snapshot | Yes |
readonly-exec | Yes |
pages | Yes |
close | Yes |
session-mode | Yes |
exec | No |
readonly-execexec that only allows read operations on the page. Available methods include:url(), title(), content(), viewportSize, waitForLoadState, waitForURLlocator(), getByRole(), getByText(), getByLabel(), getByPlaceholder(), getByAltText(), getByTitle(), getByTestId()textContent(), innerText(), boundingBox(), count(), getAttribute(), inputValue(), isVisible(), isHidden(), isEnabled(), isChecked()get(url) (GET/HEAD only, no request bodies)scrollBy(deltaX, deltaY) for scrolling by pixel offsetstate, console, URL, BufferReadonlyExecDenied error.12345678# Read page title npx libretto readonly-exec --session diag "return await page.title()" # Check if an element is visible npx libretto readonly-exec --session diag "return await page.locator('#submit').isVisible()" # Get text content of a section npx libretto readonly-exec --session diag "return await page.locator('.results').textContent()"