Skip to content

bodhi-realtime-agent / JsonMemoryStore

Class: JsonMemoryStore ​

Defined in: src/memory/json-memory-store.ts:29

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: src/memory/json-memory-store.ts:30

Parameters ​

baseDir ​

string

Returns ​

JsonMemoryStore

Methods ​

addFacts() ​

addFacts(userId, facts): Promise<void>

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

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: src/memory/json-memory-store.ts:43

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: src/memory/json-memory-store.ts:59

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: src/memory/json-memory-store.ts:52

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: src/memory/json-memory-store.ts:64

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