pub struct AgentCapabilities {
pub read: bool,
pub write: bool,
pub exec: bool,
pub allowed_paths: Vec<String>,
pub denied_paths: Vec<String>,
pub allowed_commands: Vec<String>,
pub denied_commands: Vec<String>,
}Expand description
Capabilities that control what the agent can do.
This provides a security model for primitive tools (Read, Write, Grep, Glob, Bash). Paths are matched using glob patterns.
§Example
use agent_sdk::AgentCapabilities;
// Read-only agent that can only access src/ directory
let caps = AgentCapabilities::read_only()
.with_allowed_paths(vec!["src/**/*".into()]);
// Full access agent with some restrictions
let caps = AgentCapabilities::full_access()
.with_denied_paths(vec!["**/.env*".into(), "**/secrets/**".into()]);Fields§
§read: boolCan read files
write: boolCan write/edit files
exec: boolCan execute shell commands
allowed_paths: Vec<String>Allowed path patterns (glob). Empty means all paths allowed.
denied_paths: Vec<String>Denied path patterns (glob). Takes precedence over allowed_paths.
allowed_commands: Vec<String>Allowed commands (regex patterns). Empty means all commands allowed when exec=true.
denied_commands: Vec<String>Denied commands (regex patterns). Takes precedence over allowed_commands.
Implementations§
Source§impl AgentCapabilities
impl AgentCapabilities
Sourcepub fn full_access() -> Self
pub fn full_access() -> Self
Create full access capabilities (use with caution)
Sourcepub const fn with_write(self, enabled: bool) -> Self
pub const fn with_write(self, enabled: bool) -> Self
Builder: enable write access
Sourcepub fn with_allowed_paths(self, paths: Vec<String>) -> Self
pub fn with_allowed_paths(self, paths: Vec<String>) -> Self
Builder: set allowed paths
Sourcepub fn with_denied_paths(self, paths: Vec<String>) -> Self
pub fn with_denied_paths(self, paths: Vec<String>) -> Self
Builder: set denied paths
Sourcepub fn with_allowed_commands(self, commands: Vec<String>) -> Self
pub fn with_allowed_commands(self, commands: Vec<String>) -> Self
Builder: set allowed commands
Sourcepub fn with_denied_commands(self, commands: Vec<String>) -> Self
pub fn with_denied_commands(self, commands: Vec<String>) -> Self
Builder: set denied commands
Sourcepub fn path_allowed(&self, path: &str) -> bool
pub fn path_allowed(&self, path: &str) -> bool
Check if a path is allowed (not in denied list and in allowed list if specified)
Sourcepub fn command_allowed(&self, command: &str) -> bool
pub fn command_allowed(&self, command: &str) -> bool
Check if a command is allowed
Trait Implementations§
Source§impl Clone for AgentCapabilities
impl Clone for AgentCapabilities
Source§fn clone(&self) -> AgentCapabilities
fn clone(&self) -> AgentCapabilities
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more