LlamaIndexTS
Official @wolbarg/llamaindex — wolbargBlock / WolbargMemoryBlock for createMemory({ memoryBlocks }).
What is it?
@wolbarg/llamaindex is the official LlamaIndexTS long-term memory block for Wolbarg shared memory.
It wires Wolbarg into LlamaIndex’s createMemory({ memoryBlocks }) API via BaseMemoryBlock:
get— recalls relevant memories from the last user messageput— persists conversation turns withrememberFromMessages
Soft-fails by default so memory errors never break an agent turn.
Requires Node ≥ 22.
Install
npm install wolbarg @wolbarg/llamaindex llamaindexPeers: wolbarg >= 0.5.3, @llamaindex/core >= 0.6.0, optional llamaindex >= 0.9.0.
Quick start
import { createMemory } from "llamaindex";
import { wolbarg, sqlite, openaiEmbedding } from "wolbarg";
import { wolbargBlock } from "@wolbarg/llamaindex";
const client = wolbarg({
organization: "my-app",
storage: sqlite("./memory.db"),
embedding: openaiEmbedding({
apiKey: process.env.OPENAI_API_KEY!,
model: "text-embedding-3-small",
}),
});
await client.ready();
const memory = createMemory({
memoryBlocks: [
wolbargBlock({
memory: client,
agent: "assistant",
sessionId: "demo-session",
}),
],
});
await memory.add({ role: "user", content: "I prefer dark mode." });
await memory.manageMemoryBlocks();
const messages = await memory.getLLM();wolbargBlock mirrors LlamaIndex’s staticBlock / vectorBlock naming. createWolbargMemoryBlock is an alias for WolbargMemoryBlock.
Options
| Option | Default | Description |
|---|---|---|
memory | required | Wolbarg client |
agent | required | Agent id for recall filter + remember |
id | auto UUID | Block id |
priority | 1 | LlamaIndex block priority (0 = always include) |
isLongTerm | true | Long-term block flag |
topK | 5 | Recall limit |
threshold | — | Minimum similarity |
sessionId / userId / tags / namespace | — | Attached to remember metadata |
metadata | {} | Extra remember metadata |
formatContext | default list | Format recall hits → memory message text |
rememberMode | "raw" | "raw" or "extract" |
rawStrategy | "last_user" | "last_user" or "all_user" |
onError | — | Soft-fail hook (error, phase) |
Behavior
| Method | Behavior |
|---|---|
get(messages?) | Query = last user message text → memory.recall → one { role: "memory", content } (or []) |
put(messages) | Convert to conversation turns (skips memory role) → rememberFromMessages |
| Errors | Soft-fail: get → [], put → no throw; optional onError |
Remembered rows include metadata.source = "wolbarg-llamaindex".
Config tips
wolbargBlock({
memory: client,
agent: "assistant",
topK: 8,
threshold: 0.35,
rememberMode: "raw",
rawStrategy: "last_user",
formatContext: (hits) =>
hits.map((h) => `- ${h.content.text}`).join("\n"),
onError: (err, phase) => console.warn("[wolbarg]", phase, err),
});Limitations
- Recall query uses the last user message only (not a multi-turn window).
putskips messages with role"memory"and empty content.- Does not replace LlamaIndex short-term chat buffer — use alongside
createMemory. - Requires Node ≥ 22 and Wolbarg ≥ 0.5.3 (
rememberFromMessages).