Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

index.ts

143 lines3.9 KB

1// Store contracts + named chat shapes
2export {
3 composePersistence,
4 defineAIPersistence,
5 defineMessageStore,
6 defineActivityStore,
7 defineRunStore,
8 defineInterruptStore,
9 defineMetadataStore,
10 defineGenerationRunStore,
11 defineArtifactStore,
12 defineBlobStore,
13 defineLogStore,
14 defineSessionIndexStore,
15 LogConflictError,
16 LogTruncatedError,
17 OwnershipLostError,
18 NO_OWNER_EPOCH,
19 // Run lifecycle helpers owned by @tanstack/ai, transiting through ./types so
20 // this package's public surface stays a single import for backend authors.
21 isTerminalRunStatus,
22} from './types'
23export type {
24 ActivityRecord,
25 ActivityStore,
26 MessageStore,
27 MessagePage,
28 RunStatus,
29 TerminalRunStatus,
30 RunRecord,
31 RunStore,
32 InterruptCommitEntry,
33 InterruptRecord,
34 InterruptStatus,
35 InterruptStore,
36 MetadataStore,
37 // Session store contracts
38 LogEntry,
39 LogRecord,
40 LogSnapshot,
41 LogStore,
42 OfferedInput,
43 OfferResult,
44 OrphanedLog,
45 SessionIndexEntry,
46 SessionIndexKey,
47 SessionIndexListOptions,
48 SessionIndexPage,
49 SessionIndexStore,
50 SessionMember,
51 // Named product shapes (prefer these over a sparse bag)
52 ChatTranscriptStores,
53 ChatPersistenceStores,
54 ChatWithInterruptsStores,
55 ChatTranscriptPersistence,
56 ChatPersistence,
57 ChatWithInterruptsPersistence,
58 // Generation run store contract
59 GenerationRunStatus,
60 GenerationRunRecord,
61 GenerationRunStore,
62 // Generation artifact + blob store contracts
63 ArtifactRecord,
64 ArtifactStore,
65 BlobBody,
66 BlobRecord,
67 BlobObject,
68 BlobListPage,
69 BlobPutOptions,
70 BlobGetOptions,
71 BlobRange,
72 BlobListOptions,
73 BlobStore,
74 AIPersistence,
75 AIPersistenceOverrides,
76 ComposedAIPersistenceStores,
77 // Shared conversation identity from @tanstack/ai. Stores key on
78 // Scope.threadId; authorize multi-user access with Scope.userId/tenantId.
79 Scope,
80} from './types'
81export type { PersistenceCompletion } from './capabilities'
82// AIPersistenceStores is intentionally NOT re-exported — use a named chat
83// shape or AIPersistence<{ messages: MessageStore, … }>.
84​
85// Core artifact wire types (re-exported for convenience)
86export type {
87 PersistedArtifactActivity,
88 PersistedArtifactRef,
89 PersistedArtifactRole,
90} from '@tanstack/ai'
91​
92// Middleware (chat state — locks live in @tanstack/ai as withLocks)
93export { withPersistence, withGenerationPersistence } from './middleware'
94export type {
95 WithPersistenceOptions,
96 WithGenerationPersistenceOptions,
97 ArtifactPersistenceOptions,
98 GenerationArtifactDescriptor,
99 GenerationArtifactExtractionInput,
100 GenerationArtifactNameInput,
101} from './middleware'
102​
103// Server helper: rehydrate a thread's messages for a client load
104export { reconstructChat } from './reconstruct'
105export type { ReconstructChatOptions } from './reconstruct'
106​
107// Server helper: the stored transcript of a child agent run, for a UI
108export { loadChildTranscript } from './subagent-runs'
109​
110// Server helper: rehydrate the last generation job for a client load
111export {
112 reconstructGeneration,
113 getGenerationHydration,
114} from './reconstruct-generation'
115export type {
116 ReconstructedGeneration,
117 ReconstructGenerationOptions,
118 GetGenerationHydrationOptions,
119} from './reconstruct-generation'
120​
121// Server helpers: retrieve a persisted generation artifact + its bytes
122export { retrieveArtifact, retrieveBlob } from './retrieve'
123​
124// Byte-range helpers: parse a `Range` header (routes), clamp a range to an
125// object's real size (store authors)
126export { parseRangeHeader, resolveBlobRange } from './blob-range'
127​
128// Reference in-memory implementation
129export { memoryLogState, memoryLogStore, memoryPersistence } from './memory'
130export type { MemoryLogState } from './memory'
131​
132// Persistence-owned capabilities only. Locks: @tanstack/ai.
133export {
134 PersistenceCapability,
135 InterruptsCapability,
136 getPersistence,
137 providePersistence,
138 getInterrupts,
139 provideInterrupts,
140 PersistenceCompletionCapability,
141 getPersistenceCompletion,
142 providePersistenceCompletion,
143} from './capabilities'