pub struct HookEvent {
pub kind: HookKind,
pub tool_name: Option<String>,
pub tool_runtime_name: Option<String>,
pub tool_input: Option<Value>,
pub tool_output: Option<String>,
pub message: Option<String>,
pub session_id: Option<String>,
pub transcript: Option<Vec<Value>>,
pub data: Value,
}Expand description
A hook event payload dispatched to extension handlers.
Fields are optional and populated only when relevant to the hook kind:
| Kind | tool_name | tool_input | tool_output | message | session_id |
|---|---|---|---|---|---|
before_tool_call | ✓ | ✓ | |||
after_tool_call | ✓ | ✓ | ✓ | ||
before_message | ✓ | ||||
on_message_complete | ✓ | ||||
on_compaction | ✓ | ✓ | |||
on_session_start | ✓ | ||||
on_session_end | ✓ |
The data field is available on all events for extensions that need to
attach arbitrary structured context when constructing synthetic events.
Fields§
§kind: HookKindWhich hook fired.
tool_name: Option<String>Tool name for tool-specific hooks; None for general hooks.
This is the API-safe name (sanitized for the LLM).
tool_runtime_name: Option<String>Original runtime name of the tool (before API sanitization). Extension authors typically write runtime names in their manifests.
tool_input: Option<Value>Tool input arguments for before_tool_call and after_tool_call.
tool_output: Option<String>Tool output for after_tool_call.
message: Option<String>LLM message content for before_message.
session_id: Option<String>Session identifier for session lifecycle hooks.
transcript: Option<Vec<Value>>Session message history for on_session_end.
Contains the conversation transcript so extensions (like Stelline)
can extract memories without reaching into runtime internals.
data: ValueArbitrary extension-defined data, passed through without inspection.
Implementations§
Source§impl HookEvent
impl HookEvent
Sourcepub fn before_tool_call(tool_name: &str, input: Value) -> Self
pub fn before_tool_call(tool_name: &str, input: Value) -> Self
Construct a before_tool_call event.
Sourcepub fn after_tool_call(tool_name: &str, input: Value, output: String) -> Self
pub fn after_tool_call(tool_name: &str, input: Value, output: String) -> Self
Construct an after_tool_call event carrying both input and output.
Output is truncated to MAX_HOOK_OUTPUT_SIZE to prevent sending
megabytes of bash output over the JSON-RPC pipe.
Sourcepub fn before_message(message: &str) -> Self
pub fn before_message(message: &str) -> Self
Construct a before_message event.
Sourcepub fn on_message_complete(message: &str, data: Value) -> Self
pub fn on_message_complete(message: &str, data: Value) -> Self
Construct an on_message_complete event.
Sourcepub fn on_compaction(
old_session_id: &str,
new_session_id: &str,
summary: &str,
message_count: usize,
data: Value,
) -> Self
pub fn on_compaction( old_session_id: &str, new_session_id: &str, summary: &str, message_count: usize, data: Value, ) -> Self
Construct an on_compaction event.
Sourcepub fn on_session_start(session_id: &str) -> Self
pub fn on_session_start(session_id: &str) -> Self
Construct an on_session_start event.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for HookEvent
impl<'de> Deserialize<'de> for HookEvent
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>,
Auto Trait Implementations§
impl Freeze for HookEvent
impl RefUnwindSafe for HookEvent
impl Send for HookEvent
impl Sync for HookEvent
impl Unpin for HookEvent
impl UnsafeUnpin for HookEvent
impl UnwindSafe for HookEvent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.