export interface RepoMessageStatus { type?: string; reason?: string; } export interface RepoMessageContent { type: string; text?: string; [key: string]: unknown; } export interface RepoMessage { id?: string; role?: string; status?: RepoMessageStatus; content?: string | RepoMessageContent[]; metadata?: Record; createdAt?: Date | string | number; [key: string]: unknown; } /** Entry in `repo.messages` — may be flat or wrapped `{ message: RepoMessage }`. */ export interface RepoEntry { parentId?: string | null; message?: RepoMessage; id?: string; role?: string; status?: RepoMessageStatus; content?: string | RepoMessageContent[]; [key: string]: unknown; } /** Minimal structure of the normalised thread repository used by AssistantChat. */ export interface NormalizedRepo { messages?: RepoEntry[]; headId?: string; queuedMessages?: unknown[]; [key: string]: unknown; } export declare function getRepoMessages(repo: NormalizedRepo | null | undefined): RepoEntry[]; export declare function getRepoMessage(entry: RepoEntry): RepoMessage | null; export declare function getAssistantRunDurationMs(message: { metadata?: unknown; } | null | undefined): number | null; export declare function withLastAssistantRunDuration(repo: T, durationMs: number | null | undefined): T; /** * Collapse duplicate message ids before a repository is handed to * `threadRuntime.import()`. assistant-ui's `MessageRepository` throws * "MessageRepository(performOp/link): A message with the same id already exists * in the parent tree" when the imported messages contain the same id more than * once (Sentry AGENT-NATIVE-BROWSER-2Q). Duplicate ids are never valid thread * data — they come from optimistic+echo races, streaming reconnect replays, or * multi-tab merges — so keep only the LAST occurrence of each id (the most * recent, most complete copy). parentId references stay valid because the * surviving entry keeps the same id. * * Returns the input unchanged (same reference) when there are no duplicates, so * the overwhelmingly common no-dupe case is a cheap no-op with zero behavioural * change for normal threads. */ export declare function dedupeRepoMessagesById(repo: T | null | undefined): T | null | undefined; export declare function dropEmptyAssistantMessages(repo: T | null | undefined): T | null | undefined; export declare function isAssistantMessageTerminal(message: RepoMessage | null): boolean; export declare function repoHasAssistantMessage(repo: NormalizedRepo | null | undefined): boolean; export declare function shouldImportServerThreadData(currentRepo: NormalizedRepo | null | undefined, incomingRepo: NormalizedRepo | null | undefined): boolean; //# sourceMappingURL=repo-helpers.d.ts.map