pub enum HookEvent {
ResponseStart {
response_id: String,
},
ResponseDelta {
response_id: String,
delta: String,
},
ResponseEnd {
response_id: String,
},
ToolLifecycle {
response_id: String,
tool_name: String,
phase: String,
payload: Value,
},
JobLifecycle {
job_id: String,
phase: String,
progress: Option<u8>,
detail: Option<String>,
},
ApprovalLifecycle {
approval_id: String,
phase: String,
reason: Option<String>,
},
GenericEventFrame {
frame: Box<EventFrame>,
},
}Expand description
All events that can be emitted through the hook system.
Each variant represents a distinct lifecycle or streaming event. The enum is
serialised with a "type" discriminator using snake_case naming (e.g.
"response_start", "tool_lifecycle"), making it easy to consume from
JSON-based log files or webhook receivers.
Variants§
ResponseStart
A new response stream has started.
ResponseDelta
A chunk of text has been received for an in-progress response.
Fields
ResponseEnd
A response stream has finished.
ToolLifecycle
A tool invocation has transitioned to a new phase (e.g. start, end, error).
Fields
JobLifecycle
A background job has transitioned to a new phase.
Fields
ApprovalLifecycle
An approval request has transitioned to a new phase.
Fields
GenericEventFrame
A catch-all variant that wraps an arbitrary EventFrame.
Use this when you need to forward a protocol-level event frame without mapping it to a more specific variant.
Fields
frame: Box<EventFrame>The raw event frame to forward.
Implementations§
Source§impl HookEvent
impl HookEvent
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
Serialise this event into a serde_json::Value.
Returns a JSON object with the "type" discriminator and all variant
fields. If serialisation fails (which should be extremely rare), a
fallback {"type":"serialization_error"} value is returned instead of
panicking.