refactor(FN-1633): migrate MessageStore from filesystem to SQLite backend
- Replace filesystem-based message storage with SQLite backend - Add MessageStore class using better-sqlite3 with WAL mode - Update message.ts CLI command to use new MessageStore API - Update dashboard routes and engine runtime for SQLite integration - Update all related tests for new storage implementation
This commit is contained in:
@@ -28,12 +28,20 @@ const {
|
||||
vi.mock("@fusion/core", async () => {
|
||||
const actual = await vi.importActual<typeof import("@fusion/core")>("@fusion/core");
|
||||
|
||||
// Mock database object for MessageStore
|
||||
const mockDatabase = {
|
||||
prepare: vi.fn().mockReturnValue({ run: vi.fn(), get: vi.fn(), all: vi.fn() }),
|
||||
bumpLastModified: vi.fn(),
|
||||
close: vi.fn(),
|
||||
};
|
||||
|
||||
return {
|
||||
...actual,
|
||||
TaskStore: vi.fn().mockImplementation(function(this: TaskStore, rootDir: string) {
|
||||
const self = this as unknown as Record<string, unknown>;
|
||||
self.getRootDir = () => rootDir;
|
||||
self.getFusionDir = () => rootDir + "/.fusion";
|
||||
self.getDatabase = vi.fn().mockReturnValue(mockDatabase);
|
||||
self.init = vi.fn().mockResolvedValue(undefined);
|
||||
self.listTasks = vi.fn().mockResolvedValue([]);
|
||||
self.getSettings = vi.fn().mockResolvedValue({});
|
||||
|
||||
@@ -346,8 +346,7 @@ export class InProcessRuntime
|
||||
await this.agentStore.init();
|
||||
|
||||
// Initialize MessageStore for wake-on-message behavior
|
||||
this.messageStore = new MessageStoreClass({ rootDir: this.taskStore.getFusionDir() });
|
||||
await this.messageStore.init();
|
||||
this.messageStore = new MessageStoreClass(this.taskStore.getDatabase());
|
||||
|
||||
this.heartbeatMonitor = new HeartbeatMonitor({
|
||||
store: this.agentStore,
|
||||
|
||||
Reference in New Issue
Block a user