Skip to main content
Build stateful AI agents with the AgentFS TypeScript SDK, supporting both Node.js and browser environments.

Installation

Quick Start

Core APIs

AgentFS Class

The main entry point for all AgentFS operations.

AgentFS.open(options?: AgentFSOptions)

Creates or opens an AgentFS database.

Properties

  • 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 for agent state and configuration.

kv.set(key: string, value: any)

Store a value with automatic JSON serialization.

kv.get<T>(key: string): Promise<T | undefined>

Retrieve a value with automatic deserialization.

kv.delete(key: string)

Remove a key-value pair.

kv.list(prefix: string): Promise<{ key: string, value: any }[]>

List keys matching a prefix.

Filesystem API

POSIX-like filesystem operations for managing agent data.

fs.writeFile(path: string, data: string | Buffer)

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

fs.readFile(path: string, options?: BufferEncoding): Promise<Buffer | string>

Read file contents. Returns a Buffer by default, or a string if encoding is specified.

fs.readdir(path: string): Promise<string[]>

List directory contents.

fs.stat(path: string): Promise<Stats>

Get file or directory metadata.

fs.exists(path: string): Promise<boolean>

Check if a file or directory exists.

fs.deleteFile(path: string)

Delete a file.

Tool Call Tracking API

Record and query agent tool invocations for debugging and compliance.

tools.record(name, started_at, completed_at, parameters?, result?, error?): Promise<number>

Record a tool invocation.

tools.get(id: number): Promise<ToolCall | undefined>

Get details of a specific tool call.

Browser Support

AgentFS works in browser environments using WebAssembly:

Support