import type { LaneCheckpoint, Session, Thread, ThreadTurn } from "@claudexor/schema"; import type { CreateThreadInput, CreateTurnInput, UpdateThreadInput } from "./threads.js"; /** * Pure ThreadStore support: the journal mutation codec and the idempotency * digests. Extracted from `threads.ts` so the store file stays under the * new-file complexity cap (INV-124); no behavior lives here — only parsing, * hashing, and array upkeep. */ export interface ThreadMutation { threads?: Thread[]; sessions?: Session[]; turns?: ThreadTurn[]; /** Per-lane checkpoints (INV-137): journaled alongside turns/sessions. */ checkpoints?: LaneCheckpoint[]; idempotency?: { keyDigest: string; requestDigest: string; turnId: string; }; threadCreation?: { keyDigest: string; requestDigest: string; threadId: string; }; } /** Keep a sticky primary only when it belongs to a non-empty explicit pool. */ export declare function coercePrimaryToPool(primary: string | null, pool: string[]): string | null; export declare function parseMutation(value: unknown): ThreadMutation; export declare function threadCreationIdempotency(partition: string, input: CreateThreadInput["idempotency"]): ThreadMutation["threadCreation"]; export declare function turnIdempotency(partition: string, threadId: string, input: CreateTurnInput["idempotency"]): ThreadMutation["idempotency"]; export declare function idempotencyConflict(): Error & { code: string; status: number; }; export declare function turnRunConflict(turnId: string, boundRunId: string, runId: string): Error; export declare function findIdempotentTurn(index: ReadonlyMap, getTurn: (id: string) => ThreadTurn | undefined, input: ThreadMutation["idempotency"]): ThreadTurn | undefined; export declare function upsert(items: T[], value: T): void; export declare function assertUnique(items: Array<{ id: string; }>, kind: string): void; /** Construct a NEW thread from its create input (defaults documented inline). */ export declare function buildNewThread(input: CreateThreadInput): Thread; /** Apply an UpdateThreadInput patch; a primary outside the (non-empty) pool * coerces to null (Auto) rather than persisting an incoherent state. */ export declare function mergeThreadPatch(thread: Thread, patch: UpdateThreadInput): Thread; //# sourceMappingURL=thread-store-support.d.ts.map