Wolbarg
Lifecycle methods for the Wolbarg class — constructor options including concurrency, embeddingCache, memory.dedupe, ready, close, and subscribe.
Constructor
new Wolbarg(options) // preferred
wolbarg(options) // factory (recommended in docs)
new Wolbarg() // then init() for v0.1 compatWhen llm is present, the instance type allows compress. Without it, calling compress is a compile-time error.
Common options
import { wolbarg, sqlite, openaiEmbedding, bm25 } from "wolbarg";
const ctx = wolbarg({
organization: "my-org",
storage: sqlite("./memory.db"),
embedding: openaiEmbedding({ /* … */ }),
keywordSearch: bm25(), // required when using hybrid: true
concurrency: {
maxRetries: 5,
baseBackoffMs: 50,
maxBackoffMs: 2000,
lockTimeoutMs: 5000,
},
embeddingCache: {
enabled: true,
ttlMs: undefined,
maxEntries: 10_000,
},
memory: {
dedupe: {
enabled: false, // default — opt in for upsert
strategy: "exact-or-near",
nearThreshold: 0.92,
nearCandidateLimit: 8,
},
},
});See Configuration for the full option table (including Postgres schema / SSL / maxPoolSize). Isolate factories with Project layout.
ready()
await ctx.ready();Opens storage (and telemetry when configured) and probes embedding dimensions. Called automatically by other methods; use explicitly to fail fast at startup.
close()
await ctx.close();Idempotent. Releases database connections and tears down all subscribe() listeners.
subscribe()
const stop = ctx.subscribe({ organization: "my-org" }, (e) => {
console.log(e.event, e.memoryId);
});See subscribe() and Real-time events. Organization cannot be overridden to another tenant.
init() shim
const ctx = new Wolbarg();
await ctx.init({
organization: "my-org",
database: { provider: "sqlite", connectionString: "./memory.db" },
embedding: { baseUrl, apiKey, model },
llm: { baseUrl, apiKey, model }, // optional
});Prefer constructor / wolbarg() options. See init() Compatibility.