Skip to main content

Module io

Module io 

Source
Expand description

Typed models of pi’s wire vocabulary: the messages and events shared by --mode json (one-shot JSONL event stream) and --mode rpc (command protocol; see crate::rpc).

Shapes mirror the documented TypeScript types (packages/ai/src/types.ts, packages/agent/src/types.ts, and packages/coding-agent/docs/{json,rpc}.md in earendil-works/pi). Unknown event types are preserved verbatim in PiEvent::Unknown rather than erroring, so a newer CLI degrades soft.

Structs§

Model
A model catalog entry (get_state/set_model/get_available_models). With no provider configured, get_state returns a placeholder with id: "unknown" and zeroed limits — treat contextWindow == 0 as “no real model resolved”.
Usage
Per-request/response token accounting on assistant and tool messages.
UsageCost
Dollar cost breakdown inside Usage.

Enums§

ContentBlock
One block of assistant content: text, thinking, or a tool call.
PiEvent
One event from the --mode json / --mode rpc stdout stream, discriminated on type. Known lifecycle events are typed with their primary fields lifted; every variant keeps its full payload reachable (unmodeled fields land in extra), and unknown types fall back to PiEvent::Unknown instead of erroring.
PiMessage
A conversation message, discriminated on role. This is pi’s AgentMessage union plus the RPC-only bashExecution role.