Expand description
Custom session filesystem provider (virtualizable filesystem layer). Session filesystem provider — virtualizable filesystem layer over JSON-RPC.
When ClientOptions::session_fs is set, the SDK tells the CLI to delegate
all per-session filesystem operations (readFile, writeFile, stat, …)
to a SessionFsProvider registered on each session. This lets host
applications sandbox sessions, project files into in-memory or remote
storage, and apply permission policies before bytes move.
§Concurrency
Each inbound sessionFs.* request is dispatched on its own spawned task,
matching Node’s behavior. Provider implementations MUST be safe for
concurrent invocation across distinct paths. Use internal synchronization
(e.g. tokio::sync::Mutex keyed by path) if your backing store needs
ordering.
§Errors
Provider methods return Result<T, FsError>. The SDK adapts these into
the schema’s { ..., error: Option<SessionFsError> } payload, mapping
FsError::NotFound to the wire’s ENOENT and everything else to
UNKNOWN. A From<std::io::Error> conversion is provided so handlers
backed by tokio::fs
can propagate io::Error with ?.
§Example
use std::sync::Arc;
use async_trait::async_trait;
use github_copilot_sdk::types::{SessionFsProvider, FsError, FileInfo, DirEntry};
struct MyProvider;
#[async_trait]
impl SessionFsProvider for MyProvider {
async fn read_file(&self, path: &str) -> Result<String, FsError> {
std::fs::read_to_string(path)
.map_err(FsError::from)
}
}Structs§
- DirEntry
- Single entry in a directory listing returned by
SessionFsProvider::readdir_with_types. - File
Info - File or directory metadata returned by
SessionFsProvider::stat. - Session
FsConfig - Configuration for a custom session filesystem provider.
Enums§
- DirEntry
Kind - Kind of entry returned by
SessionFsProvider::readdir_with_types. - FsError
- Error returned by a
SessionFsProvidermethod. - Session
FsConventions - Path conventions used by a session filesystem provider.
Traits§
- Session
FsProvider - Implementor-supplied filesystem backing for a session.