Skip to main content

Module protocol

Module protocol 

Source
Expand description

Shared wire protocol for rpi’s headless RPC mode (--mode rpc, the server) and the remote client (--connect).

Single source of truth: the server serializes these types and the client deserializes them, so the contract cannot drift between the two ends.

Wire shape (one JSON object per line):

  • the server opens with {"type":"ready"}, then
  • streams RemoteEvents ({"type":"agent_start"}, {"type":"message_update",…}, …), and
  • answers each RemoteCommand with a RemoteResponse ({"type":"response",…}).

These are intentionally not the core pi-agent/pi-ai types: AgentEvent is documented as process-local (see pi-agent/src/events.rs) and deliberately has no serde impl. This module projects the process-local events into a stable, wire-safe shape, and translates back only the subset the client needs. That keeps the core crates untouched and the client free of local resources.

Structs§

PromptOutcome
The prompt result payload ({outcome, finalText}).
RemoteResponse
The server’s answer to a single RemoteCommand.
SessionState
The get_state result payload, as a typed view over the response.

Enums§

RemoteCommand
A command sent from the client to the server ({"id":…,"type":…,…}).
RemoteEvent
A fine-grained lifecycle event streamed from the server to the client.
ResponseStatus
Response status for a RemoteResponse.

Functions§

tool_result_json
Serialize a tool result into the stable wire shape (content blocks, details, usage, and the batch hints).