UNPKG

histoire

Version:

A fast story book powered by Vite

23 lines • 1.83 kB
import type { UiAgentThreadBase, UiAiThread } from '@histoire/shared'; /** Serialization of one kind of persisted agent conversation (comments, AI threads). */ export interface ThreadFileCodec<T extends UiAgentThreadBase> { /** Array property in the versioned JSON document. */ key: string; /** Capitalized label used in error messages. */ label: string; /** Validate one persisted record, throwing on corrupt data. */ validate: (value: unknown) => T; } /** AI threads codec as the default of generic helpers, which thread callers omit. */ export declare function defaultCodec<T extends UiAgentThreadBase>(): ThreadFileCodec<T>; /** Read only bounded versioned JSON; missing directories remain uncreated. */ export declare function readCommentsFile<T extends UiAgentThreadBase = UiAiThread>(root: string, file: string, codec?: ThreadFileCodec<T>): Promise<T[]>; /** Report exact on-disk UTF-8 bytes, including pretty-printing and final newline. */ export declare function commentsFileBytes<T extends UiAgentThreadBase = UiAiThread>(comments: readonly T[], codec?: ThreadFileCodec<T>): number; /** Rename a private sibling after successful serialization, preserving original on failure. */ export declare function writeCommentsFile<T extends UiAgentThreadBase = UiAiThread>(root: string, file: string, comments: readonly T[], codec?: ThreadFileCodec<T>): Promise<void>; /** Physical project identity is shared by mutation lanes and pending reply reservations. */ export declare function commentsFileIdentity(root: string, file: string): Promise<string>; /** Read/modify/write ownership spans all clients and store instances for one physical file. */ export declare function withCommentsFileLock<T>(root: string, file: string, work: (key: string) => Promise<T>): Promise<T>; //# sourceMappingURL=file.d.ts.map