#[non_exhaustive]pub struct HookMatcher {
pub tool: Option<String>,
pub tool_glob: Option<String>,
pub safety: Vec<SafetyClass>,
}Expand description
Matching conditions for a single hook.
Shape is identical to defect-config’s HookMatcher; the agent crate does not depend
on config,
so this is defined independently and the CLI translates the config shape into the
agent shape at assembly time.
See hooks design for trust model.
All fields empty = match all triggers under that event.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.tool: Option<String>Match by exact tool name (only for *ToolUse* events).
tool_glob: Option<String>Glob match by tool name (only for *ToolUse* events).
safety: Vec<SafetyClass>Filter by SafetyClass (only PreToolUse); any match triggers. Empty vec = no
filter.
Implementations§
Source§impl HookMatcher
impl HookMatcher
Sourcepub fn matches_step(
&self,
tool: Option<&str>,
safety: Option<SafetyClass>,
) -> bool
pub fn matches_step( &self, tool: Option<&str>, safety: Option<SafetyClass>, ) -> bool
Matches a step model by tool name and safety (both taken from the step envelope;
non-tool steps pass None).
All fields empty = matches everything. tool is exact, tool_glob is a glob
pattern, safety matches any (empty vec = no filter).
Trait Implementations§
Source§impl Clone for HookMatcher
impl Clone for HookMatcher
Source§fn clone(&self) -> HookMatcher
fn clone(&self) -> HookMatcher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more