import { Chat } from "@ai-sdk/react"; import { type UIMessage } from "ai"; export type ChatHistoryState = { status: "loading"; } | { status: "ready"; } | { error: Error; status: "error"; }; /** A stored message row: the message plus its storage fields. */ export type StoredChatRow = UIMessage & { sequence?: unknown; timestamp?: unknown; }; /** Browser storage holding the conversation (IndexedDB in the chat shell). */ export interface ChatHistoryStore { clear: () => Promise; /** Stored rows in `sequence` order. */ read: () => Promise; } export declare const toError: (error: unknown) => Error; /** * The one Ask AI conversation a page owns. The desktop panel and the mobile * drawer both render this chat, so whichever is active sends with the full * history, sees the same status, and persists the same messages. */ export interface GeistdocsChatSession { chat: Chat; history: { getState: () => ChatHistoryState; /** * Load the stored conversation into the chat, clearing it instead when it * has expired. After a failed load, calling it again retries. Does * nothing while a load is running or once one has succeeded, so it never * replaces a conversation in progress. */ restore: () => void; subscribe: (listener: () => void) => () => void; }; /** * Prewarm an eve session for the next conversation. Does nothing when * prewarming is off, a prewarm is already pending, or the conversation has * messages. */ prewarm: () => void; } export interface CreateChatSessionOptions { /** Resolved, app-local chat route URL. */ api: string; /** Route the reader is on when a message is sent. */ getCurrentRoute: () => string | null; history: ChatHistoryStore; /** Milliseconds a stored conversation is kept after its last message. */ historyRetentionMs: number; onError: (error: Error) => void; prewarmEveAgent: boolean; } export declare const createChatSession: ({ api, getCurrentRoute, history, historyRetentionMs, onError, prewarmEveAgent, }: CreateChatSessionOptions) => GeistdocsChatSession; //# sourceMappingURL=session.d.ts.map