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

@the-brain/core

v0.2.3

Published

LLM-agnostic cognitive memory framework — biologically-inspired decay, synapses, Graph RAG

Readme

@the-brain/core

LLM-agnostic cognitive memory framework with biologically-inspired decay, synapses, and Graph RAG.

What it does

  • Memory that forgets — entries decay over time, strong ones get consolidated to long-term memory
  • Synaptic connections — weighted links between related entries, traversed like a graph
  • Hybrid intent routing — AI classification with rule-based fallback (works with local or cloud LLMs)
  • User profile adaptation — Brain learns your communication style and adapts responses
  • PDF ingest — feed documents as permanent memory (isPermanent=true, never decays)

Install

npm install @the-brain/core
# plus a storage adapter:
npm install @the-brain/adapter-mongo   # MongoDB (recommended)
npm install @the-brain/adapter-sqlite  # SQLite (zero-config)

Quick start

import { Brain, OpenAICompatibleAdapter } from "@the-brain/core";
import { SQLiteStorageAdapter } from "@the-brain/adapter-sqlite";

const brain = new Brain(
  new OpenAICompatibleAdapter(
    "http://localhost:11434/v1/chat/completions", // any OpenAI-compatible endpoint
    "llama3.2"
  ),
  new SQLiteStorageAdapter("./.brain")
);

await brain.loadActions();

// Save a fact
await brain.save("user-1", "I prefer TypeScript over JavaScript");

// Ask a question — Brain routes intent and searches memory
const result = await brain.process("user-1", "What do I prefer for coding?");
console.log(result.answer);

// Direct memory recall
const context = await brain.recall("user-1", "TypeScript preferences");
console.log(context.synapticTree);

Works with any LLM

// Local (Ollama, LM Studio)
new OpenAICompatibleAdapter("http://localhost:11434/v1/chat/completions", "llama3.2")

// Groq (free, fast)
new OpenAICompatibleAdapter(
  "https://api.groq.com/openai/v1/chat/completions",
  "llama-3.3-70b-versatile",
  process.env.GROQ_API_KEY
)

// OpenAI
new OpenAICompatibleAdapter(
  "https://api.openai.com/v1/chat/completions",
  "gpt-4o",
  process.env.OPENAI_API_KEY
)

Custom actions

await brain.registerAction(
  "TRADING_SIGNAL",
  "user asks about trading signals or market analysis",
  async (userId, text, { synapticTree }, llm) => {
    // your handler logic
    return "Signal: BUY BTC — confidence 72%";
  }
);

Config overrides

Override any default constant per Brain instance:

const brain = new Brain(llm, storage, embedding, {
  llm: {
    responseMaxTokens: 3000,   // default: 1500
    saveMaxTokens: 500,        // default: 300
  },
  memory: {
    synapseTreeDepth: 7,       // default: 5
    synapseBranchFactor: 7,    // default: 5
    contextTopEntries: 8,      // default: 5
    decayWindowMs: 30 * 24 * 60 * 60 * 1000, // default: 7 days
  },
  chat: {
    historyMaxStored: 20,      // default: 10
    maintenanceEveryN: 50,     // default: 20
    profileUpdateEveryN: 5,    // default: 10
  },
});

Memory lifecycle

Save entry (strength=5)
  → Conscious processor: analyze, build synapses, consolidate strong entries to LTM
  → Subconscious routine: decay inactive entries, prune dead ones
  → Long-term memory: strength ≥ 10 → permanent summary created

Run maintenance manually or let Brain trigger it automatically every N saves:

const { subStats, consciousStats } = await brain.runMaintenance();

License

AGPL-3.0 — github.com/greg00ry/the-brain