Skip to main content
Manage named browser sessions and control session access modes.

The --session flag

Almost every Libretto command accepts --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. Session state is stored under .libretto/sessions/<session>/:
Session directories are git-ignored. Each session runs an isolated browser instance on a dynamic port.

close

The close command closes a browser session and cleans up its state.

When to use close

  • When you are done with a session.
  • When an exploration session is no longer helping progress and you want to free up the browser.
  • For full workspace cleanup at the end of a task.
When using connect to attach to an external CDP endpoint, close clears the Libretto session record but does not terminate the remote browser process.

Flags

--session
string
The session to close. Required unless --all is passed.
--all
boolean
Close all tracked sessions in this workspace.
--force
boolean
Force-kill sessions that do not respond to SIGTERM. Requires --all.

Examples


Read-only sessions

Read-only mode prevents any mutating browser actions (clicks, typing, navigation, form fills) while still allowing inspection. This is useful for diagnosing live production sessions without risking accidental state changes.

Starting a read-only session

Pass --read-only to open, connect, or run:
You can also manually set sessionMode in .libretto/config.json to change the default for all new sessions:
Pass --write-access to open, connect, or run to override a read-only config default when creating a session.

Changing session mode

View or change the mode of an existing session with session-mode:

What’s allowed in read-only mode

readonly-exec

A restricted version of exec that only allows read operations on the page. Available methods include:
  • Page reads: url(), title(), content(), viewportSize, waitForLoadState, waitForURL
  • Locator factories: locator(), getByRole(), getByText(), getByLabel(), getByPlaceholder(), getByAltText(), getByTitle(), getByTestId()
  • Locator reads: textContent(), innerText(), boundingBox(), count(), getAttribute(), inputValue(), isVisible(), isHidden(), isEnabled(), isChecked()
  • Network: get(url) (GET/HEAD only, no request bodies)
  • Viewport: scrollBy(deltaX, deltaY) for scrolling by pixel offset
  • Other: state, console, URL, Buffer
Any mutating operation (click, fill, goto, reload, etc.) throws a ReadonlyExecDenied error.