Skip to main content

SessionFileSystem

Trait SessionFileSystem 

Source
pub trait SessionFileSystem: Send + Sync {
Show 14 methods // Required methods fn is_mount_resolver(&self) -> bool; fn read_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, content: &'life2 str, encoding: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<SessionFile>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait; fn delete_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, recursive: bool, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn list_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn stat_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<FileStat>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn grep_files<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, path_pattern: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GrepMatch>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait; fn create_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<FileInfo>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn display_root(&self) -> String { ... } fn display_path(&self, path: &str) -> String { ... } fn resolve_path(&self, input: &str) -> String { ... } fn write_file_if_content_matches<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, expected_content: &'life2 str, expected_encoding: &'life3 str, content: &'life4 str, encoding: &'life5 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait { ... } fn grep_files_with_options<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, options: &'life2 GrepOptions, ) -> Pin<Box<dyn Future<Output = Result<GrepSearchResult>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn seed_initial_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, file: &'life1 InitialFile, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Trait for session filesystem operations

This trait abstracts the session filesystem contract for tools and hosts. Implementations can:

  • Store files in a database (production)
  • Use an in-memory filesystem for testing
  • Project files onto real disk or object storage

Required Methods§

Source

fn is_mount_resolver(&self) -> bool

Whether this store is already a mount-based resolver ([MountFs]).

Used to avoid re-wrapping nested mount tables when building tool context.

Source

fn read_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Read a file by path

Source

fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, content: &'life2 str, encoding: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<SessionFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Write/create a file

Source

fn delete_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, recursive: bool, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete a file or directory

Source

fn list_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

List files in a directory

Source

fn stat_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<FileStat>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get file metadata

Source

fn grep_files<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, path_pattern: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GrepMatch>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search file contents with Rust regex syntax, optionally filtering canonical paths by glob.

Implementations compile the content pattern once before scanning and return an error for invalid regex. Basename-only globs match at any depth. Non-glob path filters retain legacy substring matching; see knowledge/runtime-resources/file-store.md.

Source

fn create_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<FileInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a directory

Provided Methods§

Source

fn display_root(&self) -> String

Human-facing root path for this filesystem.

/workspace is the stable agent namespace and the default. Direct host-backed stores may override this for host-side integrations, while MountFs restores the agent-facing root.

Source

fn display_path(&self, path: &str) -> String

Convert a canonical session path into a human-facing path.

The default renders the /workspace alias. Direct host-backed stores may override it, while MountFs presents primary workspace paths through the stable agent-facing namespace.

Source

fn resolve_path(&self, input: &str) -> String

Resolve an input path (any accepted spelling, relative or absolute) to an absolute path within this filesystem’s namespace. Relative inputs resolve against the filesystem’s current directory.

This is how a shell seeds its working directory: MountFs returns a path in its stable agent-facing namespace, so the shell and file tools share the same identity. The default is the flat VFS session form. Security decorators may authorize the returned path, so providers that accept additional aliases must use the same contained mapping here and in their I/O methods. An alias must never resolve to one workspace path here and a different storage object during the subsequent operation.

Source

fn write_file_if_content_matches<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, expected_content: &'life2 str, expected_encoding: &'life3 str, content: &'life4 str, encoding: &'life5 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Write a file only if its current content snapshot still matches.

Implementations backed by transactional storage should override this with an atomic compare-and-set update.

Source

fn grep_files_with_options<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, options: &'life2 GrepOptions, ) -> Pin<Box<dyn Future<Output = Result<GrepSearchResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search with match pagination and bounded before/after context.

Backends should override this to collect context during their content scan. The default preserves compatibility for third-party stores that only implement the original zero-context method.

Source

fn seed_initial_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, file: &'life1 InitialFile, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Seed a starter file into a session workspace.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: SessionFileSystem + ?Sized> SessionFileSystem for Arc<T>

Source§

fn display_root(&self) -> String

Source§

fn display_path(&self, path: &str) -> String

Source§

fn resolve_path(&self, input: &str) -> String

Source§

fn is_mount_resolver(&self) -> bool

Source§

fn read_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn write_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, content: &'life2 str, encoding: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<SessionFile>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Source§

fn write_file_if_content_matches<'life0, 'life1, 'life2, 'life3, 'life4, 'life5, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, expected_content: &'life2 str, expected_encoding: &'life3 str, content: &'life4 str, encoding: &'life5 str, ) -> Pin<Box<dyn Future<Output = Result<Option<SessionFile>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait, 'life4: 'async_trait, 'life5: 'async_trait,

Source§

fn delete_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, recursive: bool, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn list_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FileInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn stat_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<FileStat>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn grep_files<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, path_pattern: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<GrepMatch>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn grep_files_with_options<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: SessionId, pattern: &'life1 str, options: &'life2 GrepOptions, ) -> Pin<Box<dyn Future<Output = Result<GrepSearchResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn create_directory<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, path: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<FileInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn seed_initial_file<'life0, 'life1, 'async_trait>( &'life0 self, session_id: SessionId, file: &'life1 InitialFile, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§