Skip to main content

FileSystemToolResources

Struct FileSystemToolResources 

Source
pub struct FileSystemToolResources { /* private fields */ }
Expand description

Session-scoped resource state for filesystem tools.

FileSystemToolResources implements ToolResources and tracks which paths each session has inspected. Combined with a FileSystemToolPolicy, it enforces rules such as requiring a read before a write.

Pass an instance as the resources field of ToolContext so that filesystem tools can record and check access.

§Example

use agentkit_tool_fs::{FileSystemToolPolicy, FileSystemToolResources};

let resources = FileSystemToolResources::new()
    .with_policy(
        FileSystemToolPolicy::new()
            .require_read_before_write(true),
    );

Implementations§

Source§

impl FileSystemToolResources

Source

pub fn new() -> Self

Creates a new resource instance with all policies disabled.

Source

pub fn with_policy(self, policy: FileSystemToolPolicy) -> Self

Sets the FileSystemToolPolicy that governs mutation guards.

Source

pub fn record_read(&self, session_id: &SessionId, path: &Path)

Records that the given path was read during session_id.

This marks the path as inspected, satisfying any require_read_before_write policy for subsequent mutations.

Source

pub fn record_list(&self, session_id: &SessionId, path: &Path)

Records that the given directory was listed during session_id.

Like record_read, this marks the path as inspected.

Source

pub fn record_written(&self, session_id: &SessionId, path: &Path)

Records that the given path was written during session_id.

After a write the path is considered inspected, so subsequent mutations are allowed without an additional read.

Source

pub fn record_moved(&self, session_id: &SessionId, from: &Path, to: &Path)

Records that a path was moved from from to to during session_id.

The old path is removed from the inspected set and the new path is added.

Trait Implementations§

Source§

impl Default for FileSystemToolResources

Source§

fn default() -> FileSystemToolResources

Returns the “default value” for a type. Read more
Source§

impl ToolResources for FileSystemToolResources

Source§

fn as_any(&self) -> &dyn Any

Returns a reference to self as Any so callers can downcast to the concrete resource type.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.