chore: merge origin/main into mintlify/af82bda4 and resolve conflicts

This commit is contained in:
mintlify[bot]
2026-09-16 11:46:52 +00:00
committed by GitHub
parent b5ae772eae
commit 08d9636491
693 changed files with 55668 additions and 22676 deletions
@@ -59,4 +59,10 @@ describe("extractConversation", () => {
it("returns empty array for empty input", () => {
expect(extractConversation([])).toEqual([]);
});
it("redacts credentials before automatic capture", () => {
expect(extractConversation([
{ role: "user", content: "api_key=do-not-store-this" },
])).toEqual([{ role: "user", content: "api_key=[REDACTED]" }]);
});
});
@@ -43,8 +43,6 @@ describe("loadConfig", () => {
const config = loadConfig();
expect(config.apiKey).toBe("m0-file-key");
expect(config.userId).toBe("file-user");
expect(config.dream.enabled).toBe(true);
expect(config.dream.minHours).toBe(24);
});
it("env vars override config file", () => {
@@ -1,59 +0,0 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import * as fs from "node:fs";
import { checkCheapGates, checkMemoryGate } from "../src/dream/index.ts";
vi.mock("node:fs");
const STATE_DIR = "/tmp/test-mem0-dream";
describe("checkCheapGates", () => {
beforeEach(() => {
vi.mocked(fs.mkdirSync).mockReturnValue(undefined);
});
afterEach(() => {
vi.restoreAllMocks();
});
it("blocks when no state file exists (zero sessions)", () => {
vi.mocked(fs.readFileSync).mockImplementation(() => { throw new Error("ENOENT"); });
const result = checkCheapGates(STATE_DIR, {});
expect(result.proceed).toBe(false);
expect(result.reason).toContain("sessions");
});
it("blocks when consolidated recently", () => {
vi.mocked(fs.readFileSync).mockReturnValue(
JSON.stringify({ lastConsolidatedAt: Date.now() - 3_600_000, sessionsSince: 10, lastSessionId: null })
);
const result = checkCheapGates(STATE_DIR, {});
expect(result.proceed).toBe(false);
expect(result.reason).toContain("time");
});
it("blocks when not enough sessions", () => {
vi.mocked(fs.readFileSync).mockReturnValue(
JSON.stringify({ lastConsolidatedAt: Date.now() - 48 * 3_600_000, sessionsSince: 2, lastSessionId: null })
);
const result = checkCheapGates(STATE_DIR, {});
expect(result.proceed).toBe(false);
expect(result.reason).toContain("sessions");
});
it("proceeds when both gates pass", () => {
vi.mocked(fs.readFileSync).mockReturnValue(
JSON.stringify({ lastConsolidatedAt: Date.now() - 48 * 3_600_000, sessionsSince: 10, lastSessionId: null })
);
expect(checkCheapGates(STATE_DIR, {}).proceed).toBe(true);
});
});
describe("checkMemoryGate", () => {
it("blocks when too few memories", () => {
expect(checkMemoryGate(5, {}).pass).toBe(false);
});
it("passes when enough memories", () => {
expect(checkMemoryGate(25, {}).pass).toBe(true);
});
});
@@ -21,9 +21,9 @@ describe("resolveSearchFilters", () => {
});
});
it("global scope returns user_id with app_id wildcard", () => {
it("global scope returns user_id only", () => {
expect(resolveSearchFilters("global", ctx)).toEqual({
user_id: "kartik", app_id: "*",
user_id: "kartik",
});
});
});
@@ -6,6 +6,7 @@ const mockMem0 = {
search: vi.fn(),
add: vi.fn(),
getAll: vi.fn(),
update: vi.fn(),
delete: vi.fn(),
deleteAll: vi.fn(),
};
@@ -38,11 +39,13 @@ describe("buildToolExecute", () => {
expect(call[1].customCategories.length).toBe(10);
});
it("search with scope=global filters by user_id with app_id wildcard", async () => {
it("search uses global scope only after the user selects it", async () => {
mockMem0.search.mockResolvedValue({ results: [] });
await execute({ action: "search", query: "preferences", scope: "global" });
await expect(execute({ action: "search", query: "preferences", scope: "global" })).rejects.toThrow(/Select global/);
const globalExecute = buildToolExecute(mockMem0 as any, scopeCtx, "global");
await globalExecute({ action: "search", query: "preferences", scope: "global" });
expect(mockMem0.search).toHaveBeenCalledWith("preferences", {
filters: { user_id: "testuser", app_id: "*" },
filters: { user_id: "testuser" },
});
});
@@ -58,4 +61,19 @@ describe("buildToolExecute", () => {
await execute({ action: "delete", memory_id: fullId });
expect(mockMem0.delete).toHaveBeenCalledWith(fullId);
});
it("write actions accept the citation ID returned by search", async () => {
mockMem0.update.mockResolvedValue({ status: "updated" });
mockMem0.delete.mockResolvedValue({ message: "deleted" });
await execute({
action: "update",
memory_id: "[mem0:956e3d68-b420-4e07-a4e3-3019e7cebe6f]",
content: "updated memory",
});
await execute({ action: "delete", memory_id: "mem0:956e3d68-b420-4e07-a4e3-3019e7cebe6f" });
expect(mockMem0.update).toHaveBeenLastCalledWith("956e3d68-b420-4e07-a4e3-3019e7cebe6f", {
text: "updated memory",
});
expect(mockMem0.delete).toHaveBeenLastCalledWith("956e3d68-b420-4e07-a4e3-3019e7cebe6f");
});
});