Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Socket API

Flock exposes a newline-delimited JSON (NDJSON) API over a Unix domain socket. The in-tree flock-multiplexer server implements HerdR-compatible automation methods; flock-herdr is the NDJSON client.

Source: crates/flock-multiplexer/src/api.rs · HerdR-compatible NDJSON automation (external herdr binary not required)

Connect

SettingDefault
Socket path$FLOCK_SOCKET~/.config/flock/flock.sock$XDG_RUNTIME_DIR/flock.sock
ProtocolOne JSON request per line; one JSON response per line
Streamingevents.subscribe and pane.attach may stream additional NDJSON events

Ensure the server is running:

flock multiplexer ensure
# or
flock herd server

Example request:

{"id": 1, "method": "ping", "params": {}}

Example response:

{"id": 1, "result": {"type": "pong", "version": "...", "protocol": "..."}}

Errors use {"id": ..., "error": {"code": "...", "message": "..."}}.

Method catalog

MethodPurpose
pingHealth check; returns server and protocol version
session.snapshotFull session tree snapshot
session.attachResolve named session → workspace + pane
workspace.createCreate workspace with label, optional cwd
workspace.listList workspaces
tab.createCreate tab in workspace
tab.listList tabs (optional workspace filter)
tab.focusFocus tab by id
pane.splitBSP split (direction, ratio, optional cwd)
pane.swapSwap panes
pane.zoomZoom pane (mode: toggle / in / out)
pane.focusFocus pane
pane.listList panes (optional workspace/tab filter)
pane.readRead visible screen text
pane.send_textSend text to pane PTY
pane.send_keysSend key sequence
pane.send_inputSend text and/or keys
pane.resizeResize PTY rows/cols
pane.writeRaw write to pane
pane.attachStream pane output (subscription)
pane.report_agentHook: report agent name + state
pane.clear_agent_authorityClear agent authority on pane
agent.getAgent info for target pane
agent.sendSend text to agent pane
agent.listList agents (optional workspace filter)
agent.startStart registered agent in new/split pane
agent.explainDiagnose agent state heuristics
events.subscribeStream filtered events
events.waitBlock until matching event (timeout)
worktree.createGit worktree helper
worktree.listList worktrees
worktree.removeRemove worktree
server.live_handoffGraceful server restart (layout preserved)
server.stopAcknowledge stop (server may exit)

Methods marked Stream return an initial result then additional NDJSON event lines on the same connection.

CLI mapping

Automation needCLI
Rich status dashboardflock herd status
Attach to paneflock herd attach --pane <id>
Wait for agent idleflock herd wait --pane <id> --status idle
Install agent hooksflock integration install <agent>
Remote over SSHflock remote --ssh user@host

Agent detection

Screen heuristics detect Claude, Codex, and Cursor agent states (idle / working / blocked). Hooks via pane.report_agent provide authoritative state when integrations are installed.

Live handoff

server.live_handoff writes ~/.config/flock/sessions/handoff.json, spawns a replacement daemon, and releases the socket. PTY processes are not preserved across handoff — layout and visible text restore only.

Testing

cargo test -p flock-multiplexer
cargo test -p flock-herdr
flock multiplexer ensure
flock herd status

See Daily driver loop for the operator workflow.