pub enum RunEvent {
SessionStarted {
protocol_version: u32,
cli_version: String,
model: String,
task_id: Option<String>,
session_id: String,
},
Text {
delta: String,
},
Reasoning {
delta: String,
},
ToolStarted {
call_id: String,
},
ToolFinished {
call_id: String,
name: String,
status: String,
summary: String,
error: Option<String>,
plan: Option<PlanApproved>,
web: Option<Box<WebEventDetails>>,
},
ApprovalRequired {
call_id: String,
tool: String,
risk: String,
prompt: String,
},
TasksUpdated {
tasks: Vec<TaskLine>,
completed: u32,
total: u32,
},
Error {
message: String,
},
TurnDone {
total_tokens: Option<u64>,
stop_reason: Option<String>,
},
Result {
response: String,
reasoning: Option<String>,
total_tokens: u64,
errors: Vec<String>,
session_id: String,
structured_output: Option<Value>,
},
}Expand description
One line of the mermaid run --format ndjson stream. Internally tagged on
type (snake_case), matching the house style for stable wire unions
(ToolMetadata).
Variants§
SessionStarted
First line of every stream: protocol version + run identity.
Fields
protocol_version: u32RUN_EVENT_PROTOCOL_VERSION at the time of emission.
Text
A chunk of assistant answer text.
Reasoning
A chunk of model reasoning / thinking.
ToolStarted
A tool began executing (bracketed by a later RunEvent::ToolFinished
with the same call_id).
ToolFinished
A tool finished. name is derived from the run metadata; status is
success / error / cancelled.
Fields
plan: Option<PlanApproved>Present when this call is exit_plan_mode resolving with an
APPROVED plan — first-class plan visibility for SDK/daemon
subscribers without breaking the started/finished pairing.
Additive: absent for every other tool, and omitted from the wire
when None.
web: Option<Box<WebEventDetails>>Structured, secret-safe web transport details for web tools.
ApprovalRequired
A gated tool is waiting for approval. Headless runs surface this so a supervising process can decide.
Fields
TasksUpdated
The session task checklist changed (task_create / task_update /
a user /tasks edit). Full snapshot of the visible list, so consumers
never need to correlate diffs. Additive — protocol stays v1.
Fields
Error
The turn hit a recoverable or terminal upstream error.
TurnDone
A model turn completed (token usage + why it stopped, when known).
Fields
Result
Terminal line of the stream: the aggregated run result.
Implementations§
Source§impl RunEvent
impl RunEvent
Sourcepub fn from_msg(msg: &Msg) -> Option<RunEvent>
pub fn from_msg(msg: &Msg) -> Option<RunEvent>
Project a lifecycle Msg into a public RunEvent, or None for the
many messages that have no place in the SDK stream.
Pure and stateless: tool identity is read from the finished outcome’s
metadata rather than correlated across messages, so no projector state
is required. The wildcard arm is intentional here (this is a lossy
projection, not the reducer — most Msgs are deliberately dropped).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RunEvent
impl<'de> Deserialize<'de> for RunEvent
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>,
impl StructuralPartialEq for RunEvent
Auto Trait Implementations§
impl Freeze for RunEvent
impl RefUnwindSafe for RunEvent
impl Send for RunEvent
impl Sync for RunEvent
impl Unpin for RunEvent
impl UnsafeUnpin for RunEvent
impl UnwindSafe for RunEvent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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