refactor: update memory skill loader, plugin config, and add privacy docs (#4905)

This commit is contained in:
Kartik
2026-04-22 17:15:19 +05:30
committed by GitHub
parent 32b74e18b7
commit f5dc825d47
21 changed files with 1734 additions and 189 deletions
+28 -5
View File
@@ -214,6 +214,7 @@ class PlatformProvider implements Mem0Provider {
// ============================================================================
class OSSProvider implements Mem0Provider {
private static _warnPatched = false;
private memory: any; // Memory from mem0ai/oss
private initPromise: Promise<void> | null = null;
@@ -241,7 +242,7 @@ class OSSProvider implements Mem0Provider {
provider: "openai",
config: { model: "text-embedding-3-small" },
};
const defaultLlm = { provider: "openai", config: { model: "gpt-5.4" } };
const defaultLlm = { provider: "openai", config: { model: "gpt-5-mini" } };
const stripEmpty = (obj: Record<string, unknown>) => {
const out = { ...obj };
@@ -325,13 +326,35 @@ class OSSProvider implements Mem0Provider {
VectorCls.prototype.__patched = true;
}
// Proactively detect broken better-sqlite3 native binding (e.g. Node
// version mismatch) and skip history to avoid noisy constructor failures.
let sqliteOk = true;
if (!this.ossConfig?.disableHistory) {
try {
// @ts-ignore — better-sqlite3 is a transitive dep; no types in this package
const bs3Mod = await import("better-sqlite3");
const BS3 = bs3Mod.default ?? bs3Mod;
const testDb = new (BS3 as any)(":memory:");
(testDb as any).close();
} catch {
sqliteOk = false;
}
}
if (!OSSProvider._warnPatched) {
const origWarn = console.warn;
console.warn = (...args: unknown[]) => {
if (typeof args[0] === "string" && args[0].includes("checkCompatibility")) return;
origWarn.apply(console, args);
};
OSSProvider._warnPatched = true;
}
let mem: any;
try {
mem = new Memory(this._buildConfig());
mem = new Memory(this._buildConfig(!sqliteOk));
} catch (err) {
// If constructor fails (e.g. native SQLite binding under jiti/Docker),
// retry with a FRESH config that has history disabled.
if (!this.ossConfig?.disableHistory) {
if (!this.ossConfig?.disableHistory && sqliteOk) {
console.warn(
"[mem0] Memory initialization failed, retrying with history disabled:",
err instanceof Error ? err.message : err,