VoidBot/packages/rag/src/import-state.ts
2026-04-24 13:17:00 +01:00

31 lines
665 B
TypeScript

import { SerializedFileStore } from "./file-store";
export interface ImportedFileState {
path: string;
size: number;
mtimeMs: number;
}
export interface RagImportState {
lastRunAt?: string;
files: ImportedFileState[];
}
export class FileImportStateRepository {
private readonly store: SerializedFileStore<RagImportState>;
public constructor(filePath: string) {
this.store = new SerializedFileStore(filePath, () => ({
files: [],
}));
}
public async read(): Promise<RagImportState> {
return this.store.snapshot();
}
public async write(state: RagImportState): Promise<void> {
await this.store.overwrite(state);
}
}