Mastra
Official @wolbarg/mastra Processor — createWolbargProcessor for shared semantic recall and remember (not a Storage rewrite).
What is it?
@wolbarg/mastra is the official Mastra Processor for Wolbarg shared semantic memory.
It automatically:
- Recalls relevant memories in
processInput(from the last user text incontent.parts) - Injects them as a system message (preferred) or a prepended memory message
- Remembers the conversation in
processOutputResultviarememberFromMessages
This is not a Mastra Storage / Memory rewrite. Keep Mastra Memory for thread history if you want it; add this processor for shared semantic memory across agents.
Requires @mastra/core ≥ 1.0 (Processor API) and Node ≥ 22.
Install
npm install wolbarg @wolbarg/mastra @mastra/corePeers: wolbarg >= 0.5.3, @mastra/core >= 1.0.0. Optional peer: @mastra/memory (thread history only — not required by this package).
Quick start
import { Agent } from "@mastra/core/agent";
import { wolbarg, sqlite, openaiEmbedding } from "wolbarg";
import { createWolbargProcessor } from "@wolbarg/mastra";
const memory = wolbarg({
organization: "my-app",
storage: sqlite("./memory.db"),
embedding: openaiEmbedding({
apiKey: process.env.OPENAI_API_KEY!,
model: "text-embedding-3-small",
}),
});
await memory.ready();
// One instance for both input + output hooks
const wolbargMem = createWolbargProcessor({
memory,
agent: "assistant",
sessionId: "optional-session",
});
const agent = new Agent({
id: "assistant",
name: "Assistant",
instructions: "You are a helpful assistant.",
model: "openai/gpt-4.1-mini",
inputProcessors: [wolbargMem],
outputProcessors: [wolbargMem],
});
const result = await agent.generate("What UI theme do I prefer?");
console.log(result.text);Alias: wolbargProcessor === createWolbargProcessor.
Register the same processor instance in both inputProcessors and outputProcessors — Mastra runs input and output hooks from separate lists.
Options
| Option | Default | Description |
|---|---|---|
memory | — | Wolbarg instance (required) |
agent | — | Agent id for recall filter / remember (required) |
id | "wolbarg-memory" | Processor id |
recall | true | Run recall in processInput |
remember | true | Run remember in processOutputResult |
topK | 5 | Recall hit count |
injection | "system" | "system" appends to systemMessages; "message" prepends a system-role MastraDBMessage |
sessionId / userId / tags / namespace | — | Stored on remember metadata |
metadata | {} | Extra remember metadata (source: "wolbarg-mastra" always set) |
formatContext | default bullet list | Format recall hits into prompt text |
onError | — | (error, phase) => void |
onTelemetry | — | Soft telemetry events for recall / inject / remember |
With Mastra Memory (optional)
import { Memory } from "@mastra/memory";
const agent = new Agent({
// ...
memory: new Memory({ /* thread / working memory */ }),
inputProcessors: [wolbargMem],
outputProcessors: [wolbargMem],
});Mastra Memory handles conversation threads. Wolbarg handles cross-agent semantic recall.
Soft-fail
Recall and remember failures never crash agent generation. Use onError / onTelemetry for observability.
Limitations
- Not a Mastra Storage rewrite — thread history stays with Mastra Memory if you use it.
- Text extraction iterates
content.partswheretype === "text"(MastraDBMessageformat 2). - You must put the same instance in both processor arrays; input-only or output-only registration skips half the lifecycle.