コンテンツにスキップ

スクリプトリファレンス

Paneflow 自動化の CLI verb、selector、JSON-RPC method、event frame、config key、workspace spec、flow spec、MCP tool、hook、exit code。

これは スクリプトと自動化 の compact reference です。人間の script や LLM が正確に引用できる public surface を 列挙します。

CLI verb

paneflow binary はこれらの verb を intercept し、GUI startup の前に終了します。未知の verb は app を暗黙に起動せず、usage code 2 で終了します。

Verb主な method または enginepane に書き込むか用途
ls [--human]surface.listいいえactive workspace の pane を一覧
read <target>surface.readいいえpane scrollback を読む
search <target> <pattern>surface.searchいいえpane scrollback を検索
ps [--json]fleet.listいいえworkspace 全体の検出済み agent を一覧
status <target> [--json]surface.statusいいえ1 つの pane の agent state を読む
newworkspace.createいいえworkspace を作成
select <index>workspace.selectいいえworkspace を選択
split <h|v>surface.splitいいえpane を split
focus <target>surface.focusいいえpane とその workspace を focus
send <target> <text>surface.send_textgatedtext を stage または submit
key <target> <keystroke>surface.send_keystrokegatedsubmit しない keystroke を送信
wait --match <sel>surface.read, events.subscribeいいえpattern、idle、または両方まで block
watch [--surface <sel>] [--type <event>]events.subscribeいいえlifecycle event と surface event を stream
up <file>Workspace spec engineprefill のみ宣言的 workspace を作成
flow run <file>Flow enginesubmit する step は gatedローカル multi-agent DAG を実行

CLI が受け付ける alias: list_paneslsread_panereadsearch_panesearch に map されます。

Selector

SelectorNotes
Numeric idpaneflow read 42surface_id と完全一致
Namepaneflow status backend長く使う script で最も安定
cmdline:<substr>paneflow read cmdline:viteLinux では full foreground argv、macOS と Windows では executable basename
cwd:<path>paneflow read cwd:/home/me/apipane working directory と一致

何にも match しない selector、または複数 pane に match する selector は code 3 で終了します。ただし send --broadcastwait --anywait --all のように複数 match を明示的に受け付 ける command は例外です。

Exit code

CodeMeaning
0成功
1Runtime failure: instance unreachable、pane closed、gate refused、handler error
2CLI usage error
3target not found または ambiguous
4wait timeout または flow ready timeout

Write gate

読み取りはデフォルトで許可されています。書き込みは capability ごとに分かれます。

OperationGate
send without --submitPANEFLOW_IPC_SCRIPTING=1 または ai_unrestricted
send --submitPANEFLOW_IPC_SCRIPTING=1 または ai_unrestricted
keyPANEFLOW_IPC_SCRIPTING=1
submit = true の flow stepsystem.capabilities が report する scripting capability

send--submit がない限り carriage return を追加しません。 keyenterctrl-mctrl-j のような submit する keystroke を拒否します。1 つの surface.send_text payload は 64 KiB に制限されます。

関連する config key:

KeyDefaultMeaning
ai_unrestrictedfalse信頼された AI automation が env gate なしで text を submit できる
ai_injection_fencetruesurface.read text を信頼できない terminal envelope で包む
submit_paste_delay_ms70bracketed paste と submit carriage return の間の base delay
terminal.envnone新しい terminal に注入される environment variable

Read field

paneflow read <target> --json と raw surface.read は次を返しま す。

FieldMeaning
textscrollback text。デフォルトで fenced
lines返された line count
total_lines保持されている total line count
eofread が保持されている最古の line に到達したか
output_generationpane output によって進む monotonic counter

default と limit: lines は default 200 で、1-4000 に clamp さ れます。offset は buffer の末尾から始まります。範囲外の offset は invalid-params error です。

JSON-RPC param fenced は default で ai_injection_fence を使 います。CLI flag --rawfenced: false を渡します。

Agent state field

paneflow ps --json{"agents":[...]} を返します。 paneflow status <target> --json は 1 つの status object を返し ます。

FieldMeaning
pidagent process id。既知の場合
toolclaudecodexopencodegemini などの agent family
statethinkingwaiting_for_inputfinishederroredstalledidleunknown_running
hookedlifecycle hook event が attached されているか
reasondetection reason。no_hook を含む
surface_idpane id
surface_namepane name
workspaceworkspace index
active_tool_nameagent 内で現在動作している tool
messagewaiting prompt または permission text
last_result利用可能な場合の last turn summary
waiting_msinput 待ちに費やした時間
idle_ms最後に観測された activity からの時間
output_generationstatus 上の pane output counter

空の fleet は exit code 0{"agents":[]} です。tracked agent がない pane は error ではなく idle state を返します。

Workspace spec

paneflow up <file> は TOML workspace spec を読みます。

Top-level fieldTypeDefaultNotes
namestring"Workspace"workspace title
layoutstring"even_h"even_heven_vmain_verticaltiled
port_baseinteger3000${port_offset} allocation の base
[[panes]]arrayrequiredpane ごとに 1 entry
Pane fieldTypeDefaultNotes
cwdstringnoneexpansion と canonicalization 後に存在する必要がある
agentstringnoneagent launcher name。command と mutually exclusive
commandstringnoneraw command。agent と mutually exclusive
promptstringnoneagent input に prefill される。up は submit しない
focusboolfalseこの pane に initial focus を与える
envtablenoneterminal.env の上に merge。${port_offset} を support
namestringnonestable selector name
worktreestringnone<repo>.worktrees/ 配下の managed worktree 用 branch name
copy_envbooltruegitignored .env* files を worktree に copy
setupstringnonelaunch 前に実行される command
setup_timeout_secsinteger300setup timeout
worktree_teardownstring"auto"auto は close 時に clean worktree を削除、keep は残す

${port_offset}env value 内でのみ置換されます。不明な key は error です。workspace creation は pane を作る前に path を検 証します。

Flow spec

paneflow flow run <file> は TOML flow spec を読み、現在の Paneflow instance に対して実行します。

FieldTypeNotes
idstringrequired。unique step id
needsarraydependency。foreach では全 instance を待つ
foreacharrayfan-out。item ごとに 1 instance
paneinline tableworkspace pane field を使って pane を spawn
sendinline table{ target, text, submit? }。dependency が必要
readytable{ pattern, timeout_secs? }。regex barrier
capturetable{ var, lines }ready 後に 1-500 lines を capture
submitboolspawned pane prompt を submit。scripting access が必要

Variables:

VariableScope
${item}foreach step: cwdnameworktreeenvsend.targetready.pattern、prompt、text
${var}send.text と submitting pane.prompt 内の captured value
${var.<item>}foreach group からの capture

runner は実行前に、unknown key、missing dependency、dependency cycle、invalid regex、undefined capture、pane budget、missing timeout を検証します。Ctrl-C は orchestration loop を止めま す。作成済み pane は Paneflow に残ります。

JSON-RPC connection

PropertyValue
Linux endpoint$XDG_RUNTIME_DIR/paneflow/paneflow.sock
macOS endpointuser runtime dir。同じ Paneflow socket name
Windows endpoint\\.\pipe\paneflow
FramingNewline-delimited JSON-RPC 2.0
Request modelevents.subscribe 以外は 1 connection につき 1 request
Local trustsame user only。network listener、token、TLS はなし
Backpressureconnection cap と bounded event queue が structured error または dropped frame を返す

runtime で capability を probe します。

bash
printf '%s\n' '{"jsonrpc":"2.0","method":"system.capabilities","params":{},"id":1}' \
| nc -U "$PANEFLOW_SOCKET_PATH"

JSON-RPC method

MethodParamsReturns or notes
system.ping-liveness check
system.capabilities-{scripting, methods[]}
system.identify-{name, version, protocol}
workspace.list-index と title を持つ workspace
workspace.current-active workspace
workspace.createname?, cwd?, layout?workspace を作成
workspace.selectindexworkspace を切り替え
workspace.closeindex?workspace を閉じる
workspace.upname, layout, panes[]up と flow root が使う declarative spawn
workspace.restore_layoutlayoutlayout tree を適用
surface.list-{surfaces:[{surface_id,name,title,cwd,cmd,workspace}]}
surface.readsurface_id, lines?, offset?, fenced?scrollback と output_generation
surface.searchsurface_id, pattern, max_matches?case-insensitive substring match
surface.renamesurface_id, namepane name を rename または clear
surface.focussurface_idpane と workspace を focus
surface.statussurface_id1 つの pane の agent state
surface.send_textsurface_id, text, submit?, paste?gated PTY text write
surface.send_keystrokesurface_id, keystrokeenv-gated non-submitting keystroke
surface.splitdirection, surface_id?, cwd?, command?, prompt?, env?, name?, managed_worktree?pane を split
fleet.list-read-only fleet snapshot
events.subscribesurfaces?, types?persistent newline-delimited event stream
ai.session_starthook payloadlifecycle telemetry
ai.prompt_submithook payloadlifecycle telemetry
ai.tool_usehook payloadlifecycle telemetry
ai.notificationhook payloadlifecycle telemetry
ai.stophook payloadlifecycle telemetry
ai.exithook payloadlifecycle telemetry
ai.session_endhook payloadlifecycle telemetry

structured failure は JSON-RPC error envelope を使います: -32602 invalid params、-32601 gated method、-32001 permission、 -32000 backpressure。一部の legacy validation error はまだ result 内の {"error":"..."} として返ります。client は両方 を failure として扱ってください。

Event

paneflow watch と raw events.subscribe は newline-delimited JSON を emit します。最初の frame は subscription ack です。

Event typeMeaning
subscribedsubscription acknowledged
ai.session_startagent session starts
ai.prompt_submitprompt is submitted
ai.tool_useagent reports tool use
ai.notificationagent asks for input or permission
ai.stopagent turn stops
ai.exitagent process exits
ai.session_endagent session closes
surface_changedpane output_generation advanced
heartbeatidle keepalive
droppedsubscriber lagged and events were shed

dropped frame の後は、paneflow ps --json または paneflow status <target> --json で resync します。

MCP bridge

paneflow-mcp は、同じ Paneflow socket 上の read-only stdio MCP server です。

ToolParamsReturns
list_panes-surface_idnametitlecwdcmdworkspace を持つ pane
read_panetarget, lines?, offset?scrollback text
search_panetarget, pattern, max_matches?matching lines

typing、submitting、focusing、splitting panes のための tool はあ りません。返された terminal output は信頼できない data として fenced されます。

Lifecycle hook

paneflow-ai-hook は stdin から event JSON を読み、JSON-RPC ai.* frame を 1 つ post し、0 で終了します。停止した Paneflow instance が agent を壊さないためです。この hook surface が status、notification、psstatuswatch を支えます。

persistent paneflow hooks setup は Claude Code scoped です。 Codex は launch ごとの shim hook を使います。hook surface のな い agent も動きますが、state は process detection に限定され ることがあります。

関連

Paneflowの作者 Arthur Jean によって執筆されました。