/** Shape of a ChatMessage as received from / stored for the Friday app. */
export type StoredChatMessage = Record<string, unknown>;
export interface StoreUserMessageParams {
    sessionKey: string;
    deviceId: string;
    text: string;
    attachments: string[];
    localId?: string;
    timestampMs?: number;
    seq?: number;
    runId: string;
}
export interface StoreAssistantMessageParams {
    sessionKey: string;
    deviceId: string;
    message: StoredChatMessage;
    runId: string;
}
export interface SyncResult {
    idMappings: Record<string, string>;
    remoteMessages: StoredChatMessage[];
    latestServerId: string | null;
    hasMore: boolean;
    syncSeq: number;
}
/** Store a user message and return its serverId. */
export declare function storeUserMessage(params: StoreUserMessageParams): string;
/** Store an assistant message assembled by the accumulator. */
export declare function storeAssistantMessage(params: StoreAssistantMessageParams): string;
/** Paginated history query. Returns messages BEFORE the given cursor (for loading older messages). */
export declare function getMessagesBefore(sessionKey: string, beforeServerId: string | undefined, limit: number): {
    messages: StoredChatMessage[];
    hasMore: boolean;
};
/** Get latest serverId for a session (used as next cursor). */
export declare function getLatestServerIdForSession(sessionKey: string): string | null;
/** Process a sync request from a device. Idempotent by (deviceId, syncSeq). */
export declare function processSync(params: {
    sessionKey: string;
    deviceId: string;
    syncSeq: number;
    lastServerId: string | undefined;
    messages: StoredChatMessage[];
}): SyncResult;
export interface ImportResult {
    idMappings: Record<string, string>;
    imported: number;
}
/** Bulk import for first-time migration. Rejects if session already has data. */
export declare function importMessages(params: {
    sessionKey: string;
    deviceId: string;
    messages: StoredChatMessage[];
}): ImportResult;
export interface SessionListItem {
    sessionKey: string;
    deviceId: string;
    title: string;
    createdAt: string;
    lastActiveAt: string;
    messageCount: number;
    latestServerId: string | null;
}
export declare function listSessions(deviceId: string): SessionListItem[];
export declare function listAllSessionsList(): SessionListItem[];
export declare class ConflictError extends Error {
    constructor(message: string);
}
