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

@retaindb/sdk

v5.1.1

Published

TypeScript SDK for RetainDB - the memory bus for agentic systems

Readme

@retaindb/sdk

TypeScript SDK for RetainDB, the memory bus for agentic systems.

Install

npm install @retaindb/sdk@latest

Agent Memory Bus

import { RetainDB } from "@retaindb/sdk";

const db = new RetainDB({
  apiKey: process.env.RETAINDB_API_KEY,
  project: "my-product",
});

const task = db.agent("planner").task("checkout-redesign");

await task.event({
  type: "decision",
  summary: "Use a two-step checkout and keep Stripe.",
  salience: "high",
});

const context = await task.context("What should the builder know?");

await task.handoff({
  toAgentId: "builder",
  summary: "Continue checkout implementation.",
  context: String(context.context || ""),
});

Remember Conversations

For product chats, send the whole turn and let RetainDB decide what is worth remembering.

await db.remember([
  { role: "user", content: "We use Qdrant now, not Pinecone." },
  { role: "assistant", content: "Got it. I will remember Qdrant is the memory backend." },
], {
  userId: "user_123",
  sessionId: "chat_456",
});

const memories = await db.user("user_123").searchMemory("memory backend");

For explicit facts, pass a string:

await db.remember("User prefers concise answers.", {
  userId: "user_123",
  memoryType: "preference",
});

Conversation remember uses /v1/memory/extract/session. Direct string remember uses /v1/memory.

Direct Client

import { RetainDBClient } from "@retaindb/sdk";

const client = new RetainDBClient({
  apiKey: process.env.RETAINDB_API_KEY,
  project: "my-product",
});

await client.memory.add({
  content: "User prefers concise answers.",
  user_id: "user_123",
  write_mode: "async",
});

const results = await client.memory.search({
  query: "user preferences",
  user_id: "user_123",
});

Memory Router

Use the Memory Router when you want RetainDB to sit in front of an OpenAI-compatible chat provider. It searches memory from the current turn plus recent conversation context, injects the best grounded memories into the system prompt, calls your provider, and can remember the completed user/assistant turn.

import { createMemoryRouter } from "@retaindb/sdk/router";

const router = createMemoryRouter({
  apiKey: process.env.RETAINDB_API_KEY,
  project: "my-product",
  providerBaseUrl: "https://api.openai.com",
  providerApiKey: process.env.OPENAI_API_KEY,
  userId: "user_123",
  sessionId: "chat_456",
  memoryProfile: "quality",
  memoryTopK: 8,
  remember: { enabled: true },
});

const response = await router.chatCompletions({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "What did we decide?" }],
});

console.log(response.trace);

The router preserves your existing system prompt, adds a Relevant RetainDB memory context: block, sends x-retaindb-memory-router: v1, and records trace fields such as memory latency, provider latency, memory count, injected characters, fallback reason, and whether the turn was remembered. Memory lookup is best-effort by default, so provider calls still work during a memory outage.

v5 Rename

SDK v5 is a hard RetainDB rename. Public Whisper* exports were removed. Use SDK v4 if you still need the old names while migrating.