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

memo-grafter

v0.4.1

Published

Structured conversational memory for LLM chatbot applications

Readme

MemoGrafter

npm version

Structured memory for TypeScript chatbots.

MemoGrafter helps chatbot applications remember conversations without stuffing every old message back into the prompt. It turns conversation history into topic-based memory, recalls relevant details later, and can copy useful memory from one chatbot or session into another.

It is a memory framework, not an autonomous agent runtime. It does not run tools, schedule work, or decide goals for an agent.

MemoGrafter builds the memory graph incrementally. New chatbot turns append topic and memory nodes to the existing graph instead of clearing and rebuilding the session on every response, so grafted and externally enriched memory can survive later conversation turns. Use clearSession() explicitly when you want to reset an agent's local history and stored session memory.

Playground

What It Is For

  • Chatbots that need long-running memory.
  • Editors, document imports, and transcripts that need memory without assistant responses.
  • Assistants that should recall user preferences, prior context, and open questions.
  • Multi-chatbot or multi-session flows where selected memory can be grafted into another conversation.
  • TypeScript apps that need reusable memory, retrieval, and graph-backed conversation primitives.

How It Works

chat messages
  -> topic-based memory
  -> graph links
  -> relevant recall
  -> optional memory grafting

MemoGrafter stores conversation turns, tracks which messages have already been ingested, detects topic changes for new turns with recent context, summarizes useful context, links related memories, and retrieves or grafts memory when needed.

Install

npm install memo-grafter
npx memo-grafter init
npx memo-grafter migrate
npx memo-grafter studio

MemoGrafter runs server-side on Node.js. The built-in storage backend uses PostgreSQL with pgvector.

init is the required project setup step. It creates MemoGrafter-owned project files under src/memo-grafter/ (mg-schema.ts and mg.config.ts) without touching your database or creating an application schema entrypoint. migrate is the preferred database setup step; it creates or updates MemoGrafter-owned mg_* tables and should run once per database or deployment, not during normal app startup. studio starts a local MemoGrafter Studio host with session browsing, a focused graph view, read-only table inspection, and Prompt Preview backed by an internal DB API. Application tables and schema files remain wherever your existing tool, such as Prisma, Drizzle, or SQL migrations, expects them.

Studio resolves its database connection the same way as migration:

npx memo-grafter studio --db postgres://user:password@localhost:5432/memo_grafter

If --db is omitted, Studio reads .env / DATABASE_URL, then mg.config.ts. It starts on http://localhost:2891 or the next available port and keeps running until you stop the process. Prompt Preview uses the embedder from mg.config.ts; the generated config includes an OpenAI-compatible scaffold that activates when OPENAI_API_KEY is set, with MEMO_GRAFTER_EMBEDDING_MODEL defaulting to text-embedding-3-small.

For advanced deploy, CI, or test tooling where the CLI cannot run, PostgresGraphStore.migrate() remains available as a manual fallback. Prefer npx memo-grafter migrate for normal projects so migrations do not run every time your application starts.

Minimal Example

import "dotenv/config";

import {
  MemoGrafterAgent,
  OpenAIEmbedAdapter,
  OpenAILLMAdapter,
} from "memo-grafter";

const agent = new MemoGrafterAgent({
  db: { connectionString: process.env.DATABASE_URL! },
  llm: new OpenAILLMAdapter("gpt-4o"),
  embedder: new OpenAIEmbedAdapter("text-embedding-3-small"),
});

await agent.initialize();

await agent.invoke("I am planning a Japan trip.");
await agent.invoke("I like quiet towns, bookstores, and local cafes.");

await agent.ingestText("The product roadmap now prioritizes document imports.", {
  source: "import",
});

await agent.remember("The user prefers concise TypeScript examples.");

const recall = await agent.recall("travel preferences");
console.log(recall.facts);

await agent.close();

Shared Fleet Memory

Fleets can store common knowledge once and make it available to workers without copying it into each worker session.

const fleet = new MemoGrafterFleet(config, {
  id: "support-fleet",
  defaultWorkerMemory: "both",
});

await fleet.initialize();
await fleet.ingestToFleet("Refund policy: customers can request a refund within 30 days.");

const support = await fleet.createWorker({ color: "support" });
const recall = await support.recall("refund policy", { memory: "both" });

console.log(recall.facts);

Learn More

  • USER_GUIDE.md covers setup, configuration, adapters, queue mode, fleet APIs, examples, and troubleshooting.
  • ARCHITECTURE.md explains the current high-level implementation.
  • examples/basic-chat-memory is the simplest runnable single-agent memory demo.
  • examples/chatbot-memory-demo shows the larger two-agent grafting workflow.

License

MIT