Class SqliteKnowledgeGraph

Persistent knowledge graph backed by SQLite via SqliteBrain.

Implements the full IKnowledgeGraph interface using the knowledge_nodes and knowledge_edges tables. Extended entity/relation fields that don't have dedicated columns are serialized into the JSON properties / metadata columns.

Example

const brain = await SqliteBrain.open('/tmp/agent-brain.sqlite');
const graph = new SqliteKnowledgeGraph(brain);
await graph.initialize();

const entity = await graph.upsertEntity({
type: 'person',
label: 'Alice',
properties: { role: 'engineer' },
confidence: 0.95,
source: { type: 'user_input', timestamp: new Date().toISOString() },
});

Implements

Constructors

Methods

  • Query episodic memories with optional filters.

    Supports filtering by memory sub-type, participants, minimum importance, time range, and result limit.

    Parameters

    • Optional options: {
          types?: ("error" | "success" | "discovery" | "conversation" | "task" | "interaction")[];
          participants?: string[];
          minImportance?: number;
          timeRange?: {
              from?: string;
              to?: string;
          };
          limit?: number;
      }
      • Optional types?: ("error" | "success" | "discovery" | "conversation" | "task" | "interaction")[]
      • Optional participants?: string[]
      • Optional minImportance?: number
      • Optional timeRange?: {
            from?: string;
            to?: string;
        }
        • Optional from?: string
        • Optional to?: string
      • Optional limit?: number

    Returns Promise<EpisodicMemory[]>

  • Recall relevant memories via keyword search against summaries.

    Performs a case-insensitive substring match on the label (which contains the summary text). Increments accessCount and updates lastAccessedAt for each returned memory (Hebbian reinforcement).

    Full semantic (embedding-based) recall requires the Memory facade.

    Parameters

    • query: string
    • Optional topK: number

    Returns Promise<EpisodicMemory[]>

  • Decay the confidence of all memory-type nodes by a multiplicative factor.

    This simulates the Ebbinghaus forgetting curve — memories that are not accessed (reinforced) gradually fade.

    Parameters

    • Optional decayFactor: number

      Multiplicative factor in (0, 1). Default 0.95.

    Returns Promise<number>

    The number of memory nodes whose confidence was reduced.