* Reads and returns the entire knowledge graph.
()
| 126 | * Reads and returns the entire knowledge graph. |
| 127 | */ |
| 128 | async readGraph(): Promise<Graph> { |
| 129 | try { |
| 130 | this.emit('beforeReadGraph', {}); |
| 131 | const graph = await this.storage.loadGraph(); |
| 132 | this.emit('afterReadGraph', graph); |
| 133 | return graph; |
| 134 | } catch (error) { |
| 135 | const message = error instanceof Error ? error.message : 'Unknown error occurred'; |
| 136 | throw new Error(`Failed to read graph: ${message}`); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * Initializes the search manager. |