






















@@ -573,6 +573,66 @@ describe("resolveSharedMemoryStatusSnapshot", () => {
573573expect(getMemorySearchManager).not.toHaveBeenCalled();
574574});
575575576+it("recognizes shipped memory tables before the manager migrates them", async () => {
577+const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-status-memory-"));
578+const databasePath = path.join(tempDir, "openclaw-agent.sqlite");
579+const db = new DatabaseSync(databasePath);
580+db.exec(`
581+ CREATE TABLE meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);
582+ CREATE TABLE files (
583+ path TEXT PRIMARY KEY,
584+ source TEXT NOT NULL DEFAULT 'memory',
585+ hash TEXT NOT NULL,
586+ mtime INTEGER NOT NULL,
587+ size INTEGER NOT NULL
588+ );
589+ CREATE TABLE chunks (
590+ id TEXT PRIMARY KEY,
591+ path TEXT NOT NULL,
592+ source TEXT NOT NULL DEFAULT 'memory',
593+ start_line INTEGER NOT NULL,
594+ end_line INTEGER NOT NULL,
595+ hash TEXT NOT NULL,
596+ model TEXT NOT NULL,
597+ text TEXT NOT NULL,
598+ embedding TEXT NOT NULL,
599+ updated_at INTEGER NOT NULL
600+ );
601+ INSERT INTO files VALUES ('MEMORY.md', 'memory', 'file-hash', 10, 20);
602+ `);
603+db.close();
604+const manager = {
605+probeVectorStoreAvailability: vi.fn(async () => true),
606+probeVectorAvailability: vi.fn(async () => true),
607+status: vi.fn(() => ({
608+backend: "builtin" as const,
609+provider: "openai",
610+files: 1,
611+chunks: 0,
612+vector: { enabled: true, available: true },
613+fts: { enabled: true, available: true },
614+})),
615+close: vi.fn(async () => {}),
616+};
617+const getMemorySearchManager = vi.fn(async () => ({ manager }));
618+619+try {
620+const result = await resolveSharedMemoryStatusSnapshot({
621+cfg: {},
622+agentStatus: { defaultId: "main" },
623+memoryPlugin: { enabled: true, slot: "memory-core" },
624+resolveMemoryConfig: vi.fn(() => ({ store: { databasePath } })),
625+ getMemorySearchManager,
626+requireDefaultDatabasePath: () => databasePath,
627+});
628+629+expect(getMemorySearchManager).toHaveBeenCalledOnce();
630+expect(result?.files).toBe(1);
631+} finally {
632+fs.rmSync(tempDir, { recursive: true, force: true });
633+}
634+});
635+576636it("does not initialize memory status for an agent database owned by another feature", async () => {
577637const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-status-memory-"));
578638const databasePath = path.join(tempDir, "openclaw-agent.sqlite");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。