Build AI Systems,
That Actually Remember
Neuroscience-based memory for your AI agents. npm install. TypeScript. Zero dependencies.
$ npm install @zensation/core @zensation/algorithmsCopyYour First Memory in 3 Steps
Install
One npm install โ no additional dependencies.
npm install @zensation/core @zensation/algorithmsConfigure
Create a MemoryCoordinator โ one line.
import { MemoryCoordinator, InMemoryStorage } from '@zensation/core';
const coordinator = new MemoryCoordinator({
storage: new InMemoryStorage(),
});Use
store() to save, recall() to retrieve.
// Store a memory (auto-routes to semantic layer)
await coordinator.store('User prefers dark mode', {
type: 'fact',
confidence: 0.9,
});
// Recall relevant memories
const results = await coordinator.recall('user preferences');
// โ [{ content: 'User prefers dark mode', score: 0.92, layer: 'semantic' }]7 Memory Layers, One Coordinator
MemoryCoordinator
Orchestrates all 7 layers: auto-routing store(), cross-layer recall(), consolidate(), decay(), FSRS review queue
System Architecture
From Simple to Production-Ready
Simple Memory
store() + recall() basics
const id = await coordinator.store('User prefers dark mode', {
type: 'fact', confidence: 0.9,
});
const results = await coordinator.recall('user preferences');Spaced Repetition
FSRS scheduler for learning apps
import { getRetrievability } from '@zensation/algorithms';
// Check if a fact needs review
const retention = getRetrievability(fsrsState); // 0.0โ1.0
// Use the coordinator's built-in FSRS review queue
const queue = await coordinator.getReviewQueue(10);
await coordinator.recordReview(queue[0].id, 4); // grade: 1-5Semantic Search
Cross-layer search with ranking
const results = await coordinator.recall('machine learning basics', {
layers: ['semantic', 'episodic'],
limit: 5,
minConfidence: 0.7,
});Sleep Consolidation
Overnight memory optimization
import { selectForReplay, simulateReplay, pruneWeakConnections }
from '@zensation/algorithms';
const candidates = selectForReplay(memories, SLEEP_CONSOLIDATION_CONFIG);
const replayed = simulateReplay(candidates, SLEEP_CONSOLIDATION_CONFIG);
const pruned = pruneWeakConnections(memories, 0.1);Hebbian Learning
Co-activation strengthens connections
import { computeHebbianStrengthening, computeHebbianDecay }
from '@zensation/algorithms';
// Strengthen connection weight through co-activation
const newWeight = computeHebbianStrengthening(0.5); // current weight โ strengthened
// Apply time-based decay to connection weight
const decayedWeight = computeHebbianDecay(0.8); // current weight โ decayedFull Pipeline
Store โ Consolidate โ Decay โ Review
// Store โ Consolidate โ Decay โ Review
await coordinator.store('Meeting notes from standup', { type: 'episode' });
const consolidated = await coordinator.consolidate();
const decayed = coordinator.decay();
const queue = await coordinator.getReviewQueue(10);
await coordinator.recordReview(queue[0].id, 4);More Than a Key-Value Store
| Feature | ZenBrain | Mem0 | Zep | LangMem |
|---|---|---|---|---|
| Sleep Consolidation | โ | โ | โ | โ |
| FSRS Spaced Repetition | โ | โ | โ | โ |
| Hebbian Learning | โ | โ | โ | โ |
| Confidence Intervals | โ | โ | โ | โ |
| MemoryCoordinator | โ | โ | โ | โ |
| Zero Dependencies | โ | โ | โ | โ |
| Self-Hosted | โ | โ | โ | โ |
Integrates Everywhere
Node.js / Express
import { MemoryCoordinator } from '@zensation/core';
app.post('/chat', async (req, res) => {
const context = await coordinator.recall(req.body.message);
const response = await llm.chat(req.body.message, { context });
await coordinator.store(response, { type: 'episode' });
res.json({ response });
});Next.js / React
'use server';
import { coordinator } from '@/lib/memory';
export async function chat(message: string) {
const context = await coordinator.recall(message);
const response = await generateText({ prompt: message, context });
await coordinator.store(response, { type: 'fact', source: 'ai' });
return response;
}CLI / Scripts
import { MemoryCoordinator } from '@zensation/core';
import { createFileAdapter } from '@zensation/adapter-sqlite';
const coordinator = new MemoryCoordinator({
storage: createFileAdapter('./memory.db'),
});
await coordinator.store('Batch processed 1000 docs');Also compatible with: Deno ยท Bun ยท Cloudflare Workers
Open Source. Open Community.
GitHub
Star, Fork, Contribute
npm
@zensation/core ยท @zensation/algorithms
Discord
Questions, Showcase, Support
Documentation
API Reference, Examples, FAQ
First Good Issues on GitHub โ read CONTRIBUTING.md
Developer FAQ
Do I need a database?
No. InMemoryStorage for prototypes, SQLite adapter for zero-config persistence, PostgreSQL+pgvector for production.
How large is the bundle?
Tree-shakeable. @zensation/algorithms has 0 runtime dependencies.
Can I write custom memory layers?
Yes. Implement the Layer interface and pass it to the Coordinator.
How is this different from Mem0?
7 layers instead of key-value, Sleep Consolidation, FSRS Spaced Repetition, Confidence Intervals โ everything Mem0 doesn't have.
Is this production-ready?
276 tests, 100% passing. ZenAI uses ZenBrain algorithms internally since Phase 125.
How does Sleep Consolidation work?
Based on Stickgold & Walker 2013: selectForReplay โ simulateReplay โ pruneWeakConnections. Episodic memories are consolidated into semantic knowledge.
MCP Server?
Coming in v0.3.0 โ IDE integration for VS Code, Cursor, and other MCP-compatible tools.
License?
Apache 2.0. Commercial use allowed. No restrictions.
Ready to build?
$ npm install @zensation/coreCopyApache 2.0 ยท TypeScript ยท Zero Dependencies ยท Made in Germany