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.
|
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:
diffwhen 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 #Nwhen the file is already open in pane N, including on apanelreplace. The warning ends with, which has an unsubmitted inline reviewwhen pane N has one, and readsalready open in editor pane #Nwhen 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,editordiff, 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.
|
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.
|
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.
|
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
rangeand noselector). - The user presses
hon the focused pane. - The agent turns the file pane into an editor pane (
open --editon 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.
|
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.
|
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).
|
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.
|
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.
|
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.