Developer Tools
CORE SDK
Low-level primitives for self-healing agent behaviors. Build resilient, autonomous agents with built-in recovery and state management.
Version2.4.0
View on GitHubInstallationbash
npm install @eliza/core @eliza/runtime @eliza/memoryCore Modules
Agent Runtime
Core execution environment for autonomous agent behaviors
Memory System
Persistent and contextual memory management
Self-Healing
Automatic error recovery and state restoration
Action System
Define and execute agent capabilities
State Machine
Finite state management for agent workflows
Security Layer
Sandboxing and permission controls
API Reference
Bundle Size42kb
Dependencies3
TypeScript100%
Installation
npm install @eliza/core @eliza/runtimeQuick Start
import { Agent, Runtime } from '@eliza/core';
const agent = new Agent({
name: 'my-agent',
model: 'gpt-4',
memory: true,
selfHealing: true,
});
const runtime = new Runtime(agent);
await runtime.start();Self-Healing Setup
import { SelfHealingRuntime } from '@eliza/core';
const runtime = new SelfHealingRuntime({
checkpointInterval: 5000,
maxRetries: 3,
fallbackStrategy: 'last-known-good',
onError: async (error, context) => {
console.log('Recovering from:', error.message);
return context.restore();
},
onRecovery: async (state) => {
console.log('Recovered to state:', state.id);
},
});Defining Actions
import { defineAction } from '@eliza/core';
const sendMessage = defineAction({
name: 'SEND_MESSAGE',
description: 'Send a message to a channel',
validate: async (runtime, message) => {
return message.content.length > 0;
},
handler: async (runtime, message, state) => {
const response = await runtime.llm.generate({
context: state.context,
prompt: message.content,
});
return { success: true, response };
},
});Memory Management
import { MemoryManager } from '@eliza/core';
const memory = new MemoryManager({
vectorStore: 'pgvector',
embeddingModel: 'text-embedding-3-small',
});
// Store a memory
await memory.remember({
content: 'User prefers dark mode',
type: 'preference',
importance: 0.8,
});
// Recall relevant memories
const memories = await memory.recall({
query: 'user preferences',
limit: 10,
threshold: 0.7,
});