ctx.user data. MemoryStore is the
reference implementation; @botmesh/sqlite-store and @botmesh/redis-store provide durable ones.
Pass a store as BotConfig.store.
Methods
saveMessage()
Parameters
Returns
Promise<void>
getMessage()
Parameters
Returns
Promise<StoredMessage | undefined>
getMessagesByChat()
Parameters
Returns
Promise<StoredMessage[]>
deleteMessage()
Parameters
Returns
Promise<void>
upsertChat()
chat onto the stored record. An own field set to undefined UNSETS
that field, so a partial upsert must omit what it does not know (the Bot does).
Parameters
Returns
Promise<void>
getChat()
Parameters
Returns
Promise<StoredChat | undefined>
listChats()
Returns
Promise<StoredChat[]>
deleteChat()
Parameters
Returns
Promise<void>
upsertContact()
contact onto the stored record; same undefined = unset rule as upsertChat.
Parameters
Returns
Promise<void>
getContact()
Parameters
Returns
Promise<StoredContact | undefined>
listContacts()
Returns
Promise<StoredContact[]>
deleteContact()
Parameters
Returns
Promise<void>
getCursor()?
Parameters
Returns
Promise<string | undefined>
setCursor()?
Parameters
Returns
Promise<void>
getConversation()
Parameters
Returns
Promise<AIMessage[] | undefined>
setConversation()
Parameters
Returns
Promise<void>
clearConversation()
Parameters
Returns
Promise<void>
getCheckpoint()
Parameters
Returns
Promise<FlowCheckpoint | undefined>
setCheckpoint()
Parameters
Returns
Promise<void>
clearCheckpoint()
Parameters
Returns
Promise<void>
listCheckpoints()
Returns
Promise<[string, FlowCheckpoint][]>
setCheckpointIf()?
true) only when the stored row’s FlowCheckpoint.revision equals
expectedRevision, where 0 means “no row, or a row without revision”; otherwise
the row is left untouched and it resolves false. ONE atomic statement per store
(never a read-modify-write), so two replicas racing on one key see exactly one winner.
expectedRevision is a non-negative integer (RangeError otherwise). Optional: a
store without it keeps the local-fence behaviour; all six built-in stores implement it
and pass the shared conformance block (test-utils/store-conformance.ts).
Parameters
Returns
Promise<boolean>
clearCheckpointIf()?
true when the row is absent, or its revision (0 without one)
matched expectedRevision and it was deleted; false when a different revision is
stored (the row is left untouched). Same atomicity rule as setCheckpointIf.
Parameters
Returns
Promise<boolean>
getUserData()?
undefined when the entry is missing OR its
expiresAt is <= Date.now() (lazy expiry — expired rows may still exist
physically until purged).
Parameters
Returns
Promise<UserDataEntry | undefined>
setUserData()?
value and
expiresAt (no read-modify-write inside the store). An entry whose
expiresAt is already in the past may be dropped instead of written.
Parameters
Returns
Promise<void>
deleteUserData()?
namespace + key), one whole namespace (key omitted)
or every namespace of the user (namespace omitted; key is then ignored).
Deleting missing data is a no-op.
Parameters
Returns
Promise<void>
listUserData()?
namespace. Order unspecified.
Parameters
Returns
Promise<UserDataEntry[]>
purgeExpiredUserData()?
expiresAt <= now (default Date.now())
across the whole store; resolves with how many were removed. Stores with
native expiry (Redis) resolve 0.
Parameters
Returns
Promise<number>
start()
Returns
Promise<void>
stop()
Returns
Promise<void>