pub struct HookDef {
pub type: HookType,
pub command: Option<String>,
pub prompt: Option<String>,
pub model: Option<String>,
pub timeout: u64,
pub retry: u32,
pub on_error: OnError,
pub filter: HookFilter,
}Expand description
Hook 定义(YAML 兼容):支持 bash 和 llm 两种类型
YAML 示例(bash):
- command: "echo '{\"user_input\": \"hooked\"}'"
timeout: 10
on_error: skipYAML 示例(llm):
- type: llm
prompt: |
检查以下用户输入是否包含敏感信息:
{{user_input}}
如果包含,返回 action=stop + retry_feedback。
timeout: 30
retry: 1
on_error: skipFields§
§type: HookTypeHook 类型:bash(默认)或 llm
command: Option<String>Shell 命令(type=bash 时必填,通过 sh -c 执行)
prompt: Option<String>LLM prompt 模板(type=llm 时必填,支持 {{variable}} 模板变量)
model: Option<String>LLM 模型名覆盖(type=llm 时可选,空则使用当前活跃 provider 的模型)
timeout: u64超时秒数(bash 默认 10,llm 默认 30)
retry: u32重试次数(仅 Err 路径生效,默认 0 即不重试)
on_error: OnError脚本/LLM 失败时的处理策略(默认 skip)
filter: HookFilter条件过滤:仅当条件匹配时执行(默认无过滤)
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for HookDef
impl<'de> Deserialize<'de> for HookDef
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HookDef
impl RefUnwindSafe for HookDef
impl Send for HookDef
impl Sync for HookDef
impl Unpin for HookDef
impl UnsafeUnpin for HookDef
impl UnwindSafe for HookDef
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.