/** * Core Memory Intelligence Client * Supports API-first with offline-fallback capability */ import { MemoryIntelligenceConfig, AnalyzePatternsParams, PatternAnalysis, SuggestTagsParams, TagSuggestionsResult, FindRelatedParams, RelatedMemoriesResult, DetectDuplicatesParams, DuplicatesResult, ExtractInsightsParams, InsightsResult, HealthCheckParams, MemoryHealth, QueryMemoriesOptions, MemoryEntry, ProcessingMode } from "./types.js"; import { PredictiveRecallParams, PredictiveRecallResult } from "./prediction-types.js"; import { RecordBehaviorParams, RecordBehaviorResult, RecallBehaviorParams, RecallBehaviorResult, SuggestActionParams, SuggestActionResult, BehaviorPattern } from "./behavior-types.js"; import { HttpClient } from "../utils/http-client.js"; import { UsageInfo, TierInfo } from "../utils/response-adapter.js"; export interface IntelligenceResponse { data: T; usage?: UsageInfo; tier_info?: TierInfo; fromCache?: boolean; } export declare class MemoryIntelligenceClient { private httpClient; private defaultResponseFormat; private processingMode; constructor(config: MemoryIntelligenceConfig); /** * Get the current processing mode */ getProcessingMode(): ProcessingMode; /** * Check if cache is enabled (for offline-fallback mode) */ isCacheEnabled(): boolean; /** * Clear the response cache */ clearCache(): void; /** * Get HTTP client for direct API access */ getHttpClient(): HttpClient; /** * Query memories from the API */ queryMemories(userId: string, options?: QueryMemoriesOptions): Promise; /** * Analyze usage patterns and trends in memory collection */ analyzePatterns(params: AnalyzePatternsParams): Promise>; /** * Get AI-powered tag suggestions for a memory */ suggestTags(params: SuggestTagsParams): Promise>; /** * Find semantically related memories using vector similarity */ findRelated(params: FindRelatedParams): Promise>; /** * Detect potential duplicate memories */ detectDuplicates(params: DetectDuplicatesParams): Promise>; /** * Extract insights and patterns from memories */ extractInsights(params: ExtractInsightsParams): Promise>; /** * Check the health and organization quality of memories */ healthCheck(params: HealthCheckParams): Promise>; /** * Predictive Memory Recall - AI that anticipates what you need * * Uses a weighted scoring algorithm: * - Semantic similarity to current context (40%) * - Temporal relevance (recency decay curve) (30%) * - Usage frequency (20%) * - Serendipity factor (adjacent discoveries) (10%) * * @example * ```typescript * const result = await client.predictiveRecall({ * userId: "user-123", * context: { * currentProject: "Building dashboard components", * recentTopics: ["React", "performance", "hooks"], * contextText: "Optimizing render performance for data tables" * }, * limit: 5, * minConfidence: 50 * }); * * for (const prediction of result.data.predictions) { * console.log(`[${prediction.confidence}%] ${prediction.title}`); * console.log(` Reason: ${prediction.reason}`); * console.log(` Action: ${prediction.suggestedAction}`); * } * ``` */ predictiveRecall(params: PredictiveRecallParams): Promise>; /** * Record feedback on a prediction (for improving accuracy over time) * * @example * ```typescript * await client.recordPredictionFeedback({ * memoryId: "mem-123", * userId: "user-123", * useful: true, * action: "clicked" * }); * ``` */ recordPredictionFeedback(params: { memoryId: string; userId: string; useful: boolean; action: "clicked" | "saved" | "dismissed" | "ignored"; dismissReason?: "not_relevant" | "already_know" | "not_now" | "other"; }): Promise; /** * Record a successful behavior pattern for future recall * * The system automatically: * - Generates an embedding from the trigger description * - Detects and updates duplicates (>95% similarity) * - Tracks usage counts for pattern prioritization * * @example * ```typescript * const result = await client.recordBehavior({ * user_id: "user-123", * trigger: "User wants to refactor a React component to use hooks", * context: { * project: "dashboard-app", * active_files: ["src/components/DataTable.tsx"] * }, * actions: [ * { tool: "read_file", parameters: { path: "src/components/DataTable.tsx" }, outcome: "success" }, * { tool: "analyze_code", parameters: { focus: "class_components" }, outcome: "success" }, * { tool: "edit_file", parameters: { path: "src/components/DataTable.tsx" }, outcome: "success" } * ], * final_outcome: "success" * }); * * if (result.data.was_duplicate) { * console.log("Updated existing pattern:", result.data.pattern.id); * } * ``` */ recordBehavior(params: RecordBehaviorParams): Promise>; /** * Recall similar behavior patterns based on current context * * Use this to find workflows that match the user's current task, * enabling AI assistants to suggest proven approaches. * * @example * ```typescript * const result = await client.recallBehavior({ * user_id: "user-123", * context: { * current_task: "Need to optimize database queries for user dashboard" * }, * limit: 5, * similarity_threshold: 0.7 * }); * * for (const match of result.data.patterns) { * console.log(`[${Math.round(match.similarity_score * 100)}%] ${match.pattern.trigger}`); * console.log(` Actions: ${match.pattern.actions.map(a => a.tool).join(" → ")}`); * } * ``` */ recallBehavior(params: RecallBehaviorParams): Promise>; /** * Get AI-powered action suggestions based on learned patterns * * Analyzes the current state and completed steps to predict * what action the user should take next based on similar workflows. * * @example * ```typescript * const result = await client.suggestAction({ * user_id: "user-123", * current_state: { * task_description: "Implementing user authentication with OAuth", * completed_steps: [ * "create src/auth/oauth.ts", * "inspect package.json" * ] * }, * max_suggestions: 3 * }); * * for (const suggestion of result.data.suggestions) { * console.log(`[${Math.round(suggestion.confidence * 100)}%] ${suggestion.action}`); * console.log(` Tool: ${suggestion.tool}`); * console.log(` Why: ${suggestion.reasoning}`); * } * ``` */ suggestAction(params: SuggestActionParams): Promise>; /** * List all behavior patterns for a user * * @example * ```typescript * const patterns = await client.listBehaviorPatterns("user-123", { limit: 20 }); * console.log(`Found ${patterns.length} patterns`); * ``` */ listBehaviorPatterns(userId: string, options?: { limit?: number; offset?: number; }): Promise; }