Expand description
EventMsg-out API in crates/protocol (issue #5261, Phase A1 of the
core/protocol extraction spec).
Mirrors crates/tui/src/core/events::Event variant-by-variant as a
serializable protocol. The TUI’s rx_event / Event channel, the
app-server’s SSE stream, and the CLI’s stream-json output all speak this
one type so headless and TUI observe byte-identical event shapes for the
same Op.
Parity is compile-enforced from the engine side:
crates/tui/src/core/protocol_parity.rs matches every engine Event
variant exhaustively into an EventMsg (protocol_covers_engine_events).
Adding an engine variant without a twin here fails to compile.
Payload fidelity rules for this phase:
- Scalars, ids, lifecycle enums, route/billing receipts, tool outcomes, MCP snapshots, approvals, and gate decisions are typed here.
- Deep domain payloads whose canonical serde type still lives above this
crate (goal snapshots, sub-agent results, coordination projections,
mailbox messages, transcript messages, tool catalogs, tool inspection
snapshots, workflow UI events) cross as
serde_json::Valueproduced by that type’s ownSerialize. They are typed in later phases; the variant and its field names are already stable. - Engine-only handles (
oneshot/Notify,Arc<HookExecutor>) never cross. A variant that carried one is projected without it.
Structs§
- Agent
Progress Activity - Lifecycle metadata paired with a human-readable
AgentProgressmessage. - Agent
Roster Row - One row of the receipts-only agent roster.
- Event
Envelope - Envelope that carries an
EventMsgover the wire / channel with a monotonic seq so consumers can detect drops. Mirrors the existingRuntimeEventEnvelopebut typed toEventMsg. - McpDiscovered
Item - One discovered MCP tool / resource / prompt.
- McpManager
Snapshot - Engine-owned MCP pool snapshot.
- McpServer
Snapshot - One configured MCP server as seen by the engine-owned pool.
- Route
Billing Envelope - Billing evidence captured at application admission before the provider permit. This does not attest network delivery. Absent before admission.
- Token
Usage - Token usage reported by a provider for one model call or one whole turn.
Field-for-field twin of the engine’s
Usage;Nonemeans the provider did not report the fact, never zero. - Turn
Route - Provider/model route resolved for a model-backed turn.
- Turn
Route Receipt - Secret-free proof of the base route a turn’s client was installed on. The credential generation digest is redacted by design on the engine side and never crosses; only its presence does.
- User
Input Request - Structured clarification request (
request_user_input).
Enums§
- Event
Msg - One event emitted by the core engine to every consumer (TUI, CLI,
app-server, tests). This is the
EventMsg-out half of theOp-in /EventMsg-out contract: a projection of every internal engineEventvariant plus the thread/session ids that route it. - Route
Product - Credential/pay-mode product truth captured at the client-freeze boundary.
- SubAgent
Follow UpOutcome - Receipt for an operator follow-up to a child agent.
- Tool
Call Error - Structured error surfaced by a tool execution.
- Tool
Call Outcome - Outcome of a tool call: the engine’s
Result<ToolResult, ToolError>. - Tool
Gate - Which permission gate produced a
ToolGateDecision. - Tool
Gate Verdict - What a permission gate decided for one proposed tool call.
- Turn
Outcome Status - Final status for a turn (
TurnComplete.status).
Constants§
- EVENT_
KINDS - Every wire tag
EventMsgcan carry, in declaration order. Kept next to the enum so a new variant is added here in the same edit; the test below proves the list andkind_stragree.