Skip to main content

AggregatedHookOutput

Struct AggregatedHookOutput 

Source
pub struct AggregatedHookOutput {
    pub permission: Option<HookPermission>,
    pub updated_input: Option<Value>,
    pub updated_output: Option<ToolOutput>,
    pub additional_context: Vec<String>,
    pub prevent_continuation: bool,
    pub stop_reason: Option<String>,
    pub blocking_errors: Vec<String>,
    pub system_messages: Vec<String>,
}
Expand description

多个 Hook 结果的聚合 — 并行执行后合并。

§聚合规则

  • 权限Deny > Ask > Allow(最严格的获胜)
  • updated_input / updated_output:最后一个设置者获胜
  • additional_context / blocking_errors / system_messages:合并
  • prevent_continuation:任一 Hook 设置即生效

§Examples

use katu_core::hook::{AggregatedHookOutput, HookOutput, HookPermission};

let mut agg = AggregatedHookOutput::default();

// Hook A: allow
agg.merge(HookOutput::allow(), "hook_a");
assert_eq!(agg.permission, Some(HookPermission::Allow));

// Hook B: deny(更严格,覆盖 allow)
agg.merge(HookOutput::deny("unsafe"), "hook_b");
assert!(agg.permission.as_ref().unwrap().is_deny());

Fields§

§permission: Option<HookPermission>

聚合后的权限决策(最严格的获胜)。

§updated_input: Option<Value>

最终的 updated_input(最后一个设置者获胜)。

§updated_output: Option<ToolOutput>

最终的 updated_output。

§additional_context: Vec<String>

所有 Hook 注入的上下文(合并)。

§prevent_continuation: bool

任一 Hook 阻止继续。

§stop_reason: Option<String>

第一个 stop_reason。

§blocking_errors: Vec<String>

所有 blocking_error(合并,带 hook 名前缀)。

§system_messages: Vec<String>

所有 system_message(合并)。

Implementations§

Source§

impl AggregatedHookOutput

Source

pub fn merge(&mut self, output: HookOutput, hook_name: &str)

合并单个 Hook 的输出。

Source

pub fn has_decision(&self) -> bool

是否有任何 Hook 做出了实质性决策。

Source

pub fn has_blocking_errors(&self) -> bool

是否有阻塞性错误。

Source

pub fn is_denied(&self) -> bool

是否被拒绝。

Trait Implementations§

Source§

impl Clone for AggregatedHookOutput

Source§

fn clone(&self) -> AggregatedHookOutput

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 AggregatedHookOutput

Source§

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

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

impl Default for AggregatedHookOutput

Source§

fn default() -> AggregatedHookOutput

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

Auto Trait Implementations§

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.

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.