/** * @license * Copyright 2025 OSAgent OC * SPDX-License-Identifier: Apache-2.0 */ export interface Episode { id: string; timestamp: number; sessionId: string; /** What the user asked for */ userIntent: string; /** What was actually done */ actions: EpisodeAction[]; /** Final outcome */ outcome: 'success' | 'partial' | 'failed' | 'cancelled'; /** Summary of what happened */ summary: string; /** Lessons learned (for future reference) */ lessons?: string[]; /** Tags for categorization */ tags: string[]; /** Files that were modified */ filesModified?: string[]; /** Tools that were used */ toolsUsed?: string[]; /** Duration in milliseconds */ durationMs?: number; /** Token usage */ tokenUsage?: { input: number; output: number; }; } export interface EpisodeAction { type: 'tool_call' | 'agent_dispatch' | 'user_input' | 'decision'; description: string; result?: 'success' | 'failed' | 'skipped'; details?: Record; } export interface EpisodeQuery { /** Search in user intent and summary */ text?: string; /** Filter by tags */ tags?: string[]; /** Filter by outcome */ outcome?: Episode['outcome']; /** Filter by date range */ fromDate?: Date; toDate?: Date; /** Maximum number of results */ limit?: number; } export interface EpisodicMemoryStats { totalEpisodes: number; successRate: number; mostUsedTags: Array<{ tag: string; count: number; }>; averageDuration: number; totalTokens: number; } /** * Episodic Memory Service * * Stores and retrieves memories of past sessions, including: * - What the user asked for * - What actions were taken * - What the outcome was * - Lessons learned * * This enables OSAgent to: * - Learn from past mistakes * - Recall similar situations * - Build context over time */ export declare class EpisodicMemoryService { private episodesDir; private indexPath; private index; private initialized; constructor(baseDir?: string); /** * Initialize the episodic memory service */ initialize(): Promise; /** * Load the episodes index */ private loadIndex; /** * Save the episodes index */ private saveIndex; /** * Record a new episode */ recordEpisode(episode: Omit): Promise; /** * Query episodes */ queryEpisodes(query: EpisodeQuery): Promise; /** * Get a specific episode by ID */ getEpisode(id: string): Promise; /** * Find similar episodes based on user intent */ findSimilarEpisodes(userIntent: string, limit?: number): Promise; /** * Get lessons learned from past episodes */ getLessonsLearned(tags?: string[]): Promise; /** * Get memory statistics */ getStats(): Promise; /** * Clear all episodes (for testing) */ clear(): Promise; } export declare const episodicMemory: EpisodicMemoryService;