Skip to main content

Hooks

Struct Hooks 

Source
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

Source

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§

Source§

impl Clone for Hooks

Source§

fn clone(&self) -> Self

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 Hooks

Source§

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

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

impl Default for Hooks

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more