WatermelonChatStorageAdapter
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:90
Everything useChatStorage reads and writes for chats, so a hook can run on local or server storage.
Implements
Constructors
Constructor
new WatermelonChatStorageAdapter(
options:WatermelonChatStorageAdapterOptions):WatermelonChatStorageAdapter
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:95
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
WatermelonChatStorageAdapter
Methods
addMemoryLinks()
addMemoryLinks(
conversationId:string,items:ConversationMemoryInput[]):Promise<void>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:320
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>
Implementation of
clearMemoryLinks()
clearMemoryLinks(
conversationId:string):Promise<void>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:324
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<void>
Implementation of
clearMessages()
clearMessages(
conversationId:string):Promise<void>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:225
Clears all messages in a conversation (used for the “clear chat” action).
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<void>
Implementation of
createConversation()
createConversation(
options?:CreateConversationOptions,defaultTitle?:string):Promise<StoredConversation>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:119
Parameters
| Parameter | Type |
|---|---|
|
| |
|
|
|
Returns
Promise<StoredConversation>
Implementation of
ChatBackend.createConversation
createMessage()
createMessage(
options:CreateMessageOptions):Promise<StoredMessage>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:190
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<StoredMessage>
Implementation of
deleteConversation()
deleteConversation(
conversationId:string):Promise<boolean>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:138
Soft delete. Implementations are responsible for cascading to messages/media.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<boolean>
Implementation of
ChatBackend.deleteConversation
deleteMessage()
deleteMessage(
uniqueId:string):Promise<string|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:312
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<string | null>
Implementation of
deleteSummary()
deleteSummary(
conversationId:string):Promise<void>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:308
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<void>
Implementation of
getAllFiles()
getAllFiles(
options?:object):Promise<StoredFileWithContext[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:263
Parameters
| Parameter | Type | Description |
|---|---|---|
|
|
|
‐ |
|
|
|
Filter files by conversation ID |
|
|
|
Maximum number of files to return |
Returns
Promise<StoredFileWithContext[]>
Implementation of
getConversation()
getConversation(
conversationId:string):Promise<StoredConversation|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:108
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredConversation | null>
Implementation of
getConversations()
getConversations(
options?:ConversationQueryOptions):Promise<StoredConversation[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:112
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<StoredConversation[]>
Implementation of
getMemoryLinks()
getMemoryLinks(
conversationId:string):Promise<StoredConversationMemory[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:316
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredConversationMemory[]>
Implementation of
getMessageCount()
getMessageCount(
conversationId:string):Promise<number>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:186
Total message count for a conversation. Optional (additive change).
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<number>
Implementation of
getMessages()
getMessages(
conversationId:string):Promise<StoredMessage[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:167
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredMessage[]>
Implementation of
getMessagesByIds()
getMessagesByIds(
uniqueIds: readonlystring[]):Promise<StoredMessage[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:178
Reads messages by id in the order asked, leaving out ids that are not stored.
Parameters
| Parameter | Type |
|---|---|
|
|
readonly |
Returns
Promise<StoredMessage[]>
Implementation of
getMessageSkeletons()
getMessageSkeletons(
conversationId:string):Promise<MessageSkeleton[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:182
Whole-thread branch-tree skeleton (no decrypt). See
getMessageSkeletonsOp. Optional for the same additive-change rationale.
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<MessageSkeleton[]>
Implementation of
ChatBackend.getMessageSkeletons
getMessagesPage()
getMessagesPage(
conversationId:string,options:GetMessagesPageOptions):Promise<StoredMessage[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:171
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[]>
Implementation of
getSummary()
getSummary(
conversationId:string):Promise<StoredConversationSummary|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:286
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredConversationSummary | null>
Implementation of
getToolCallEventIds()
getToolCallEventIds(
conversationId:string):Promise<Set<string>>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:267
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<Set<string>>
Implementation of
ChatBackend.getToolCallEventIds
observeConversations()
observeConversations(
options?:ConversationQueryOptions):ChatStorageObservable<StoredConversation[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:142
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
ChatStorageObservable<StoredConversation[]>
Implementation of
ChatBackend.observeConversations
observeMessages()
observeMessages(
conversationId:string):ChatStorageObservable<StoredMessage[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:229
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
ChatStorageObservable<StoredMessage[]>
Implementation of
searchChunks()
searchChunks(
queryVector:number[],options?:ChatChunkSearchOptions):Promise<ChunkSearchResult[]>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:275
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<ChunkSearchResult[]>
Implementation of
updateConversationPinned()
updateConversationPinned(
conversationId:string,pinned:boolean):Promise<boolean>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:134
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>
Implementation of
ChatBackend.updateConversationPinned
updateConversationProject()
updateConversationProject(
conversationId:string,projectId:string|null):Promise<boolean>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:130
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<boolean>
Implementation of
ChatBackend.updateConversationProject
updateConversationTitle()
updateConversationTitle(
conversationId:string,title:string):Promise<boolean>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:126
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<boolean>
Implementation of
ChatBackend.updateConversationTitle
updateMessageChunks()
updateMessageChunks(
uniqueId:string,chunks:MessageChunk[],embeddingModel:string):Promise<StoredMessage|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:202
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
| |
|
|
|
Returns
Promise<StoredMessage | null>
Implementation of
ChatBackend.updateMessageChunks
updateMessageEmbedding()
updateMessageEmbedding(
uniqueId:string,vector:number[],embeddingModel:string):Promise<StoredMessage|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:194
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
Returns
Promise<StoredMessage | null>
Implementation of
ChatBackend.updateMessageEmbedding
updateMessageError()
updateMessageError(
uniqueId:string,error:string|null):Promise<StoredMessage|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:210
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
Returns
Promise<StoredMessage | null>
Implementation of
ChatBackend.updateMessageError
updateMessageFeedback()
updateMessageFeedback(
uniqueId:string,feedback:MessageFeedback):Promise<StoredMessage|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:214
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
Returns
Promise<StoredMessage | null>
Implementation of
ChatBackend.updateMessageFeedback
updateMessageFileIds()
updateMessageFileIds(
uniqueId:string,fileIds:string[]):Promise<StoredMessage|null>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:221
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>
Implementation of
ChatBackend.updateMessageFileIds
upsertMessage()
upsertMessage(
options:CreateMessageOptions&object):Promise<StoredMessage>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:271
Parameters
| Parameter | Type |
|---|---|
|
|
|
Returns
Promise<StoredMessage>
Implementation of
upsertSummary()
upsertSummary(
conversationId:string,summary:string,summarizedUpTo:string,tokenCount:number):Promise<StoredConversationSummary>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:293
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Returns
Promise<StoredConversationSummary>
Implementation of
warmChunkCache()
warmChunkCache(
options:object):Promise<number>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:282
Fills a chunk vector cache ahead of the first search, for backends that score on the device.
Parameters
| Parameter | Type |
|---|---|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
Returns
Promise<number>
Implementation of
write()
write<
T>(fn: (adapter:ChatStorageAdapter) =>Promise<T>):Promise<T>
Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:343
WatermelonDB nests database.write() safely: each method we call inside
the callback already wraps its own writes, and Watermelon collapses the
nesting under a single action. The callback receives the same adapter
instance.
Type Parameters
| Type Parameter |
|---|
|
|
Parameters
| Parameter | Type |
|---|---|
|
|
( |
Returns
Promise<T>
Implementation of