{"version":3,"sources":["../../src/vue/composables/useMemoryIntelligence.ts","../../src/core/types.ts","../../src/core/errors.ts"],"names":["inject","ref","z"],"mappings":";;;;;;AAkBO,IAAM,uBAAA,0BACJ,oBAAoB;AAEtB,SAAS,qBAAA,GAAwB;AACtC,EAAA,MAAM,MAAA,GAASA,WAAO,uBAAuB,CAAA;AAC7C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,MAAM,IAAI,MAAM,wCAAwC,CAAA;AAAA,EAC1D;AACA,EAAA,OAAO,EAAE,MAAA,EAAO;AAClB;AAUA,SAAS,SACP,aAAA,EACe;AACf,EAAA,MAAM,IAAA,GAAOC,QAAc,IAAI,CAAA;AAC/B,EAAA,MAAM,OAAA,GAAUA,QAAI,KAAK,CAAA;AACzB,EAAA,MAAM,KAAA,GAAQA,QAAkB,IAAI,CAAA;AAEpC,EAAA,MAAM,OAAA,GAAU,UAAU,IAAA,KAAgB;AACxC,IAAA,OAAA,CAAQ,KAAA,GAAQ,IAAA;AAChB,IAAA,KAAA,CAAM,KAAA,GAAQ,IAAA;AACd,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAAS,MAAM,aAAA,CAAc,GAAG,IAAI,CAAA;AAC1C,MAAA,IAAA,CAAK,KAAA,GAAQ,MAAA;AAAA,IACf,SAAS,GAAA,EAAK;AACZ,MAAA,KAAA,CAAM,KAAA,GAAQ,eAAe,KAAA,GAAQ,GAAA,GAAM,IAAI,KAAA,CAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAAA,IAClE,CAAA,SAAE;AACA,MAAA,OAAA,CAAQ,KAAA,GAAQ,KAAA;AAAA,IAClB;AAAA,EACF,CAAA;AAEA,EAAA,MAAM,QAAQ,MAAM;AAClB,IAAA,IAAA,CAAK,KAAA,GAAQ,IAAA;AACb,IAAA,KAAA,CAAM,KAAA,GAAQ,IAAA;AACd,IAAA,OAAA,CAAQ,KAAA,GAAQ,KAAA;AAAA,EAClB,CAAA;AAEA,EAAA,OAAO,EA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BAAA;AAAA,EACd;AACF;AAEO,IAAM,eAAA,GAAN,cAA8B,uBAAA,CAAwB;AAAA,EAC3D,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF","file":"index.cjs","sourcesContent":["/**\n * Vue composables for Memory Intelligence\n */\n\nimport { inject, ref, InjectionKey } from \"vue\";\nimport type { MemoryIntelligenceClient, IntelligenceResponse } from \"../../core/client.js\";\nimport type {\n  PatternAnalysis,\n  TagSuggestionsResult,\n  RelatedMemoriesResult,\n  DuplicatesResult,\n  InsightsResult,\n  MemoryHealth,\n} from \"../../core/types.js\";\nimport type {\n  PredictiveRecallResult,\n} from \"../../core/prediction-types.js\";\n\nexport const MEMORY_INTELLIGENCE_KEY: InjectionKey<MemoryIntelligenceClient> =\n  Symbol(\"memoryIntelligence\");\n\nexport function useMemoryIntelligence() {\n  const client = inject(MEMORY_INTELLIGENCE_KEY);\n  if (!client) {\n    throw new Error(\"MemoryIntelligence client not provided\");\n  }\n  return { client };\n}\n\ninterface UseAsyncState {\n  data: any;\n  loading: any;\n  error: any;\n  execute: (...args: any[]) => Promise<void>;\n  reset: () => void;\n}\n\nfunction useAsync<T>(\n  asyncFunction: (...args: any[]) => Promise<T>\n): UseAsyncState {\n  const data = ref<T | null>(null);\n  const loading = ref(false);\n  const error = ref<Error | null>(null);\n\n  const execute = async (...args: any[]) => {\n    loading.value = true;\n    error.value = null;\n    try {\n      const result = await asyncFunction(...args);\n      data.value = result as any;\n    } catch (err) {\n      error.value = err instanceof Error ? err : new Error(String(err));\n    } finally {\n      loading.value = false;\n    }\n  };\n\n  const reset = () => {\n    data.value = null;\n    error.value = null;\n    loading.value = false;\n  };\n\n  return { data, loading, error, execute, reset };\n}\n\nexport function usePatternAnalysis() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<IntelligenceResponse<PatternAnalysis>>((params) => client.analyzePatterns(params));\n}\n\nexport function useTagSuggestions() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<IntelligenceResponse<TagSuggestionsResult>>((params) => client.suggestTags(params));\n}\n\nexport function useRelatedMemories() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<IntelligenceResponse<RelatedMemoriesResult>>((params) => client.findRelated(params));\n}\n\nexport function useDuplicateDetection() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<IntelligenceResponse<DuplicatesResult>>((params) => client.detectDuplicates(params));\n}\n\nexport function useInsightExtraction() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<IntelligenceResponse<InsightsResult>>((params) => client.extractInsights(params));\n}\n\nexport function useHealthCheck() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<IntelligenceResponse<MemoryHealth>>((params) => client.healthCheck(params));\n}\n\n/**\n * Predictive memory recall composable\n *\n * AI-powered prediction of memories you'll need based on your current context.\n *\n * @example\n * ```vue\n * <script setup>\n * import { usePredictiveRecall } from '@lanonasis/mem-intel-sdk/vue';\n *\n * const { data, loading, error, execute } = usePredictiveRecall();\n *\n * // Trigger predictions\n * const getPredictions = () => {\n *   execute({\n *     userId: 'user-123',\n *     context: {\n *       currentProject: 'Building dashboard',\n *       recentTopics: ['React', 'performance']\n *     },\n *     limit: 5\n *   });\n * };\n * </script>\n *\n * <template>\n *   <div v-if=\"loading\">Loading predictions...</div>\n *   <div v-else-if=\"data\">\n *     <div v-for=\"pred in data.data.predictions\" :key=\"pred.id\">\n *       <h3>{{ pred.title }} ({{ pred.confidence }}%)</h3>\n *       <p>{{ pred.reason }}</p>\n *     </div>\n *   </div>\n * </template>\n * ```\n */\nexport function usePredictiveRecall() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<IntelligenceResponse<PredictiveRecallResult>>((params) => client.predictiveRecall(params));\n}\n\n/**\n * Record prediction feedback composable\n *\n * @example\n * ```vue\n * <script setup>\n * import { usePredictionFeedback } from '@lanonasis/mem-intel-sdk/vue';\n *\n * const { execute: recordFeedback, loading } = usePredictionFeedback();\n *\n * const handlePredictionClick = (memoryId: string) => {\n *   recordFeedback({\n *     memoryId,\n *     userId: 'user-123',\n *     useful: true,\n *     action: 'clicked'\n *   });\n * };\n * </script>\n * ```\n */\nexport function usePredictionFeedback() {\n  const { client } = useMemoryIntelligence();\n  return useAsync<void>((params) => client.recordPredictionFeedback(params));\n}\n","/**\n * Type definitions for Memory Intelligence SDK\n */\n\nimport { z } from \"zod\";\n\n// Response format enum\nexport const ResponseFormat = {\n  JSON: \"json\",\n  MARKDOWN: \"markdown\",\n} as const;\n\nexport type ResponseFormatType = (typeof ResponseFormat)[keyof typeof ResponseFormat];\n\n// Memory type enum\nexport const MemoryType = z.enum([\n  \"context\",\n  \"project\",\n  \"knowledge\",\n  \"reference\",\n  \"personal\",\n  \"workflow\",\n]);\n\nexport type MemoryTypeValue = z.infer<typeof MemoryType>;\n\n// Optional query-scope hint for context-aware rollouts.\nexport const QueryScope = z.enum([\n  \"personal\",\n  \"team\",\n  \"organization\",\n  \"hybrid\",\n]);\n\nexport type QueryScopeValue = z.infer<typeof QueryScope>;\n\n// Processing mode for SDK operations\nexport type ProcessingMode = 'api' | 'offline-fallback';\n\n// Configuration interface\nexport interface MemoryIntelligenceConfig {\n  apiUrl?: string; // Lanonasis API URL (default: https://api.lanonasis.com/api/v1)\n  apiKey?: string; // Lanonasis API key (format: lano_xxxxxxxxxx)\n  authToken?: string; // Bearer token for user-scoped auth (dashboard/SSO)\n  authType?: 'apiKey' | 'bearer'; // Explicitly set auth type; inferred from apiKey/authToken if not provided\n  allowMissingAuth?: boolean; // Allow client creation without auth (SDK consumers should gate calls)\n  timeout?: number; // Request timeout in milliseconds (default: 30000)\n  responseFormat?: ResponseFormatType;\n  headers?: Record<string, string>; // Custom headers\n\n  /**\n   * Processing mode for intelligence operations\n   * - 'api': Always use Lanonasis API endpoints (default)\n   * - 'offline-fallback': Use API, fall back to cached/local data if unreachable\n   * @default 'api'\n   */\n  processingMode?: ProcessingMode;\n\n  /**\n   * Enable caching of API responses for offline fallback\n   * Only used when processingMode is 'offline-fallback'\n   * @default true\n   */\n  enableCache?: boolean;\n\n  /**\n   * Cache TTL in milliseconds (default: 5 minutes)\n   * @default 300000\n   */\n  cacheTTL?: number;\n}\n\n// API response wrapper from Edge Functions\nexport interface EdgeFunctionResponse<T> {\n  success: boolean;\n  data?: T;\n  error?: {\n    message: string;\n    code?: string;\n  };\n  usage?: {\n    tokens_used: number;\n    cost_usd: number;\n    cached: boolean;\n  };\n  tier_info?: {\n    tier: string;\n    usage_remaining: number;\n  };\n}\n\nexport interface MemoryQueryContext {\n  organizationId?: string;\n  topicId?: string;\n  memoryTypes?: MemoryTypeValue[];\n  queryScope?: QueryScopeValue;\n}\n\n// Tool parameter interfaces\nexport interface AnalyzePatternsParams extends MemoryQueryContext {\n  userId: string;\n  timeRangeDays?: number;\n  responseFormat?: ResponseFormatType;\n}\n\nexport interface SuggestTagsParams {\n  memoryId: string;\n  userId: string;\n  maxSuggestions?: number;\n  includeExistingTags?: boolean;\n  responseFormat?: ResponseFormatType;\n}\n\nexport interface FindRelatedParams extends MemoryQueryContext {\n  memoryId: string;\n  userId: string;\n  limit?: number;\n  similarityThreshold?: number;\n  responseFormat?: ResponseFormatType;\n}\n\nexport interface DetectDuplicatesParams extends MemoryQueryContext {\n  userId: string;\n  similarityThreshold?: number;\n  maxPairs?: number;\n  responseFormat?: ResponseFormatType;\n}\n\nexport interface ExtractInsightsParams extends MemoryQueryContext {\n  userId: string;\n  topic?: string;\n  memoryType?: MemoryTypeValue;\n  maxMemories?: number;\n  responseFormat?: ResponseFormatType;\n}\n\nexport interface HealthCheckParams extends MemoryQueryContext {\n  userId: string;\n  responseFormat?: ResponseFormatType;\n}\n\n// Tool result interfaces\nexport interface PatternAnalysis {\n  total_memories: number;\n  memories_by_type: Record<string, number>;\n  memories_by_day_of_week: Record<string, number>;\n  peak_creation_hours: number[];\n  average_content_length: number;\n  most_common_tags: Array<{ tag: string; count: number }>;\n  creation_velocity: {\n    daily_average: number;\n    trend: \"increasing\" | \"stable\" | \"decreasing\";\n  };\n  insights: string[];\n}\n\nexport interface TagSuggestion {\n  tag: string;\n  confidence: number;\n  reasoning: string;\n}\n\nexport interface TagSuggestionsResult {\n  memory_id: string;\n  existing_tags: string[];\n  suggestions: TagSuggestion[];\n  context: {\n    memory_type: string;\n    related_memories_analyzed: number;\n  };\n}\n\nexport interface RelatedMemory {\n  id: string;\n  title: string;\n  type: string;\n  similarity_score: number;\n  shared_tags: string[];\n  content_preview: string;\n}\n\nexport interface RelatedMemoriesResult {\n  source_memory: {\n    id: string;\n    title: string;\n    type: string;\n  };\n  related_memories: RelatedMemory[];\n  total_found: number;\n}\n\nexport interface DuplicateEntry {\n  id: string;\n  title: string;\n  similarity: number;\n  created_at: string;\n}\n\nexport interface DuplicateGroup {\n  primary_id: string;\n  primary_title: string;\n  duplicates: DuplicateEntry[];\n  similarity_score: number;\n}\n\nexport interface DuplicatesResult {\n  duplicate_groups: DuplicateGroup[];\n  total_groups: number;\n  total_duplicates: number;\n  detection_method: \"semantic\" | \"text\";\n  threshold_used: number;\n  memories_analyzed: number;\n  potential_storage_savings: string;\n}\n\nexport interface Insight {\n  type: \"themes\" | \"connections\" | \"gaps\" | \"actions\" | \"summary\";\n  content: string;\n  confidence: number;\n  related_memory_ids: string[];\n}\n\nexport interface InsightsResult {\n  insights: Insight[];\n  overall_summary: string;\n  memories_analyzed: number;\n  insight_types: string[];\n  topic_filter?: string | null;\n  generated_at: string;\n}\n\nexport interface HealthScoreBreakdown {\n  organization: number;\n  tagging: number;\n  recency: number;\n  completeness: number;\n  diversity: number;\n}\n\nexport interface HealthScore {\n  overall: number;\n  breakdown: HealthScoreBreakdown;\n}\n\nexport interface HealthStatistics {\n  total_memories: number;\n  active_memories: number;\n  archived_memories: number;\n  memories_with_tags: number;\n  unique_tags: number;\n  memory_types: number;\n  recent_memories_30d: number;\n  stale_memories_90d: number;\n}\n\nexport interface HealthIssue {\n  severity: \"high\" | \"medium\" | \"low\";\n  category: string;\n  description: string;\n  affected_count: number;\n  recommendation: string;\n}\n\nexport interface MemoryHealth {\n  health_score: HealthScore;\n  status: \"excellent\" | \"good\" | \"needs_attention\" | \"poor\";\n  statistics: HealthStatistics;\n  issues: HealthIssue[];\n  recommendations: string[];\n  generated_at: string;\n}\n\n// Memory entry interface (from database)\nexport interface MemoryEntry {\n  id: string;\n  user_id: string;\n  organization_id?: string | null;\n  topic_id?: string | null;\n  title: string;\n  content: string;\n  type: MemoryTypeValue;\n  memory_type?: string | null;\n  tags?: string[];\n  metadata?: Record<string, any>;\n  embedding?: number[];\n  access_count?: number | null;\n  last_accessed?: string | null;\n  created_at: string;\n  updated_at: string;\n}\n\n// Query options for internal use\nexport interface QueryMemoriesOptions extends MemoryQueryContext {\n  type?: string;\n  limit?: number;\n  offset?: number;\n  includeEmbeddings?: boolean;\n}\n","/**\n * SDK-specific error classes\n */\n\nexport class MemoryIntelligenceError extends Error {\n  constructor(message: string) {\n    super(message);\n    this.name = \"MemoryIntelligenceError\";\n  }\n}\n\nexport class ConfigurationError extends MemoryIntelligenceError {\n  constructor(message: string) {\n    super(message);\n    this.name = \"ConfigurationError\";\n  }\n}\n\nexport class MemoryNotFoundError extends MemoryIntelligenceError {\n  constructor(memoryId: string) {\n    super(`Memory not found: ${memoryId}`);\n    this.name = \"MemoryNotFoundError\";\n  }\n}\n\nexport class DatabaseError extends MemoryIntelligenceError {\n  constructor(message: string, public originalError?: Error) {\n    super(message);\n    this.name = \"DatabaseError\";\n  }\n}\n\nexport class EmbeddingError extends MemoryIntelligenceError {\n  constructor(message: string, public originalError?: Error) {\n    super(message);\n    this.name = \"EmbeddingError\";\n  }\n}\n\nexport class ValidationError extends MemoryIntelligenceError {\n  constructor(message: string) {\n    super(message);\n    this.name = \"ValidationError\";\n  }\n}\n"]}