Skip to main content
Build high-performance stateful AI agents with the AgentFS Rust SDK.

Installation

Add AgentFS to your Cargo.toml:

Quick Start

Core APIs

AgentFS Struct

The main entry point for all AgentFS operations.

AgentFS::open(options: AgentFSOptions)

Creates or opens an AgentFS database.
AgentFSOptions Configuration:

Fields

  • kv: Key-value store interface
  • fs: Filesystem interface
  • tools: Tool call tracking interface
  • db: Direct access to the underlying Turso database

Key-Value Store API

Fast, typed storage with Serde serialization support.

kv.set<T: Serialize>(key: &str, value: T)

Store any serializable value.

kv.get<T: DeserializeOwned>(key: &str) -> Option<T>

Retrieve and deserialize values.

kv.delete(key: &str)

Remove a key-value pair.

kv.list(options: ListOptions)

List keys with filtering and pagination.

kv.clear()

Remove all key-value pairs.

Filesystem API

POSIX-like filesystem operations for managing agent data.

fs.write_file(path: &str, data: &[u8])

Write bytes to a file, creating parent directories as needed.

fs.read_file(path: &str) -> Vec<u8>

Read file contents as bytes.

fs.mkdir(path: &str)

Create a directory, optionally creating parent directories.

fs.readdir(path: &str) -> Vec<DirEntry>

List directory contents with metadata.

fs.stat(path: &str) -> FileStat

Get file or directory metadata.

fs.exists(path: &str) -> bool

Check if a file or directory exists.

fs.rm(path: &str)

Remove a file or empty directory.

fs.rename(old_path: &str, new_path: &str)

Move or rename files and directories.

fs.copy_file(src: &str, dest: &str)

Copy a file to a new location.

Tool Call Tracking API

Record and query agent tool invocations.

tools.record()

Record a tool invocation with timing and I/O data.

tools.list(options: ToolListOptions)

Query recorded tool calls.

tools.get(id: &str) -> Option<ToolCall>

Get details of a specific tool call.

tools.delete(id: &str)

Remove a tool call record.

tools.clear()

Remove all tool call records.

Support