Skip to main content

Module event_msg

Module event_msg 

Source
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::Value produced by that type’s own Serialize. 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§

AgentProgressActivity
Lifecycle metadata paired with a human-readable AgentProgress message.
AgentRosterRow
One row of the receipts-only agent roster.
EventEnvelope
Envelope that carries an EventMsg over the wire / channel with a monotonic seq so consumers can detect drops. Mirrors the existing RuntimeEventEnvelope but typed to EventMsg.
McpDiscoveredItem
One discovered MCP tool / resource / prompt.
McpManagerSnapshot
Engine-owned MCP pool snapshot.
McpServerSnapshot
One configured MCP server as seen by the engine-owned pool.
RouteBillingEnvelope
Billing evidence captured at application admission before the provider permit. This does not attest network delivery. Absent before admission.
TokenUsage
Token usage reported by a provider for one model call or one whole turn. Field-for-field twin of the engine’s Usage; None means the provider did not report the fact, never zero.
TurnRoute
Provider/model route resolved for a model-backed turn.
TurnRouteReceipt
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.
UserInputRequest
Structured clarification request (request_user_input).

Enums§

EventMsg
One event emitted by the core engine to every consumer (TUI, CLI, app-server, tests). This is the EventMsg-out half of the Op-in / EventMsg-out contract: a projection of every internal engine Event variant plus the thread/session ids that route it.
RouteProduct
Credential/pay-mode product truth captured at the client-freeze boundary.
SubAgentFollowUpOutcome
Receipt for an operator follow-up to a child agent.
ToolCallError
Structured error surfaced by a tool execution.
ToolCallOutcome
Outcome of a tool call: the engine’s Result<ToolResult, ToolError>.
ToolGate
Which permission gate produced a ToolGateDecision.
ToolGateVerdict
What a permission gate decided for one proposed tool call.
TurnOutcomeStatus
Final status for a turn (TurnComplete.status).

Constants§

EVENT_KINDS
Every wire tag EventMsg can 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 and kind_str agree.