MCPcopy Create free account
hub / github.com/anus-dev/ANUS / loadCheckpoint

Method loadCheckpoint

packages/core/src/core/logger.ts:329–357  ·  view source on GitHub ↗
(tag: string)

Source from the content-addressed store, hash-verified

327 }
328
329 async loadCheckpoint(tag: string): Promise<Content[]> {
330 if (!this.initialized) {
331 console.error(
332 'Logger not initialized or checkpoint file path not set. Cannot load checkpoint.',
333 );
334 return [];
335 }
336
337 const path = await this._getCheckpointPath(tag);
338 try {
339 const fileContent = await fs.readFile(path, 'utf-8');
340 const parsedContent = JSON.parse(fileContent);
341 if (!Array.isArray(parsedContent)) {
342 console.warn(
343 `Checkpoint file at ${path} is not a valid JSON array. Returning empty checkpoint.`,
344 );
345 return [];
346 }
347 return parsedContent as Content[];
348 } catch (error) {
349 const nodeError = error as NodeJS.ErrnoException;
350 if (nodeError.code === 'ENOENT') {
351 // This is okay, it just means the checkpoint doesn't exist in either format.
352 return [];
353 }
354 console.error(`Failed to read or parse checkpoint file ${path}:`, error);
355 return [];
356 }
357 }
358
359 async deleteCheckpoint(tag: string): Promise<boolean> {
360 if (!this.initialized || !this.anusDir) {

Callers 2

logger.test.tsFile · 0.80
chatCommand.tsFile · 0.80

Calls 2

_getCheckpointPathMethod · 0.95
readFileMethod · 0.80

Tested by

no test coverage detected