Skip to main content

PiEvent

Enum PiEvent 

Source
pub enum PiEvent {
    AgentStart,
    AgentEnd {
        messages: Vec<PiMessage>,
    },
    TurnStart,
    TurnEnd {
        message: Box<PiMessage>,
        tool_results: Vec<PiMessage>,
    },
    MessageStart {
        message: Box<PiMessage>,
    },
    MessageUpdate {
        message: Option<Box<PiMessage>>,
        usage: Option<Usage>,
        assistant_message_event: Value,
    },
    MessageEnd {
        message: Box<PiMessage>,
    },
    ToolExecutionStart {
        tool_call_id: String,
        tool_name: String,
        args: Value,
    },
    ToolExecutionUpdate {
        tool_call_id: String,
        tool_name: String,
        args: Value,
        partial_result: Value,
    },
    ToolExecutionEnd {
        tool_call_id: String,
        tool_name: String,
        result: Value,
        is_error: bool,
    },
    Unknown {
        event_type: String,
        payload: Value,
    },
}
Expand description

One event from the --mode json / --mode rpc stdout stream, discriminated on type. Known lifecycle events are typed with their primary fields lifted; every variant keeps its full payload reachable (unmodeled fields land in extra), and unknown types fall back to PiEvent::Unknown instead of erroring.

Variants§

§

AgentStart

agent_start

§

AgentEnd

agent_end — carries the turn’s messages.

Fields

§messages: Vec<PiMessage>
§

TurnStart

turn_start

§

TurnEnd

turn_end

Fields

§message: Box<PiMessage>
§tool_results: Vec<PiMessage>
§

MessageStart

message_start

Fields

§message: Box<PiMessage>
§

MessageUpdate

message_update — streaming delta; in --mode json the cumulative message snapshot is omitted and only the incremental assistantMessageEvent (kept raw here) arrives.

Fields

§usage: Option<Usage>
§assistant_message_event: Value
§

MessageEnd

message_end

Fields

§message: Box<PiMessage>
§

ToolExecutionStart

tool_execution_start

Fields

§tool_call_id: String
§tool_name: String
§args: Value
§

ToolExecutionUpdate

tool_execution_update

Fields

§tool_call_id: String
§tool_name: String
§args: Value
§partial_result: Value
§

ToolExecutionEnd

tool_execution_end

Fields

§tool_call_id: String
§tool_name: String
§result: Value
§is_error: bool
§

Unknown

Any other type (session events like queue_update, compaction_start/compaction_end, bash_execution_update, extension UI requests, and whatever future CLIs add). The full object is preserved.

Fields

§event_type: String
§payload: Value

Implementations§

Source§

impl PiEvent

Source

pub fn event_type(&self) -> &str

The wire type string.

Source

pub fn from_value(v: Value) -> Result<Self, Error>

Parse one stdout JSON object into a typed event.

Trait Implementations§

Source§

impl Clone for PiEvent

Source§

fn clone(&self) -> PiEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PiEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PiEvent

Source§

fn eq(&self, other: &PiEvent) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for PiEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.