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
+35 -1
View File
@@ -119,7 +119,12 @@ describe("OSSProvider — disableHistory passthrough to Memory", () => {
expect(capturedConfig!.disableHistory).toBe(true);
});
it("does not set disableHistory when not configured", async () => {
it("does not set disableHistory when not configured and sqlite works", async () => {
// Mock better-sqlite3 so the proactive probe succeeds
vi.doMock("better-sqlite3", () => {
return { default: class { close() {} } };
});
const { createProvider } = await import("./index.ts");
const cfg = mem0ConfigSchema.parse({
mode: "open-source",
@@ -248,6 +253,12 @@ describe("OSSProvider — graceful SQLite fallback", () => {
});
it("retries with disableHistory: true when initial construction fails", async () => {
// Mock better-sqlite3 so the proactive probe succeeds — tests the
// catch-retry fallback path for other constructor errors.
vi.doMock("better-sqlite3", () => {
return { default: class { close() {} } };
});
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
const { createProvider } = await import("./index.ts");
const cfg = mem0ConfigSchema.parse({
@@ -274,6 +285,29 @@ describe("OSSProvider — graceful SQLite fallback", () => {
warnSpy.mockRestore();
});
it("proactively disables history when better-sqlite3 binary is broken", async () => {
// Do NOT mock better-sqlite3 — let probe detect the real version mismatch
// (or force it to fail if native binary happens to work on this Node).
vi.doMock("better-sqlite3", () => {
return { default: class { constructor() { throw new Error("NODE_MODULE_VERSION mismatch"); } } };
});
const { createProvider } = await import("./index.ts");
const cfg = mem0ConfigSchema.parse({
mode: "open-source",
oss: {},
});
const api = { resolvePath: (p: string) => p } as any;
const provider = createProvider(cfg, api);
const results = await provider.search("test", { user_id: "u1" });
expect(results).toBeDefined();
// Only ONE constructor call — probe detected broken sqlite, skipped retry
expect(capturedConfigs).toHaveLength(1);
expect(capturedConfigs[0].disableHistory).toBe(true);
});
it("does not retry when disableHistory is already true", async () => {
// Force the constructor to always throw, regardless of disableHistory
forceConstructorError = "vector store connection refused";