Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

Tirea is an immutable state-driven agent framework built in Rust. It combines typed JSON state management with an agent loop, providing full traceability of state changes, replay capability, and component isolation.

Crate Overview

CrateDescription
tirea-stateCore library: typed state, JSON patches, apply, conflict detection
tirea-state-deriveProc-macro for #[derive(State)]
tirea-contractShared contracts: thread/events/tools/plugins/runtime/storage/protocol
tirea-agentosAgent runtime: inference engine, tool execution, orchestration, plugin composition
tirea-extension-*Plugins: permission, reminder, observability, skills, MCP, A2UI
tirea-protocol-ag-uiAG-UI protocol adapters
tirea-protocol-ai-sdk-v6Vercel AI SDK v6 protocol adapters
tirea-store-adaptersStorage adapters: memory/file/postgres/nats-buffered
tirea-agentos-serverHTTP/SSE/NATS gateway server
tireaUmbrella crate that re-exports core modules

Architecture

┌─────────────────────────────────────────────────────┐
│  Application Layer                                    │
│  - Register tools, define agents, call run_stream    │
└─────────────────────────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────┐
│  AgentOs                                             │
│  - Prepare run, execute phases, emit events          │
└─────────────────────────────────────────────────────┘
                         │
                         ▼
┌─────────────────────────────────────────────────────┐
│  Thread + State Engine                               │
│  - Thread history, RunContext delta, apply_patch     │
└─────────────────────────────────────────────────────┘

Core Principle

All state transitions follow a deterministic, pure-function model:

State' = apply_patch(State, Patch)
  • Same (State, Patch) always produces the same State'
  • apply_patch never mutates its input
  • Full history enables replay to any point in time

What’s in This Book

  • Tutorials — Learn by building a first agent and first tool
  • How-to — Task-focused implementation guides for integration and operations
  • Reference — API, protocol, config, and schema lookup pages
  • Explanation — Architecture and design rationale

If you are new to the repository, use this order:

  1. Read First Agent to see the smallest runnable flow.
  2. Read First Tool to understand state reads and writes.
  3. Read Typed Tool Reference before writing production tools.
  4. Use Build an Agent and Add a Tool as implementation checklists.
  5. Return to Architecture and Run Lifecycle and Phases when you need the full execution model.

Repository Map

These paths matter most when you move from docs into code:

PathPurpose
crates/tirea-contract/Core runtime contracts: tools, events, state/runtime interfaces
crates/tirea-agentos/Agent runtime: inference engine, tool execution, orchestration, extensions
crates/tirea-agentos-server/HTTP/SSE/NATS server surfaces
crates/tirea-state/Immutable state patch/apply/conflict engine
examples/src/Small backend examples for tools, agents, and state
examples/ai-sdk-starter/Shortest browser-facing end-to-end example
examples/copilotkit-starter/Richer end-to-end UI example with approvals and persistence
docs/book/src/This documentation source

For the full Rust API documentation, see the API Reference.