Expand description
§AgentFS - Filesystem Abstraction for AI Agents
AgentFS provides a high-level filesystem abstraction for AI agents, offering POSIX-like file operations, key-value storage, and tool call auditing.
§Features
- Filesystem: POSIX-like file and directory operations
- KV Store: Key-value storage for agent state
- Tool Recording: Audit trail for agent tool calls
- Backend Agnostic: Works with any AgentDB backend (SQL, KV, Graph)
§Example
ⓘ
use agentfs::AgentFS;
use agentsql::{SqlBackend, SqlBackendConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a SQLite-backed agent filesystem
let backend = SqlBackend::sqlite("agent.db").await?;
let agent_fs = AgentFS::new(Box::new(backend), "my-agent", "/agent").await?;
// Write a file
agent_fs.fs.write_file("/output/report.txt", b"Hello World").await?;
// Store state
agent_fs.kv.set("session_id", b"12345").await?;
// Record a tool call (workflow-based API)
let id = agent_fs.tools.start(
"web_search",
Some(serde_json::json!({"query": "Rust async"}))
).await?;
// ... perform the search ...
agent_fs.tools.success(id, Some(serde_json::json!({"results": []}))).await?;
Ok(())
}Re-exports§
pub use error::AgentFsError;pub use error::Result;pub use filesystem::DbFileSystem;pub use filesystem::FileSystem;pub use filesystem::Stats;pub use kvstore::DbKvStore;pub use kvstore::KvStore;pub use tools::DbToolRecorder;pub use tools::ToolCall;pub use tools::ToolCallStats;pub use tools::ToolCallStatus;pub use tools::ToolRecorder;
Modules§
- error
- Error types for AgentFS
- filesystem
- Filesystem operations for AgentFS
- kvstore
- Key-value store for agent state
- rig_
integration - Rig.rs integration documentation (available even when feature is disabled) Rig.rs FileSystem trait integration for AgentFS
- tools
- Tool call recording and auditing
Structs§
- AgentFS
- Main AgentFS struct providing filesystem, KV store, and tool recording