Skip to content

Variable: ImportCursorStorageNamespace

Makaio Framework


Makaio Framework / ai-adapters-core / ImportCursorStorageNamespace

const ImportCursorStorageNamespace: StorageNamespace<"importCursor", SubjectRecordFromSchemaRecord<{ delete: { request: ZodObject<{ filePath: ZodString; }, $strip>; response: ZodObject<{ success: ZodBoolean; }, $strip>; }; get: { request: ZodObject<{ filePath: ZodString; }, $strip>; response: ZodObject<{ cursor: ZodNullable<ZodObject<{ bytesRead: ZodNumber; filePath: ZodString; lastModified: ZodString; sessionContext: ZodOptional<ZodCustom<…, …>>; }, $strip>>; }, $strip>; }; set: { request: ZodObject<{ bytesRead: ZodNumber; filePath: ZodString; lastModified: ZodString; sessionContext: ZodOptional<ZodCustom<object & object, object & object>>; }, $strip>; response: ZodObject<{ success: ZodBoolean; }, $strip>; }; }>, { bytesRead: number; filePath: string; lastModified: string; sessionContext: never; }, StorageNamespaceExtensions, { delete: { request: ZodObject<{ filePath: ZodString; }, $strip>; response: ZodObject<{ success: ZodBoolean; }, $strip>; }; get: { request: ZodObject<{ filePath: ZodString; }, $strip>; response: ZodObject<{ cursor: ZodNullable<ZodObject<{ bytesRead: ZodNumber; filePath: ZodString; lastModified: ZodString; sessionContext: ZodOptional<ZodCustom<… & …, … & …>>; }, $strip>>; }, $strip>; }; set: { request: ZodObject<{ bytesRead: ZodNumber; filePath: ZodString; lastModified: ZodString; sessionContext: ZodOptional<ZodCustom<object & object, object & object>>; }, $strip>; response: ZodObject<{ success: ZodBoolean; }, $strip>; }; }>

Defined in: ../../../adapters/core/src/log-importer/cursor-storage.ts:73

Import cursor storage namespace.

Provides bus subjects for tracking import progress within external log files. Cursors enable resumption from the last successfully processed position after restarts, preventing duplicate event emission.

Storage domain: storage:importCursor

Cursors track byte offsets rather than line numbers for efficiency. The lastModified timestamp enables detection of file truncation/rotation: if the file’s mtime is older than the stored cursor, the file was likely rotated and should be re-read from the beginning.

import { ImportCursorStorageSubjects } from '@makaio/ai-adapters-core';
// Get cursor for file (returns null if not found)
const result = await bus.request(ImportCursorStorageSubjects.get, {
filePath: '/home/user/.claude/projects/foo/session.jsonl',
});
if (result.cursor) {
console.log(`Resuming from byte ${result.cursor.bytesRead}`);
}
// Update cursor after processing
await bus.request(ImportCursorStorageSubjects.set, {
filePath: '/home/user/.claude/projects/foo/session.jsonl',
bytesRead: 12345,
lastModified: '2025-12-09T10:30:00Z',
});

ImportCursorPosition - Type definition for cursor positions