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

@memofs/adapter-ai-sdk

v1.3.0-beta.2

Published

Vercel AI SDK adapter for MemoFS memory tools, runtime bridging, and context builders.

Readme

@memofs/adapter-ai-sdk

Vercel AI SDK adapter for MemoFS memory tools, runtime bridging, and context builders.

What is this?

Vercel AI SDK adapter for MemoFS. Bridges a MemoFS memory engine into the framework-neutral MemofsMemoryRuntime contract and exposes a ready-to-use Vercel AI SDK memory tool, prompt context builders, and agent-session instructions.

This package is the provider implementation of MemoFS's AI-framework runtime contract — the runtime equivalent of the embedder interface/impl split (Embedder in core; @memofs/adapter-openai, -voyage, -transformers as provider packages).

Installation

npm install @memofs/adapter-ai-sdk

Requires Node.js >= 22.

This package has a required peer dependency on the Vercel AI SDK:

npm install ai

Quick Start

1. Build the runtime

import { MemoFS } from "@memofs/core";
import { createNodeFsMemoryStore } from "@memofs/core/node-fs";
import { createAiSdkRuntimeFromMemofs } from "@memofs/adapter-ai-sdk";

const store = createNodeFsMemoryStore({ rootDir: "." });
const memo = new MemoFS({ store, projectId: "demo" });
const runtime = createAiSdkRuntimeFromMemofs(memo);

Every recall goes through MemoFS.recall (the single hybrid engine: BM25 + fuzzy + embeddings + recency boost + optional reranker), so recall quality never changes between local, cloud, and hybrid modes.

2. Use the memory tool with the Vercel AI SDK

import { generateText, tool } from "ai";
import { buildRuntimeMemoryToolDefinition } from "@memofs/adapter-ai-sdk";

const memoryTool = buildRuntimeMemoryToolDefinition({
  runtime,
  access: { projectId: "demo", userId: "user_123" },
  allowWrites: true,
  allowCoreUpdates: true,
});

const result = await generateText({
  model: yourModel,
  tools: { memory: tool(memoryTool) },
  prompt: "Remember that the deploy target is Cloudflare Workers.",
});

The tool accepts a zod discriminated union of commands: read_core_memory, update_core_memory, remember, list_notes, search, and (when supported) index.

3. Inject memory into the prompt

import { buildRuntimeMemoryContext } from "@memofs/adapter-ai-sdk";

const { text } = await buildRuntimeMemoryContext({
  runtime,
  access: { projectId: "demo" },
  query: "deploy target",
  includeCoreMemory: true,
  includeNotes: true,
  includeRecall: true,
});

// Pass `text` as part of your `system` prompt.

API

| Export | Description | |--------|-------------| | createAiSdkRuntimeFromMemofs(memo) | Bridges a MemoFS client into a MemofsMemoryRuntime. | | buildRuntimeMemoryToolDefinition(options) | A { description, inputSchema, execute } tool for the Vercel AI SDK. | | runRuntimeMemoryTool(options, input) | Runs a single validated tool command (used by the tool definition; also callable directly). | | buildRuntimeMemoryContext(input) | Builds a prompt-ready memory text (core memory + notes + recall). | | buildPrepareCallMemoryText(...) | Builds memory text for a single model call. | | buildAgentSessionInstructions(...) | Scaffolds instructions for an agent session workspace. | | runtimeMemoryToolInputSchema | The zod discriminated union the tool validates against. | | scopePolicy helpers | normalizeAccessContext, inferWriteScope, createScopeMetadata, canReadMemoryMetadata, createRecallFilters. |

Scoping

All reads and writes are scoped through the access context (project, workspace, tenant, user, conversation, participant-shared), so an agent never crosses a memory boundary it wasn't given. Writes additionally pass through inferWriteScope and the allowWrites / allowCoreUpdates / allowIndexing / allowSecrets flags.

Boundary

This package owns the Vercel AI SDK integration only: the runtime bridge, the zod memory tool, the prompt/context builders, the agent-session instructions, and the scope policy. It does not own:

  • The framework-neutral MemofsMemoryRuntime contract (that lives in @memofs/core).
  • The memory engine, stores, recall, or agentfs/ (also core).
  • Other framework adapters (LangChain / OpenAI Agents SDK / Mastra are future sibling packages that will implement the same contract).

Contributing

See our central Contributing Guide and development scripts for details on formatting, linting, and testing within the monorepo.

License

MIT