pub struct Hooks {
pub(crate) pre_tool_use: Vec<(String, Arc<dyn ErasedHookCallback>)>,
pub(crate) post_tool_use: Vec<(String, Arc<dyn ErasedHookCallback>)>,
pub(crate) post_tool_use_failure: Vec<(String, Arc<dyn ErasedHookCallback>)>,
pub(crate) user_prompt_submit: Vec<Arc<dyn ErasedHookCallback>>,
pub(crate) stop: Vec<Arc<dyn ErasedHookCallback>>,
pub(crate) subagent_stop: Vec<Arc<dyn ErasedHookCallback>>,
pub(crate) subagent_start: Vec<Arc<dyn ErasedHookCallback>>,
pub(crate) pre_compact: Vec<Arc<dyn ErasedHookCallback>>,
pub(crate) notification: Vec<Arc<dyn ErasedHookCallback>>,
pub(crate) permission_request: Vec<(String, Arc<dyn ErasedHookCallback>)>,
pub(crate) default_timeout_secs: Option<u64>,
}Expand description
Registry of hook callbacks. Construct with HooksBuilder, attach to
OptionsBuilder via .hooks(...).
Fields§
§pre_tool_use: Vec<(String, Arc<dyn ErasedHookCallback>)>§post_tool_use: Vec<(String, Arc<dyn ErasedHookCallback>)>§post_tool_use_failure: Vec<(String, Arc<dyn ErasedHookCallback>)>§user_prompt_submit: Vec<Arc<dyn ErasedHookCallback>>§stop: Vec<Arc<dyn ErasedHookCallback>>§subagent_stop: Vec<Arc<dyn ErasedHookCallback>>§subagent_start: Vec<Arc<dyn ErasedHookCallback>>§pre_compact: Vec<Arc<dyn ErasedHookCallback>>§notification: Vec<Arc<dyn ErasedHookCallback>>§permission_request: Vec<(String, Arc<dyn ErasedHookCallback>)>§default_timeout_secs: Option<u64>Timeout (seconds) the CLI should apply to every hook callback.
None means “use the default forge-sdk emits” (120 seconds).
Overridable via
HooksBuilder::default_timeout_secs for scenarios that need
to provoke control_cancel_request on slow callbacks.
Implementations§
Source§impl Hooks
impl Hooks
Sourcepub(crate) fn mint_registry(&self) -> HookRegistry
pub(crate) fn mint_registry(&self) -> HookRegistry
Mint opaque callback_ids (e.g. hook_0, hook_1, …) for every
registered callback and return them bundled for dispatch-time
lookup. Returns a map id → callback plus a parallel metadata
vector describing which event/matcher each id belongs to (used to
populate the initialize control_request payload).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Hooks
impl !UnwindSafe for Hooks
impl Freeze for Hooks
impl Send for Hooks
impl Sync for Hooks
impl Unpin for Hooks
impl UnsafeUnpin for Hooks
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
Mutably borrows from an owned value. Read more