ChatBackend
Defined in: src/lib/storage/ChatBackend.ts:38
Everything useChatStorage reads and writes for chats, so a hook can run on local or server storage.
Extends
Extended by
Methods
addMemoryLinks()
addMemoryLinks(
conversationId:string,items:ConversationMemoryInput[]):Promise<void>
Defined in: src/lib/storage/ChatBackend.ts:80
Records the memories a turn drew on in recall order, moving already-linked ones to this turn with their new score.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<void>
clearMemoryLinks()
clearMemoryLinks(
conversationId:string):Promise<void>
Defined in: src/lib/storage/ChatBackend.ts:81
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<void>
clearMessages()
clearMessages(
conversationId:string):Promise<void>
Defined in: src/lib/storage/ChatStorageAdapter.ts:125
Clears all messages in a conversation (used for the “clear chat” action).
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<void>
Inherited from
ChatStorageAdapter.clearMessages
confirmMessagePersisted()?
optionalconfirmMessagePersisted(message:StoredMessage):Promise<void>
Defined in: src/lib/storage/ChatBackend.ts:55
Confirms the message data in persistent storage; rejects if the write fails or remains in the queue.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<void>
createConversation()
createConversation(
options?:CreateConversationOptions,defaultTitle?:string):Promise<StoredConversation>
Defined in: src/lib/storage/ChatBackend.ts:39
Parameters
| Parameter | Type |
|---|---|
|
| |
|
|
|
Returns
Promise<StoredConversation>
Overrides
ChatStorageAdapter.createConversation
createMessage()
createMessage(
options:CreateMessageOptions):Promise<StoredMessage>
Defined in: src/lib/storage/ChatStorageAdapter.ts:94
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<StoredMessage>
Inherited from
ChatStorageAdapter.createMessage
deleteConversation()
deleteConversation(
conversationId:string):Promise<boolean>
Defined in: src/lib/storage/ChatStorageAdapter.ts:63
Soft delete. Implementations are responsible for cascading to messages/media.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<boolean>
Inherited from
ChatStorageAdapter.deleteConversation
deleteMessage()
deleteMessage(
uniqueId:string):Promise<string|null>
Defined in: src/lib/storage/ChatBackend.ts:77
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<string | null>
deleteSummary()
deleteSummary(
conversationId:string):Promise<void>
Defined in: src/lib/storage/ChatBackend.ts:76
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<void>
getAllFiles()
getAllFiles(
options?:object):Promise<StoredFileWithContext[]>
Defined in: src/lib/storage/ChatBackend.ts:43
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
Filter files by conversation ID |
|
|
|
Maximum number of files to return |
Returns
Promise<StoredFileWithContext[]>
Overrides
ChatStorageAdapter.getAllFiles
getConversation()
getConversation(
conversationId:string):Promise<StoredConversation|null>
Defined in: src/lib/storage/ChatStorageAdapter.ts:48
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredConversation | null>
Inherited from
ChatStorageAdapter.getConversation
getConversations()
getConversations(
options?:ConversationQueryOptions):Promise<StoredConversation[]>
Defined in: src/lib/storage/ChatStorageAdapter.ts:50
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<StoredConversation[]>
Inherited from
ChatStorageAdapter.getConversations
getMemoryLinks()
getMemoryLinks(
conversationId:string):Promise<StoredConversationMemory[]>
Defined in: src/lib/storage/ChatBackend.ts:78
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredConversationMemory[]>
getMessageCount()
getMessageCount(
conversationId:string):Promise<number>
Defined in: src/lib/storage/ChatBackend.ts:51
Total message count for a conversation. Optional (additive change).
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<number>
Overrides
ChatStorageAdapter.getMessageCount
getMessages()
getMessages(
conversationId:string):Promise<StoredMessage[]>
Defined in: src/lib/storage/ChatStorageAdapter.ts:69
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredMessage[]>
Inherited from
ChatStorageAdapter.getMessages
getMessagesByIds()
getMessagesByIds(
uniqueIds: readonlystring[]):Promise<StoredMessage[]>
Defined in: src/lib/storage/ChatBackend.ts:50
Reads messages by id in the order asked, leaving out ids that are not stored.
Parameters
| Parameter | Type |
|---|---|
|
|
readonly |
Returns
Promise<StoredMessage[]>
getMessageSkeletons()
getMessageSkeletons(
conversationId:string):Promise<MessageSkeleton[]>
Defined in: src/lib/storage/ChatBackend.ts:48
Whole-thread branch-tree skeleton (no decrypt). See
getMessageSkeletonsOp. Optional for the same additive-change rationale.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<MessageSkeleton[]>
Overrides
ChatStorageAdapter.getMessageSkeletons
getMessagesPage()
getMessagesPage(
conversationId:string,options:GetMessagesPageOptions):Promise<StoredMessage[]>
Defined in: src/lib/storage/ChatBackend.ts:44
Paginated display read: newest limit messages (optionally below
beforeMessageId), ascending, with embeddings skipped. See
getMessagesPageOp.
Optional so this is an additive, non-breaking interface change (same rationale as updateMessageFileIds). The default WatermelonChatStorageAdapter provides it.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<StoredMessage[]>
Overrides
ChatStorageAdapter.getMessagesPage
getSummary()
getSummary(
conversationId:string):Promise<StoredConversationSummary|null>
Defined in: src/lib/storage/ChatBackend.ts:69
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredConversationSummary | null>
getToolCallEventIds()
getToolCallEventIds(
conversationId:string):Promise<Set<string>>
Defined in: src/lib/storage/ChatBackend.ts:52
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<Set<string>>
observeConversations()
observeConversations(
options?:ConversationQueryOptions):ChatStorageObservable<StoredConversation[]>
Defined in: src/lib/storage/ChatStorageAdapter.ts:65
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
ChatStorageObservable<StoredConversation[]>
Inherited from
ChatStorageAdapter.observeConversations
observeMessages()
observeMessages(
conversationId:string):ChatStorageObservable<StoredMessage[]>
Defined in: src/lib/storage/ChatStorageAdapter.ts:127
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
ChatStorageObservable<StoredMessage[]>
Inherited from
ChatStorageAdapter.observeMessages
searchChunks()
searchChunks(
queryVector:number[],options?:ChatChunkSearchOptions):Promise<ChunkSearchResult[]>
Defined in: src/lib/storage/ChatBackend.ts:56
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<ChunkSearchResult[]>
searchKeywords()?
optionalsearchKeywords(query:string,options?:ChatKeywordSearchOptions):Promise<StoredMessage[]>
Defined in: src/lib/storage/ChatBackend.ts:61
Messages holding every word of query across the account’s chats, newest first, for backends that keep a word index.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<StoredMessage[]>
updateConversationPinned()
updateConversationPinned(
conversationId:string,pinned:boolean):Promise<boolean>
Defined in: src/lib/storage/ChatStorageAdapter.ts:60
Pin or unpin a conversation. Pinning stamps pinnedAt; list queries are
NOT reordered — consumers sort pinned chats first using pinnedAt.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<boolean>
Inherited from
ChatStorageAdapter.updateConversationPinned
updateConversationProject()
updateConversationProject(
conversationId:string,projectId:string|null):Promise<boolean>
Defined in: src/lib/storage/ChatStorageAdapter.ts:56
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<boolean>
Inherited from
ChatStorageAdapter.updateConversationProject
updateConversationTitle()
updateConversationTitle(
conversationId:string,title:string):Promise<boolean>
Defined in: src/lib/storage/ChatStorageAdapter.ts:54
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<boolean>
Inherited from
ChatStorageAdapter.updateConversationTitle
updateMessageChunks()
updateMessageChunks(
uniqueId:string,chunks:MessageChunk[],embeddingModel:string):Promise<StoredMessage|null>
Defined in: src/lib/storage/ChatStorageAdapter.ts:102
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
| |
|
|
|
Returns
Promise<StoredMessage | null>
Inherited from
ChatStorageAdapter.updateMessageChunks
updateMessageEmbedding()
updateMessageEmbedding(
uniqueId:string,vector:number[],embeddingModel:string):Promise<StoredMessage|null>
Defined in: src/lib/storage/ChatStorageAdapter.ts:96
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Promise<StoredMessage | null>
Inherited from
ChatStorageAdapter.updateMessageEmbedding
updateMessageError()
updateMessageError(
uniqueId:string,error:string|null):Promise<StoredMessage|null>
Defined in: src/lib/storage/ChatStorageAdapter.ts:108
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<StoredMessage | null>
Inherited from
ChatStorageAdapter.updateMessageError
updateMessageFeedback()
updateMessageFeedback(
uniqueId:string,feedback:MessageFeedback):Promise<StoredMessage|null>
Defined in: src/lib/storage/ChatStorageAdapter.ts:110
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<StoredMessage | null>
Inherited from
ChatStorageAdapter.updateMessageFeedback
updateMessageFileIds()?
optionalupdateMessageFileIds(uniqueId:string,fileIds:string[]):Promise<StoredMessage|null>
Defined in: src/lib/storage/ChatStorageAdapter.ts:122
Replace a message’s attached media ids (fileIds). Used to attach a
generated artifact (e.g. a rendered document PDF) to the assistant message
that produced it, after streaming. Pass the FULL desired list.
Optional so this is an additive, non-breaking interface change: only hosts wiring document/artifact generation need it, and existing custom adapters keep compiling without implementing it. The default WatermelonChatStorageAdapter provides it.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<StoredMessage | null>
Inherited from
ChatStorageAdapter.updateMessageFileIds
upsertMessage()
upsertMessage(
options:CreateMessageOptions&object):Promise<StoredMessage>
Defined in: src/lib/storage/ChatBackend.ts:53
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredMessage>
upsertSummary()
upsertSummary(
conversationId:string,summary:string,summarizedUpTo:string,tokenCount:number):Promise<StoredConversationSummary>
Defined in: src/lib/storage/ChatBackend.ts:70
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Promise<StoredConversationSummary>
warmChunkCache()?
optionalwarmChunkCache(options:object):Promise<number>
Defined in: src/lib/storage/ChatBackend.ts:63
Fills a chunk vector cache ahead of the first search, for backends that score on the device.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
Returns
Promise<number>
write()
write<
T>(fn: (adapter:ChatStorageAdapter) =>Promise<T>):Promise<T>
Defined in: src/lib/storage/ChatStorageAdapter.ts:139
Run a set of mutations inside a single write transaction. Any mutation calls made on the adapter inside the callback are grouped into one atomic write on backends that support it.
On backends without transaction support, this may fall back to sequential writes. Implementations must document the guarantee they provide.
Type Parameters
| Type Parameter |
|---|
|
|
Parameters
| Parameter | Type |
|---|---|
|
|
( |
Returns
Promise<T>
Inherited from