Architecture
PiFi has three kinds of components. The README shows how they fit together in a deployment; this page shows what is inside them.
Who owns what
For the core, module, plugin and adapter boundary and feature checklist, see the ownership contract; for the kinds of host, client, scope and trigger and who can add one, see modules.
| Area | Owner |
|---|---|
| Tasks, automations, dispatch decisions, scopes, devices, clients and their bindings, notifications | Coordinator |
| Which session is a branch’s primary, subagent parents, where a session was started | Coordinator |
| Branches and their stages | Nobody: derived from workspaces, sessions and tracked issues (model.md) |
| Pi processes, interactions, filesystem and git state | Host |
| Native conversation history (Pi’s session files) | Pi |
| Issues, assignees, board columns | GitHub (a tracked-issue snapshot in the coordinator; see scopes.md) |
| Transcript items for display | Coordinator (a cache built from host events) |
Reliability rules
- Ordered, durable events. Hosts write each event to a local outbox before sending it and resend unacknowledged events after reconnecting. The coordinator assigns one global sequence number; clients reconnect with a cursor and get the missed events or a snapshot. Streaming text is sent live but not stored.
- Commands run once. Every command carries an ID, and hosts store receipts, so a resent command returns the stored result. A task launch is recorded before it is sent and carries a dispatch key the host remembers, so a lost reply or a restart never starts work twice. An uncertain launch is reconciled with its host, never moved to another host.
- Control is versioned. Taking over a run increments its control revision; hosts reject automated commands that carry an older revision.
- Interactions are answered once. An answer must match the interaction’s ID and revision; a second answer gets the first one’s result.
- Nothing is replayed after a crash. An interrupted session keeps its Pi conversation and waits for you to resume it.
Orchestration and external services
The coordinator persists task hierarchy, agent inbox messages, policy rules and approvals. The host binds bridge requests to the actual session and forwards them over the authenticated host link; Pi does not receive a device token. Task and message creation use tool-call identity for deduplication, but a lost Pi enqueue receipt can leave delivery uncertain: execution is not exactly once. See policies.md.
GitHub operations run in an isolated coordinator-side worker (@pifi/catalog-github) using GitHub App or PAT credentials stored in the coordinator data directory; hosts need only git and Pi. See github.md.
Pi integration
Each live session is one Pi process: by default interactive Pi in a terminal holder, controlled through an extension (terminal-sessions.md); as a fallback, pi --mode rpc, spoken to over JSON lines on stdin and stdout. PiFi also loads a small bridge extension into every Pi it starts; it reports when an extension opens a dialog, including terminal-only dialogs that RPC mode cannot show, so PiFi can say so instead of hiding it. Supported capabilities and known limits are listed in compatibility.md.
Packages
| Package | Role |
|---|---|
protocol |
Shared zod schemas and types: entities, events, host and client wire formats, REST API |
pi-runtime |
Pi RPC client, session runtime, version gate and the bridge extension |
adapter-sdk |
Adapter manifest, hooks, registry and portable UI components |
adapter-examples |
An example adapter for adapter authors |
host-agent |
The host agent: Pi supervisor, worktrees, outbox, dispatch, enrollment |
coordinator |
The coordinator: sign-in, tasks, scheduler, attention, push, operations |
web |
The web app (desktop and mobile layouts) |
terminal |
Coordinator client library: REST, live sync, the Pi terminal relay client |
cli |
The pifi command |
test-fixtures |
Mock model and identity provider, isolated Pi environments for tests |