teodor-new-chat-ui 4.1.55 → 4.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ChatMessage, CheckpointSnapshot, CheckpointSummary } from '@/types/api';
|
|
2
|
+
export type PendingInterrupt = {
|
|
3
|
+
id: string;
|
|
4
|
+
value: any;
|
|
5
|
+
} | null;
|
|
6
|
+
export type CheckpointIdentity = {
|
|
7
|
+
checkpointId: string | null;
|
|
8
|
+
checkpointNs: string | null;
|
|
9
|
+
};
|
|
10
|
+
export type CheckpointRef = {
|
|
11
|
+
checkpointId: string;
|
|
12
|
+
checkpointNs: string | null;
|
|
13
|
+
};
|
|
14
|
+
export declare function hashString(str: string): string;
|
|
15
|
+
export declare function coerceString(value: unknown): string | null;
|
|
16
|
+
export declare function getNested(source: unknown, path: string[]): unknown;
|
|
17
|
+
export declare function getNestedString(source: unknown, paths: string[][]): string | null;
|
|
18
|
+
export declare function interruptsEqual(a: PendingInterrupt, b: PendingInterrupt): boolean;
|
|
19
|
+
export declare function findLastInterrupt(messages: ChatMessage[]): PendingInterrupt;
|
|
20
|
+
export declare function extractInterruptFromState(state: unknown): PendingInterrupt;
|
|
21
|
+
export declare function resolveCheckpointIdentity(snapshot?: CheckpointSnapshot | null, fallback?: {
|
|
22
|
+
checkpointId?: string | null;
|
|
23
|
+
checkpointNs?: string | null;
|
|
24
|
+
}): CheckpointIdentity;
|
|
25
|
+
export declare function checkpointRefKey(ref: CheckpointRef): string;
|
|
26
|
+
export declare function checkpointIdentityKey(identity: CheckpointIdentity): string;
|
|
27
|
+
export declare function makeSnapshotKey(snapshot: CheckpointSnapshot): string;
|
|
28
|
+
export declare function parseCheckpointRef(entry: unknown): CheckpointRef | null;
|
|
29
|
+
export declare function extractMessagesFromSnapshot(snapshot?: CheckpointSnapshot | null): ChatMessage[];
|
|
30
|
+
export declare function summarizeSnapshot(snapshot: CheckpointSnapshot): CheckpointSummary | null;
|
|
31
|
+
export declare function buildCheckpointSummaries(snapshots: CheckpointSnapshot[]): CheckpointSummary[];
|
|
32
|
+
export declare function dedupeSnapshots(list: CheckpointSnapshot[]): CheckpointSnapshot[];
|
|
33
|
+
export declare function mergeSnapshotLists(existing: CheckpointSnapshot[], incoming: CheckpointSnapshot[], mode: 'replace' | 'prepend'): CheckpointSnapshot[];
|
|
34
|
+
export declare function sortSnapshotsChronologically(snapshots: CheckpointSnapshot[]): CheckpointSnapshot[];
|
|
35
|
+
export declare function reconcilePendingQueue(snapshots: CheckpointSnapshot[], existingQueue: CheckpointRef[]): CheckpointRef[];
|
|
36
|
+
export declare function findSnapshotByIdentity(snapshots: CheckpointSnapshot[], identity: CheckpointIdentity): CheckpointSnapshot | null;
|
|
37
|
+
export declare function snapshotSignature(checkpoints: CheckpointSnapshot[]): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ThreadSummary } from '@/types/api';
|
|
2
|
+
export declare const THREAD_CACHE_KEY = "cachedThreads";
|
|
3
|
+
export declare const MESSAGE_CACHE_VERSION = "v1";
|
|
4
|
+
export declare const CACHE_SAVE_DEBOUNCE_MS = 300;
|
|
5
|
+
export declare const MAX_CACHED_THREADS = 200;
|
|
6
|
+
export declare function scheduleIdle(cb: () => void): void;
|
|
7
|
+
export declare function canUseStorage(): boolean;
|
|
8
|
+
export declare function safeGetItem(key: string): string | null;
|
|
9
|
+
export declare function safeSetItem(key: string, value: string): void;
|
|
10
|
+
export declare function safeRemoveItem(key: string): void;
|
|
11
|
+
export declare function loadCachedThreads(): ThreadSummary[];
|
|
12
|
+
export declare function makeThreadCacheKey(baseHost: string, token?: string | null): string;
|
|
13
|
+
export declare function loadCachedThreadsByKey(key: string): ThreadSummary[];
|
|
14
|
+
export declare function persistThreadsByKey(key: string, threads: ThreadSummary[]): void;
|
|
15
|
+
export declare function migrateLegacyThreadsIfNeeded(scopedKey: string): ThreadSummary[];
|
|
16
|
+
export type ThreadsStore = {
|
|
17
|
+
byId: Record<string, ThreadSummary>;
|
|
18
|
+
order: string[];
|
|
19
|
+
};
|
|
20
|
+
export declare function buildStoreFromArray(arr: ThreadSummary[]): ThreadsStore;
|
|
21
|
+
export declare function storeToArray(store: ThreadsStore): ThreadSummary[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
2
|
+
import type { ThreadSummary } from '@/types/api';
|
|
3
|
+
import type { ChatApi } from '@/lib/chat-api';
|
|
4
|
+
type UseThreadListOptions = {
|
|
5
|
+
api: ChatApi;
|
|
6
|
+
baseHost: string;
|
|
7
|
+
onError?: (error: string) => void;
|
|
8
|
+
initialThreadId?: string | null;
|
|
9
|
+
clearAllMessageCaches?: () => void;
|
|
10
|
+
onAuthTokenChange?: (token: string | null | undefined) => void;
|
|
11
|
+
onThreadRemoved?: (threadId: string, context: {
|
|
12
|
+
wasCurrent: boolean;
|
|
13
|
+
}) => void;
|
|
14
|
+
};
|
|
15
|
+
export type UseThreadListResult = {
|
|
16
|
+
threads: ThreadSummary[];
|
|
17
|
+
currentThreadId: string | null;
|
|
18
|
+
setCurrentThreadId: Dispatch<SetStateAction<string | null>>;
|
|
19
|
+
isLoadingThreads: boolean;
|
|
20
|
+
threadsError: string | null;
|
|
21
|
+
refreshThreads: () => Promise<void>;
|
|
22
|
+
createThread: (title?: string) => Promise<ThreadSummary | null>;
|
|
23
|
+
deleteThread: (threadId: string) => Promise<void>;
|
|
24
|
+
renameThread: (threadId: string, title: string) => Promise<void>;
|
|
25
|
+
persistThreadsCache: () => void;
|
|
26
|
+
hydrateThreadsFromCache: () => void;
|
|
27
|
+
upsertThreadSummary: (summary: ThreadSummary) => void;
|
|
28
|
+
};
|
|
29
|
+
export declare function useThreadList(options: UseThreadListOptions): UseThreadListResult;
|
|
30
|
+
export {};
|