pub struct PathPolicy { /* private fields */ }Expand description
A PermissionPolicy that governs FileSystemPermissionRequests by
checking whether target paths fall within allowed or protected directory trees.
Protected roots take priority: any path under a protected root is denied
immediately. Paths under an allowed root are permitted. Paths outside both
sets either require approval or are denied, depending on
require_approval_outside_allowed.
§Example
use agentkit_tools_core::PathPolicy;
let policy = PathPolicy::new()
.allow_root("/workspace/project")
.protect_root("/workspace/project/.env")
.require_approval_outside_allowed(true);Implementations§
Source§impl PathPolicy
impl PathPolicy
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new path policy with no roots and approval required for paths outside allowed roots.
Sourcepub fn allow_root(self, root: impl Into<PathBuf>) -> Self
pub fn allow_root(self, root: impl Into<PathBuf>) -> Self
Adds a directory tree that filesystem operations are allowed to target.
Sourcepub fn protect_root(self, root: impl Into<PathBuf>) -> Self
pub fn protect_root(self, root: impl Into<PathBuf>) -> Self
Adds a directory tree that filesystem operations are never allowed to target.
Sourcepub fn require_approval_outside_allowed(self, value: bool) -> Self
pub fn require_approval_outside_allowed(self, value: bool) -> Self
When true (the default), paths outside allowed roots trigger an
approval request instead of an outright denial.
Trait Implementations§
Source§impl Default for PathPolicy
impl Default for PathPolicy
Source§impl PermissionPolicy for PathPolicy
impl PermissionPolicy for PathPolicy
Source§fn evaluate(&self, request: &dyn PermissionRequest) -> PolicyMatch
fn evaluate(&self, request: &dyn PermissionRequest) -> PolicyMatch
Evaluate the request and return a match or
PolicyMatch::NoOpinion.Auto Trait Implementations§
impl Freeze for PathPolicy
impl RefUnwindSafe for PathPolicy
impl Send for PathPolicy
impl Sync for PathPolicy
impl Unpin for PathPolicy
impl UnsafeUnpin for PathPolicy
impl UnwindSafe for PathPolicy
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