Developer Hub

Build AI Systems,
That Actually Remember

Neuroscience-based memory for your AI agents. npm install. TypeScript. Zero dependencies.

$ npm install @zensation/core @zensation/algorithmsCopy
TypeScriptApache 2.0Zero Dependencies276 Tests
12Algorithms
7Memory Layers
276Tests
0Dependencies
Apache 2.0License
Get Started in 5 Minutes

Your First Memory in 3 Steps

1

Install

One npm install โ€” no additional dependencies.

npm install @zensation/core @zensation/algorithms
2

Configure

Create a MemoryCoordinator โ€” one line.

import { MemoryCoordinator, InMemoryStorage } from '@zensation/core';

const coordinator = new MemoryCoordinator({
  storage: new InMemoryStorage(),
});
3

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' }]
Neuroscience-Inspired Architecture

7 Memory Layers, One Coordinator

๐Ÿง 
Working MemoryActive task focus
Baddeley 2000
โฑ๏ธ
Short-TermSession context
Atkinson & Shiffrin 1968
๐Ÿ“ธ
EpisodicConcrete experiences
Tulving 1972
๐Ÿ“š
SemanticFactual knowledge
Tulving 1972
โš™๏ธ
ProceduralLearned procedures
Squire 2004
๐Ÿ’Ž
CorePersistent identity
Conway 2005
๐Ÿ”—
Cross-ContextCross-context links
Moscovitch 2005

MemoryCoordinator

Orchestrates all 7 layers: auto-routing store(), cross-layer recall(), consolidate(), decay(), FSRS review queue

System Architecture

MCPServersClientReact ยท CLI ยท MCPREST APIExpress ยท JWT ยท Rate-LimitService LayerClaude ยท RAG ยท Agents ยท ToolsMemory SystemHiMeS 4-Layer ยท FSRS ยท KGData LayerPostgreSQL ยท pgvector ยท Redis
Ready-to-Use Patterns

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-5

Semantic 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 โ†’ decayed

Full 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);
Why ZenBrain?

More Than a Key-Value Store

FeatureZenBrainMem0ZepLangMem
Sleep Consolidationโœ“โœ—โœ—โœ—
FSRS Spaced Repetitionโœ“โœ—โœ—โœ—
Hebbian Learningโœ“โœ—โœ—โœ—
Confidence Intervalsโœ“โœ—โœ—โœ—
MemoryCoordinatorโœ“โœ—โœ—โœ—
Zero Dependenciesโœ“โœ—โœ—โœ—
Self-Hostedโœ“โœ“โœ“โœ—
276Tests, 100% passing
12Algorithms, peer-reviewed
0Runtime dependencies
276Tests, 100% passing
12Algorithms, peer-reviewed
0Runtime dependencies
Works With Your Stack

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

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/coreCopy

Apache 2.0 ยท TypeScript ยท Zero Dependencies ยท Made in Germany