Skip to main content

PermissionRequest

Trait PermissionRequest 

Source
pub trait PermissionRequest: Send + Sync {
    // Required methods
    fn kind(&self) -> &'static str;
    fn summary(&self) -> String;
    fn metadata(&self) -> &MetadataMap;
    fn as_any(&self) -> &dyn Any;
}
Expand description

A description of an operation that requires permission before it can proceed.

Tool implementations return PermissionRequest objects from Tool::proposed_requests so the executor can evaluate them against the active PermissionChecker before invoking the tool.

Built-in implementations include ShellPermissionRequest, FileSystemPermissionRequest, and McpPermissionRequest.

§Implementing a custom request

use std::any::Any;
use agentkit_core::MetadataMap;
use agentkit_tools_core::PermissionRequest;

struct NetworkPermissionRequest {
    url: String,
    metadata: MetadataMap,
}

impl PermissionRequest for NetworkPermissionRequest {
    fn kind(&self) -> &'static str { "network.http" }
    fn summary(&self) -> String { format!("HTTP request to {}", self.url) }
    fn metadata(&self) -> &MetadataMap { &self.metadata }
    fn as_any(&self) -> &dyn Any { self }
}

Required Methods§

Source

fn kind(&self) -> &'static str

A dot-separated category string (e.g. "filesystem.write", "shell.command").

Source

fn summary(&self) -> String

Human-readable one-line description of what is being requested.

Source

fn metadata(&self) -> &MetadataMap

Arbitrary metadata attached to this request.

Source

fn as_any(&self) -> &dyn Any

Returns self as Any so policies can downcast to the concrete type.

Implementors§