pub enum HookEvent {
PreToolUse,
PostToolUse,
}Expand description
When a participant is consulted.
One variant per interception point mentra offers. It is spelled out rather
than assumed so a config file says when a hook fires — and the default is
PreToolUse, so every hooks file written before there
was a second point still means what it said.
The two are not two halves of one question. Before the call, the whole question is whether it should happen and in what form; afterwards it has happened, and the only thing left to decide is what the model is shown. A hook that wants both says so twice.
Variants§
PreToolUse
Before the tool runs — and, since mentra 0.24, before the schema check
and the ToolAuthorizer too.
So a hook is asked about every registered call, including ones the approver goes on to refuse: being consulted is not being approved, and a participant with side effects of its own must not read it that way. What it may take from the ordering is that a rewrite it returns is what the approver is then asked about.
PostToolUse
After the tool ran, before the model is shown what it returned.
Too late to stop anything: the side effects have happened and the unmodified result has already reached the event stream. What a participant still has is the output, which is the only place some questions can be answered at all — whether a grep pulled a credential out of a file nobody meant to expose, whether stderr carries an internal hostname.
Trait Implementations§
impl Copy for HookEvent
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>,
impl Eq for HookEvent
impl StructuralPartialEq for HookEvent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.