pub struct JsonLineEvent {
pub event_type: String,
pub extra: HashMap<String, Value>,
}Expand description
A single parsed JSONL event from --json output.
The event_type field corresponds to the "type" key in the JSON.
All other fields are captured in extra.
Fields§
§event_type: String§extra: HashMap<String, Value>Implementations§
Source§impl JsonLineEvent
impl JsonLineEvent
Sourcepub fn session_id(&self) -> Option<&str>
pub fn session_id(&self) -> Option<&str>
Returns the session_id field, if present and a string.
Sourcepub fn is_turn_completed(&self) -> bool
pub fn is_turn_completed(&self) -> bool
Returns true when this is the terminal event of a successful turn.
Sourcepub fn is_turn_failed(&self) -> bool
pub fn is_turn_failed(&self) -> bool
Returns true when this is the terminal event of a failed turn.
Sourcepub fn usage(&self) -> Option<TokenUsage>
pub fn usage(&self) -> Option<TokenUsage>
Token counts reported by a turn.completed event.
Returns None on any other event, or when no usage object is
present. The CLI reports tokens, not money; see TokenUsage.
Sourcepub fn agent_message_text(&self) -> Option<String>
pub fn agent_message_text(&self) -> Option<String>
Assistant text carried by an item.completed agent-message item.
Returns None for any other event or item type.
Real output uses a type discriminator and a text field; see the
schema block at the top of this module. An item_type discriminator
and a content block array are also accepted, neither of them
observed. Tolerating the unobserved shapes is deliberate: the previous
parser committed to one exact layout and silently yielded empty results
when it was wrong, which is the bug this replaces.
Sourcepub fn content_text(&self) -> Option<String>
pub fn content_text(&self) -> Option<String>
Extracts concatenated text from a content blocks array.
Each block with "type": "text" contributes its "text" value.
Returns None if there is no content array or no text blocks.
Sourcepub fn item_type(&self) -> Option<&str>
pub fn item_type(&self) -> Option<&str>
The item discriminator on an item.* event.
agent_message and command_execution are the observed values. This
is the field to match on when narrowing an item event, and it is
present on item.started as well as item.completed.
Accepts item_type as well as type for the same reason
agent_message_text does.
Sourcepub fn command_execution(&self) -> Option<CommandExecution>
pub fn command_execution(&self) -> Option<CommandExecution>
A shell command the model ran, from a command_execution item.
None for any other item. exit_code and status are only populated
on item.completed; an item.started for the same command carries the
command alone.
Trait Implementations§
Source§impl Clone for JsonLineEvent
impl Clone for JsonLineEvent
Source§fn clone(&self) -> JsonLineEvent
fn clone(&self) -> JsonLineEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more