コンテンツにスキップ
PaneflowPaneflow

スクリプトリファレンス

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 を実行
sessions [--json] [--follow]worker の session streamいいえウィンドウの有無にかかわらず agent session state を読む

CLI が受け付ける alias: list_panes は ls、read_pane は read、search_pane は search に map されます。

Selector

Selector例Notes
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 --broadcast、 wait --any、wait --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 を追加しません。 key は enter、ctrl-m、ctrl-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 --raw は fenced: false を渡します。

Agent state field

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

FieldMeaning
pidagent process id。既知の場合
toolclaude、codex、opencode、gemini などの agent family
statethinking、waiting_for_input、finished、errored、stalled、idle、unknown_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_h、even_v、main_vertical、tiled
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
worktreestringnoneworktrees.dir ルート配下の managed worktree 用 branch name(設定スキーマ参照)
fromstringHEADup が worktree を作るときに branch の起点にする branch または commit
copy_envbooltrueリポジトリの .worktreeinclude のエントリを worktree に copy。ファイルがなければ最上位の .env* と AGENTS.override.md
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: cwd、name、worktree、env、send.target、ready.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。XDG_RUNTIME_DIR が未設定か書き込み可能なディレクトリでない場合は $TMPDIR、それもなければ ~/.cache/run
macOS endpoint$TMPDIR/paneflow/paneflow.sock、なければ ~/Library/Caches/run。XDG_RUNTIME_DIR は無視されます
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.closeindexworkspace を閉じる
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.* lifecycle method は app socket で受け付けられなくなりました。 agent status は paneflow-ai-hook reporter から届き、events.subscribe は 引き続き ai.* event を配信します。

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_id、name、title、cwd、cmd、workspace を持つ 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 を読み、lifecycle event (ai.stop、ai.notification など) を 1 つローカル host に送り、0 で 終了します。停止した Paneflow instance が agent を壊さないためです。この hook surface が status、notification、ps、status、watch、 paneflow sessions を支えます。

コマンド効果
paneflow integrations listinstaller を持つ runtime とその状態を一覧
paneflow integrations install <runtime>claude-code (または claude) か codex の hook をインストールし、paneflow MCP server を登録
paneflow integrations remove <runtime>Paneflow 自身の handler だけを削除。同じ hook group にある自分の handler は残る
paneflow hooks setupinstaller を持つ検出済み runtime をすべてインストール
paneflow hooks uninstallintegration と paneflow MCP entry を削除
paneflow hooks statusruntime ごとに <runtime>: <state> を 1 行表示。常に 0 で終了

hook はマシンごとに一度、CLI か Settings > Agents からインストールします。 Claude Code の hook は $CLAUDE_CONFIG_DIR/settings.json (デフォルト ~/.claude/settings.json)、Codex の hook は $CODEX_HOME/hooks.json (デフォルト ~/.codex/hooks.json) に入り、Paneflow の pane の外ではすぐに 終了します。その他の agent には installer がなく、動作はしますが state は process detection に限定されます。

Worker とセッション

agent state は home ごとの worker が保持し、paneflow serve run として起動 されます。worker は PANEFLOW_HOME ごとに 1 つ切り離されて動作し、hook event をセッションごとの 1 つの状態にまとめ、再起動時にはディスクから再構築し、 実行中のシェルには一切触れません。ウィンドウが動いていないと ps と status は hook state を見られず、send --submit もそれで確認できません。 paneflow sessions は worker を直接読みます。

コマンド効果
paneflow serve startこの PANEFLOW_HOME の worker を起動、または既存の worker を採用
paneflow serve statuspid、protocol、home、セッション数、capability を表示
paneflow serve stop [--drain-ms 5000]worker を停止。ターミナルには触れない
paneflow sessions [--json] [--follow]サイドバーと同じセッション一覧を表示。--follow は遷移ごとに 1 行を表示し、worker の再起動後に自動で再接続
paneflow sessions ack <session-id>...完了したターンが立てた unread フラグを下ろす

関連

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