packages/schemas/README.md
This directory contains the single source of truth for all elizaOS types. These Protocol Buffer schemas are compiled to generate type definitions for TypeScript, Python, and Rust.
schemas/
├── buf.yaml # Buf module configuration
├── buf.gen.yaml # Code generation configuration
├── eliza/v1/ # Proto definitions (versioned)
│ ├── primitives.proto # UUID, Content, Media, Metadata
│ ├── memory.proto # Memory, MemoryMetadata
│ ├── state.proto # State, ActionPlan, WorkingMemory
│ ├── environment.proto # Entity, Room, World, Relationship
│ ├── components.proto # Action, Provider, Evaluator
│ ├── agent.proto # Character, Agent
│ ├── service.proto # Service types
│ ├── model.proto # Model types, generation params
│ ├── events.proto # Event types and payloads
│ ├── plugin.proto # Plugin, Route definitions
│ ├── task.proto # Task types
│ ├── database.proto # Database, logging types
│ ├── messaging.proto # WebSocket, streaming types
│ └── ipc.proto # Cross-language IPC messages
└── README.md
Generated output:
├── packages/typescript/src/types/generated/ # TypeScript
├── packages/python/elizaos/types/generated/ # Python
└── packages/rust/src/types/generated/ # Rust
Install Buf CLI:
# macOS
brew install bufbuild/buf/buf
# Linux
curl -sSL "https://github.com/bufbuild/buf/releases/latest/download/buf-$(uname -s)-$(uname -m)" -o /usr/local/bin/buf
chmod +x /usr/local/bin/buf
# npm (cross-platform)
npm install -g @bufbuild/buf
# From the schemas directory
cd schemas
# Lint proto files
buf lint
# Generate code for all languages
buf generate
# Or use the npm script from project root
npm run generate:types
eliza/v1/buf lint to check for errorsbuf generate to regenerate typesAll schemas are under eliza/v1/. When breaking changes are needed, create eliza/v2/ and maintain both during migration.
Proto3 has first-class JSON mapping. All messages can be serialized to JSON for debugging:
snake_case in proto → camelCase in JSON (automatic)google.protobuf.Struct for dynamic/unknown fieldsUse optional keyword for fields that may not be present:
message Memory {
optional string id = 1; // Optional on creation
string entity_id = 2; // Always required
}
Always include UNSPECIFIED = 0 as the first enum value:
enum MemoryType {
MEMORY_TYPE_UNSPECIFIED = 0;
MEMORY_TYPE_DOCUMENT = 1;
MEMORY_TYPE_MESSAGE = 2;
}
Use google.protobuf.Struct for JSON-like dynamic data:
import "google/protobuf/struct.proto";
message Content {
string text = 1;
google.protobuf.Struct data = 2; // Dynamic properties
}
@bufbuild/protobuf@elizaos/core/types/generatedbetterproto for clean, Pythonic codeelizaos.types.generatedprost (WASM-compatible)serde support for JSON serializationelizaos::types::generated.proto file in eliza/v1/PascalCasesnake_caseSCREAMING_SNAKE_CASEENUM_NAME_VALUE_NAMEbuf lint to validatebuf generate to create codeThe generated types replace the manual type definitions in:
packages/typescript/src/types/*.tspackages/python/elizaos/types/*.pypackages/rust/src/types/*.rsDuring migration, a compatibility layer re-exports generated types with the original names. This allows gradual migration:
// packages/typescript/src/types/index.ts
export * from "./generated";
export { Memory as MemoryType } from "./generated/eliza/v1/memory_pb";
# Lint proto files
buf lint
# Check for breaking changes
buf breaking --against '.git#branch=main'
# Generate code
buf generate
# Update dependencies
buf dep update
# Format proto files
buf format -w