refactor: drop orgId, projectId, enableGraph config options, update CLI prompts, and clean up related code (#4734)
This commit is contained in:
@@ -175,7 +175,6 @@ function createMockCfg() {
|
||||
apiKey: "m0-test-key-1234",
|
||||
baseUrl: "https://api.mem0.ai",
|
||||
topK: 5,
|
||||
enableGraph: false,
|
||||
autoCapture: true,
|
||||
autoRecall: true,
|
||||
searchThreshold: 0.5,
|
||||
@@ -967,7 +966,7 @@ describe("registerCliCommands", () => {
|
||||
const configCmd = findCommand(mem0, "config")!;
|
||||
const getCmd = findCommand(configCmd, "get")!;
|
||||
|
||||
getCmd._action!("org_id");
|
||||
getCmd._action!("email");
|
||||
|
||||
expect(consoleSpy.log).toHaveBeenCalledWith("(not set)");
|
||||
});
|
||||
@@ -1033,18 +1032,6 @@ describe("registerCliCommands", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("coerces 'true' to boolean for boolean keys", () => {
|
||||
const { mem0 } = setup();
|
||||
const configCmd = findCommand(mem0, "config")!;
|
||||
const setCmd = findCommand(configCmd, "set")!;
|
||||
|
||||
setCmd._action!("enable_graph", "true");
|
||||
|
||||
expect(writePluginAuth).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ enableGraph: true }),
|
||||
);
|
||||
});
|
||||
|
||||
it("coerces 'false' to boolean false for boolean keys", () => {
|
||||
const { mem0 } = setup();
|
||||
const configCmd = findCommand(mem0, "config")!;
|
||||
@@ -1069,18 +1056,6 @@ describe("registerCliCommands", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("coerces 'yes' to boolean true for boolean keys", () => {
|
||||
const { mem0 } = setup();
|
||||
const configCmd = findCommand(mem0, "config")!;
|
||||
const setCmd = findCommand(configCmd, "set")!;
|
||||
|
||||
setCmd._action!("enable_graph", "yes");
|
||||
|
||||
expect(writePluginAuth).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ enableGraph: true }),
|
||||
);
|
||||
});
|
||||
|
||||
it("coerces integer string for integer keys", () => {
|
||||
const { mem0 } = setup();
|
||||
const configCmd = findCommand(mem0, "config")!;
|
||||
@@ -1412,5 +1387,73 @@ describe("registerCliCommands", () => {
|
||||
expect.stringContaining("Failed to get event"),
|
||||
);
|
||||
});
|
||||
|
||||
it("event list returns early in open-source mode", async () => {
|
||||
const provider = createMockProvider();
|
||||
const cfg = { ...createMockCfg(), mode: "open-source" as const };
|
||||
const mockApi = {
|
||||
registerCli: vi.fn((cb: any) => {
|
||||
const root = createMockCommand("root");
|
||||
cb({ program: root });
|
||||
const mem0 = findCommand(root, "mem0")!;
|
||||
const eventCmd = findCommand(mem0, "event")!;
|
||||
const listCmd = findCommand(eventCmd, "list")!;
|
||||
listCmd._action!();
|
||||
}),
|
||||
logger: { info: vi.fn(), warn: vi.fn() },
|
||||
} as any;
|
||||
|
||||
registerCliCommands(
|
||||
mockApi,
|
||||
null as any,
|
||||
provider as any,
|
||||
cfg as any,
|
||||
vi.fn().mockReturnValue("testuser"),
|
||||
vi.fn((id: string) => `testuser:agent:${id}`),
|
||||
vi.fn().mockReturnValue({ user_id: "testuser", top_k: 5 }),
|
||||
vi.fn().mockReturnValue(undefined),
|
||||
);
|
||||
|
||||
// Wait for async action
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
|
||||
expect(consoleSpy.log).toHaveBeenCalledWith(
|
||||
"Event tracking is only available in platform mode.",
|
||||
);
|
||||
});
|
||||
|
||||
it("event status returns early in open-source mode", async () => {
|
||||
const provider = createMockProvider();
|
||||
const cfg = { ...createMockCfg(), mode: "open-source" as const };
|
||||
const mockApi = {
|
||||
registerCli: vi.fn((cb: any) => {
|
||||
const root = createMockCommand("root");
|
||||
cb({ program: root });
|
||||
const mem0 = findCommand(root, "mem0")!;
|
||||
const eventCmd = findCommand(mem0, "event")!;
|
||||
const statusCmd = findCommand(eventCmd, "status")!;
|
||||
statusCmd._action!("evt-123");
|
||||
}),
|
||||
logger: { info: vi.fn(), warn: vi.fn() },
|
||||
} as any;
|
||||
|
||||
registerCliCommands(
|
||||
mockApi,
|
||||
null as any,
|
||||
provider as any,
|
||||
cfg as any,
|
||||
vi.fn().mockReturnValue("testuser"),
|
||||
vi.fn((id: string) => `testuser:agent:${id}`),
|
||||
vi.fn().mockReturnValue({ user_id: "testuser", top_k: 5 }),
|
||||
vi.fn().mockReturnValue(undefined),
|
||||
);
|
||||
|
||||
// Wait for async action
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
|
||||
expect(consoleSpy.log).toHaveBeenCalledWith(
|
||||
"Event tracking is only available in platform mode.",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -69,10 +69,7 @@ describe("readPluginAuth", () => {
|
||||
apiKey: "sk-test-123",
|
||||
baseUrl: "https://custom.api.com",
|
||||
userId: "user-1",
|
||||
orgId: "org-1",
|
||||
projectId: "proj-1",
|
||||
mode: "platform",
|
||||
enableGraph: true,
|
||||
autoRecall: true,
|
||||
autoCapture: false,
|
||||
topK: 10,
|
||||
@@ -87,17 +84,14 @@ describe("readPluginAuth", () => {
|
||||
apiKey: "sk-test-123",
|
||||
baseUrl: "https://custom.api.com",
|
||||
userId: "user-1",
|
||||
orgId: "org-1",
|
||||
projectId: "proj-1",
|
||||
mode: "platform",
|
||||
enableGraph: true,
|
||||
autoRecall: true,
|
||||
autoCapture: false,
|
||||
topK: 10,
|
||||
});
|
||||
});
|
||||
|
||||
it("handles snake_case aliases (api_key, base_url, user_id, org_id, project_id)", () => {
|
||||
it("handles snake_case aliases (api_key, base_url, user_id)", () => {
|
||||
setConfigFile({
|
||||
plugins: {
|
||||
entries: {
|
||||
@@ -107,8 +101,6 @@ describe("readPluginAuth", () => {
|
||||
api_key: "sk-snake",
|
||||
base_url: "https://snake.api.com",
|
||||
user_id: "user-snake",
|
||||
org_id: "org-snake",
|
||||
project_id: "proj-snake",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -119,8 +111,6 @@ describe("readPluginAuth", () => {
|
||||
expect(auth.apiKey).toBe("sk-snake");
|
||||
expect(auth.baseUrl).toBe("https://snake.api.com");
|
||||
expect(auth.userId).toBe("user-snake");
|
||||
expect(auth.orgId).toBe("org-snake");
|
||||
expect(auth.projectId).toBe("proj-snake");
|
||||
});
|
||||
|
||||
it("returns empty object when JSON is invalid", () => {
|
||||
|
||||
@@ -64,11 +64,6 @@ describe("mem0ConfigSchema.parse() — defaults", () => {
|
||||
expect(cfg.searchThreshold).toBe(0.5);
|
||||
});
|
||||
|
||||
it("enableGraph defaults to false", () => {
|
||||
const cfg = mem0ConfigSchema.parse({ apiKey: "test-key" });
|
||||
expect(cfg.enableGraph).toBe(false);
|
||||
});
|
||||
|
||||
it("customInstructions defaults to DEFAULT_CUSTOM_INSTRUCTIONS", () => {
|
||||
const cfg = mem0ConfigSchema.parse({ apiKey: "test-key" });
|
||||
expect(cfg.customInstructions).toBe(DEFAULT_CUSTOM_INSTRUCTIONS);
|
||||
@@ -274,14 +269,6 @@ describe("mem0ConfigSchema.parse() — explicit overrides", () => {
|
||||
expect(cfg.autoRecall).toBe(false);
|
||||
});
|
||||
|
||||
it("enableGraph can be set to true", () => {
|
||||
const cfg = mem0ConfigSchema.parse({
|
||||
apiKey: "k",
|
||||
enableGraph: true,
|
||||
});
|
||||
expect(cfg.enableGraph).toBe(true);
|
||||
});
|
||||
|
||||
it("custom topK is used when provided", () => {
|
||||
const cfg = mem0ConfigSchema.parse({ apiKey: "k", topK: 20 });
|
||||
expect(cfg.topK).toBe(20);
|
||||
@@ -330,18 +317,6 @@ describe("mem0ConfigSchema.parse() — explicit overrides", () => {
|
||||
expect(cfg.baseUrl).toBe("https://custom.api.com");
|
||||
});
|
||||
|
||||
it("orgId is passed through when provided", () => {
|
||||
const cfg = mem0ConfigSchema.parse({ apiKey: "k", orgId: "org-123" });
|
||||
expect(cfg.orgId).toBe("org-123");
|
||||
});
|
||||
|
||||
it("projectId is passed through when provided", () => {
|
||||
const cfg = mem0ConfigSchema.parse({
|
||||
apiKey: "k",
|
||||
projectId: "proj-456",
|
||||
});
|
||||
expect(cfg.projectId).toBe("proj-456");
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -359,22 +334,23 @@ describe("mem0ConfigSchema.parse() — oss config", () => {
|
||||
historyDbPath: "/tmp/history.db",
|
||||
disableHistory: false,
|
||||
};
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "oss", oss: ossConfig });
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "open-source", oss: ossConfig });
|
||||
expect(cfg.mode).toBe("open-source");
|
||||
expect(cfg.oss).toEqual(ossConfig);
|
||||
});
|
||||
|
||||
it("ignores oss when it is not a plain object", () => {
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "oss", oss: "not-an-object" });
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "open-source", oss: "not-an-object" });
|
||||
expect(cfg.oss).toBeUndefined();
|
||||
});
|
||||
|
||||
it("ignores oss when it is an array", () => {
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "oss", oss: [1, 2, 3] });
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "open-source", oss: [1, 2, 3] });
|
||||
expect(cfg.oss).toBeUndefined();
|
||||
});
|
||||
|
||||
it("ignores oss when it is null", () => {
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "oss", oss: null });
|
||||
const cfg = mem0ConfigSchema.parse({ mode: "open-source", oss: null });
|
||||
expect(cfg.oss).toBeUndefined();
|
||||
});
|
||||
});
|
||||
@@ -388,7 +364,6 @@ describe("mem0ConfigSchema.parse() — skills config", () => {
|
||||
triage: {
|
||||
enabled: true,
|
||||
importanceThreshold: 3,
|
||||
enableGraph: false,
|
||||
credentialPatterns: ["sk-", "ghp_"],
|
||||
},
|
||||
recall: {
|
||||
|
||||
@@ -127,7 +127,6 @@ describe("providerToBackend — add", () => {
|
||||
immutable: true,
|
||||
infer: false,
|
||||
expires: "2027-01-01",
|
||||
enableGraph: true,
|
||||
});
|
||||
|
||||
expect(provider.add).toHaveBeenCalledWith(
|
||||
@@ -139,7 +138,6 @@ describe("providerToBackend — add", () => {
|
||||
immutable: true,
|
||||
infer: false,
|
||||
expiration_date: "2027-01-01",
|
||||
enable_graph: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -32,7 +32,6 @@ function createMockToolDeps(overrides = {}): ToolDeps {
|
||||
mode: "platform",
|
||||
userId: "testuser",
|
||||
topK: 5,
|
||||
enableGraph: false,
|
||||
autoCapture: true,
|
||||
autoRecall: true,
|
||||
searchThreshold: 0.5,
|
||||
|
||||
Reference in New Issue
Block a user