// Types for the Agent Memory Plugin (LanceDB) /** * Memory categories for classification. * * Categories help with: * - Storage: Admin knows what "type" of memory to capture * - Retrieval: Can filter by category for more precise recall * * Guidelines: * - preference: User preferences, settings, likes/dislikes * - decision: Choices made, conclusions reached * - fact: Factual information, verified data * - error: Errors made, bugs spotted, problems encountered * - learned: Verified conclusions, lessons learned, insights * - uncertain: Information that needs further verification */ export enum Category { PREFERENCE = "preference", FACT = "fact", DECISION = "decision", ERROR = "error", LEARNED = "learned", UNCERTAIN = "uncertain" } /** * Metadata schema for memory entries. * * Use metadata to store: * - Source references (note_path, url, etc.) * - Tags for additional filtering * - Validation status * - Any custom fields needed * * Example: * { * "note_path": "05-Knowledge/Research/memory.md", * "note_title": "Memory System Analysis", * "tags": ["memory", "lancedb", "plugin"], * "validated": true, * "source_url": "https://github.com/..." * } */ export interface MemoryMetadata { note_path?: string; // Path to note in vault note_title?: string; // Title of referenced note source_url?: string; // External URL reference tags?: string[]; // Custom tags for filtering validated?: boolean; // Whether this has been verified validated_at?: number; // Timestamp of validation (ms) created_via?: string; // How this was captured (e.g., "daily-standup") related_ids?: string[];// Related memory IDs [key: string]: unknown; // Allow custom fields } export interface MemoryEntry { id: string; text: string; vector: number[]; category: Category; scope: string; importance: number; // 0-1 timestamp: number; // milliseconds metadata?: string; // JSON string source: string; // "manual", "auto-session", "auto-correction", "auto-preference" access_count?: number; // how many times this memory has been recalled last_accessed?: number; // timestamp of last recall (milliseconds) } export interface MemorySearchResult extends MemoryEntry { score: number; // 0-100 similarity } export interface MemoryStats { total: number; byCategory: Record; byScope: Record; oldestTimestamp?: number; newestTimestamp?: number; } export interface StoreMemoryParams { text: string; category?: Category; scope?: string; importance?: number; metadata?: Record; source?: string; } export interface RecallMemoriesParams { query: string; scope?: string; category?: Category; limit?: number; minImportance?: number; } export interface ForgetMemoriesParams { query?: string; memoryId?: string; scope?: string; } export interface ListMemoriesParams { scope?: string; category?: Category; limit?: number; } export interface UpdateMemoryParams { memoryId: string; text?: string; category?: Category; importance?: number; scope?: string; } // Config export interface MemoryConfig { ollamaUrl: string; embeddingModel: string; embeddingDim: number; dbPath: string; } export const DEFAULT_CONFIG: MemoryConfig = { ollamaUrl: "http://localhost:11434", embeddingModel: "bge-m3:latest", embeddingDim: 1024, dbPath: ".opencode/memory/agent-memory.db" };