Skip to content

Protocol

The protocol is NDJSON over a socket, either a Windows named pipe or a Unix namespaced socket, that lets external processes tile panes and interact with a Laura workspace. All external interactions, including the laura CLI, flow through the protocol.

Tip

Laura handles interactions in two ways: over the protocol, from an outside process, and in-process, inside the workspace. In-process interactions, like commenting on a line, scrolling, and submitting an inline review, don't use the protocol (see In-process interactions).

Addressing

Laura opens one socket for the workspace and sets LAURA_TAB to the socket's name in the shell. A client connects to the socket and sends a request.

The socket name includes the process id and a random nonce (laura-<pid>-<nonce>-<n>), so a new Laura process that reuses an old process id never reuses an old workspace's name. A client holding the LAURA_TAB of a closed workspace fails to connect instead of reaching a different, live workspace.

Panes

The workspace's panes form a split tree: Laura adds a pane by splitting an existing pane in two. Laura gives each pane an integer id (u64), counting up within the workspace. The shell is always pane 0. Laura never reuses an id within a workspace, so closing a middle pane leaves a gap (ids 0, 4 after closing 1..3). Requests address panes by id.

Messages

Each connection carries one request and one response: the client connects, sends a single request frame, reads a single response frame, and the socket closes. A frame is one JSON object on a single line (NDJSON). The response comes from the TUI process, which holds the live layout state.

Every message has a type field, such as open or ok, plus the fields listed under that message below, with their defaults. When a client reads the end of the stream with no response frame, the client treats the result as ok.

While the user types a comment or review body, Laura holds requests to the workspace and answers them once the user finishes or cancels.

open

Split a pane and render a file in the new pane, or show a page from a URL in a browser pane.

path · string · required
File to render, or an http:// or https:// URL for a browser pane. With a URL, Laura returns error with highlight, diff or edit, and ignores follow. With panel on a browser pane, Laura loads the URL in the same pane.
split · integer · default: focused pane
Pane to split.
dir · string · optional — absent → inferred
horizontal or vertical.
ratio · integer · optional — absent → inferred
New pane's percent, 1..99.
side · string · optional — absent → inferred
first/second — where the new pane lands.
focus · boolean · default: true
Move focus into the new pane.
tail · boolean · default: false
Marks the pane as a tail pane: the user can pause it, and the web app shows the log icon. laura tail sets it.
dry_run · boolean · default: false
Report the resulting layout without changing anything.
highlight · [int, int] · default: null
[start, end], applied as the pane first paints.
diff · boolean · default: false
Open straight into the inline diff view.
panel · integer · default: null
Replace this pane's content in place (same id, rect, focus) instead of splitting. Laura ignores split/dir/ratio/side when panel is set. Laura returns error for the shell, for an id with no pane, and while the pane has an unsubmitted inline review or unsaved Neovim edits.
edit · boolean · default: false
Run Neovim on the file in an editor pane. Never moves focus, whatever focus says. With panel on the same file, attaches Neovim in place and keeps the pane's threads. Returns error with highlight or diff, which editor panes don't show, and with the reason when editor panes are off (see Editor panes).
Request
{
  "type": "open",
  "path": "spec.md",
  "split": null,
  "dir": null,
  "ratio": null,
  "side": null,
  "focus": true,
  "dry_run": false,
  "highlight": null,
  "diff": false,
  "panel": null,
  "edit": false
}
Response · opened
{
  "type": "opened",
  "pane": 1,
  "warnings": []
}

opened holds the new pane id, which laura open prints, and a list of warnings. Laura still opens the pane when it returns a warning. Laura returns these as warnings, not errors:

  • diff when there is nothing to diff (no changes vs HEAD — nothing to diff).
  • already open in pane #N — use `laura open <url> --panel N` when the URL is already open in browser pane N.
  • already open in pane #N when the file is already open in pane N, including on a panel replace. The warning ends with , which has an unsubmitted inline review when pane N has one, and reads already open in editor pane #N when pane N is an editor pane without one.

With dry_run, Laura returns a report instead of opened.

Inference. When dir, ratio, side, and split are all absent, Laura picks the split. Laura splits the newest pane and alternates the orientation by depth (a dwindle), so repeated bare opens each split off the newest pane. Laura sizes the new pane as follows:

  • In a side-by-side split, the new pane gets 50%.
  • In a stacked split, the new pane gets the rows of its file, up to 50%.
  • With follow, edit or diff, or for an HTML page or a markdown file in the web app, the new pane gets 50%.

Setting any one of those fields turns inference off. When a split would shrink a pane below the minimum size Laura can render, Laura returns error.

close

Close a pane, or close every pane and return the workspace to shell-only.

pane · integer · default: focused pane
Pane to remove.
all · boolean · default: false
Return the workspace to shell-only.
Request
{
  "type": "close",
  "pane": null,
  "all": false
}
Response · ok | error
{
  "type": "ok"
}

Laura never closes the shell (pane 0). Laura returns error when the pane has an unsubmitted inline review or unsaved Neovim edits. With all, Laura returns error and closes nothing when any pane has either.

focus

Focus a pane by id.

pane · integer · required
Pane to focus.
Request
{
  "type": "focus",
  "pane": 1
}
Response · ok
{
  "type": "ok"
}

highlight

Highlight a range of lines in a pane and scroll the lines into view. In a browser pane, highlight the element that a CSS selector finds.

pane · integer · default: focused pane
Pane to highlight.
range · [int, int] · default: null
Lines [start, end], 1-based inclusive, in a file pane.
selector · string · default: null
CSS selector of an element on the page that a browser pane shows. With no range and no selector, Laura clears the pane's highlight.
Request
{
  "type": "highlight",
  "pane": null,
  "range": [40, 52]
}
Browser pane
{
  "type": "highlight",
  "pane": 2,
  "selector": "main > h1"
}
Clear · range: null
{
  "type": "highlight",
  "pane": null,
  "range": null
}
Response · ok | warning | error
{
  "type": "ok"
}
{
  "type": "warning",
  "message": "pane #2 is paused — …"
}

On a frozen pane, Laura returns error for a range but still clears the highlight for range: null. On an editor pane, Laura returns error for both, so annotate the lines with comment instead.

On a paused pane, Laura highlights the range and returns warning, because the user doesn't see new output in the pane: pane #N is paused — the user doesn't see new output, so Laura highlights the content that the pane holds. laura highlight prints the warning and exits 0.

Line numbers are the file's source lines, matching the gutter and the inline review's L<n>. In markdown, Laura maps source lines to rows as the agent reference describes.

The highlight stays until one of these happens:

  • The agent sets a new highlight or clears it (no range and no selector).
  • The user presses h on the focused pane.
  • The agent turns the file pane into an editor pane (open --edit on the same file).

Moving focus or the cursor doesn't change the highlight. Laura clamps out-of-range lines to the file, including after a reload that shortens the file. Clearing the highlight doesn't move the cursor or scroll the pane.

A file pane takes a range and a browser pane takes a selector. Laura returns error for the other one, and for a selector that matches no element. Browser panes lists each error.

diffview

Toggle a pane's inline diff view against git HEAD.

pane · integer · default: focused pane
Pane to toggle.
on · boolean | null · default: null
null to toggle, true/false to set.
Request
{
  "type": "diffview",
  "pane": null,
  "on": null
}
Response · ok | error
{
  "type": "ok"
}
{
  "type": "error",
  "message": "nothing to diff"
}

Laura returns error when there is nothing to diff (git isn't installed, or the file is clean or untracked). Laura also returns error on an editor pane, so annotate the lines with comment instead.

comment

Annotate a line: start a thread on the line, or add a reply to the user's thread there. In a browser pane, annotate the element that a CSS selector finds. When the user presses Shift+S, Laura submits every thread as one inline review and clears the pane's threads. Laura returns error for an empty or absent body.

pane · integer · default: focused pane
Pane to comment on.
line · integer · default: null
1-based source line of the thread (same mapping as highlight), in a file pane.
selector · string · default: null
CSS selector of an element on the page that a browser pane shows. A file pane takes a line and a browser pane takes a selector. Laura returns error for the other one, as Browser panes lists.
body · string | null · default: null
Comment text. Starts a thread or appends a reply. An empty or absent body returns error.
author · string | null · default: session agent
Attribution label for the comment. When omitted, defaults to the session's ready --agent name, falling back to agent if the workspace was never readied.
Request
{
  "type": "comment",
  "pane": null,
  "line": 42,
  "body": "handled — see the retry loop",
  "author": "agent"
}
Browser pane
{
  "type": "comment",
  "pane": 2,
  "selector": "#email",
  "body": "Add a label to this field"
}
Response · ok | error
{
  "type": "ok"
}
{
  "type": "error",
  "message": "no pane #3"
}

layout

Return the current layout without changing anything.

No parameters. Request
{
  "type": "layout"
}
Response · report
{
  "type": "report",
  "area": {},
  "panes": [
    {
      "id": 0,
      "kind": "pty",
      "rect": {},
      "overflow_rows": 0,
      "clipped": false
    }
  ]
}

The report has one entry per pane, with rect, content_rows, visible_rows, overflow_rows, and clipped, so a client can check whether the content overflows the pane. In the web app, a pane's border takes three rows, so visible_rows is the pane's height minus three. For the shell in the web app, visible_rows is the shell's row count, the same as stty size prints. kind is pty (the shell), panel (a file pane), editor (an editor pane, with its path), or browser (a browser pane, with its URL as path and the page's title). A pane that the user paused also has "paused": true. A pane that a line the user dragged sizes also has "pinned": true: an open doesn't move that line, and --ratio sizes only the new split. Editor panes and browser panes report content_rows: null, because Neovim and Laura's browser size their own content.

While the web app shows the shell in the drawer, the shell also has "drawer": true, and the shell's rect is the whole area, because the drawer floats over the panes. The other panes tile the whole area without the shell. In this state, a split of the shell splits the first other pane instead, so an open with split: 0 or with the shell focused tiles the panes that the user sees. With no other pane open, the shell also has "drawer": true, and the first pane takes the whole area.

When the user shows the shell as a pane while no other pane is open, the shell's rect is the left 40% of area. An open without split flags then gives the new pane the right 60%.

ready

Mark the workspace as hosting an agent, which enables commenting and submitting (see In-process interactions).

session · string | null · default: laura-<pid>-<n>
Names the journal session.
agent · string | null · default: null
Attributes journal events, and the agent's comments, to this name.
title · string | null · default: null
Sets the session label: a short name for the task, such as flat elevation profile.
Request
{
  "type": "ready",
  "session": "demo",
  "agent": "claude",
  "title": "flat elevation profile"
}
Response · ready
{
  "type": "ready",
  "journal": "~/.laura/sessions/<session>.ndjson",
  "experimental": ["editor"],
  "web_app": true,
  "browser_url": "http://127.0.0.1:<port>",
  "layout": { "area": {}, "panes": [ … ] }
}

journal is the path to the session's journal. experimental lists the experimental features enabled in the workspace (editor: editor panes; see the CLI reference), and is empty when none are enabled. web_app is true when the user uses the web app, and false in the TUI. browser_url is the shell's LAURA_BROWSER_URL, where the agent's browser tools connect to Laura's browser (see Work on a page with the agent). browser_url is set only when the web app runs and Laura found Chrome or Edge, and is null otherwise. layout is the same report that layout returns. layout is null when the running Laura is older than the laura CLI and doesn't send the field.

A ready without title, or with a blank title, keeps the workspace's session label. Laura removes the spaces at the start and end of title. A ready without agent for the same session keeps the session's agent name. A ready with a new session starts a new journal, and Laura writes the later events to the new journal.

say

Say something to the user. Laura journals the text as a say event, and the web app shows the text in the History and in the shell button (see The History and the shell). The TUI shows the first line of the text as a notice.

body · string · required
The text, in markdown.
Request
{
  "type": "say",
  "body": "The tests pass. Look at the retry in pane #2."
}
Response · ok
{
  "type": "ok"
}

A blank body returns the error laura say needs a body.

update

Reserved for asking a file pane to reload. The laura CLI doesn't send update yet, and Laura answers it with ok.

path · string · required
File whose pane to reload.
Request
{
  "type": "update",
  "path": "spec.md"
}

In-process interactions

Laura handles the user's keystrokes inside the Laura process, which already holds the layout, so in-process interactions never use the socket. The in-process interactions are:

  • comment (c), collapse/expand threads (r), jump to the next/prev thread (n/N), submit (Shift+S), and refresh (Ctrl+R)
  • focus (Ctrl+P), scrolling, diff toggle (d), and pause/resume a tail pane (p)

See Navigating the workspace for the keystrokes for all interactions.

The user's actions in the workspace aren't protocol messages, and the agent can't send them.

Until the workspace receives a ready message, the user can't comment or submit an inline review.