@semanaut/zpi-peer3.2.3
pi extension: equal, durable pi peers, each in its own terminal — a console window, a tmux window, or a Herdr tab, whichever matches where the spawning pi runs — plus a letter channel between any pi sessions. Runs on Linux, macOS and Windows; macOS has no
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
@semanaut/zpi-peer
Equal, durable pi peers plus a letter channel between any pi sessions, for pi.
Peers are equal instances, not subordinates: each runs in its own terminal — a console window, a tmux window, or a Herdr tab, whichever matches where the spawning pi runs — with its own context, its own token budget, and its own mistakes. A peer is an ordinary separate pi process, so when it exits its session id goes dark while its history stays durable on disk, and the peer can always be brought back.
Platforms
- Linux, macOS, Windows. Windows needs no WSL or Cygwin: a peer opens in a native console window.
- Three carriers: a console window, a tmux window, or a Herdr tab. A peer lands in the carrier the spawning pi itself runs in, and a revive lands there too.
- macOS has not been exercised yet. It is built for, not tested on: if anything misbehaves there — spawn, revive, letters — please open an issue at https://github.com/spaceater/zpi-peer/issues.
Management
- Spawn: a peer is launched in a new window or tab of your own carrier, with a pre-assigned sessionId, on pi's own default model.
peer_spawnreturns only once the peer is verifiably up, and reports a failure instead of a sid that never booted. - Liveness: a session is alive exactly while its process is alive. Ending the peer (closing its window, killing its tmux pane, closing its Herdr tab, or killing the process) makes the session id go dark; the session file remains on disk.
- Revive: a dark session is restarted with
pi --session <sid>, restoring its full history. The sid becomes disk-durable once the peer submits its first message; a peer killed before that cannot be resumed. - State on screen: the tmux window status bar shows one slot per running Pi, in current pane index order. Slots show idle (
[ ]), working (a spinner), or waiting for input ([⏸]) and disappear when Pi exits. The extension installs the status format automatically on the current tmux server. Herdr shows each pane's agent state by itself. - The normal workflow works: switch windows or panes, watch a peer work live, kill it by hand when done.
If you use tmux
Turn pane borders on — pi keeps each pane's terminal title up to date as <name> - <directory>, and the border is where tmux shows it, so a window holding several panes stays readable:
set -g pane-border-status top
The four tools
peer_spawn(task, context?)— launch an equal peer in its own terminal (a console window, a tmux window, or a Herdr tab, matching where you run).taskis delivered as the peer's first user message;contextisfork:<sessionId>(inherit that session's full history, nothing else),handoff:<text>(your own text, prepended to the task), or omitted. There is no name, model or role parameter: the peer starts unnamed and runs on pi's default model.peer_list(contact?, page?)— list sessions with their contact counts, cwd and sessionId, newest first, 15 per page. Filter by contact ("self"= the sessions you have spawned or exchanged letters with; any sessionId = who that session communicated with).peer_send_letter(to, headline, message)— deliver a letter to one or more pi sessions' mailboxes, peers and human-started alike.tois a list: every id must already exist on disk, or the whole call is rejected and nothing is sent — so one letter can reach several sessions that all need it, without repeating the call.headlineis the only text injected into the recipient — the body is not — so it has to let them triage the letter alone; the recipient reads the body from the letter file and then moves it into the mailbox'sarchive/, so the inbox stays clean and the letter is kept. Dead recipients are revived automatically, in parallel.peer_name(name?)— read or set a session's own name. Omit the argument to read the name as it exists on disk (the lastsession_infoentry — the same value every external reader sees); pass a name to set it, effective immediately. The tool never touches another session: renaming another peer goes through a letter, so the peer also learns why its name changed.
Nothing is assigned from outside
A peer is born with no name, no role and no procedure installed in it. Everything it knows about its mission arrives in two places — the task text and the optional context (and, later, letters). That is the whole design: there is no side channel, no hidden identity store, and no system prompt injection, so a peer can inspect every instruction it is under and push back on it.
Consequences worth knowing:
- It is unnamed until it names itself.
peer_listshows—until then, and its letters leave from a bare sessionId. A task should normally ask the peer to name itself from its mission first. - The brief has to carry the whole brief. Goal, boundaries, deliverable shape, evidence standard, what "done" means, where to reply. What you leave unsaid is a decision you handed to the peer without saying so.
- The model is the peer's own. Neither the spawner's model nor one named at spawn is propagated; a peer's model comes from its own pi configuration.
- A stance is text. "Verify by doing, then criticize" or "commit to one recommendation and name the fact that would flip it" travels in the task or in a letter — there is no role slot to put it in.
Data layout
<agent dir>/peer/registry/<sessionId>/contacts.txt— append-only contact log, one sessionId per line (both directions, written by whoever spawned or mailed).<agent dir>/peer/letters/<sessionId>/— the session's mailbox (pending-*.mdletters awaiting announcement, later the same name without the prefix);archive/inside it keeps the letters that session has read, since reading moves the letter rather than deleting it.
Compatibility
zpi-peer only adds tools and session-scoped handlers and patches no pi internals, so it does not affect subagent or other orchestration extensions and can be used alongside them.
Automatic revival
Mailing a dead recipient revives it automatically: the letter is written first, then the session is relaunched via pi --session <sid> in a new window of the caller's carrier, and the call waits (up to ~25s) until the peer is verifiably up — a running session gets the notice within ~1.5s (steer while running, followUp when idle). If the revive fails, the letter stays queued and is read at the next start. The revive never bypasses pi's own resume logic: a peer that is not up within the budget (pi exited, or waits at an interactive prompt) counts as a failure.
Bundled skill
Installs the peer-orchestrator skill alongside the extension: when to spawn peers (only for genuinely parallel, independent work), how to write a self-contained task — with three example briefs to adapt — how to choose a peer's starting context, how to batch follow-up letters, and how naming works now that only a session can name itself.