Skip to content

aneequrrehman/recall

Repository files navigation

Recall β€” AI memory layer that lives in your stack

npm version npm downloads CI status

Composable building blocks for adding persistent memory to AI applications.
LLM-powered fact extraction, intelligent deduplication, vector search, and queryable structured memory β€” all in your existing database.


Note: This project is not actively maintained. I built the initial version as a proof of concept. Since then, I started working on a full product based on the structured memory approach. I'll come back to these packages soon.


Quick Start

pnpm add @youcraft/recall @youcraft/recall-adapter-sqlite \
  @youcraft/recall-embeddings-openai @youcraft/recall-extractor-openai
import { createMemory } from '@youcraft/recall'
import { sqliteAdapter } from '@youcraft/recall-adapter-sqlite'
import { openaiEmbeddings } from '@youcraft/recall-embeddings-openai'
import { openaiExtractor } from '@youcraft/recall-extractor-openai'

const memory = createMemory({
  db: sqliteAdapter({ filename: 'memories.db' }),
  embeddings: openaiEmbeddings({ apiKey: process.env.OPENAI_API_KEY! }),
  extractor: openaiExtractor({ apiKey: process.env.OPENAI_API_KEY! }),
})

// Extract memories from a conversation
await memory.extract(
  `User: I'm a software engineer working at Acme Corp.
   Assistant: Nice! What kind of projects do you work on?
   User: Mostly backend stuff in TypeScript.`,
  { userId: 'user_123' }
)

// Query relevant memories
const memories = await memory.query('What does the user do for work?', {
  userId: 'user_123',
  limit: 5,
})
// => [{ content: "User is a software engineer at Acme Corp", ... }]

Why Recall?

Most apps today already have their own infrastructure β€” background jobs, vector databases, workflow engines, and code to store and retrieve embeddings. Why deploy yet another service just for memory?

Recall takes a different approach: composable building blocks that fit into your existing stack.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Your Existing Infrastructure           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Backgroundβ”‚  β”‚  Vector   β”‚  β”‚    Database     β”‚  β”‚
β”‚  β”‚   Jobs    β”‚  β”‚  Search   β”‚  β”‚ (Postgres/etc)  β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚        β”‚              β”‚                 β”‚           β”‚
β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                       β”‚                             β”‚
β”‚               β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”                     β”‚
β”‚               β”‚    Recall     β”‚  ← just a library   β”‚
β”‚               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Building Blocks, Not a Service

Recall is a library you import, not a service you deploy. Pick the pieces you need:

  • Choose your database β€” SQLite for local dev, Postgres for production, MySQL if that's what you have
  • Choose your embeddings β€” OpenAI, Cohere, Voyage, or bring your own
  • Choose your extractor β€” GPT, Claude, or implement the interface
  • Use your existing workflows β€” Inngest, Vercel Workflow DevKit, or any background job system

Two Flavors of Memory

Core Memory Structured Memory
Package @youcraft/recall @youcraft/recall-structured
Storage Vector similarity search SQL tables with schemas
Best for Fuzzy recall, semantic search Precise queries, analytics
Query style "What does the user like?" "How much did I spend last month?"
Status Stable Experimental

Structured Memory lets you define Zod schemas and query memories with SQL precision β€” perfect for tracking payments, workouts, medications, or any structured data.


Features

  • LLM-powered extraction β€” Automatically extract facts from conversations
  • Intelligent consolidation β€” Deduplicate memories with ADD/UPDATE/DELETE/NONE decisions
  • Vector similarity search β€” Find relevant memories using embeddings
  • Pluggable architecture β€” Swap databases, embedding providers, and extractors
  • TypeScript-first β€” Full type safety with comprehensive interfaces
  • Zero lock-in β€” All data stays in your infrastructure

How Memory Consolidation Works

When you call extract(), Recall doesn't just blindly insert new memories. It uses a two-step LLM process:

  1. Extract β€” LLM identifies facts from the conversation
  2. Consolidate β€” For each fact, Recall:
    • Searches for similar existing memories
    • Asks the LLM to decide: ADD, UPDATE, DELETE, or NONE
    • Executes the decision
New fact: "User's name is John Doe"
Existing: [{ id: "abc", content: "User's name is John" }]

LLM Decision: UPDATE (merge into "User's name is John Doe")

This prevents duplicate memories and keeps your memory store clean.

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Your Application                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     @youcraft/recall (core)                     β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚   extract() β”‚  β”‚   query()   β”‚  β”‚  list/get/update/delete β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                   β”‚                     β”‚
          β–Ό                   β–Ό                     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Extractor    β”‚  β”‚   Embeddings    β”‚  β”‚   Database Adapter  β”‚
β”‚ OpenAI/Anthropicβ”‚  β”‚ OpenAI/Cohere/  β”‚  β”‚ SQLite/PostgreSQL/  β”‚
β”‚                 β”‚  β”‚ Voyage          β”‚  β”‚ MySQL               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

API Reference

// Extract and store memories from text (with automatic consolidation)
await memory.extract(text, { userId })

// Find relevant memories using vector similarity
await memory.query(context, { userId, limit?, threshold? })

// CRUD operations
await memory.list(userId)                          // List all memories
await memory.get(id)                               // Get single memory
await memory.update(id, { content?, metadata? })   // Update memory
await memory.delete(id)                            // Delete memory
await memory.clear(userId)                         // Clear all user memories

Packages

Core

Package Description
@youcraft/recall Core memory client with extract, query, and CRUD operations
@youcraft/recall-structured Schema-based structured memory with Zod validation
@youcraft/recall-client Client SDK for hosted Recall API

Database Adapters

Package Description
@youcraft/recall-adapter-sqlite SQLite adapter using better-sqlite3
@youcraft/recall-adapter-postgresql PostgreSQL adapter with pgvector support
@youcraft/recall-adapter-mysql MySQL adapter using mysql2

Embeddings Providers

Package Description
@youcraft/recall-embeddings-openai OpenAI text-embedding models
@youcraft/recall-embeddings-cohere Cohere embed models
@youcraft/recall-embeddings-voyage Voyage AI embeddings

Extractors

Package Description
@youcraft/recall-extractor-openai GPT-based fact extraction
@youcraft/recall-extractor-anthropic Claude-based fact extraction

Integrations

Package Description
@youcraft/recall-ai-sdk Vercel AI SDK integration
@youcraft/recall-mcp MCP tool definitions
@youcraft/recall-mcp-server Standalone MCP server for Claude, Cursor, etc.

Examples

Example Description
with-inngest Next.js chatbot with background memory extraction
with-inngest-structured Structured memory with Inngest workflows
with-wdk Vercel Workflow DevKit integration
with-client Using the Recall client SDK

Documentation

Visit recall-docs-sand.vercel.app for full documentation:

P.S. docs are generated by AI.

License

MIT

Packages

 
 
 

Contributors