Recall Quickstart for TypeScript
Native binding via napi-rs. Idiomatic TypeScript, real Promises, full async/await. Requires Node 20+ and TypeScript 5+.
Install
bash
pnpm add @arc-labs/recall
# or: npm install @arc-labs/recall
# or: yarn add @arc-labs/recallInitialize
The default store is embedded SQLite + sqlite-vec. Single file; no network. Swap to Postgres + pgvector for production.
typescript
import { Recall } from "@arc-labs/recall";
const recall = new Recall({
store: { type: "sqlite", path: "./recall.db" },
// For production:
// store: { type: "postgres", url: process.env.DATABASE_URL },
});Write a memory
typescript
await recall.write({
scope: { user_id: "u_alice" },
source: {
turn: {
user: "I prefer dark mode in my IDE — light themes hurt my eyes.",
assistant: "Noted — I'll default to dark mode for editor recommendations.",
},
},
});
// The 7-stage pipeline runs:
// pre-filter → extract → classify → resolve → dedupe → conflict → persist
// Result: 1 preference stored ("user prefers dark mode in IDE", confidence 0.93)Retrieve
typescript
const results = await recall.search({
scope: { user_id: "u_alice" },
query: "what theme should I use?",
limit: 10,
});
console.log(results[0]);
// {
// id: "mem_01H...",
// type: "preference",
// content: "user prefers dark mode in IDE",
// confidence: 0.93,
// score: 0.91,
// freshness: 1.0,
// }Render into a prompt
typescript
const ctx = await recall.context({
scope: { user_id: "u_alice" },
query: userMessage,
budget: 1500, // tokens
});
// ctx.render("structured") produces:
// memories.preferences:
// - [mem_01H...] user prefers dark mode in IDE (conf 0.93)
// memories.facts: []
const response = await openai.chat.completions.create({
model: "gpt-4.1",
messages: [
{
role: "system",
content: `You have these memories about the user:\n${ctx.render("structured")}`,
},
{ role: "user", content: userMessage },
],
});Type-safe everywhere
The TS SDK ships full TypeScript types. Errors are typed; query results are typed; you get IDE autocomplete on everything.
typescript
import type { Memory, MemoryType, RecallError } from "@arc-labs/recall";
// All types are exported and stable across versions.
function describeMemory(m: Memory): string {
switch (m.type) {
case "preference":
return `User prefers ${m.content}`;
case "fact":
return `Fact: ${m.content}`;
case "event":
return `Event on ${m.timestamp}: ${m.content}`;
// exhaustive — TS will flag if you forget a case
}
}Done.
You have a working memory layer in TypeScript. Continue with the docs for production patterns, or browse the Learn track for architecture deep-dives.