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

memorysync-ai-sdk

v1.0.0

Published

MemorySync memory for the Vercel AI SDK: recall + persistence middleware for generateText/streamText, standalone helpers, and agent memory tools. Supports AI SDK v6 and v7.

Readme

memorysync-ai-sdk

MemorySync memory for the Vercel AI SDK: wrap any model once and it remembers your users — recalled context injected before generation, the exchange persisted after it, streaming-safe. Supports AI SDK v6 and v7 from one build.

npm install memorysync-ai-sdk ai

Middleware — one wrap, long-term memory

import { generateText, wrapLanguageModel } from "ai";
import { openai } from "@ai-sdk/openai";
import { createMemorySyncMiddleware } from "memorysync-ai-sdk";

const model = wrapLanguageModel({
  model: openai("gpt-4o-mini"),
  middleware: createMemorySyncMiddleware({
    userId: "customer-7",   // per-end-user scoping — required
    sessionId: "thread-42", // groups the stored transcript
  }),
});

await generateText({ model, prompt: "I'm vegetarian and I fly aisle." });

// Any later call — same user, any process, any provider:
const { text } = await generateText({
  model,
  prompt: "Book my trip: flight plus a dinner spot.",
});
// The model already saw: vegetarian, aisle seat — injected from memory.

Works identically with streamText: persistence happens once when the stream finishes; an aborted stream stores nothing. Memory failures never break generation — recall failures degrade to no context, persist failures are reported through onError, never thrown.

Options: recall: false (write-only), persist: false (read-only), k, template, onError, specificationVersion: "v3" for exact types on AI SDK 6.

Recalled memories ride the result: result.providerMetadata.memorysync.memories[{ id, text, score }].

Helpers

import { getMemoryContext, searchMemories, saveTurn, createMemorySyncOnFinish } from "memorysync-ai-sdk";

const context = await getMemoryContext("what should I cook?", { userId: "customer-7" });
const hits = await searchMemories("dietary preferences", { userId: "customer-7" });
await saveTurn({ user: "I'm vegetarian", assistant: "Noted!" }, { userId: "customer-7" });

const result = streamText({
  model,
  prompt,
  onFinish: createMemorySyncOnFinish({ userId: "customer-7", user: prompt }),
});

All writes share the same idempotency seeds — retries and mixed styles cannot double-store a turn.

Agent tools

import { generateText, stepCountIs } from "ai";
import { memorySyncTools } from "memorysync-ai-sdk";

const { text } = await generateText({
  model: openai("gpt-4o-mini"),
  tools: { ...memorySyncTools({ userId: "customer-7" }) },
  stopWhen: stepCountIs(5),
  prompt: "Remember that I prefer aisle seats.",
});

Five tools — addMemory, searchMemory, listMemories, updateMemory, deleteMemory — that never throw (failures come back as readable strings) with idempotent writes. readOnly: true returns search + list only.

Version support

| Package | Requires | Runtime | |---|---|---| | memorysync-ai-sdk | ai >=6 <8 (peer) | Node 18+ (ai@7 itself requires Node 22+) |

Edge-safe: no Node-only imports — runs on Vercel Edge and Cloudflare Workers.

Documentation

Full guide: https://docs.memorysync.io/guides/vercel-ai-sdk

Set MEMORYSYNC_API_KEY in the environment (create a key at memorysync.io). MIT licensed.