(conversation: Content[], tag: string)
| 311 | } |
| 312 | |
| 313 | async saveCheckpoint(conversation: Content[], tag: string): Promise<void> { |
| 314 | if (!this.initialized) { |
| 315 | console.error( |
| 316 | 'Logger not initialized or checkpoint file path not set. Cannot save a checkpoint.', |
| 317 | ); |
| 318 | return; |
| 319 | } |
| 320 | // Always save with the new encoded path. |
| 321 | const path = this._checkpointPath(tag); |
| 322 | try { |
| 323 | await fs.writeFile(path, JSON.stringify(conversation, null, 2), 'utf-8'); |
| 324 | } catch (error) { |
| 325 | console.error('Error writing to checkpoint file:', error); |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | async loadCheckpoint(tag: string): Promise<Content[]> { |
| 330 | if (!this.initialized) { |
no test coverage detected