MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / FileSystemStore

Class FileSystemStore

apps/webuiapps/src/lib/FileSystemStore.ts:31–710  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 * Manages in-memory file tree structure
30 */
31export class FileSystemStore {
32 private nodes: Map<string, FileNode>;
33 private pathIndex: Map<string, string>;
34 private rootId: string;
35 private listeners: Set<FileSystemListener>;
36 private fileApi?: FileOperations;
37
38 constructor(fileApi?: FileOperations) {
39 this.nodes = new Map();
40 this.pathIndex = new Map();
41 this.rootId = 'root';
42 this.listeners = new Set();
43 this.fileApi = fileApi;
44
45 // Initialize root node
46 this.initRoot();
47 }
48
49 /**
50 * Initialize root node
51 */
52 private initRoot(): void {
53 const rootNode: FileNode = {
54 id: this.rootId,
55 name: '',
56 path: '/',
57 type: 'folder',
58 parentId: null,
59 children: [],
60 metadata: {
61 createdAt: Date.now(),
62 updatedAt: Date.now(),
63 },
64 };
65 this.nodes.set(this.rootId, rootNode);
66 this.pathIndex.set('/', this.rootId);
67 }
68
69 // ============ Event System ============
70
71 /**
72 * Emit event
73 */
74 private emit(type: FileSystemEventType, nodeId?: string, path?: string): void {
75 const event: FileSystemEvent = {
76 type,
77 nodeId,
78 path,
79 timestamp: Date.now(),
80 };
81 this.listeners.forEach((listener) => {
82 try {
83 listener(event);
84 } catch (error) {
85 console.error('[FileSystemStore] Listener error:', error);
86 }
87 });
88 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected