Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mem0-ts/src/oss/src/config/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MemoryConfig } from "../types";
import { getDefaultHistoryDbPath } from "../utils/sqlite";

export const DEFAULT_MEMORY_CONFIG: MemoryConfig = {
disableHistory: false,
Expand Down Expand Up @@ -29,7 +30,7 @@ export const DEFAULT_MEMORY_CONFIG: MemoryConfig = {
historyStore: {
provider: "sqlite",
config: {
historyDbPath: "memory.db",
historyDbPath: getDefaultHistoryDbPath(),
},
},
};
4 changes: 3 additions & 1 deletion mem0-ts/src/oss/src/tests/sqlite-backward-compat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ describe("backward compat: ConfigManager.mergeConfig", () => {
expect(cfg.llm.provider).toBe("openai");
expect(cfg.historyStore).toBeDefined();
expect(cfg.historyStore!.provider).toBe("sqlite");
expect(cfg.historyStore!.config.historyDbPath).toBe("memory.db");
expect(cfg.historyStore!.config.historyDbPath).toBe(
path.join(os.homedir(), ".mem0", "history.db"),
);
expect(cfg.disableHistory).toBe(false);
});

Expand Down
6 changes: 4 additions & 2 deletions mem0-ts/src/oss/src/tests/sqlite-path-resolution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ describe("ConfigManager.mergeConfig – historyDbPath handling", () => {
expect(cfg.historyStore?.config.historyDbPath).toBe("/tmp/explicit.db");
});

it("preserves default memory.db when nothing is provided", () => {
it("preserves default history.db under ~/.mem0 when nothing is provided", () => {
const cfg = ConfigManager.mergeConfig({});
expect(cfg.historyStore?.provider).toBe("sqlite");
expect(cfg.historyStore?.config.historyDbPath).toBe("memory.db");
expect(cfg.historyStore?.config.historyDbPath).toBe(
path.join(os.homedir(), ".mem0", "history.db"),
);
});

it("respects only historyStore.config when top-level is absent", () => {
Expand Down
4 changes: 4 additions & 0 deletions mem0-ts/src/oss/src/utils/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export function getDefaultVectorStoreDbPath(): string {
return path.join(os.homedir(), ".mem0", "vector_store.db");
}

export function getDefaultHistoryDbPath(): string {
return path.join(os.homedir(), ".mem0", "history.db");
}

export function ensureSQLiteDirectory(dbPath: string): void {
if (!dbPath || dbPath === ":memory:" || dbPath.startsWith("file:")) {
return;
Expand Down
Loading