Skip to Content
Anuma SDKReactInternalClassesWatermelonChatStorageAdapter

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

ParameterType

options

WatermelonChatStorageAdapterOptions

Returns

WatermelonChatStorageAdapter

Methods

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

ParameterType

conversationId

string

items

ConversationMemoryInput[]

Returns

Promise<void>

Implementation of

ChatBackend.addMemoryLinks


clearMemoryLinks(conversationId: string): Promise<void>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:324 

Parameters

ParameterType

conversationId

string

Returns

Promise<void>

Implementation of

ChatBackend.clearMemoryLinks


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

ParameterType

conversationId

string

Returns

Promise<void>

Implementation of

ChatBackend.clearMessages


createConversation()

createConversation(options?: CreateConversationOptions, defaultTitle?: string): Promise<StoredConversation>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:119 

Parameters

ParameterType

options?

CreateConversationOptions

defaultTitle?

string

Returns

Promise<StoredConversation>

Implementation of

ChatBackend.createConversation


createMessage()

createMessage(options: CreateMessageOptions): Promise<StoredMessage>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:190 

Parameters

ParameterType

options

CreateMessageOptions

Returns

Promise<StoredMessage>

Implementation of

ChatBackend.createMessage


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

ParameterType

conversationId

string

Returns

Promise<boolean>

Implementation of

ChatBackend.deleteConversation


deleteMessage()

deleteMessage(uniqueId: string): Promise<string | null>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:312 

Parameters

ParameterType

uniqueId

string

Returns

Promise<string | null>

Implementation of

ChatBackend.deleteMessage


deleteSummary()

deleteSummary(conversationId: string): Promise<void>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:308 

Parameters

ParameterType

conversationId

string

Returns

Promise<void>

Implementation of

ChatBackend.deleteSummary


getAllFiles()

getAllFiles(options?: object): Promise<StoredFileWithContext[]>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:263 

Parameters

ParameterTypeDescription

options?

object

‐

options.conversationId?

string

Filter files by conversation ID

options.limit?

number

Maximum number of files to return

Returns

Promise<StoredFileWithContext[]>

Implementation of

ChatBackend.getAllFiles


getConversation()

getConversation(conversationId: string): Promise<StoredConversation | null>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:108 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredConversation | null>

Implementation of

ChatBackend.getConversation


getConversations()

getConversations(options?: ConversationQueryOptions): Promise<StoredConversation[]>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:112 

Parameters

ParameterType

options?

ConversationQueryOptions

Returns

Promise<StoredConversation[]>

Implementation of

ChatBackend.getConversations


getMemoryLinks(conversationId: string): Promise<StoredConversationMemory[]>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:316 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredConversationMemory[]>

Implementation of

ChatBackend.getMemoryLinks


getMessageCount()

getMessageCount(conversationId: string): Promise<number>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:186 

Total message count for a conversation. Optional (additive change).

Parameters

ParameterType

conversationId

string

Returns

Promise<number>

Implementation of

ChatBackend.getMessageCount


getMessages()

getMessages(conversationId: string): Promise<StoredMessage[]>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:167 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredMessage[]>

Implementation of

ChatBackend.getMessages


getMessagesByIds()

getMessagesByIds(uniqueIds: readonly string[]): 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

ParameterType

uniqueIds

readonly string[]

Returns

Promise<StoredMessage[]>

Implementation of

ChatBackend.getMessagesByIds


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

ParameterType

conversationId

string

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

ParameterType

conversationId

string

options

GetMessagesPageOptions

Returns

Promise<StoredMessage[]>

Implementation of

ChatBackend.getMessagesPage


getSummary()

getSummary(conversationId: string): Promise<StoredConversationSummary | null>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:286 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredConversationSummary | null>

Implementation of

ChatBackend.getSummary


getToolCallEventIds()

getToolCallEventIds(conversationId: string): Promise<Set<string>>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:267 

Parameters

ParameterType

conversationId

string

Returns

Promise<Set<string>>

Implementation of

ChatBackend.getToolCallEventIds


observeConversations()

observeConversations(options?: ConversationQueryOptions): ChatStorageObservable<StoredConversation[]>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:142 

Parameters

ParameterType

options?

ConversationQueryOptions

Returns

ChatStorageObservable<StoredConversation[]>

Implementation of

ChatBackend.observeConversations


observeMessages()

observeMessages(conversationId: string): ChatStorageObservable<StoredMessage[]>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:229 

Parameters

ParameterType

conversationId

string

Returns

ChatStorageObservable<StoredMessage[]>

Implementation of

ChatBackend.observeMessages


searchChunks()

searchChunks(queryVector: number[], options?: ChatChunkSearchOptions): Promise<ChunkSearchResult[]>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:275 

Parameters

ParameterType

queryVector

number[]

options?

ChatChunkSearchOptions

Returns

Promise<ChunkSearchResult[]>

Implementation of

ChatBackend.searchChunks


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

ParameterType

conversationId

string

pinned

boolean

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

ParameterType

conversationId

string

projectId

string | null

Returns

Promise<boolean>

Implementation of

ChatBackend.updateConversationProject


updateConversationTitle()

updateConversationTitle(conversationId: string, title: string): Promise<boolean>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:126 

Parameters

ParameterType

conversationId

string

title

string

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

ParameterType

uniqueId

string

chunks

MessageChunk[]

embeddingModel

string

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

ParameterType

uniqueId

string

vector

number[]

embeddingModel

string

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

ParameterType

uniqueId

string

error

string | null

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

ParameterType

uniqueId

string

feedback

MessageFeedback

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

ParameterType

uniqueId

string

fileIds

string[]

Returns

Promise<StoredMessage | null>

Implementation of

ChatBackend.updateMessageFileIds


upsertMessage()

upsertMessage(options: CreateMessageOptions & object): Promise<StoredMessage>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:271 

Parameters

ParameterType

options

CreateMessageOptions & object

Returns

Promise<StoredMessage>

Implementation of

ChatBackend.upsertMessage


upsertSummary()

upsertSummary(conversationId: string, summary: string, summarizedUpTo: string, tokenCount: number): Promise<StoredConversationSummary>

Defined in: src/lib/storage/WatermelonChatStorageAdapter.ts:293 

Parameters

ParameterType

conversationId

string

summary

string

summarizedUpTo

string

tokenCount

number

Returns

Promise<StoredConversationSummary>

Implementation of

ChatBackend.upsertSummary


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

ParameterType

options

object

options.chunkCache

ChunkVectorCache

options.embeddingModel?

string

options.limit?

number

options.signal?

AbortSignal

Returns

Promise<number>

Implementation of

ChatBackend.warmChunkCache


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

T

Parameters

ParameterType

fn

(adapter: ChatStorageAdapter) => Promise<T>

Returns

Promise<T>

Implementation of

ChatBackend.write

Last updated on