export interface JsonStoreOptions { /** 使用项目级目录({cwd})而非全局目录(~/.agent) */ projectLocal?: boolean; /** 直接使用绝对路径(忽略 projectLocal) */ absolutePath?: string; } /** * 通用 JSON 文件存储 * * - read(): 读取整个 JSON 文件(带缓存) * - write(): 原子写入(先写 .tmp 再 rename) * - 自动创建父目录 */ export declare class JsonStore { private filePath; private cache; private cacheTime; /** 缓存有效期(毫秒),0 = 永久 */ private ttl; private useProjectDir; constructor(relativePath: string, ttl?: number, options?: JsonStoreOptions); /** 读取 JSON 数据 */ read(defaultValue: T): T; /** 原子写入 JSON 数据 */ write(data: T): void; /** 异步读取 JSON 数据 */ readAsync(defaultValue: T): Promise; /** 异步原子写入 JSON 数据 */ writeAsync(data: T): Promise; /** 清除缓存,强制下次从文件读取 */ invalidate(): void; /** 获取文件路径(调试用) */ getPath(): string; } /** * 列表型 JSON 存储(数组) * 提供便捷的 CRUD 方法,内部使用 JsonStore */ export declare class JsonListStore { private store; constructor(relativePath: string, options?: JsonStoreOptions & { ttl?: number; }); list(): T[]; findById(id: number): T | undefined; add(item: T): T; update(id: number, updates: Partial): T | undefined; remove(id: number): boolean; filter(predicate: (item: T) => boolean): T[]; maxId(): number; getPath(): string; replaceAll(data: T[]): void; /** 清除缓存,强制下次从文件读取 */ invalidate(): void; } //# sourceMappingURL=json-store.d.ts.map