High-Level Architecture
Component Responsibilities
Gateway Process
The gateway is the single host process. It never runs untrusted code — all agent computation happens inside sandboxes.Channels
The gateway always runs in its own process. The TUI (the only built-in channel) runs as a separate process. Other channels (Telegram, Discord, etc.) are provided by plugins and run in-process with the gateway.
The TUI runs pi’s
InteractiveMode locally for the full pi experience (editor, streaming, model switching, compaction). LLM calls are proxied through the gateway’s /api/chat/stream endpoint — the TUI never needs API keys. Tool execution (read, write, patch, exec) is proxied through the gateway’s HTTP API to the sandbox.
Sandbox (per agent)
Each agent gets its own Docker container. The container is long-lived (sleep infinity) and commands are executed via docker exec.
What Lives Where
❌ Dashed-X lines = no access. Secrets, config, session settings, and logs never enter the sandbox.
