New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@monoes/memory

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@monoes/memory

Memory module - JSON pattern store, SQLite + embeddings backend, and a standalone pure-JS HNSW index; not a single unified backend

npmnpm
Version
1.0.12
Version published
Weekly downloads
996
65.17%
Maintainers
1
Weekly downloads
 
Created
Source

@monoes/memory

license node

Persistent memory backends for Monomind agents — SQLite (native or WASM) key-value storage with brute-force cosine vector search, a standalone pure-JS HNSW index, JSONL episodic memory, and a chunked knowledge store.

Part of the Monomind ecosystem. The only hard dependency is sql.js (WASM); better-sqlite3 is optional and loaded dynamically when installed. LanceDB support was removed — SQLite is the only backend now.

Install

npm install @monoes/memory

# optional: native SQLite (faster than the sql.js WASM fallback)
npm install better-sqlite3

What's in the box

ExportWhat it does
UnifiedMemoryServiceHigh-level store/get/search facade backed by SQLiteBackend
SQLiteBackend / SqlJsBackendStructured key-value memory with brute-force cosine vector search (native SQLite or zero-compile WASM)
HNSWIndexPure-JS approximate nearest-neighbor index with quantization support — standalone, not wired into SQLiteBackend.search() (see the honesty review's HNSW growth plan for why and when to change that)
EpisodicStoreJSON-lines episodic memory — accumulates agent runs into summarized episodes
chunkDocument, KnowledgeStore, KnowledgeRetrieverDocument chunking + retrieval for knowledge bases
QueryBuilder / query()Fluent query construction (namespace, tags, threshold, sort)
CacheManager, TieredCacheManagerLRU caching with size/TTL limits
createDatabase, getPlatformInfoPlatform-aware provider selection (better-sqlite3 → sql.js → JSON fallback)
SwarmCheckpointerPersist/restore swarm agent state snapshots
MemoryMigratorImport from SQLite, JSON, or Markdown sources
PromptVersionStore, ControllerRegistryPrompt version history; init-level controller registry

Note: Monomind's live hook/routing hot path uses plain JSON pattern files and keyword-based episodic recall — the vector backends here are opt-in, used when an embedding generator and the optional native dependencies are provided.

Quick start — key-value memory

import { SQLiteBackend } from '@monoes/memory';

const backend = new SQLiteBackend({ databasePath: './data/memory.db' });
await backend.initialize();

await backend.store({
  id: 'mem-1',
  key: 'user-preference',
  content: 'User prefers dark mode',
  type: 'semantic',
  namespace: 'preferences',
  tags: ['ui'],
});

const entry = await backend.getByKey('preferences', 'user-preference');
import { UnifiedMemoryService } from '@monoes/memory';

// Backed by SQLiteBackend — brute-force cosine similarity, no extra install
const memory = new UnifiedMemoryService({
  persistencePath: './data/memory.db',
  dimensions: 1536,
  embeddingGenerator: async (text) => myEmbedder.embed(text),
});
await memory.initialize();

Or use the standalone pure-JS index directly:

import { HNSWIndex } from '@monoes/memory';

const index = new HNSWIndex({ dimensions: 1536, M: 16, efConstruction: 200, metric: 'cosine' });
await index.addPoint('mem-1', new Float32Array(embedding));
const results = await index.search(queryVector, 10);
// [{ id: 'mem-1', distance: 0.05 }, ...]

Episodic memory

import { EpisodicStore } from '@monoes/memory';

const store = new EpisodicStore({ filePath: './data/episodes.jsonl', maxRunsPerEpisode: 20 });
// Accumulates agent runs into episodes, one JSON object per line

Query builder

import { query } from '@monoes/memory';

const q = query()
  .semantic('authentication patterns')
  .inNamespace('security')
  .withTags(['auth'])
  .threshold(0.7)
  .limit(20)
  .sortByNewest()
  .build();

Cross-platform notes

createDatabase() picks the best available provider per platform: better-sqlite3 (native, fastest) → sql.js (WASM, zero compilation, works everywhere including Windows without a toolchain) → JSON file fallback. See docs/CROSS_PLATFORM.md and docs/WINDOWS_SUPPORT.md.

License

MIT

FAQs

Package last updated on 26 Jul 2026

Related posts