Skip to main content

OwnerApprovalRequest

Struct OwnerApprovalRequest 

Source
pub struct OwnerApprovalRequest {
    pub effects: Vec<EffectKey>,
    pub summary: String,
    pub subject: String,
    pub risk: ApprovalRisk,
    pub warnings: Vec<String>,
    pub card: Option<Box<ApprovalCard>>,
}
Expand description

What the owner is asked to approve.

Fields§

§effects: Vec<EffectKey>

The effects the call would have. A denial records them in crate::RunState::declined.

§summary: String

What the owner sees.

§subject: String

The exact action string that stored grants are matched against (for example a command line, or METHOD url).

§risk: ApprovalRisk§warnings: Vec<String>§card: Option<Box<ApprovalCard>>

What the card says, as typed facts each channel renders. Plain words only, never authority: grants match subject. None shows summary and warnings as they are.

Implementations§

Source§

impl OwnerApprovalRequest

Source

pub fn plain( summary: impl Into<String>, subject: impl Into<String>, risk: ApprovalRisk, warnings: Vec<String>, ) -> Self

A request with no declared effects and no card: the owner sees summary and warnings, and stored grants match subject.

Source

pub fn for_call(call: &ToolCall, info: &ToolInfo, why: &str) -> Self

The request to ask the owner about call, the way aidaemon_policies::ApprovalPolicy asks: the call’s declared effects (from info), its tool and arguments as the subject grants match, ApprovalRisk::Critical for a destructive tool and ApprovalRisk::High otherwise, and a card naming the action (a command line collapsed under its title, else the tool with its arguments collapsed). why ends the summary when it is not empty.

A hook asks with it through crate::ToolDecision::ask:

use aidaemon_core::{OwnerApprovalRequest, ToolCall, ToolDecision, ToolInfo};

fn decide(call: &ToolCall, info: &ToolInfo) -> ToolDecision {
    ToolDecision::ask(OwnerApprovalRequest::for_call(call, info, "it spends money"))
}
Source

pub fn for_tool( tool: &str, arguments: &Value, info: &ToolInfo, why: &str, ) -> Self

OwnerApprovalRequest::for_call from a tool name and arguments (Value::Null when there are none).

Trait Implementations§

Source§

impl Clone for OwnerApprovalRequest

Source§

fn clone(&self) -> Self

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 OwnerApprovalRequest

Source§

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

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

impl<'de> Deserialize<'de> for OwnerApprovalRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for OwnerApprovalRequest

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for OwnerApprovalRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for OwnerApprovalRequest

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.