pub enum LifecycleEvent {
Show 15 variants
SessionStart {
source: Option<String>,
},
SessionEnd {
reason: Option<String>,
},
WorkingStart,
WorkingEnd,
Idle,
PromptSubmit {
prompt: Option<String>,
},
NeedsInput {
reason: NeedsInputReason,
},
ToolCallStart {
name: Tool,
tool_use_id: Option<String>,
input: Option<Value>,
},
ToolCallEnd {
name: Tool,
tool_use_id: Option<String>,
is_error: bool,
},
ContextCompactStart {
trigger: Option<String>,
},
ContextUpdate {
tokens: Option<u64>,
cost_usd: Option<f64>,
},
ProviderModelChange {
provider: Option<String>,
model: Option<String>,
},
Notification {
message: Option<String>,
kind: Option<NotificationKind>,
},
ChildSessionStart {
id: Option<String>,
role: Option<String>,
},
ChildSessionEnd {
id: Option<String>,
},
}Expand description
Vendor-neutral lifecycle event.
Adapters translate native vendor events into these variants; the daemon dispatches on them to update session state.
Eq is intentionally not derived: ContextUpdate carries an
Option<f64> cost, which is not Eq.
Variants§
SessionStart
Session opened. source carries why (Claude: startup/resume/
clear; pi: startup).
SessionEnd
Session closed. reason is vendor-supplied when available
(pi session_shutdown.reason; Claude SessionEnd.reason).
WorkingStart
Agent began a working block.
(Pi agent_start; Claude has no direct analog — synthesized
from UserPromptSubmit or first PreToolUse.)
WorkingEnd
Agent finished a working block.
(Pi agent_end; Claude Stop.)
Idle
Explicit idle signal. Distinct from WorkingEnd because pi can
transition idle → idle (no work happened) via
ctx.isIdle() && !ctx.hasPendingMessages().
PromptSubmit
User submitted a prompt.
NeedsInput
Session is waiting on user input.
Fields
reason: NeedsInputReasonToolCallStart
A tool started executing.
tool_use_id is the correlation id pairing this with its later
ToolCallEnd (Claude tool_use_id, pi toolCallId). input
is the tool arguments JSON, when the vendor exposes it.
ToolCallEnd
A tool finished executing. tool_use_id matches the originating
ToolCallStart.
ContextCompactStart
Context compaction is starting. trigger is the cause
(Claude: auto/manual).
ContextUpdate
Periodic context-usage update (tokens used, accumulated cost).
Either field may be None if the vendor doesn’t expose it.
ProviderModelChange
Provider or model changed mid-session (pi model_select).
Notification
Free-form notification surfaced to the user. kind carries an
optional sub-type the UI can render specially.
ChildSessionStart
A child session (subagent / task / fork) started.
id is a vendor-supplied correlation id; role is a free-form
tag (e.g. Claude subagent role: "explore", "plan").
ChildSessionEnd
A child session finished.
Implementations§
Source§impl LifecycleEvent
impl LifecycleEvent
Sourcepub fn is_terminal_for_turn(&self) -> bool
pub fn is_terminal_for_turn(&self) -> bool
True if this event ends/clears the session’s working state.
Sourcepub fn is_starting(&self) -> bool
pub fn is_starting(&self) -> bool
True if this event opens the session’s working state.
Trait Implementations§
Source§impl Clone for LifecycleEvent
impl Clone for LifecycleEvent
Source§fn clone(&self) -> LifecycleEvent
fn clone(&self) -> LifecycleEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LifecycleEvent
impl Debug for LifecycleEvent
Source§impl<'de> Deserialize<'de> for LifecycleEvent
impl<'de> Deserialize<'de> for LifecycleEvent
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>,
Source§impl PartialEq for LifecycleEvent
impl PartialEq for LifecycleEvent
Source§fn eq(&self, other: &LifecycleEvent) -> bool
fn eq(&self, other: &LifecycleEvent) -> bool
self and other values to be equal, and is used by ==.