WOLBΛRG

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:

  1. Recalls relevant memories in processInput (from the last user text in content.parts)
  2. Injects them as a system message (preferred) or a prepended memory message
  3. Remembers the conversation in processOutputResult via rememberFromMessages

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/core

Peers: 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

OptionDefaultDescription
memoryWolbarg instance (required)
agentAgent id for recall filter / remember (required)
id"wolbarg-memory"Processor id
recalltrueRun recall in processInput
remembertrueRun remember in processOutputResult
topK5Recall hit count
injection"system""system" appends to systemMessages; "message" prepends a system-role MastraDBMessage
sessionId / userId / tags / namespaceStored on remember metadata
metadata{}Extra remember metadata (source: "wolbarg-mastra" always set)
formatContextdefault bullet listFormat recall hits into prompt text
onError(error, phase) => void
onTelemetrySoft 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.parts where type === "text" (MastraDBMessage format 2).
  • You must put the same instance in both processor arrays; input-only or output-only registration skips half the lifecycle.