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
impl FileSystemToolResources
Sourcepub fn with_policy(self, policy: FileSystemToolPolicy) -> Self
pub fn with_policy(self, policy: FileSystemToolPolicy) -> Self
Sets the FileSystemToolPolicy that governs mutation guards.
Sourcepub fn record_read(&self, session_id: &SessionId, path: &Path)
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.
Sourcepub fn record_list(&self, session_id: &SessionId, path: &Path)
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.
Sourcepub fn record_written(&self, session_id: &SessionId, path: &Path)
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.
Sourcepub fn record_moved(&self, session_id: &SessionId, from: &Path, to: &Path)
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.