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

@zensation/ai-sdk

v0.1.4

Published

Vercel AI SDK memory middleware: agent memory that recalls before a model call and stores the turn after it. Zero runtime dependencies.

Readme

@zensation/ai-sdk

Status: early release. The option shape may still change before 1.0. The memory layers underneath are the ones the ZenBrain paper describes and the benchmarks measure.

ZenBrain as Vercel AI SDK middleware. Recall what is relevant before the model call, store the turn after it. Works with any provider the AI SDK supports, because it never touches the provider.

npm install @zensation/ai-sdk @zensation/core @zensation/adapter-sqlite
import { generateText, wrapLanguageModel } from 'ai';
import { openai } from '@ai-sdk/openai';
import { MemoryCoordinator } from '@zensation/core';
import { SqliteAdapter } from '@zensation/adapter-sqlite';
import { zenbrainMemory } from '@zensation/ai-sdk';

const coordinator = new MemoryCoordinator({
  storage: new SqliteAdapter({ filename: './memory.db' }),
});

const model = wrapLanguageModel({
  model: openai('gpt-5'),
  middleware: zenbrainMemory({ coordinator }),
});

await generateText({ model, prompt: 'Anna moved to Hamburg in March.' });

// A later call, possibly days later, in a different process:
const { text } = await generateText({ model, prompt: 'Where does Anna live?' });

Between the two calls nothing was passed by hand. The second prompt arrives at the model with a system message in front of it:

Relevant memories from earlier sessions:
- Anna moved to Hamburg in March.

Zero runtime dependencies

The middleware is a plain object; wrapLanguageModel is called by you. Nothing here is imported from ai at runtime — only its types are. So this package installs nothing:

| Package | Runtime dependencies | |---|--:| | @zensation/ai-sdk | 0 | | @zensation/core | 1 (@zensation/algorithms) | | @zensation/algorithms | 0 |

That claim is checked in CI on every push against the packed tarballs rather than the source tree.

Options

zenbrainMemory({
  coordinator,                     // required — you own its lifecycle

  recall: {                        // or false to switch searching off
    limit: 5,                      // how many memories to inject
    layers: ['semantic', 'core'],  // which layers to search
    minConfidence: 0.6,            // drop anything below this
    taskType: 'coding',            // context-dependent retrieval hint
  },

  store: {                         // or false to switch writing off
    user: true,                    // store the user's message (default)
    assistant: false,              // store the reply too (default off)
    context: 'work',               // context domain for what gets stored
  },

  header: 'Relevant memories from earlier sessions:',

  onError: (err, phase) => console.warn(`[zenbrain] ${phase} failed`, err),
});

Two defaults worth knowing

Replies are not stored by default. A model's answer is derived from the question and cheap to regenerate; storing both sides doubles the volume and fills semantic memory with your own model's phrasing. Turn it on with store: { assistant: true } when the answer carries information the question does not.

Failures are swallowed. If recall or store throws, the call goes through anyway, unmodified. A memory layer that breaks a chat is worse than one that forgets. Pass onError to see what is being hidden — without it, failures are silent by design.

Where the memory lands

Routing on store is automatic: a general statement becomes a semantic fact, a narrated event an episode, a sequence of instructions a procedure. Which layer a memory lands in decides how it decays and whether it survives consolidation. The seven layers, their retention rules and the algorithms behind them are documented in the main README.

Consolidation does not run on its own. Call coordinator.consolidate() on a schedule that suits your application.

What this release does not do

  • No embedding provider is configured unless you pass one. Semantic search then runs without vectors: recall still works, less sharply than the benchmarked configuration.
  • Streaming stores on flush. The reply is written once the stream completes. An aborted stream stores the user's turn but not the partial answer.
  • Only text is read. File and tool parts of a message are ignored when building the recall query and when storing.
  • One recall per call. There is no re-retrieval mid-generation.

Streaming

streamText works the same way and passes the stream through untouched:

const result = streamText({
  model: wrapLanguageModel({
    model: openai('gpt-5'),
    middleware: zenbrainMemory({ coordinator, store: { assistant: true } }),
  }),
  prompt: 'Which theme should I use?',
});

for await (const chunk of result.textStream) process.stdout.write(chunk);

About ZenBrain

ZenBrain is a seven-layer, neuroscience-derived memory architecture for LLM agents, built as zero-dependency TypeScript and published under Apache-2.0. On LongMemEval-500 three of nine head-to-head answer-quality comparisons hold against Letta, Mem0 and A-Mem — all three against A-Mem, the remaining six are ties, none lost (three competitors x three LLM judges, Bonferroni-corrected, version-matched) — reaching 91.3% of a full-context oracle's binary-judge accuracy at 1/109.6 of the per-query token cost.

License: Apache-2.0