Skip to Content

MemoryStore

Defined in: src/lib/memory/store/types.ts:281 

One user’s memories, pitched at what the apps do with them rather than at the storage ops underneath. Two backends are intended: the on-device WatermelonDB vault (createLocalMemoryStore) and, later, an HTTP client for the server-side store.

Every value crossing this interface is plain data — no WatermelonDB Model, Query or Collection — so a remote backend can serialize it. The one exception is the DEVICE-LOCAL LLM-call knobs on MemoryRecallOptions and MemoryRetainOptions, which a remote store uses on the device rather than forwarding to nearby. Server persistence is authoritative; content decryption and plaintext-dependent processing remain on the device. Reads are whole-result rather than per-row so a chat turn costs a handful of calls (recall, then retain per fact), not one per memory.

Writes resolve null / false for a memory that is missing, deleted or not owned by this store’s user; they don’t throw for it.

Properties

decay?

readonly optional decay: MemoryDecay

Defined in: src/lib/memory/store/types.ts:355 

Rule-based decay, available without the local-only MemoryMaintenance.


factSource

readonly factSource: RecallFactSource

Defined in: src/lib/memory/store/types.ts:338 

The fact lane of recall, for callers that fuse it with other lanes such as conversation chunks.


maintenance?

optional maintenance: MemoryMaintenance

Defined in: src/lib/memory/store/types.ts:353 

TRANSITIONAL — see MemoryMaintenance. Absent on a remote backend.


masksEmbeddingInput

readonly masksEmbeddingInput: boolean

Defined in: src/lib/memory/store/types.ts:340 

True when the store was built with embeddingOptions.maskInput, so every embedding request it makes is masked.


topicMaintenance

readonly topicMaintenance: MemoryTopicMaintenance

Defined in: src/lib/memory/store/types.ts:357 

Topic-extraction upkeep, available on every backend.

Methods

addTopics()

addTopics(memoryId: string, topics: readonly EntityInput[], options?: object): Promise<StoredEntity[]>

Defined in: src/lib/memory/store/types.ts:316 

Add topics alongside the existing ones (auto-tagging stays on).

Parameters

ParameterType

memoryId

string

topics

readonly EntityInput[]

options?

object

options.canWrite?

() => Promise<boolean>

options.signal?

AbortSignal

options.unlessUserManaged?

boolean

Returns

Promise<StoredEntity[]>


archive()

archive(id: string): Promise<boolean>

Defined in: src/lib/memory/store/types.ts:311 

Parameters

ParameterType

id

string

Returns

Promise<boolean>


counts()?

optional counts(): Promise<MemoryCounts>

Defined in: src/lib/memory/store/types.ts:287 

Metadata-only counts for the live, archived and quarantined lists.

Returns

Promise<MemoryCounts>


create()

create(input: MemoryCreate): Promise<StoredVaultMemory>

Defined in: src/lib/memory/store/types.ts:303 

Manual save; missing embeddings are filled in the background.

Parameters

ParameterType

input

MemoryCreate

Returns

Promise<StoredVaultMemory>


createMany()

createMany(inputs: MemoryCreate[]): Promise<StoredVaultMemory[]>

Defined in: src/lib/memory/store/types.ts:305 

One write for a batch of manual saves; migration/restore uses lower-level operations.

Parameters

ParameterType

inputs

MemoryCreate[]

Returns

Promise<StoredVaultMemory[]>


createTopic()?

optional createTopic(name: string): Promise<string | null>

Defined in: src/lib/memory/store/types.ts:283 

Creates an account-scoped topic without requiring a memory.

Parameters

ParameterType

name

string

Returns

Promise<string | null>


delete()

delete(id: string): Promise<boolean>

Defined in: src/lib/memory/store/types.ts:308 

Soft delete; also drops the memory’s topic links.

Parameters

ParameterType

id

string

Returns

Promise<boolean>


get()

get(id: string): Promise<StoredVaultMemory | null>

Defined in: src/lib/memory/store/types.ts:290 

Parameters

ParameterType

id

string

Returns

Promise<StoredVaultMemory | null>


importTopics()?

optional importTopics(topics: readonly object[]): Promise<void>

Defined in: src/lib/memory/store/types.ts:285 

Imports local topic metadata without replacing server entries or tombstones.

Parameters

ParameterType

topics

readonly object[]

Returns

Promise<void>


list()

list(options?: MemoryListOptions): Promise<StoredVaultMemory[]>

Defined in: src/lib/memory/store/types.ts:289 

Memories newest-first, decrypted, WITH embedding (Memory Graph edges read it).

Parameters

ParameterType

options?

MemoryListOptions

Returns

Promise<StoredVaultMemory[]>


listArchived()

listArchived(): Promise<StoredVaultMemory[]>

Defined in: src/lib/memory/store/types.ts:292 

Decay-archived memories (not deleted, quarantined or superseded), most recently archived first.

Returns

Promise<StoredVaultMemory[]>


listProjections()

listProjections(options?: MemoryListOptions): Promise<VaultMemoryProjection[]>

Defined in: src/lib/memory/store/types.ts:300 

The memories MemoryStore.list would return, without decrypting content.

Parameters

ParameterType

options?

MemoryListOptions

Returns

Promise<VaultMemoryProjection[]>


listTopics()

listTopics(): Promise<MemoryTopic[]>

Defined in: src/lib/memory/store/types.ts:298 

Every topic by canonical name, with its kind and linked-memory count.

Returns

Promise<MemoryTopic[]>


memoriesByTopics()

memoriesByTopics(names: readonly string[]): Promise<Map<string, Set<string>>>

Defined in: src/lib/memory/store/types.ts:294 

Memory id → which of names it is linked to. Names are matched case-insensitively.

Parameters

ParameterType

names

readonly string[]

Returns

Promise<Map<string, Set<string>>>


recall()

recall(query: string, options?: MemoryRecallOptions): Promise<RecallResult>

Defined in: src/lib/memory/store/types.ts:335 

Parameters

ParameterType

query

string

options?

MemoryRecallOptions

Returns

Promise<RecallResult>


recordRecalls()?

optional recordRecalls(memoryIds: readonly string[]): Promise<void>

Defined in: src/lib/memory/store/types.ts:333 

Count one answer for each memory in memoryIds; call it once after the answer finishes, with the pre-retrieved ids plus any the memory tool recalled during it, so stopped and failed answers are not counted.

Parameters

ParameterType

memoryIds

readonly string[]

Returns

Promise<void>


repairEmbeddings()?

optional repairEmbeddings(options?: EmbeddingRepairOptions): Promise<EmbeddingRepairResult>

Defined in: src/lib/memory/store/types.ts:350 

Re-embeds memories the backend cannot rank with the current model. Absent where recall re-embeds lazily.

Parameters

ParameterType

options?

EmbeddingRepairOptions

Returns

Promise<EmbeddingRepairResult>


restore()

restore(id: string): Promise<boolean>

Defined in: src/lib/memory/store/types.ts:312 

Parameters

ParameterType

id

string

Returns

Promise<boolean>


retain()

retain(content: string, options?: MemoryRetainOptions): Promise<RetainResult>

Defined in: src/lib/memory/store/types.ts:336 

Parameters

ParameterType

content

string

options?

MemoryRetainOptions

Returns

Promise<RetainResult>


setEnabled()?

optional setEnabled(id: string, enabled: boolean): Promise<StoredVaultMemory | null>

Defined in: src/lib/memory/store/types.ts:331 

Switch a memory on or off for answers; a switched-off memory stays listed but is never recalled.

Parameters

ParameterType

id

string

enabled

boolean

Returns

Promise<StoredVaultMemory | null>


setTopics()

setTopics(memoryId: string, topics: readonly EntityInput[]): Promise<StoredVaultMemory | null>

Defined in: src/lib/memory/store/types.ts:314 

Replace the memory’s topics with a user-chosen set and stop auto-tagging it.

Parameters

ParameterType

memoryId

string

topics

readonly EntityInput[]

Returns

Promise<StoredVaultMemory | null>


setVisibility()

setVisibility(id: string, visibility: VaultMemoryVisibility, options?: object): Promise<StoredVaultMemory | null>

Defined in: src/lib/memory/store/types.ts:325 

Parameters

ParameterType

id

string

visibility

VaultMemoryVisibility

options?

object

options.twinOptIn?

boolean

Returns

Promise<StoredVaultMemory | null>


subscribe()

subscribe(onChange: () => void, options?: MemorySubscribeOptions): () => void

Defined in: src/lib/memory/store/types.ts:347 

Call onChange after the store’s memories change; re-read to see what changed. Does not fire for the state at subscription time — read once after subscribing. Returns the unsubscribe function.

Parameters

ParameterType

onChange

() => void

options?

MemorySubscribeOptions

Returns

(): void

Returns

void


supersede()

supersede(id: string, supersededById: string): Promise<boolean>

Defined in: src/lib/memory/store/types.ts:310 

Retire id behind the newer supersededById (both must be live and owned).

Parameters

ParameterType

id

string

supersededById

string

Returns

Promise<boolean>


topicsByMemories()

topicsByMemories(memoryIds: readonly string[]): Promise<Map<string, Set<string>>>

Defined in: src/lib/memory/store/types.ts:296 

Memory id → its canonical (lowercased) topic names. Unlinked ids are absent.

Parameters

ParameterType

memoryIds

readonly string[]

Returns

Promise<Map<string, Set<string>>>


update()

update(id: string, patch: MemoryUpdate): Promise<StoredVaultMemory | null>

Defined in: src/lib/memory/store/types.ts:306 

Parameters

ParameterType

id

string

patch

MemoryUpdate

Returns

Promise<StoredVaultMemory | null>

Last updated on