Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
ADR 0285: RACP-WS transport in packages/racp
- Status: Accepted for implementation
- Date: 2026-09-18
- Related: D373, D374, D375, D447, D448, ADR 0205, ADR 0284
Context
R0 froze the RACP contract as typebox schemas and R1 delivered the headless Agent Host
module, but nothing moved a JSON-RPC frame between processes: R2 needs the normative
RACP-WS binding on both sides of an SSH tunnel — a server the pi-host bundle binds on
loopback and a client Electron main runs — plus the device-token pairing of security §3.4.
Decision
- A new workspace package,
packages/racp, holds both ends of the binding and depends onshared,agent-host, andwsonly;RacpServerandRacpClienttake an injected transport, so the same code runs overwsin production and an in-memory pair in tests, withbindRacpWebSocketandwsClientTransportas the adapters. - The server is a thin catalog over the module: every operation in
RACP_OPERATIONSdispatches through the catalog's role rule, core session, turn, event, approval, and input operations call the module directly, and the remote-host profile goes throughRacpHostOperations, whichpi-hostimplements. - Authentication is a header profile with Host-issued device tokens: the upgrade request
must carry
Authorization: Bearer, and a token in the URL, non-loopback peer, wrong path, missing subprotocol, or binary frame is refused before any RPC;pdt1.device andppt1.pairing tokens are stored as SHA-256 hashes and compared in constant time, and a pairing token is single-use, expiring, and authenticates onlyconnection/pair, which mints anownerdevice. - Three catalog additions, all in the remote-host profile —
connection/pair,project/register, andproject/browse— come with the shared error codesPAIRING_FAILED,PAIRING_TOKEN_EXPIRED,CAPABILITY_UNAVAILABLE,REMOTE_PATH_NOT_FOUND,REMOTE_PATH_FORBIDDEN,HOST_DISCONNECTED,HOST_BOOTSTRAP_FAILED,HOST_VERSION_MISMATCH,REMOTE_AUTH_FAILED,REMOTE_CONNECTION_FAILED, andREMOTE_FORWARD_FAILED;connection/initializegainsserver.hostId. - Reconnect is the client's and replay is the Host's: the client reconnects with bounded
backoff, rejects the dropped connection's in-flight calls with
HOST_DISCONNECTED, never re-sends them, and remembers the last durable cursor per session so the caller resubscribes withafter, while the Host answers with a replay or a snapshot plusresyncReasonand a dropped connection releases its subscriptions without touching a turn. StartTurnParams.input.userMessageIdis threaded fromturn/start'sinput.messageIdthrough the queue record to the runtime, so a remote client keeps its optimistic user row id (D288).
Consequences
pi-hostcomposesRacpServer+bindRacpWebSocketover the module andRuntimeService(ADR 0284); the desktop adapter composesRacpClient+wsClientTransport.- Attachments and the tool relay are advertised as unavailable (
attachments: false,toolRelay: false) and fail withCAPABILITY_UNAVAILABLEuntil their own change. - The server bind refuses a non-loopback address rather than offering a TLS path.
Alternatives
- Run RACP inside Electron main first: the only scheduled client is the desktop, so a desktop listener would add network surface with no consumer.
- Static shared secret instead of pairing: security §3.2 and §3.4 require a single-use token that becomes a revocable per-device credential.