Skip to Content

VaultChatBackend

Defined in: src/lib/chatStore/vaultBackend.ts:128 

A ChatBackend over vault: a cache, an optimistic outbox and a change poller.

Extends

Methods

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

ParameterType

conversationId

string

items

ConversationMemoryInput[]

Returns

Promise<void>

Inherited from

ChatBackend.addMemoryLinks


clearCache()

clearCache(): Promise<void>

Defined in: src/lib/chatStore/vaultBackend.ts:147 

Deletes this account’s cached chats and stops caching; call it on logout or a wallet switch.

Returns

Promise<void>


clearMemoryLinks(conversationId: string): Promise<void>

Defined in: src/lib/storage/ChatBackend.ts:81 

Parameters

ParameterType

conversationId

string

Returns

Promise<void>

Inherited from

ChatBackend.clearMemoryLinks


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

ParameterType

conversationId

string

Returns

Promise<void>

Inherited from

ChatBackend.clearMessages


close()

close(): void

Defined in: src/lib/chatStore/vaultBackend.ts:148 

Returns

void


confirmMessagePersisted()?

optional confirmMessagePersisted(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

ParameterType

message

StoredMessage

Returns

Promise<void>

Inherited from

ChatBackend.confirmMessagePersisted


createConversation()

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

Defined in: src/lib/storage/ChatBackend.ts:39 

Parameters

ParameterType

options?

CreateConversationOptions

defaultTitle?

string

Returns

Promise<StoredConversation>

Inherited from

ChatBackend.createConversation


createMessage()

createMessage(options: CreateMessageOptions): Promise<StoredMessage>

Defined in: src/lib/storage/ChatStorageAdapter.ts:94 

Parameters

ParameterType

options

CreateMessageOptions

Returns

Promise<StoredMessage>

Inherited from

ChatBackend.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

ParameterType

conversationId

string

Returns

Promise<boolean>

Inherited from

ChatBackend.deleteConversation


deleteMessage()

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

Defined in: src/lib/storage/ChatBackend.ts:77 

Parameters

ParameterType

uniqueId

string

Returns

Promise<string | null>

Inherited from

ChatBackend.deleteMessage


deleteSummary()

deleteSummary(conversationId: string): Promise<void>

Defined in: src/lib/storage/ChatBackend.ts:76 

Parameters

ParameterType

conversationId

string

Returns

Promise<void>

Inherited from

ChatBackend.deleteSummary


flush()

flush(): Promise<void>

Defined in: src/lib/chatStore/vaultBackend.ts:131 

Sends queued writes now; resolves once the outbox is empty, waiting on a retry, or stopped.

Returns

Promise<void>


getAllFiles()

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

Defined in: src/lib/storage/ChatBackend.ts:43 

Parameters

ParameterTypeDescription

options?

object

‐

options.conversationId?

string

Filter files by conversation ID

options.limit?

number

Maximum number of files to return

Returns

Promise<StoredFileWithContext[]>

Inherited from

ChatBackend.getAllFiles


getConversation()

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

Defined in: src/lib/storage/ChatStorageAdapter.ts:48 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredConversation | null>

Inherited from

ChatBackend.getConversation


getConversations()

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

Defined in: src/lib/storage/ChatStorageAdapter.ts:50 

Parameters

ParameterType

options?

ConversationQueryOptions

Returns

Promise<StoredConversation[]>

Inherited from

ChatBackend.getConversations


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

Defined in: src/lib/storage/ChatBackend.ts:78 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredConversationMemory[]>

Inherited from

ChatBackend.getMemoryLinks


getMessageCount()

getMessageCount(conversationId: string): Promise<number>

Defined in: src/lib/storage/ChatBackend.ts:51 

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

Parameters

ParameterType

conversationId

string

Returns

Promise<number>

Inherited from

ChatBackend.getMessageCount


getMessages()

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

Defined in: src/lib/storage/ChatStorageAdapter.ts:69 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredMessage[]>

Inherited from

ChatBackend.getMessages


getMessagesByIds()

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

ParameterType

uniqueIds

readonly string[]

Returns

Promise<StoredMessage[]>

Inherited from

ChatBackend.getMessagesByIds


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

ParameterType

conversationId

string

Returns

Promise<MessageSkeleton[]>

Inherited from

ChatBackend.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

ParameterType

conversationId

string

options

GetMessagesPageOptions

Returns

Promise<StoredMessage[]>

Inherited from

ChatBackend.getMessagesPage


getSummary()

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

Defined in: src/lib/storage/ChatBackend.ts:69 

Parameters

ParameterType

conversationId

string

Returns

Promise<StoredConversationSummary | null>

Inherited from

ChatBackend.getSummary


getToolCallEventIds()

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

Defined in: src/lib/storage/ChatBackend.ts:52 

Parameters

ParameterType

conversationId

string

Returns

Promise<Set<string>>

Inherited from

ChatBackend.getToolCallEventIds


importChats()

importChats(chats: readonly object[]): Promise<{ conversations: number; messages: number; }>

Defined in: src/lib/chatStore/vaultBackend.ts:137 

Copies imported conversations and messages into vault with their own ids, times and order, leaving ids vault already holds as they are.

Parameters

ParameterType

chats

readonly object[]

Returns

Promise<{ conversations: number; messages: number; }>


observeConversations()

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

Defined in: src/lib/storage/ChatStorageAdapter.ts:65 

Parameters

ParameterType

options?

ConversationQueryOptions

Returns

ChatStorageObservable<StoredConversation[]>

Inherited from

ChatBackend.observeConversations


observeMessages()

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

Defined in: src/lib/storage/ChatStorageAdapter.ts:127 

Parameters

ParameterType

conversationId

string

Returns

ChatStorageObservable<StoredMessage[]>

Inherited from

ChatBackend.observeMessages


poll()

poll(): Promise<void>

Defined in: src/lib/chatStore/vaultBackend.ts:133 

Applies changes other devices made since the last poll.

Returns

Promise<void>


searchChunks()

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

Defined in: src/lib/storage/ChatBackend.ts:56 

Parameters

ParameterType

queryVector

number[]

options?

ChatChunkSearchOptions

Returns

Promise<ChunkSearchResult[]>

Inherited from

ChatBackend.searchChunks


searchKeywords()

searchKeywords(query: string, options?: ChatKeywordSearchOptions): Promise<StoredMessage[]>

Defined in: src/lib/chatStore/vaultBackend.ts:135 

Messages holding every word of query across this account’s chats, newest first; empty when vault keeps no word hashes.

Parameters

ParameterType

query

string

options?

ChatKeywordSearchOptions

Returns

Promise<StoredMessage[]>

Overrides

ChatBackend.searchKeywords


status()

status(): object

Defined in: src/lib/chatStore/vaultBackend.ts:145 

Returns

object

pending

pending: number

stopped?

optional stopped: string


subscribe()

subscribe(listener: (event: VaultChatEvent) => void): () => void

Defined in: src/lib/chatStore/vaultBackend.ts:129 

Parameters

ParameterType

listener

(event: VaultChatEvent) => void

Returns

(): void

Returns

void


updateConversationContext()

updateConversationContext(conversationId: string, context: object): Promise<boolean>

Defined in: src/lib/chatStore/vaultBackend.ts:141 

Sets keys of a conversation’s app context, each saved on its own so devices editing different keys keep both; null clears a key.

Parameters

ParameterType

conversationId

string

context

{[key: string]: ChatJson; }

Returns

Promise<boolean>


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

ParameterType

conversationId

string

pinned

boolean

Returns

Promise<boolean>

Inherited from

ChatBackend.updateConversationPinned


updateConversationProject()

updateConversationProject(conversationId: string, projectId: string | null): Promise<boolean>

Defined in: src/lib/storage/ChatStorageAdapter.ts:56 

Parameters

ParameterType

conversationId

string

projectId

string | null

Returns

Promise<boolean>

Inherited from

ChatBackend.updateConversationProject


updateConversationTitle()

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

Defined in: src/lib/storage/ChatStorageAdapter.ts:54 

Parameters

ParameterType

conversationId

string

title

string

Returns

Promise<boolean>

Inherited from

ChatBackend.updateConversationTitle


updateMessageChunks()

updateMessageChunks(uniqueId: string, chunks: MessageChunk[], embeddingModel: string): Promise<StoredMessage | null>

Defined in: src/lib/storage/ChatStorageAdapter.ts:102 

Parameters

ParameterType

uniqueId

string

chunks

MessageChunk[]

embeddingModel

string

Returns

Promise<StoredMessage | null>

Inherited from

ChatBackend.updateMessageChunks


updateMessageEmbedding()

updateMessageEmbedding(uniqueId: string, vector: number[], embeddingModel: string): Promise<StoredMessage | null>

Defined in: src/lib/storage/ChatStorageAdapter.ts:96 

Parameters

ParameterType

uniqueId

string

vector

number[]

embeddingModel

string

Returns

Promise<StoredMessage | null>

Inherited from

ChatBackend.updateMessageEmbedding


updateMessageError()

updateMessageError(uniqueId: string, error: string | null): Promise<StoredMessage | null>

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

Parameters

ParameterType

uniqueId

string

error

string | null

Returns

Promise<StoredMessage | null>

Inherited from

ChatBackend.updateMessageError


updateMessageFeedback()

updateMessageFeedback(uniqueId: string, feedback: MessageFeedback): Promise<StoredMessage | null>

Defined in: src/lib/storage/ChatStorageAdapter.ts:110 

Parameters

ParameterType

uniqueId

string

feedback

MessageFeedback

Returns

Promise<StoredMessage | null>

Inherited from

ChatBackend.updateMessageFeedback


updateMessageFileIds()?

optional updateMessageFileIds(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

ParameterType

uniqueId

string

fileIds

string[]

Returns

Promise<StoredMessage | null>

Inherited from

ChatBackend.updateMessageFileIds


upsertMessage()

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

Defined in: src/lib/storage/ChatBackend.ts:53 

Parameters

ParameterType

options

CreateMessageOptions & object

Returns

Promise<StoredMessage>

Inherited from

ChatBackend.upsertMessage


upsertSummary()

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

Defined in: src/lib/storage/ChatBackend.ts:70 

Parameters

ParameterType

conversationId

string

summary

string

summarizedUpTo

string

tokenCount

number

Returns

Promise<StoredConversationSummary>

Inherited from

ChatBackend.upsertSummary


warmChunkCache()?

optional warmChunkCache(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

ParameterType

options

object

options.chunkCache

ChunkVectorCache

options.embeddingModel?

string

options.limit?

number

options.signal?

AbortSignal

Returns

Promise<number>

Inherited from

ChatBackend.warmChunkCache


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

T

Parameters

ParameterType

fn

(adapter: ChatStorageAdapter) => Promise<T>

Returns

Promise<T>

Inherited from

ChatBackend.write

Last updated on