References API Methods
This page lists every method of Paneflow's API, as paneflow api docs prints them
in Paneflow 0.20.0. Call one with paneflow api call <method> key=value, from Lua
as paneflow.<namespace>.<method>{...}, or as JSON-RPC 2.0 on Paneflow's local
socket, one JSON message per line. See CLI automation for how
to use them.
Each method shows the process that serves it: window (the app), worker
(paneflow serve) or host (paneflow host, which owns the terminal sessions).
A method tagged scripting or orchestration needs that gate open under ipc
in paneflow.json, or a grant for the calling pane. A note with a rule on its left
marks where the code answers differently from what the method declares.
action
action.invoke
action.invokeRun an action of init.lua with arguments and return what it returned. Arguments are checked against its schema first; a run is stopped after 30 seconds. With wait_ms, a run still going past it answers {status: running, run_id} for action.wait. With ctx.origin agent, only an action declared with agents = true runs.
| Field | Type | Required | Description |
|---|---|---|---|
args | table | The action's arguments, checked against its declared schema | |
ctx | table | ||
name | string | Yes | |
wait_ms | integer | Milliseconds to wait for the run to end, at most 25000; past it the reply is {status: running, run_id} and action.wait keeps waiting. Absent waits for the end |
| Result | Type |
|---|---|
result | any? |
run_id | string? |
status | "done"|"running"|"rate_limited"? |
local result = paneflow.action.invoke{ name = "dev_layout", args = { file = "app.log" }, ctx = { origin = "cli" } }{
"result": {
"surface_id": 12
}
}action.list
action.listList the actions init.lua declared, with their titles, argument schemas and sources.
| Result | Type |
|---|---|
actions | table[] |
local result = paneflow.action.list(){
"actions": [
{
"name": "dev_layout",
"title": "Dev layout",
"category": "Actions",
"keywords": [
"split"
],
"args": {
"type": "object",
"properties": {
"file": {
"type": "string"
}
},
"required": [
"file"
],
"additionalProperties": false
},
"agents": false,
"source": "init.lua:3"
}
]
}action.wait
action.waitKeep waiting on an action run that action.invoke returned as {status: running, run_id}: the run's result with status done, the same running status, or the action's error.
| Field | Type | Required | Description |
|---|---|---|---|
run_id | string | Yes | |
wait_ms | integer | Milliseconds to wait, 0 by default, at most 25000 |
| Result | Type |
|---|---|
result | any? |
run_id | string? |
status | "done"|"running"|"rate_limited"? |
local result = paneflow.action.wait{ run_id = "6f1c0e9a2b7d4c3e8f5a1b2c3d4e5f60", wait_ms = 20000 }{
"result": {
"surface_id": 12
},
"status": "done"
}agent
agent.acknowledge
agent.acknowledgeClear the unread mark of sessions and publish the lowered rows.
| Field | Type | Required | Description |
|---|---|---|---|
session | string | One session, when sessions is absent | |
sessions | string[] |
| Result | Type |
|---|---|
acknowledged | string[] |
local result = paneflow.agent.acknowledge{ sessions = { "123e4567-e89b-42d3-a456-426614174000" } }{
"acknowledged": [
"123e4567-e89b-42d3-a456-426614174000"
]
}agent.activity_log
agent.activity_logRead the most recent agent activity entries.
| Field | Type | Required | Description |
|---|---|---|---|
limit | integer | Entries to return, 50 by default |
| Result | Type |
|---|---|
entries | any[] |
local result = paneflow.agent.activity_log{ limit = 2 }{
"entries": []
}agent.follow
agent.followStream the session projection: a snapshot header, then one frame per reduced transition.
A stream: Lua cannot call it. React to events with paneflow.on or paneflow.wait.
| Result | Type |
|---|---|
capabilities | string[] |
core_connected | boolean |
following | boolean? |
sessions | any[] |
usage | any |
worker | table |
local result = paneflow.agent.follow(){
"worker": {
"name": "paneflow-serve",
"version": "0.20.0",
"build_id": "9f2c",
"protocol": 1,
"required_core_protocol": 1,
"pid": 4242,
"home": "/home/me/.paneflow",
"endpoint": "/home/me/.paneflow/serve/worker.sock",
"started_at_ms": 1763600000000,
"capabilities": [
"agent.follow"
]
},
"capabilities": [
"agent.follow"
],
"core_connected": true,
"sessions": [],
"usage": {},
"following": true
}agent.snapshot
agent.snapshotRead every session's reduced agent row and the usage frame.
| Result | Type |
|---|---|
capabilities | string[] |
core_connected | boolean |
following | boolean? |
sessions | any[] |
usage | any |
worker | table |
local result = paneflow.agent.snapshot(){
"worker": {
"name": "paneflow-serve",
"version": "0.20.0",
"build_id": "9f2c",
"protocol": 1,
"required_core_protocol": 1,
"pid": 4242,
"home": "/home/me/.paneflow",
"endpoint": "/home/me/.paneflow/serve/worker.sock",
"started_at_ms": 1763600000000,
"capabilities": [
"agent.follow"
]
},
"capabilities": [
"agent.follow"
],
"core_connected": true,
"sessions": [],
"usage": {}
}agent_prompt
agent_prompt.resolve
agent_prompt.resolveAsk the user, in the window, the question or the permission request a coding agent's hook received, when agent_prompts is paneflow in paneflow.json. Holds one 300 second deadline for the whole call and replies answered with the JSON the hook prints, or declined, after which the agent asks in its own terminal.
reason can also be busy.
| Field | Type | Required | Description |
|---|---|---|---|
agent | string | The agent's runtime name, such as claude or codex | |
event | "ask_user_question"|"permission_request" | Yes | |
payload | any | Yes | The hook's input JSON, as the agent wrote it |
session | string | The Paneflow session of the agent; the worker replaces it with the caller's own session when the caller runs in a pane |
| Result | Type |
|---|---|
output | any? |
reason | string? |
status | "answered"|"declined" |
local result = paneflow.agent_prompt.resolve{ event = "permission_request", agent = "claude", payload = { tool_name = "Bash", tool_input = { command = "rm -rf build" } } }{
"status": "answered",
"output": {
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": {
"behavior": "allow"
}
}
}
}client
client.dispatch_action
client.dispatch_actionDispatch a built-in action in the window as the command palette does, and reply once it is dispatched.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | A name from client.list_actions, such as toggle_zoom |
| Result | Type |
|---|---|
dispatched | boolean |
name | string |
local result = paneflow.client.dispatch_action{ name = "toggle_zoom" }{
"dispatched": true,
"name": "toggle_zoom"
}client.list_actions
client.list_actionsList the window's built-in actions: the names key bindings and client.dispatch_action accept.
| Result | Type |
|---|---|
actions | table[] |
local result = paneflow.client.list_actions(){
"actions": [
{
"name": "toggle_zoom",
"description": "Zoom the focused pane",
"group": "Panes & splits"
}
]
}config
config.reload
config.reloadLoad init.lua again now and return the status; a failed load keeps the previous configuration active.
| Result | Type |
|---|---|
actions | integer |
bindings | integer |
found | boolean |
handler_errors | integer |
handlers | integer |
loaded_at_ms | integer? |
ok | boolean |
path | string |
problems | table[] |
timer_errors | integer |
timers | integer |
local result = paneflow.config.reload(){
"path": "/home/me/.paneflow/init.lua",
"found": false,
"ok": true,
"actions": 0,
"bindings": 0,
"handlers": 0,
"timers": 0,
"handler_errors": 0,
"timer_errors": 0,
"problems": []
}config.status
config.statusRead the state of init.lua: its path, whether it was found, when it loaded, what it declared and its load problems.
| Result | Type |
|---|---|
actions | integer |
bindings | integer |
found | boolean |
handler_errors | integer |
handlers | integer |
loaded_at_ms | integer? |
ok | boolean |
path | string |
problems | table[] |
timer_errors | integer |
timers | integer |
local result = paneflow.config.status(){
"path": "/home/me/.paneflow/init.lua",
"found": true,
"loaded_at_ms": 1763600000000,
"ok": false,
"actions": 2,
"bindings": 1,
"handlers": 1,
"timers": 0,
"handler_errors": 0,
"timer_errors": 0,
"problems": [
{
"file": "init.lua",
"line": 7,
"severity": "error",
"message": "unexpected symbol near 'end'"
}
]
}events
events.follow
events.followStream the worker's numbered event log: a following header, then every event with consecutive seq values, keepalive frames when quiet, and an end frame when the worker closes the stream. A since that left the ring, or an epoch from another worker start, is refused with -32040 and data {reason: evicted, seq, epoch}.
A stream: Lua cannot call it. React to events with paneflow.on or paneflow.wait.
| Field | Type | Required | Description |
|---|---|---|---|
epoch | string | The epoch since belongs to; a different epoch is refused with an evicted error | |
since | integer | Replay the events after this seq first; refused with an evicted error when they left the ring | |
types | string[] | Only send these types: exact names or a family such as terminal.* | |
workspace_id | integer | Only send events about this layout workspace id |
| Result | Type |
|---|---|
epoch | string |
seq | integer |
type | "following" |
local result = paneflow.events.follow{ types = { "terminal.*", "pane.closed" } }{
"type": "following",
"seq": 41,
"epoch": "1a2b-19a7c3f0e00-0"
}events.subscribe
events.subscribeStream surface and agent events as JSON lines: a subscribed frame, then events, heartbeat and dropped frames.
A stream: Lua cannot call it. React to events with paneflow.on or paneflow.wait.
| Field | Type | Required | Description |
|---|---|---|---|
surfaces | integer[] | Only stream events about these surfaces | |
types | string[] | Only stream these event types: surface_changed and the ai.* lifecycle types |
| Result | Type |
|---|---|
id | integer |
type | "subscribed" |
local result = paneflow.events.subscribe{ types = { "surface_changed" } }{
"type": "subscribed",
"id": 1
}fleet
fleet.list
fleet.listList the agents running in every workspace.
When no window is open, the host answers, and each row also carries session and generation.
| Result | Type |
|---|---|
agents | table[] |
local result = paneflow.fleet.list(){
"agents": [
{
"pid": 4242,
"tool": "claude",
"state": "waiting_for_input",
"hooked": true,
"reason": null,
"surface_id": 7,
"surface_name": "claude",
"workspace": 0,
"active_tool_name": null,
"message": "needs a decision",
"last_result": null,
"waiting_ms": 3000,
"idle_ms": 3000
}
]
}grant
grant.delegate
grant.delegateGive a pane the caller spawned a grant no wider than one the caller holds.
| Field | Type | Required | Description |
|---|---|---|---|
duration_secs | integer | Seconds the delegated grant lasts, until the delegator's grant ends by default | |
rights | ("write"|"spawn"|"layout")[] | Yes | |
scope | "workspace"|"instance" | ||
session | string | Yes | The session of a pane the caller spawned with surface.split |
| Result | Type |
|---|---|
expires_at_ms | integer? |
granted | boolean |
id | string? |
reason | string? |
local result = paneflow.grant.delegate{ session = "223e4567-e89b-42d3-a456-426614174000", rights = { "write" } }{
"granted": true,
"id": "g-2",
"expires_at_ms": 1800000000000
}grant.list
grant.listList the grants panes hold, with the revision of the set; a pane sees the grants it holds or delegated.
| Result | Type |
|---|---|
grants | table[] |
revision | integer |
local result = paneflow.grant.list(){
"revision": 4,
"grants": []
}grant.request
grant.requestAsk the human for rights the calling pane does not hold, for a scope and a time.
| Field | Type | Required | Description |
|---|---|---|---|
duration_secs | integer | Seconds the grant lasts once allowed, 3600 by default; 0 asks for a grant with no expiry | |
reason | string | Why the agent needs it, shown to the human | |
rights | ("write"|"spawn"|"layout")[] | Yes | Rights asked for, among write, spawn and layout |
scope | "workspace"|"instance" | workspace reaches the calling pane's own workspace, instance every workspace |
| Result | Type |
|---|---|
expires_at_ms | integer? |
granted | boolean |
id | string? |
reason | string? |
local result = paneflow.grant.request{ rights = { "write" }, scope = "workspace", duration_secs = 600 }{
"granted": true,
"id": "g-1",
"expires_at_ms": 1800000000000
}grant.revoke
grant.revokeRevoke a grant and every grant delegated from it.
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The grant to revoke; every grant delegated from it is revoked too |
| Result | Type |
|---|---|
revision | integer |
revoked | string[] |
local result = paneflow.grant.revoke{ id = "g-1" }{
"revoked": [
"g-1",
"g-2"
],
"revision": 5
}keymap
keymap.list
keymap.listList the key bindings init.lua declared and the keys it unbound, for the window to apply.
| Result | Type |
|---|---|
bindings | table[] |
unbound | table[] |
local result = paneflow.keymap.list(){
"bindings": [
{
"key": "ctrl-alt-d",
"action": "dev_layout",
"args": {
"file": "app.log"
},
"source": "init.lua:9",
"target": "lua"
}
],
"unbound": [
{
"key": "ctrl-shift-w",
"source": "init.lua:10"
}
]
}layout
layout.adopt
layout.adoptHand the worker a client's model after an outage. The worker takes it when its own revision is not greater than the revision it last acknowledged to the client, and otherwise returns its own view.
| Field | Type | Required | Description |
|---|---|---|---|
acknowledged | integer | Yes | The last revision the worker acknowledged to this client |
view | table | Yes | The layout model as plain data: {revision, state: {version, workspaces, active_workspace, active_space}, undo}, every workspace, tab, pane, split and surface carrying its stable id |
| Result | Type |
|---|---|
accepted | boolean |
revision | integer |
view | table? |
local result = paneflow.layout.adopt{ view = { revision = 14, state = { version = 3, workspaces = { }, active_workspace = 0, active_space = nil } }, acknowledged = 12 }{
"accepted": true,
"revision": 14,
"view": null
}layout.apply
layout.applyApply one layout op to the worker's model and return the new revision and its events. A refused op fails with -32070 and data {reason}: not_found, zoomed, pane_limit, tab_limit, surface_limit, ids_exhausted, invalid, or window_owns_layout while a window of an earlier build owns the layout.
A request that sets a command, a prompt or an env is refused with -32601 unless ipc.orchestration, ipc.scripting or ai_unrestricted is true in paneflow.json, or a spawn or layout grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
ids_from | integer | The client's next id when it applied the op; ids the op allocates are taken from the client's leases from here | |
op | table | Yes | One layout operation, named by its op field: split, close_pane, focus_pane, rename_surface, set_ratios, bind_session and the others of paneflow-layout, with the ids it acts on |
spawned_by | string | The session of the pane that asked the window for this op; the worker records it as the spawner of the terminals the op creates. Only the attached window may send it |
| Result | Type |
|---|---|
events | table[] |
revision | integer |
local result = paneflow.layout.apply{ op = { op = "focus_pane", pane = 5 } }{
"revision": 13,
"events": [
{
"type": "pane.focused",
"workspace_id": 1,
"tab_id": 2,
"pane_id": 5,
"data": {}
},
{
"type": "layout.changed",
"workspace_id": 1,
"tab_id": 2,
"data": {
"revision": 13
}
}
]
}layout.attach
layout.attachAttach this connection as a layout client until it closes, and return the view, its revision and the worker's epoch.
| Field | Type | Required | Description |
|---|---|---|---|
client | string | A name for the client in worker.status |
| Result | Type |
|---|---|
epoch | string |
revision | integer |
view | table |
local result = paneflow.layout.attach{ client = "window" }{
"epoch": "1a2b-19a7c3f0e00-0",
"revision": 12,
"view": {
"revision": 12,
"state": {
"version": 3,
"workspaces": [],
"active_workspace": 0,
"active_space": null
}
}
}layout.launch
layout.launchStart the terminal of a surface for the attached layout client that created it: the worker builds the launch from its configuration and the layout and creates the session under the id the client chose, which the client binds with bind_session. The surface must have no session or this one. Fails with -32070 and data {reason}: not_attached, not_found, invalid, host_unreachable or launch_failed with the host's message.
A request that sets a command, a prompt or an env is refused with -32601 unless ipc.orchestration, ipc.scripting or ai_unrestricted is true in paneflow.json, or a spawn or layout grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
appearance | any | The colors the terminal answers color queries with: {foreground, background, cursor, palette of 256 [r, g, b], dark} | |
cell | any | The cell size in pixels: {width, height} | |
cols | integer | Initial width in cells; 120 when absent | |
confine_to | string | A worktree the working directory must stay inside; a cwd outside it starts at the worktree | |
cwd | string | The working directory the client asks for | |
env | table<string, string> | Variables for this terminal, above the global and space ones | |
fallback | string | The directory used when cwd no longer exists | |
rows | integer | Initial height in cells; 40 when absent | |
session | string | Yes | The session id the client chose for the new terminal |
surface_id | integer | Yes | The terminal surface to start |
| Result | Type |
|---|---|
events | table[] |
notices | string[] |
revision | integer |
local result = paneflow.layout.launch{ surface_id = 7, session = "0190e4d2-7b2a-7c3d-8e4f-a1b2c3d4e5f6", cwd = "/home/me/project" }{
"revision": 15,
"events": [
{
"type": "layout.changed",
"workspace_id": 1,
"tab_id": 2,
"data": {
"revision": 15
}
}
],
"notices": []
}layout.lease_ids
layout.lease_idsGrant this connection a contiguous block of 1,024 ids for the elements it creates; the worker never grants an id twice, across restarts included.
| Result | Type |
|---|---|
end | integer |
start | integer |
local result = paneflow.layout.lease_ids(){
"start": 4097,
"end": 5121
}layout.sweep
layout.sweepRemove the records of ended sessions that no surface of the layout, no undo hold and no pending launch names, and with live, also stop the live sessions this host started that nothing holds. The attached layout client calls it after it restores; the worker runs the host requests. Fails with -32070 and data {reason}: not_attached or host_unreachable.
| Field | Type | Required | Description |
|---|---|---|---|
keep | string[] | Sessions the client holds outside the layout, such as dock terminals, which the sweep must keep | |
live | boolean | Also stop the live sessions this host started that nothing holds, as the first sweep after a restore does |
| Result | Type |
|---|---|
forgotten | string[] |
stopped | string[] |
local result = paneflow.layout.sweep{ live = true, keep = { } }{
"forgotten": [
"0190e4d2-7b2a-7c3d-8e4f-a1b2c3d4e5f6"
],
"stopped": []
}layout.view
layout.viewReturn the layout model the worker holds, with its revision and the worker's epoch.
| Field | Type | Required | Description |
|---|---|---|---|
unless_revision | integer | The revision the client holds; when it is still the worker's, view is null |
| Result | Type |
|---|---|
attached | boolean |
epoch | string |
revision | integer |
view | table? |
local result = paneflow.layout.view(){
"epoch": "1a2b-19a7c3f0e00-0",
"revision": 12,
"attached": true,
"view": {
"revision": 12,
"state": {
"version": 3,
"workspaces": [],
"active_workspace": 0,
"active_space": null
},
"undo": {
"records": [],
"held": []
}
}
}pane
pane.write
pane.writeRelay a message from one agent's pane into another's, once a human allows the pair.
request arrives as a number. With submit, the reply also carries delivered, started, reason and, when known, state.
| Field | Type | Required | Description |
|---|---|---|---|
scope | "workspace"|"all" | ||
session | string | Yes | The session to write into |
source_session | string | Yes | The calling pane's session (PANEFLOW_SESSION_ID) |
submit | boolean | ||
text | string | Yes | Text to relay, prefixed with a provenance line |
| Result | Type |
|---|---|
bytes | integer? |
message | string? |
request | string? |
status | string |
submit_mode | string? |
submitted | boolean? |
local result = paneflow.pane.write{ source_session = "123e4567-e89b-42d3-a456-426614174000", session = "223e4567-e89b-42d3-a456-426614174000", text = "the tests pass on main" }{
"status": "approval_pending",
"request": "7",
"message": "a human must allow it"
}peer
peer.classify
peer.classifySay whether a process runs inside one of the host's panes, and which one.
| Field | Type | Required | Description |
|---|---|---|---|
pid | integer | Yes | PID of the process to classify |
started_at | integer | Yes | Start time the caller read for that PID, in the host's process clock |
| Result | Type |
|---|---|
in_pane | boolean |
session | string? |
stale | boolean? |
unverified | string? |
workspace | string? |
local result = paneflow.peer.classify{ pid = 4242, started_at = 9876543 }{
"in_pane": true,
"session": "123e4567-e89b-42d3-a456-426614174000",
"workspace": "223e4567-e89b-42d3-a456-426614174000"
}prompt
prompt.follow
prompt.followStream the prompts this client can show: a following header, a requested frame for each pending prompt oldest first, then requested frames (id, spec, origin, remaining time, token) and ended frames (id, reason), keepalive frames when quiet. A pane never receives an agent's prompt.
| Field | Type | Required | Description |
|---|---|---|---|
kinds | ("input"|"pick")[] | Yes | The prompt kinds this client can show |
| Result | Type |
|---|---|
kinds | ("input"|"pick")[] |
pending | integer |
type | "following" |
local result = paneflow.prompt.follow{ kinds = { "input", "pick" } }{
"type": "following",
"kinds": [
"input",
"pick"
],
"pending": 1
}prompt.reply
prompt.replyAnswer or cancel a pending prompt. The first reply wins and every follower receives ended; a later one is refused with -32060 and data {reason: not_pending}. An agent's prompt takes a reply only with its token, from outside every pane.
| Field | Type | Required | Description |
|---|---|---|---|
answer | string|string[]|table | The text, the id, the list of ids or {text}, as the prompt's kind takes | |
cancel | boolean | Dismiss the prompt; the asker receives cancelled | |
id | integer | Yes | |
token | string | The requested frame's token; required for an agent's prompt |
| Result | Type |
|---|---|
id | integer |
reason | "answered"|"cancelled"|"timeout"|"no_client"|"failed" |
local result = paneflow.prompt.reply{ id = 3, answer = "feature/login" }{
"id": 3,
"reason": "answered"
}prompt.request
prompt.requestAsk the user through every attached client that can show the prompt; the first answer wins. Returns {status: answered, answer} within wait_ms, {status: pending, id} when wait_ms passes first, or the reason it ended: cancelled, timeout, no_client, unsupported, busy, rate_limited (an agent asking more than 3 times in a burst or more than once a second after it) or failed with a detail.
| Field | Type | Required | Description |
|---|---|---|---|
allow_other | boolean | Accept typed text that matches no item; the answer is {text} | |
body | string | Shown under the title, line breaks kept; at most 16384 bytes | |
confirm | string | Label of the confirming row | |
items | (string|table)[] | The choices of a pick prompt, at most 2000: an id string or an item | |
kind | "input"|"pick" | Yes | input asks for a line of text, pick for a choice among items |
multiple | boolean | Let the user tick several items; the answer is the list of ids | |
origin | table | Who asks, shown under the title | |
placeholder | string | ||
timeout | number | Seconds before the prompt ends with timeout: 300 by default, at most 3600 | |
title | string | Yes | |
value | string | Text the field starts with | |
wait_ms | integer | Milliseconds to wait for the answer before returning pending with the id, 0 by default, at most 25000 |
| Result | Type |
|---|---|
answer | string|string[]|table? |
detail | string? |
id | integer? |
status | "answered"|"pending"|"cancelled"|"timeout"|"no_client"|"unsupported"|"busy"|"rate_limited"|"failed" |
local result = paneflow.prompt.request{ kind = "input", title = "New branch", value = "feature/", wait_ms = 20000, origin = { kind = "action", name = "new_branch", title = "New branch" } }{
"status": "answered",
"id": 3,
"answer": "feature/login"
}prompt.wait
prompt.waitKeep waiting on a pending prompt by id, with the same outcomes as prompt.request.
| Field | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | |
wait_ms | integer | Milliseconds to wait, 0 by default, at most 25000 |
| Result | Type |
|---|---|
answer | string|string[]|table? |
detail | string? |
id | integer? |
status | "answered"|"pending"|"cancelled"|"timeout"|"no_client"|"unsupported"|"busy"|"rate_limited"|"failed" |
local result = paneflow.prompt.wait{ id = 4, wait_ms = 20000 }{
"status": "answered",
"id": 4,
"answer": "web"
}surface
surface.focus
surface.focusReveal a surface and give it the keyboard focus.
| Field | Type | Required | Description |
|---|---|---|---|
surface_id | integer | Yes |
| Result | Type |
|---|---|
focused | boolean |
scope | string |
surface_id | integer |
workspace | integer |
local result = paneflow.surface.focus{ surface_id = 7 }{
"focused": true,
"surface_id": 7,
"workspace": 0,
"scope": "workspace"
}surface.list
surface.listList the surfaces of the shown workspace, or of one workspace, with their identity.
| Field | Type | Required | Description |
|---|---|---|---|
scope | "workspace"|"all" | "all" reads beyond the calling pane's workspace when orchestration is open for it | |
scope_session | string | List the workspace that holds this session | |
workspace_id | integer | List this workspace instead of the shown one |
| Result | Type |
|---|---|
pane_count | integer |
scope_workspace_id | integer? |
surfaces | table[] |
workspace | integer |
local result = paneflow.surface.list(){
"pane_count": 1,
"workspace": 0,
"scope_workspace_id": null,
"surfaces": [
{
"surface_id": 7,
"name": "shell",
"title": "~/dev",
"cwd": "/home/me/dev",
"cmd": "zsh",
"workspace_id": 1,
"workspace": 0,
"scope": "workspace",
"tab_id": 1,
"tab_title": "Terminal",
"space": null,
"sandboxed": false
}
]
}surface.read
surface.readRead a surface's trailing scrollback lines.
| Field | Type | Required | Description |
|---|---|---|---|
fenced | boolean | Wrap the text in an untrusted-output fence; the ai_injection_fence setting decides when absent | |
lines | integer | Trailing lines to return, clamped to 1..4000 | |
name | string | Pick the surface by its unique name instead of its id | |
offset | integer | Lines to skip back from the end of the buffer | |
scope | "workspace"|"all" | "all" reads beyond the calling pane's workspace when orchestration is open for it | |
scope_session | string | ||
surface_id | integer | The surface to read; the first surface of the shown tab when absent | |
workspace_id | integer |
| Result | Type |
|---|---|
eof | boolean |
lines | integer |
output_generation | integer |
text | string |
total_lines | integer |
truncated | boolean |
local result = paneflow.surface.read{ surface_id = 7, lines = 2, fenced = false }{
"text": "cargo test\nok",
"lines": 2,
"total_lines": 40,
"eof": false,
"output_generation": 12,
"truncated": false
}surface.rename
surface.renameGive a surface a custom name, or clear it.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | The new name; an absent or empty name clears the custom name | |
new_name | string | Alias of name | |
surface_id | integer |
| Result | Type |
|---|---|
name | string? |
renamed | boolean |
local result = paneflow.surface.rename{ surface_id = 7, name = "tests" }{
"renamed": true,
"name": "tests"
}surface.search
surface.searchFind the scrollback lines of a surface that contain a pattern.
| Field | Type | Required | Description |
|---|---|---|---|
fenced | boolean | Add a text field holding every match in one untrusted-output fence; the ai_injection_fence setting decides when absent | |
max_matches | integer | Matches to return, clamped to 1..1000 | |
name | string | ||
pattern | string | Yes | Substring or pattern to find, at most 512 bytes |
scope | "workspace"|"all" | "all" reads beyond the calling pane's workspace when orchestration is open for it | |
scope_session | string | ||
surface_id | integer | ||
workspace_id | integer |
| Result | Type |
|---|---|
matches | table[] |
text | string? |
truncated | boolean |
local result = paneflow.surface.search{ surface_id = 7, pattern = "error" }{
"matches": [
{
"line": 31,
"text": "error[E0308]: mismatched types"
}
],
"truncated": false
}surface.send_keystroke
surface.send_keystrokeSend a named key such as escape or ctrl-c to a surface.
Refused with -32601 unless ipc.scripting or ai_unrestricted is true in paneflow.json, or a write grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
keystroke | string | Dash-separated key such as escape, ctrl-c or alt-f; required, and never one that submits a line | |
scope | "workspace"|"all" | ||
scope_session | string | ||
surface_id | integer |
| Result | Type |
|---|---|
sent | boolean |
local result = paneflow.surface.send_keystroke{ surface_id = 7, keystroke = "ctrl-c" }{
"sent": true
}surface.send_text
surface.send_textWrite text into a surface, submitting it only when asked.
Refused with -32601 unless ipc.scripting or ai_unrestricted is true in paneflow.json, or a write grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
force | boolean | Write even when the agent waits for a decision; the write is logged | |
paste | boolean | Force or refuse bracketed paste; decided from the target when absent | |
scope | "workspace"|"all" | ||
scope_session | string | The calling pane's session; writes stay in its workspace | |
submit | boolean | Submit with a carriage return after the text | |
surface_id | integer | ||
text | string | Text to write; required unless submit is true. At most 64 KiB |
| Result | Type |
|---|---|
agent_target | boolean |
agent_tool | string? |
length | integer |
paste | boolean |
sent | boolean |
submit_mode | "deferred_paste_cr"|"inline_cr"? |
submitted | boolean |
terminal_bracketed_paste | boolean |
local result = paneflow.surface.send_text{ surface_id = 7, text = "cargo test" }{
"sent": true,
"length": 10,
"submitted": false,
"paste": false,
"submit_mode": null,
"agent_target": false,
"agent_tool": null,
"terminal_bracketed_paste": false
}surface.split
surface.splitSplit the pane holding a surface and start a terminal in the new pane.
A request that sets a command, a prompt or an env is refused with -32601 unless ipc.orchestration, ipc.scripting or ai_unrestricted is true in paneflow.json, or a spawn or layout grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
command | string | ||
cwd | string | ||
direction | "horizontal"|"vertical" | Yes | horizontal stacks the panes, vertical puts them side by side |
env | table<string, string> | ||
label | string | ||
managed_worktree | table | ||
name | string | Alias of label | |
profile | "normal"|"agent"|"cached" | ||
prompt | string | ||
surface_id | integer | Split the pane holding this surface; the shown tab's first pane when absent | |
worktree | table | Create or reuse a Paneflow worktree for the new pane, which then starts in it; exclusive with managed_worktree |
| Result | Type |
|---|---|
direction | string |
new_tab | boolean |
notices | string[]? |
panes | integer |
split | boolean |
surface_id | integer |
tab_id | integer |
local result = paneflow.surface.split{ surface_id = 7, direction = "vertical" }{
"split": true,
"new_tab": false,
"tab_id": 3,
"direction": "vertical",
"panes": 2,
"surface_id": 9
}surface.status
surface.statusRead a surface's agent state, hook status and output generation.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | ||
surface_id | integer |
| Result | Type |
|---|---|
active_tool_name | string? |
hooked | boolean |
idle_ms | integer? |
last_result | string? |
message | string? |
output_generation | integer |
session | string |
state | string? |
state_seq | integer? |
surface_id | integer |
tool | string? |
waiting_ms | integer? |
local result = paneflow.surface.status{ surface_id = 7 }{
"surface_id": 7,
"state": "thinking",
"state_seq": 4,
"hooked": true,
"tool": "claude",
"active_tool_name": "Bash",
"message": null,
"last_result": null,
"waiting_ms": null,
"idle_ms": 1200,
"output_generation": 12,
"session": "123e4567-e89b-42d3-a456-426614174000"
}system
system.capabilities
system.capabilitiesList the methods this endpoint serves and whether its gates are open.
When no window is open, the host answers: its reply carries controller and host in place of methods.
| Result | Type |
|---|---|
methods | string[] |
orchestration | boolean |
scripting | boolean |
local result = paneflow.system.capabilities(){
"scripting": false,
"orchestration": false,
"methods": [
"system.ping",
"surface.list"
]
}system.counters
system.countersRead the app's work counters: renders, git spawns, process spawns.
| Result | Type |
|---|---|
counters | table |
local result = paneflow.system.counters(){
"counters": {
"root_renders": 120,
"sidebar_renders": 40,
"host_agent_snapshots_applied": 3,
"session_list_calls": 2,
"git_spawns": {
"total": 5,
"probe": 4,
"user_action": 1,
"by_subcommand": {
"status": 4,
"other": 1
}
},
"process_spawns": 7,
"process_identity": {
"pid": 4242,
"started_at": 1763600000000
}
}
}system.describe
system.describeDescribe every method, or one: owner, gate, params and result schemas, examples.
| Field | Type | Required | Description |
|---|---|---|---|
method | string | Describe only this method |
| Result | Type |
|---|---|
callable | boolean |
examples | table[] |
fallback | string? |
gate | string |
gate_note | string? |
in_capabilities | boolean |
methods | table[] |
name | string |
owner | string |
params | any |
reply | string |
result | any |
stream | boolean |
summary | string |
local result = paneflow.system.describe{ method = "system.ping" }{
"name": "system.ping",
"summary": "Check that the endpoint answers.",
"owner": "window",
"fallback": null,
"gate": "none",
"gate_note": null,
"reply": "inline",
"stream": false,
"in_capabilities": true,
"callable": true,
"params": {
"type": "object"
},
"result": {
"type": "object",
"properties": {
"pong": {
"type": "boolean"
}
}
},
"examples": [
{
"params": {},
"result": {
"pong": true
}
}
]
}system.identify
system.identifyName the running app, its version and its wire protocol.
| Result | Type |
|---|---|
name | string |
protocol | string |
version | string |
local result = paneflow.system.identify(){
"name": "PaneFlow",
"version": "0.20.0",
"protocol": "jsonrpc-2.0"
}system.ping
system.pingCheck that the endpoint answers.
| Result | Type |
|---|---|
pong | boolean |
local result = paneflow.system.ping(){
"pong": true
}system.whoami
system.whoamiSay how the answering process identifies the caller: window, worker, pane, external or unverified.
| Result | Type |
|---|---|
principal | string |
reason | string? |
session | string? |
workspace | string? |
local result = paneflow.system.whoami(){
"principal": "pane",
"session": "123e4567-e89b-42d3-a456-426614174000",
"workspace": "223e4567-e89b-42d3-a456-426614174000"
}tmux
tmux.compat
tmux.compatRun a tmux command for an agent team, as the paneflow tmux shim does.
| Field | Type | Required | Description |
|---|---|---|---|
argv | string[] | Yes | The tmux command line, at most 256 arguments and 256 KiB |
scope_session | string | ||
surface_id | integer | Yes | The calling pane's surface |
team | string | Yes | Team name, 1 to 64 bytes |
| Result | Type |
|---|---|
exit | integer |
stderr | string |
stdout | string |
local result = paneflow.tmux.compat{ team = "review", surface_id = 7, argv = { "display-message", "-p", "#{pane_id}" } }{
"stdout": "%0\n",
"stderr": "",
"exit": 0
}usage
usage.import
usage.importStart importing past activity from the agents' local logs.
accounts[].agent takes claude-code, codex or grok.
| Field | Type | Required | Description |
|---|---|---|---|
accounts | table[] | ||
force | boolean | usage.import only: start again even when an import already ran |
A value with no declared fields.
local result = paneflow.usage.import{ force = false }{}usage.refresh
usage.refreshRead fresh usage for the running agents and the listed accounts.
accounts[].agent takes claude-code, codex or grok.
| Field | Type | Required | Description |
|---|---|---|---|
accounts | table[] | ||
force | boolean | usage.import only: start again even when an import already ran |
A value with no declared fields.
local result = paneflow.usage.refresh{ accounts = { { agent = "codex", config_dir = "/home/me/.codex" } } }{}usage.snapshot
usage.snapshotRead the usage ledger snapshot.
A value with no declared fields.
local result = paneflow.usage.snapshot(){}worker
worker.hello
worker.helloOpen a worker connection and read the worker's identity and capabilities.
| Result | Type |
|---|---|
build_id | string |
capabilities | string[] |
endpoint | string |
home | string |
name | string |
pid | integer |
protocol | integer |
required_core_protocol | integer |
started_at_ms | integer |
version | string |
local result = paneflow.worker.hello(){
"name": "paneflow-serve",
"version": "0.20.0",
"build_id": "9f2c",
"protocol": 1,
"required_core_protocol": 1,
"pid": 4242,
"home": "/home/me/.paneflow",
"endpoint": "/home/me/.paneflow/serve/worker.sock",
"started_at_ms": 1763600000000,
"capabilities": [
"agent.follow"
]
}worker.shutdown
worker.shutdownAsk the worker to stop; terminals keep running in the host.
| Result | Type |
|---|---|
pid | integer |
stopping | boolean |
local result = paneflow.worker.shutdown(){
"stopping": true,
"pid": 4242
}worker.status
worker.statusRead the worker's pid, version, session count and counters.
The reply also carries a layout object.
| Result | Type |
|---|---|
capabilities | string[] |
core_connected | boolean |
counters | any |
endpoint | string |
home | string |
pid | integer |
protocol | integer |
session_count | integer |
version | string |
local result = paneflow.worker.status(){
"pid": 4242,
"protocol": 1,
"home": "/home/me/.paneflow",
"endpoint": "/home/me/.paneflow/serve/worker.sock",
"version": "0.20.0",
"session_count": 3,
"core_connected": true,
"capabilities": [
"agent.follow"
],
"counters": {
"sweeps": 10
}
}workspace
workspace.close
workspace.closeClose the workspace at an index; the last workspace cannot be closed.
| Field | Type | Required | Description |
|---|---|---|---|
index | integer | Yes | Zero-based workspace index |
| Result | Type |
|---|---|
closed | integer |
local result = paneflow.workspace.close{ index = 1 }{
"closed": 1
}workspace.create
workspace.createOpen a workspace with one terminal, or with a layout document.
A request that sets a command, a prompt or an env is refused with -32601 unless ipc.orchestration, ipc.scripting or ai_unrestricted is true in paneflow.json, or a spawn or layout grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
cwd | string | Directory of the first pane; it must exist | |
layout | table | ||
name | string | Workspace title | |
space | string | Space by name or id; the active space when absent |
| Result | Type |
|---|---|
index | integer |
panes | integer |
title | string |
local result = paneflow.workspace.create{ name = "review" }{
"index": 1,
"title": "review",
"panes": 1
}workspace.current
workspace.currentDescribe the shown workspace with its layout document, or null when none is shown.
| Result | Type |
|---|---|
cwd | string |
index | integer |
layout | table? |
panes | integer |
space | table? |
title | string |
local result = paneflow.workspace.current(){
"index": 0,
"title": "paneflow",
"cwd": "/home/me/dev/paneflow",
"panes": 1,
"space": null,
"layout": {
"type": "pane",
"surfaces": [
{
"surface_type": "terminal",
"name": "shell"
}
]
}
}workspace.list
workspace.listList every workspace with its title, directory, pane count and space.
| Result | Type |
|---|---|
workspaces | table[] |
local result = paneflow.workspace.list(){
"workspaces": [
{
"index": 0,
"title": "paneflow",
"cwd": "/home/me/dev/paneflow",
"panes": 2,
"active": true,
"space": null
}
]
}workspace.restore_layout
workspace.restore_layoutConform the shown tab to a layout document, reusing its panes.
A request that sets a command, a prompt or an env is refused with -32601 unless ipc.orchestration, ipc.scripting or ai_unrestricted is true in paneflow.json, or a spawn or layout grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
layout | table | Yes | Holds between 1 and 32 panes |
| Result | Type |
|---|---|
panes | integer |
restored | boolean |
local result = paneflow.workspace.restore_layout{ layout = { type = "split", direction = "vertical", children = { { type = "pane", surfaces = { {} } }, { type = "pane", surfaces = { {} } } } } }{
"restored": true,
"panes": 2
}workspace.select
workspace.selectShow the workspace at an index.
| Field | Type | Required | Description |
|---|---|---|---|
index | integer | Yes | Zero-based workspace index |
| Result | Type |
|---|---|
selected | integer |
local result = paneflow.workspace.select{ index = 1 }{
"selected": 1
}workspace.up
workspace.upOpen a workspace from pane specs, each with its own directory, command or prompt.
A request that sets a command, a prompt or an env is refused with -32601 unless ipc.orchestration, ipc.scripting or ai_unrestricted is true in paneflow.json, or a spawn or layout grant covers the calling pane.
| Field | Type | Required | Description |
|---|---|---|---|
layout | string | Layout preset | |
name | string | Workspace title | |
panes | table[] | Yes | |
space | string |
| Result | Type |
|---|---|
index | integer |
labels | string[] |
notices | string[]? |
panes | integer |
surface_ids | integer[] |
title | string |
local result = paneflow.workspace.up{ name = "agents", panes = { { label = "api" }, { label = "web" } } }{
"index": 1,
"title": "agents",
"panes": 2,
"surface_ids": [
11,
12
],
"labels": [
"api",
"web"
]
}