pub enum Event {
Show 30 variants
SessionStarted {
session_id: String,
project: String,
},
SessionDone {
session_id: String,
status: String,
},
SessionCancelled {
session_id: String,
},
SessionStatusChanged {
session_id: String,
status: String,
},
SessionInput {
session_id: String,
input: String,
},
ToolStarted {
session_id: String,
tool: String,
call_id: String,
args_preview: String,
},
ToolFinished {
session_id: String,
tool: String,
call_id: String,
success: bool,
result_preview: String,
},
ToolError {
session_id: String,
tool: String,
call_id: String,
error: String,
},
Log {
session_id: String,
level: String,
message: String,
},
Progress {
session_id: String,
message: String,
percent: Option<f32>,
},
Message {
session_id: String,
text: String,
},
PmThinking {
session_id: String,
text: String,
},
PmDelegating {
session_id: String,
agent: String,
task_preview: String,
},
AgentSpawned {
session_id: String,
agent: String,
},
AgentMessage {
session_id: String,
agent: String,
text: String,
},
AgentDone {
session_id: String,
agent: String,
status: String,
},
AgentFailed {
session_id: String,
agent: String,
error: String,
},
ToolCalled {
session_id: String,
tool: String,
preview: String,
},
ToolResult {
session_id: String,
tool: String,
preview: String,
},
AstOperation {
session_id: String,
op: String,
detail: String,
},
PhaseStarted {
session_id: String,
phase: String,
},
PhaseDone {
session_id: String,
phase: String,
status: String,
},
PhaseSkipped {
session_id: String,
phase: String,
persona: String,
},
PersonaDetected {
session_id: String,
persona: String,
},
LlmRequested {
session_id: String,
agent_name: String,
model: String,
prompt_tokens: Option<u32>,
},
LlmResponded {
session_id: String,
agent_name: String,
model: String,
completion_tokens: Option<u32>,
latency_ms: u64,
},
AgentStarted {
session_id: String,
agent_name: String,
runner_type: String,
},
ReportGenerated {
session_id: String,
agent_name: String,
word_count: usize,
status: String,
},
RecapGenerated {
session_id: String,
summary: String,
table_rows: Vec<(String, String)>,
},
Ping,
}Expand description
Real-time event types streamed to UI clients (browser, future Tauri).
Why: A single tagged enum keeps wire-format evolution tractable —
serde(tag = "type") produces {"type":"agent_message", ...} so the UI
can pattern-match on type and the back-end can grow new variants without
breaking older clients (unknown variants degrade to “ignored event”).
What: Variants cover the full PM lifecycle plus a Ping keepalive so SSE
connections don’t time out behind reverse proxies. session_id correlates
events to a specific task; the UI filters by session when scoped to a
task view.
Test: event_serializes_with_type_tag asserts the wire shape for one
variant; Event::Ping round-trips for the keepalive path.
Variants§
SessionStarted
SessionDone
SessionCancelled
SessionStatusChanged
A session’s lifecycle status changed (#2054 session-attach protocol).
Why: SessionStarted/SessionDone/SessionCancelled cover the two
endpoints of a session’s life, but the daemon-owned Session model
(vision spec Axiom 4) also transitions through intermediate states
(e.g. created -> running) that a freshly-session.attached
client should see. This variant is the generic “status is now X”
signal crate::session::registry::SessionRegistry emits on every
transition, including the two endpoints (so a client that attaches
mid-stream sees a uniform status trail rather than mixing this
variant with the older ones).
What: status is a lowercase string matching
session::model::SessionStatus’s serde representation ("created",
"running", "cancelled", "finished", "failed").
Test: session::registry::tests::create_publishes_started_and_status_events.
SessionInput
Input was received for a session via session.send (#2054).
Why: distinct from AgentMessage (sub-agent -> PM activity) —
this is the client -> daemon direction. Emitting it is what makes
session.send observably reach a freshly-session.attached client
in M1, ahead of any real agent-loop wiring (task.*, #2056).
What: input is the raw string the caller passed to session.send.
Test: session::registry::tests::send_publishes_input_event.
ToolStarted
A tool invocation began. Distinct from the older ToolCalled (which
has no started/finished/error distinction or call-correlation id, and
predates the session-attach protocol) — this is the tcode
session.attach taxonomy’s tool-lifecycle kind.
Why: call_id correlates this with the matching ToolFinished/
ToolError when a session runs multiple tool calls in sequence or
concurrently.
What: args_preview is truncated via preview() before emission.
Test: session::registry::registry_tests::record_tool_started_publishes_event.
ToolFinished
A tool invocation completed (success or failure signalled by success,
not a separate error variant — use ToolError for exceptional
failures the caller wants to narrate distinctly, e.g. a timeout).
ToolError
A tool invocation raised an exceptional error (as opposed to
completing with success: false) — e.g. the tool process crashed or
timed out rather than returning a normal failure result.
Log
A structured log line scoped to a session, for operators/UIs that want daemon-side diagnostics without parsing stderr.
Progress
A coarse progress update for a long-running session operation.
percent is None when progress isn’t quantifiable (e.g. “still
searching”) — the UI falls back to an indeterminate spinner.
Message
A generic, freeform session-scoped message that doesn’t fit any more specific kind — the taxonomy’s catch-all, used sparingly.
PmThinking
PmDelegating
AgentSpawned
AgentMessage
AgentDone
AgentFailed
ToolCalled
ToolResult
AstOperation
Emitted when an AST-native tool performs a structural code operation (symbol lookup, edit, insert, import, validation, patch apply, or project pre-indexing). Surfaces in the REPL’s thinking-step display so users can see structural analysis happening in real time.
Why: AST-native tools replace whole-file rewrites with surgical edits.
Without dedicated telemetry the user only sees opaque ToolCalled
events and loses the narrative of “indexed project → looked up symbol
→ staged edit → applied patch”. This event makes the AST narrative
visible.
What: op is a short label (index, lookup, edit, insert,
import, validate, patch); detail is a human-readable
substring (e.g. “42 symbols from src/” or “fn parse_args in main.rs”).
Test: ast_operation_round_trips_through_subscribe round-trips one
variant through the bus.
PhaseStarted
PhaseDone
PhaseSkipped
#196: a phase was skipped because the active persona opts out of it.
Why: Operators and the UI need visibility when persona-aware skipping
changes the executed workflow shape (e.g. [hacker] skipping QA).
Without this event the run looks like phases silently disappeared.
What: Carries the phase name and the persona that triggered the skip.
PersonaDetected
#196: emitted once per workflow run when a persona is detected from the task text. Lets the UI surface “running in [hacker] mode” before any phases execute, so users immediately see why the pipeline shape may differ from the default.
LlmRequested
Emitted just before any LLM chat-completion HTTP call leaves the
process. Pairs with LlmResponded so consumers can compute latency
independently and surface in-flight calls in the UI.
Why: Operators debugging slow runs need to see WHICH model is in flight
at any moment, not just retroactively in totals. prompt_tokens is
optional because we don’t always know the prompt size up front.
What: agent_name may be empty for top-level PM calls; model is the
resolved provider/model string sent on the wire.
LlmResponded
Emitted after every LLM chat-completion HTTP call returns successfully. Carries the wall-clock latency so the UI can render “model X took Yms” badges without waiting for end-of-run perf aggregation.
Fields
AgentStarted
Emitted when an agent’s actual work loop begins — distinct from
AgentSpawned, which fires when the subprocess is kicked off.
AgentStarted fires AFTER the spawn handshake (or at the start of an
in-process runner loop) so the UI can show “spawning…” vs. “running”
states. runner_type is one of “subprocess”, “claude-code”, “inline”.
ReportGenerated
Emitted when an agent produces its final result before returning to the PM. Lets the UI render “agent X returned a Y-word report” badges without parsing the result body.
Why: A coarse signal of agent productivity that complements
AgentDone. word_count is a cheap whitespace-split count; status
mirrors the agent’s IPC status field (“success” or “error”).
RecapGenerated
Emitted when a session recap is generated after N completed tasks (#371).
Carries the session ID, a one-line prose summary, and structured table rows.
Consumed by TUI (renders ※ recap: banner) and SSE → GUI (RecapPanel).
Fields
Ping
Implementations§
Source§impl Event
impl Event
Sourcepub fn session_id(&self) -> Option<&str>
pub fn session_id(&self) -> Option<&str>
Return the event’s session_id if it has one. Used by the SSE
handler to filter the broadcast stream to a single task subscription.
Why: Variants without a session (currently just Ping) must always
pass the filter — losing keepalives would defeat their purpose.
What: Returns Some(&str) for variants that carry a session, None
for keepalives. The SSE filter treats None as “always include”.
Sourcepub fn kind(&self) -> &'static str
pub fn kind(&self) -> &'static str
The stable kind string for this event — identical to the serde
"type" tag #[serde(tag = "type", rename_all = "snake_case")]
produces on the wire.
Why (#2055): SessionEventEnvelope carries kind as a top-level
field (vision spec’s envelope requirement) so a client can filter/
route on it without parsing into the nested event payload. Hand-
written rather than derived from serde reflection (no such API exists
without an extra dependency) — kind_matches_serde_tag_for_every_variant
guards the two from drifting apart.
What: Returns the exact snake_case tag string for every variant.
Test: kind_matches_serde_tag_for_every_variant.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnsafeUnpin for Event
impl UnwindSafe for Event
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more