/** * Append-only conversation persistence as plain markdown. * * Each conversation is a file at `/conversations/.md` * with a frontmatter header (`schema: conversation/v1`, `id`, `agent`, * `started`, `status`) and a body composed of `## — ` * blocks. Append-only: turns are concatenated to the body, never * rewritten in place. Readers tolerant to clock skew use the timestamp * in each block, not file mtime. * * The format is intentionally trivial — git-diffable, human-editable, * survives `cat`. Designed to converge with the AIP runtime/v1 spec * (TBD) once it lands. */ type ConvRole = "user" | "assistant" | "system"; interface ConversationMeta { id: string; agent: string; started: string; status: "open" | "closed"; } interface ConversationTurn { role: ConvRole; at: string; /** Optional sub-attribution after the role (e.g. agent id). */ attribution?: string; content: string; } interface ConversationStore { /** * Open a conversation. If the file doesn't exist, it's created with * a frontmatter header. If it exists, no-op (idempotent). */ open(id: string, meta: { agent: string; }): Promise; appendTurn(id: string, role: ConvRole, content: string, opts?: { attribution?: string; at?: string; }): Promise; read(id: string): Promise<{ meta: ConversationMeta; turns: ConversationTurn[]; }>; list(): Promise>; /** Workspace-relative path to the conv file, for tooling. */ pathFor(id: string): string; } interface FileConversationStoreOptions { /** Absolute workspace root. */ workspace: string; /** Override `/conversations`. */ dir?: string; } declare function fileConversationStore(opts: FileConversationStoreOptions): ConversationStore; export { type ConvRole, type ConversationMeta, type ConversationStore, type ConversationTurn, type FileConversationStoreOptions, fileConversationStore };