/** * Memory Service * * Pure domain logic for the memory subsystem. * Owns ID generation, level determination, scoring/ranking algorithms, * and embedding coordination. No DB calls — those live in MemoryRepository. */ import { MemoryType, MemoryLevel } from "@massa-th0th/shared"; import type { MemoryRow } from "../../data/memory/memory-repository.js"; export interface Memory { id: string; content: string; type: MemoryType; level: MemoryLevel; userId: string | null; sessionId: string | null; projectId: string | null; agentId: string | null; importance: number; tags: string[]; createdAt: number; accessCount: number; lastAccessed: number | null; /** Pinned memories are decay-exempt (Phase 1). 0/1 from the row. */ pinned?: number; score?: number; embedding?: any; } export interface ScoredMemory extends Memory { score: number; } export declare class MemoryService { private static instance; private embeddingService; private constructor(); static getInstance(): MemoryService; generateEmbedding(text: string): Promise; generateId(type: MemoryType, userId?: string): string; /** * Determine the memory level (L0–L4) using agent hierarchy rules. */ determineLevel(type: MemoryType, opts: { userId?: string; sessionId?: string; projectId?: string; agentId?: string; }): MemoryLevel; rowToMemory(row: MemoryRow): Memory; /** * Rank memories by semantic similarity + temporal + access + type priors. * Stability–plasticity balance: * semantic 65%, temporal 20%, access 10%, type 5% */ semanticRank(memories: Memory[], queryEmbedding: number[], limit: number): ScoredMemory[]; private cosineSimilarity; /** * Temporal salience curve — delegates to the pure, tested `decayScore` * (Phase 1, borrowed from ai-memory decay.rs). Blends a recency-decayed * salience term with an access-reinforcement term; pinned memories are * exempt. Tunable via `config.memory.decay`. */ private temporalScore; /** * Log-curve access reinforcement with saturation. */ private accessBoost; /** * Small priors for reusable memory types. */ private typeBoost; } //# sourceMappingURL=memory-service.d.ts.map