Skip to content

bodhi-realtime-agent / JsonMemoryStore

Class: JsonMemoryStore

Defined in: memory/json-memory-store.ts:31

File-based MemoryStore that persists facts and directives as a JSON file per user.

File layout ({baseDir}/{userId}.json):

json
{
  "directives": { "pacing": "slow" },
  "facts": [
    { "content": "Prefers dark mode", "category": "preference" }
  ]
}

All writes use write-file-atomic for crash-safe persistence.

Implements

Constructors

Constructor

new JsonMemoryStore(baseDir): JsonMemoryStore

Defined in: memory/json-memory-store.ts:32

Parameters

baseDir

string

Returns

JsonMemoryStore

Methods

addFacts()

addFacts(userId, facts): Promise<void>

Defined in: memory/json-memory-store.ts:34

Append new facts to the user's memory (creates the store entry if needed).

Parameters

userId

string

facts

MemoryFact[]

Returns

Promise<void>

Implementation of

MemoryStore.addFacts


getAll()

getAll(userId): Promise<MemoryFact[]>

Defined in: memory/json-memory-store.ts:45

Retrieve all stored facts for a user (empty array if none).

Parameters

userId

string

Returns

Promise<MemoryFact[]>

Implementation of

MemoryStore.getAll


getDirectives()

getDirectives(userId): Promise<Record<string, string>>

Defined in: memory/json-memory-store.ts:61

Retrieve structured directives (e.g. behavior presets) for a user.

Parameters

userId

string

Returns

Promise<Record<string, string>>

Implementation of

MemoryStore.getDirectives


replaceAll()

replaceAll(userId, facts): Promise<void>

Defined in: memory/json-memory-store.ts:54

Atomically replace all facts for a user (used by consolidation).

Parameters

userId

string

facts

MemoryFact[]

Returns

Promise<void>

Implementation of

MemoryStore.replaceAll


setDirectives()

setDirectives(userId, directives): Promise<void>

Defined in: memory/json-memory-store.ts:66

Persist structured directives for a user (preserves existing facts).

Parameters

userId

string

directives

Record<string, string>

Returns

Promise<void>

Implementation of

MemoryStore.setDirectives

Built with VitePress