References Scripting reference
This is the compact reference for Scripting and automation. It names the public surface a human script or LLM can quote exactly.
CLI verbs
The paneflow binary intercepts these verbs and exits before GUI
startup. Unknown verbs exit with usage code 2 instead of silently
launching the app.
| Verb | Primary method or engine | Writes to panes? | Use |
|---|---|---|---|
ls [--human] [--raw] | surface.list | No | List panes in the active workspace, fenced when printed to a program |
read <target> [--raw] | surface.read | No | Read pane scrollback, fenced unless --raw |
search <target> <pattern> [--raw] | surface.search | No | Search pane scrollback, fenced unless --raw |
ps [--json] | fleet.list | No | List detected agents across workspaces |
status <target> [--json] | surface.status | No | Read one pane's agent state |
new [--name] [--cwd] [--space] | workspace.create | No | Create a workspace, in the active space unless --space names another |
select <index> | workspace.select | No | Select a workspace, switching to its space |
split <h|v> | surface.split | No | Split a pane |
focus <target> | surface.focus | No | Focus a pane and its workspace |
send <target> <text> | surface.send_text | Gated | Stage or submit text |
key <target> <keystroke> | surface.send_keystroke | Gated | Send one non-submitting keystroke |
wait --match <sel> | surface.read, events.subscribe | No | Block until a pattern or idle, whichever comes first |
watch [--surface <sel>] [--type <event>] | events.subscribe | No | Stream lifecycle and surface events |
up <file> | Workspace spec engine | Prefill only | Create a declarative workspace |
flow run <file> | Flow engine | Gated for submitting steps | Run a local multi-agent DAG |
sessions [--json] [--follow] | Worker session stream | No | Read agent session state, with or without a window |
write <target> <text> [--submit] | pane.write | After a human allows the pair | Message another agent's pane |
ask <question> [--option <text>]... | prompt.request, prompt.wait | No | Ask the user in the window and print the answer |
do <script|action> [key=value]... | Lua runtime, action.invoke | When the script writes | Run Lua or an init.lua action |
actions [--json] | action.list | No | List the init.lua actions |
api list|describe|call | Method registry | When the method writes | List, describe, or call any JSON-RPC method |
From a pane, ls, read, search, and write stay in that pane's
workspace; --scope all reaches every workspace once ipc.orchestration
is true in paneflow.json.
Aliases accepted by the CLI: list_panes maps to ls,
read_pane maps to read, and search_pane maps to search.
Selectors
| Selector | Example | Notes |
|---|---|---|
| Numeric id | paneflow read 42 | Matches surface_id exactly |
| Name | paneflow status backend | Best selector for durable scripts |
cmdline:<substr> | paneflow read cmdline:vite | Full foreground argv on Linux, executable basename on macOS and Windows |
cwd:<path> | paneflow read cwd:/home/me/api | Matches the pane working directory |
A selector that matches nothing or several panes exits with code 3,
except commands that explicitly accept multiple matches such as
send --broadcast, wait --any, and wait --all.
Exit codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Runtime failure: instance unreachable, pane closed, gate refused, or handler error |
2 | CLI usage error |
3 | Target not found or ambiguous, or send refused a target agent that waits for a decision or left the foreground |
4 | wait timeout, flow ready timeout, ask still pending <id>, or do --wait still running <run_id> |
Write gates
Reading is allowed by default. Writes are split by capability:
| Operation | Gate |
|---|---|
send without --submit | ipc.scripting or ai_unrestricted |
send --submit | ipc.scripting or ai_unrestricted |
key | ipc.scripting or ai_unrestricted |
send --scope all, key --scope all, flow run --scope all from inside a pane | ipc.orchestration |
Host session.input from a control client | ipc.scripting |
Host session.create from a control client with a command, prompt, or env | ipc.orchestration |
Host session.create from a control client, otherwise | ipc.scripting |
Flow step with submit = true | Scripting capability reported by system.capabilities |
These keys live in paneflow.json: ipc.scripting implies
ipc.orchestration, and ai_unrestricted opens both. The deprecated
PANEFLOW_IPC_SCRIPTING=1 and PANEFLOW_IPC_ORCHESTRATION=1 still
apply as the scripting guide describes, and a refused
request still answers with its former message, which names them.
send does not append a carriage return unless --submit is present.
key rejects submitting keystrokes such as enter, ctrl-m, and
ctrl-j. A single surface.send_text payload is capped at 64 KiB.
Relevant config keys:
| Key | Default | Meaning |
|---|---|---|
ipc.scripting | false | Opens text and keystroke writes; implies ipc.orchestration |
ipc.orchestration | false | Lets a request launch a command, a prompt, or env, and lets --scope all reach every workspace |
ai_unrestricted | false | Opens both gates for every caller |
ai_injection_fence | true | Wraps surface.read text in an untrusted terminal envelope |
submit_paste_delay_ms | 70 | Base delay between bracketed paste and the submit carriage return |
terminal.env | none | Environment variables injected into new terminals |
Read fields
paneflow read <target> --json and raw surface.read return:
| Field | Meaning |
|---|---|
text | Scrollback text, fenced by default |
lines | Returned line count |
total_lines | Total retained lines |
eof | Whether the read reached the oldest retained line |
output_generation | Monotonic counter advanced by pane output |
Defaults and limits: lines defaults to 200 and clamps to 1-4000.
offset starts from the end of the buffer. Passing an out-of-range
offset is an invalid-params error.
The fenced JSON-RPC param defaults to ai_injection_fence. The CLI
flag --raw passes fenced: false.
Agent state fields
paneflow ps --json returns {"agents":[...]}. paneflow status <target> --json returns one status object.
| Field | Meaning |
|---|---|
pid | Agent process id, when known |
tool | Agent family such as claude, codex, opencode, or gemini |
state | thinking, waiting_for_input, finished, errored, idle, or unknown_running |
hooked | Whether the current launch reports through lifecycle hooks Paneflow installs; a hook from a previous launch never counts |
state_seq | Per-session counter that increases on every state transition, on status |
reason | Detection reason, including no_hook |
surface_id | Pane id |
surface_name | Pane name |
workspace | Workspace index |
active_tool_name | Tool currently running inside the agent |
message | Waiting prompt or permission text |
last_result | Last turn summary, when available |
waiting_ms | Time spent waiting for input |
idle_ms | Time since observed activity |
output_generation | Pane output counter, on status; absent when unknown |
An empty fleet is {"agents":[]} with exit code 0. A pane with no
tracked agent returns idle state, not an error.
Workspace spec
paneflow up <file> reads a TOML workspace spec.
| Top-level field | Type | Default | Notes |
|---|---|---|---|
name | string | "Workspace" | Workspace title |
space | string | active space | Space name (any case) or id; Default names the default space |
layout | string | "even_h" | even_h, even_v, main_vertical, or tiled |
port_base | integer | 3000 | Base for ${port_offset} allocation |
[[panes]] | array | required | One entry per pane |
| Pane field | Type | Default | Notes |
|---|---|---|---|
cwd | string | none | Must exist after expansion and canonicalization |
agent | string | none | Agent launcher name, mutually exclusive with command |
command | string | none | Raw command, mutually exclusive with agent |
prompt | string | none | Prefilled into an agent input, never submitted by up |
focus | bool | false | Gives initial focus to this pane |
env | table | none | Merged over terminal.env; supports ${port_offset} |
name | string | none | Stable selector name |
worktree | string | none | Branch name for a managed worktree under the worktrees.dir root (see the configuration schema) |
from | string | HEAD | Branch or commit the worktree branch starts from when up creates it |
copy_env | bool | true | Copies the repository's .worktreeinclude entries into the worktree, or the top-level .env* files and AGENTS.override.md without that file |
setup | string | none | Command run before launch |
setup_timeout_secs | integer | 300 | Setup timeout |
worktree_teardown | string | "auto" | auto removes clean worktrees on close; keep leaves them |
${port_offset} substitutes only inside env values. Unknown keys are
errors. Workspace creation validates paths before creating panes.
Flow spec
paneflow flow run <file> reads a TOML flow spec and runs it against
the current Paneflow instance.
| Field | Type | Notes |
|---|---|---|
id | string | Required, unique step id |
needs | array | Dependencies; on foreach, waits for all instances |
foreach | array | Fan-out, one instance per item |
pane | inline table | Spawn a pane using workspace pane fields |
send | inline table | { target, text, submit? }; requires a dependency |
ready | table | { pattern, timeout_secs? }; regex barrier |
capture | table | { var, lines }; captures 1-500 lines after ready |
submit | bool | Submits a spawned pane prompt; requires scripting access |
Variables:
| Variable | Scope |
|---|---|
${item} | foreach steps: cwd, name, worktree, env, send.target, ready.pattern, prompts, and texts |
${var} | Captured values inside send.text and submitting pane.prompt |
${var.<item>} | Captures from a foreach group |
The runner validates unknown keys, missing dependencies, dependency
cycles, invalid regexes, undefined captures, pane budget, and missing
timeouts before execution. Ctrl-C stops the orchestration loop; panes
that were created remain in Paneflow.
JSON-RPC connection
| Property | Value |
|---|---|
| Linux endpoint | $XDG_RUNTIME_DIR/paneflow/paneflow.sock; when XDG_RUNTIME_DIR is unset or not a writable directory, $TMPDIR, else ~/.cache/run |
| macOS endpoint | $TMPDIR/paneflow/paneflow.sock, else ~/Library/Caches/run; XDG_RUNTIME_DIR is ignored |
| Windows endpoint | \\.\pipe\paneflow |
| Isolated home endpoint | When PANEFLOW_HOME names a directory other than the default home, the window of that home listens on its own endpoint: paneflow-ipc-<fingerprint>.sock in $XDG_RUNTIME_DIR (Linux only), else $TMPDIR, else /tmp, and \\.\pipe\paneflow-ipc-<fingerprint> on Windows. <fingerprint> is 16 hexadecimal digits derived from the home path. A PANEFLOW_SOCKET_PATH that names another endpoint is ignored unless PANEFLOW_ALLOW_SOCKET_OVERRIDE=1 |
| Framing | Newline-delimited JSON-RPC 2.0 |
| Request model | On Linux and macOS, one connection carries several requests, answered in order with one reply per request that has an id; the connection closes after 30 s without a request. On Windows, each pipe connection answers one request. events.subscribe turns its connection into the event stream, which takes no further request |
| Local trust | Same user only; no network listener, no token, no TLS |
| Backpressure | Connection cap and bounded event queues return structured errors or dropped frames |
Probe capabilities at runtime:
printf '%s\n' '{"jsonrpc":"2.0","method":"system.capabilities","params":{},"id":1}' \
| nc -U "$PANEFLOW_SOCKET_PATH"JSON-RPC methods
| Method | Params | Returns or notes |
|---|---|---|
system.ping | - | Liveness check |
system.capabilities | - | {scripting, methods[]} |
system.identify | - | {name, version, protocol} |
workspace.list | - | Workspaces with global indexes, titles, and space: {id, name} or null for the default space |
workspace.current | - | Shown workspace, with its space |
workspace.create | name?, cwd?, layout?, space? | Create a workspace; space is a name (any case) or id, the active space when absent; an unknown one is refused with unknown space: <value> |
workspace.select | index | Switch workspace, and to its space when it is hidden |
workspace.close | index | Close a workspace |
workspace.up | name, layout, panes[], space? | Declarative spawn used by up and flow roots; space as for workspace.create |
workspace.restore_layout | layout | Apply a layout tree |
surface.list | - | {surfaces:[{surface_id,name,title,cwd,cmd,workspace,space}]} |
surface.read | surface_id, lines?, offset?, fenced? | Scrollback and output_generation |
surface.search | surface_id, pattern, max_matches? | Case-insensitive substring matches |
surface.rename | surface_id, name | Rename or clear a pane name |
surface.focus | surface_id | Focus pane and workspace |
surface.status | surface_id | Agent state for one pane |
surface.send_text | surface_id, text, submit?, paste? | Gated PTY text write |
surface.send_keystroke | surface_id, keystroke | Env-gated non-submitting keystroke |
surface.split | direction, surface_id?, cwd?, command?, prompt?, env?, profile?, name?, managed_worktree?, worktree? | Split a pane; {split, new_tab, tab_id, direction, panes, surface_id, notices?} |
tmux.compat | team, surface_id, argv, scope_session? | tmux command from a Claude Code team pane; team is the token Paneflow gave that team's panes, and the reply is {stdout, stderr, exit} |
fleet.list | - | Read-only fleet snapshot |
events.subscribe | surfaces?, types? | Persistent newline-delimited event stream |
A surface.split with worktree creates or reuses a Paneflow worktree
for the new pane, which then starts in it: {branch, from?, copy_env?, setup?, setup_timeout_secs?, teardown?}, exclusive with
managed_worktree. branch is created when it does not exist, from
from when given, and setup needs the orchestration gate. Without
cwd, the request plans from the anchor tab's bound worktree, else from
the workspace folder, as a plain split does. A pane bound to another
worktree than the anchor's tab opens a tab of its own: the answer then
has split: false and new_tab: true, and tab_id names the tab that
holds the new pane. notices lists what the worktree setup reported,
such as the files copied from .worktreeinclude or a failed setup.
The ai.* lifecycle methods are no longer accepted on the app socket;
lifecycle events come from the paneflow-ai-hook reporter, and
events.subscribe still delivers ai.* events.
Structured failures use JSON-RPC error envelopes: -32602 invalid
params, -32601 gated method, -32001 permission, and -32000
backpressure. Some legacy validation errors still arrive as
{"error":"..."} inside result; clients should treat both shapes as
failures.
Events
paneflow watch and raw events.subscribe emit newline-delimited JSON.
The first frame acknowledges the subscription.
| Event type | Meaning |
|---|---|
subscribed | Subscription acknowledged |
ai.session_start | Agent session starts |
ai.prompt_submit | Prompt is submitted |
ai.tool_use | Agent reports tool use |
ai.notification | Agent asks for input or permission |
ai.stop | Agent turn stops |
ai.exit | Agent process exits |
ai.session_end | Agent session closes |
surface_changed | Pane output_generation advanced |
heartbeat | Idle keepalive |
dropped | Subscriber lagged and events were shed |
After a dropped frame, resync with paneflow ps --json or
paneflow status <target> --json.
Agent verbs
Agents drive Paneflow through the CLI from their shell tool; there is no MCP server.
| Verb | Prints | Exit |
|---|---|---|
write <target> <text> | written, approval_pending <request> until a human allows the pair, or no_window; --json prints the whole reply | 0, 0, 1 |
ask <question> | The answer, one picked option per line, or pending <id> after --timeout (20 s by default) | 0, 0, 4 |
ask --resume <id> | The answer to a question still pending | 0 or 4 |
do <action> --wait <duration> | The action's result, or running <run_id> once the wait passes | 0 or 4 |
do --resume <run_id> [--wait <duration>] | The result of a run still going | 0 or 4 |
write is the only agent verb that writes into a pane, and only after a
human allows that pair of agent sessions in Paneflow; the
automation guide describes its controls. Terminal text
from read, search, and ls is fenced as <untrusted_terminal_output>
when printed to a program, and an agent never passes --raw.
Lifecycle hooks
paneflow-ai-hook reads event JSON on stdin, sends one lifecycle event
(ai.stop, ai.notification, and so on) to the local host, and exits 0 so
a stopped Paneflow instance does not break the agent. Hooks carry the agent's
identity and session metadata to ps, status, watch, and
paneflow sessions; turn status comes from OSC 7501.
| Command | Effect |
|---|---|
paneflow integrations list | List the runtimes that have an installer and their state |
paneflow integrations install <runtime> | Install the hooks, the status line, and the paneflow-conductor skill for claude-code (or claude) or codex |
paneflow integrations remove <runtime> | Remove Paneflow's own handlers; a handler of yours in the same hook group is kept |
paneflow hooks setup | Install every detected runtime that has an installer |
paneflow hooks uninstall | Remove the integrations |
paneflow mcp uninstall | Remove the paneflow MCP entries an older Paneflow wrote, printing each one |
paneflow hooks status | Print one <runtime>: <state> line per runtime; always exits 0 |
Hooks are installed once per machine, from the CLI or Settings > Agents.
Claude Code hooks go to $CLAUDE_CONFIG_DIR/settings.json (default
~/.claude/settings.json), Codex hooks to $CODEX_HOME/hooks.json (default
~/.codex/hooks.json), and they exit immediately outside a Paneflow pane.
Other agents have no installer: they still run, are detected from their
process, and get a turn status only when they report it through OSC 7501.
Worker and sessions
Agent state lives in a per-home worker, started as paneflow serve run. It
runs detached, one per PANEFLOW_HOME, reduces each session's declared
OSC 7501 status to one state, rebuilds that state from disk when it restarts,
and never touches a running shell. status, send --submit, and wait --idle read the reduced
state from the worker whether or not a window is open; paneflow sessions
reads the worker directly.
| Command | Effect |
|---|---|
paneflow serve start | Start the worker for this PANEFLOW_HOME, or adopt the one already serving it |
paneflow serve status | Print the pid, protocol, home, session count, and capabilities |
paneflow serve stop [--drain-ms 5000] | Stop the worker; terminals are untouched |
paneflow sessions [--json] [--follow] | Print the session list the sidebar shows; --follow prints one line per transition and reconnects when the worker restarts |
paneflow sessions ack <session-id>... | Lower the unread flag a finished turn raises |