npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@monoes/memory

v2.24.0

Published

Memory module - JSON pattern store and a SQLite + embeddings backend with a size-gated HNSW ANN fast path built in

Readme

@monoes/memory

npm version license node

Persistent memory backends for Monomind agents — SQLite in WAL journal mode (PRAGMA journal_mode = WAL, schema v3.0.0) key-value storage with dense ONNX ModernBERT 768d + Okapi BM25 RRF hybrid search, surface query routing, Open Knowledge Format (OKF) transfer, Cognee-style knowledge graph triplets, and EWC pattern consolidation.

Part of the Monomind ecosystem. The embedded storage layer uses better-sqlite3 with sql.js (WASM zero-compile fallback).

Install

npm install @monoes/memory

better-sqlite3 ships as a direct dependency (native SQLite; sql.js WASM is the fallback storage engine) — no separate install needed.

Native module install blocked? If initialization throws Could not locate the bindings file, your npm's allowScripts policy blocked better-sqlite3's native build — run npm install-scripts approve better-sqlite3 && npm rebuild better-sqlite3.

Core Architecture & Schema v3.0.0

Schema Architecture & Storage Engine

  • Storage Driver: Operates over SQLite with WAL mode (PRAGMA journal_mode = WAL) using better-sqlite3 with a WASM sql.js fallback.
  • Dual Schema Support:

Hybrid Search: ONNX ModernBERT 768d + BM25 RRF

Retrieval uses a dual-arm hybrid search architecture combined with Reciprocal Rank Fusion (RRF):

  1. Dense Vector Search:
    • Model: Alibaba-NLP/gte-modernbert-base (768 dimensions).
    • Embedding Pipeline: @xenova/transformers ONNX feature extraction.
    • Acceleration: Standalone pure-JS HNSWIndex (dimensions=768, M=16, efConstruction=200, metric='cosine').
  2. Lexical Arm (In-Process Okapi BM25):
    • Parameters: $k_1 = 1.2$, $b = 0.75$.
    • Tokenizer: Exact parity with the evaluation harness (text-tokens.ts).
    • Live-Only Indexing: Built dynamically over live chunks with warning thresholds at 50,000 chunks (LIVE_CHUNK_WARN_THRESHOLD) and persistent review at 1,000,000 chunks (SCALING_REVIEW_CHUNKS).
  3. Reciprocal Rank Fusion (RRF):
    • Fuses ranked candidate lists using adaptive constant $k = \max(30, \min(60, 20 + 2 \times \text{top_k}))$: $$\text{Score}(d) = \sum_{m} \frac{1}{\text{rrf_k} + \text{rank}_m + 1} \times (0.75 + 0.5 \times \text{importance})$$

Surface Query Router

The QueryRouter (query-router.ts) evaluates queries across 4 target surfaces: chunks (prior 0.5), kg (wt 2), rules (wt 2), and memory (wt 2):

  • Negation Gate: Uses a 20-character pre-match window (NEGATION_RE) to bypass negated query phrases.
  • Confidence Gate: Requires top surface score $\ge 2 \times$ runner-up score; low-confidence queries query all surfaces and fuse results.
  • Telemetry Persistence: Cross-process misroutes are recorded to .monomind/metrics/route-overrides.json.

Open Knowledge Format (OKF) Bundles

Supports document and memory export/import via Open Knowledge Format (OKF) Markdown files with YAML frontmatter headers:

  • Document OKF: Exported via exportToOKF() with frontmatter (type: Document, title, description, resource, tags, timestamp, contentHash, chunkCount) and an index.md manifest.
  • Memory Transfer OKF: CLI commands monomind memory export and import export/restore key-value memory entries across namespace directory trees.

EWC Pattern Consolidation & SONA Router

  • EWC Consolidation (ewc-consolidation.ts): Applies Elastic Weight Consolidation using an EMA-updated Fisher information matrix (computeFisherMatrix) persisted in .swarm/ewc-fisher.json to prevent catastrophic forgetting during pattern updates.
  • SONA Router (sona-optimizer.ts): Extracts routing patterns from hooksTrajectoryEnd events into .swarm/sona-patterns.json.

Exported Components

| Export | What it does | |---|---| | SQLiteBackend / SqlJsBackend | Structured key-value storage in SQLite WAL mode (native + WASM fallback) | | HNSWIndex | Standalone pure-JS approximate nearest-neighbor index (768d) | | chunkDocument, KnowledgeStore, KnowledgeRetriever | Document chunking + retrieval pipeline | | QueryBuilder / query() | Fluent query construction | | CacheManager | In-memory LRU caching with size/TTL limits | | SwarmCheckpointer | Persist/restore swarm agent state snapshots | | MemoryMigrator | Import from SQLite, JSON, or Markdown sources | | PromptVersionStore | Prompt version history & prompt experiment tracking |

Cross-Platform Notes

The memory storage engine selects the best available SQLite driver per platform: better-sqlite3 (native, fastest) with automatic fallback to sql.js (WASM, zero compilation, works everywhere including Windows without a toolchain).

Links

License

MIT