pub struct ScopeGuard { /* private fields */ }Expand description
Checks tool scope requirements against an agent’s ScopePolicy.
Integrate with the executor by calling ScopeGuard::check before
executing a tool. If the check fails and an ApprovalHandler is provided,
the guard escalates to the handler so a human operator can override.
Implementations§
Source§impl ScopeGuard
impl ScopeGuard
pub fn new(policy: ScopePolicy) -> Self
Sourcepub fn check(&self, tool_schema: &ToolSchema) -> ScopeCheckResult
pub fn check(&self, tool_schema: &ToolSchema) -> ScopeCheckResult
Check whether tool_schema may be executed under the current policy.
- If the schema has no
required_scopes, the result is alwaysAllowed(unlessdefault_denyis set — that case is handled separately). - If all required scopes are granted,
Allowedis returned. - Otherwise,
Deniedis returned with the list of missing scopes.
Sourcepub async fn check_with_escalation<H: ApprovalHandler>(
&self,
tool_schema: &ToolSchema,
tool_call: &ToolCall,
handler: &H,
) -> Result<bool, ApprovalError>
pub async fn check_with_escalation<H: ApprovalHandler>( &self, tool_schema: &ToolSchema, tool_call: &ToolCall, handler: &H, ) -> Result<bool, ApprovalError>
Check scope and, on denial, escalate to the provided ApprovalHandler.
Returns Ok(true) if execution should proceed (allowed or overridden by
the approval handler), Ok(false) if denied, or an error if the handler
itself failed.
Trait Implementations§
Source§impl Clone for ScopeGuard
impl Clone for ScopeGuard
Source§fn clone(&self) -> ScopeGuard
fn clone(&self) -> ScopeGuard
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ScopeGuard
impl RefUnwindSafe for ScopeGuard
impl Send for ScopeGuard
impl Sync for ScopeGuard
impl Unpin for ScopeGuard
impl UnsafeUnpin for ScopeGuard
impl UnwindSafe for ScopeGuard
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more