Rice Rust SDK
Rust SDK for Rice - Unified Storage and State Management.
Installation
Add the following to your Cargo.toml:
[]
= { = "rice-sdk", = "0.1.4" }
= { = "1.0", = ["full"] }
Quick Start
The SDK provides a unified Client to access both Storage and State services.
use ;
use Trace;
async
Configuration
The SDK uses the config crate to load settings from rice.config.{toml,json,yaml} files and environment variables.
1. Configuration File (rice.config.toml)
Control which services are enabled.
[]
= true
[]
= true
2. Environment Variables (.env)
Configure connection details and authentication.
# --- Storage ---
# URL of your Storage instance (default: localhost:50051)
# Supports both gRPC and HTTP (auto-detected)
STORAGE_INSTANCE_URL=http://localhost:50051
# Auth token
STORAGE_AUTH_TOKEN=my-secret-token
# User for auto-login
STORAGE_USER=admin
# --- State ---
# URL of your State instance
STATE_INSTANCE_URL=http://localhost:50051
# Auth token
STATE_AUTH_TOKEN=my-secret-token
State Features
The State service provides comprehensive AI agent memory and cognition capabilities.
Core Memory Operations
// Focus - Store in short-term working memory
state.focus.await?;
// Drift - Read current working memory
let items = state.drift.await?;
// Commit - Store in long-term episodic memory
state.commit.await?;
// Reminisce - Recall relevant memories
let memories = state.reminisce.await?;
Working Memory (Structured Variables)
Store and manage structured state variables.
// Set variable (value must be a JSON string)
state.set_variable.await?;
// Get variable
let var = state.get_variable.await?;
// List variables
let all_vars = state.list_variables.await?;
// Delete variable
state.delete_variable.await?;
Goals
Manage hierarchical goals.
// Add a goal
let goal = state.add_goal.await?;
// Update goal status
state.update_goal.await?;
// List goals
let goals = state.list_goals.await?;
Concepts
Define structured concepts (Level 4 Agency).
let schema = json!;
state.define_concept.await?;
let concepts = state.list_concepts.await?;
Actions & Decision Cycles
Track actions and run decision loops.
// Submit an action
state.submit_action.await?;
// Run decision cycle
let candidates = vec!;
let result = state.run_cycle.await?;
Pub/Sub (Real-time Events)
Subscribe to real-time events from the State service, such as variable updates or memory commits. This is useful for multi-agent coordination.
// Subscribe to variable updates
let mut stream = state.subscribe.await?;
while let Some = stream.message.await?
AI Tool Definitions
The SDK provides pre-built tool definitions (JSON schemas) for integration with LLMs.
use ;
// Get OpenAI-compatible function definitions
let tools = state_tools;
// Get Anthropic-compatible tool definitions
let tools = state_tools;
License
Proprietary. All Rights Reserved.