pub struct Hooks { /* private fields */ }Expand description
The hooks of every loaded plugin, ready to run around a tool call.
Implementations§
Source§impl Hooks
impl Hooks
pub fn new( hooks: Vec<Arc<Hook>>, workspace: PathBuf, profile: impl Into<String>, ) -> Self
Sourcepub async fn before(
&self,
tool: &str,
arguments: &Value,
call_id: Option<&str>,
) -> Verdict
pub async fn before( &self, tool: &str, arguments: &Value, call_id: Option<&str>, ) -> Verdict
Every before_tool hook runs in load order; the first refusal wins. A hook that
cannot run (missing file, timeout, crash) refuses too: a guard that silently stops
guarding is worse than a stopped tool.
call_id names the model-issued tool call this is (None when the caller is not
the loop). With concurrency above 1 the payloads of several calls interleave, so a
hook that keeps per-call state keys on it.
Sourcepub async fn after(
&self,
tool: &str,
arguments: &Value,
outcome: ToolOutcome,
call_id: Option<&str>,
) -> ToolOutcome
pub async fn after( &self, tool: &str, arguments: &Value, outcome: ToolOutcome, call_id: Option<&str>, ) -> ToolOutcome
Every matching after_tool hook sees the outcome; a hook that prints something and
exits 0 replaces the output, so one hook can redact what another added. A failing
hook leaves the output alone.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Hooks
impl Freeze for Hooks
impl Move for Hooks
impl RefUnwindSafe for Hooks
impl Send for Hooks
impl Sync for Hooks
impl Unpin for Hooks
impl UnsafeUnpin for Hookswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<Arc<Hook>>: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
impl UnwindSafe 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