@lanonasis/mem-intel-sdk 1.1.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +230 -15
  2. package/README.md +258 -4
  3. package/dist/core/client.d.ts +51 -0
  4. package/dist/core/client.d.ts.map +1 -1
  5. package/dist/core/index.cjs +146 -13
  6. package/dist/core/index.cjs.map +1 -1
  7. package/dist/core/index.d.ts +1 -0
  8. package/dist/core/index.d.ts.map +1 -1
  9. package/dist/core/index.js +145 -14
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/prediction-types.d.ts +270 -0
  12. package/dist/core/prediction-types.d.ts.map +1 -0
  13. package/dist/core/types.d.ts +62 -39
  14. package/dist/core/types.d.ts.map +1 -1
  15. package/dist/index.cjs +106 -13
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.js +106 -13
  18. package/dist/index.js.map +1 -1
  19. package/dist/node/client.d.ts.map +1 -1
  20. package/dist/node/index.cjs +107 -13
  21. package/dist/node/index.cjs.map +1 -1
  22. package/dist/node/index.js +107 -13
  23. package/dist/node/index.js.map +1 -1
  24. package/dist/react/context/MemoryIntelligenceProvider.d.ts +4 -3
  25. package/dist/react/context/MemoryIntelligenceProvider.d.ts.map +1 -1
  26. package/dist/react/hooks/useMemoryIntelligence.d.ts +83 -0
  27. package/dist/react/hooks/useMemoryIntelligence.d.ts.map +1 -1
  28. package/dist/react/index.cjs +125 -21
  29. package/dist/react/index.cjs.map +1 -1
  30. package/dist/react/index.js +123 -15
  31. package/dist/react/index.js.map +1 -1
  32. package/dist/server/index.cjs +343 -40
  33. package/dist/server/index.cjs.map +1 -1
  34. package/dist/server/index.js +343 -40
  35. package/dist/server/index.js.map +1 -1
  36. package/dist/server/mcp-server.d.ts.map +1 -1
  37. package/dist/utils/http-client.d.ts +4 -1
  38. package/dist/utils/http-client.d.ts.map +1 -1
  39. package/dist/utils/prediction-engine.d.ts +90 -0
  40. package/dist/utils/prediction-engine.d.ts.map +1 -0
  41. package/dist/vue/composables/useMemoryIntelligence.d.ts +59 -0
  42. package/dist/vue/composables/useMemoryIntelligence.d.ts.map +1 -1
  43. package/dist/vue/index.cjs.map +1 -1
  44. package/dist/vue/index.js.map +1 -1
  45. package/package.json +9 -3
@@ -0,0 +1,270 @@
1
+ /**
2
+ * Predictive Memory System Types
3
+ *
4
+ * The AI that anticipates what you need before you realize it.
5
+ *
6
+ * Scoring Algorithm:
7
+ * - Semantic similarity to current context (40%)
8
+ * - Temporal relevance (recency decay curve) (30%)
9
+ * - Usage frequency of similar memories (20%)
10
+ * - Serendipity factor (adjacent/surprising topics) (10%)
11
+ */
12
+ import { z } from "zod";
13
+ import { ResponseFormatType, MemoryTypeValue } from "./types.js";
14
+ /**
15
+ * Context describing the user's current work/focus
16
+ */
17
+ export interface PredictiveContext {
18
+ /** Current project or task description */
19
+ currentProject?: string;
20
+ /** Recent work patterns or topics */
21
+ recentTopics?: string[];
22
+ /** Current files being worked on */
23
+ activeFiles?: string[];
24
+ /** Free-form context text (e.g., current task, meeting notes) */
25
+ contextText?: string;
26
+ /** Team channel or conversation topics (for team-aware predictions) */
27
+ teamContext?: string;
28
+ }
29
+ /**
30
+ * Parameters for predictive memory recall
31
+ */
32
+ export interface PredictiveRecallParams {
33
+ /** User ID */
34
+ userId: string;
35
+ /** Current context for prediction scoring */
36
+ context: PredictiveContext;
37
+ /** Maximum predictions to return (default: 5, max: 20) */
38
+ limit?: number;
39
+ /** Minimum confidence threshold (0-100, default: 40) */
40
+ minConfidence?: number;
41
+ /** Include serendipity/surprise suggestions (default: true) */
42
+ includeSerendipity?: boolean;
43
+ /** Filter by memory types */
44
+ memoryTypes?: MemoryTypeValue[];
45
+ /** Time window in days for recency scoring (default: 90) */
46
+ timeWindowDays?: number;
47
+ /** Response format */
48
+ responseFormat?: ResponseFormatType;
49
+ }
50
+ export declare const PredictiveRecallParamsSchema: z.ZodObject<{
51
+ userId: z.ZodString;
52
+ context: z.ZodObject<{
53
+ currentProject: z.ZodOptional<z.ZodString>;
54
+ recentTopics: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
55
+ activeFiles: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
56
+ contextText: z.ZodOptional<z.ZodString>;
57
+ teamContext: z.ZodOptional<z.ZodString>;
58
+ }, "strip", z.ZodTypeAny, {
59
+ currentProject?: string | undefined;
60
+ recentTopics?: string[] | undefined;
61
+ activeFiles?: string[] | undefined;
62
+ contextText?: string | undefined;
63
+ teamContext?: string | undefined;
64
+ }, {
65
+ currentProject?: string | undefined;
66
+ recentTopics?: string[] | undefined;
67
+ activeFiles?: string[] | undefined;
68
+ contextText?: string | undefined;
69
+ teamContext?: string | undefined;
70
+ }>;
71
+ limit: z.ZodDefault<z.ZodNumber>;
72
+ minConfidence: z.ZodDefault<z.ZodNumber>;
73
+ includeSerendipity: z.ZodDefault<z.ZodBoolean>;
74
+ memoryTypes: z.ZodOptional<z.ZodArray<z.ZodEnum<["context", "project", "knowledge", "reference", "personal", "workflow"]>, "many">>;
75
+ timeWindowDays: z.ZodDefault<z.ZodNumber>;
76
+ responseFormat: z.ZodDefault<z.ZodEnum<["json", "markdown"]>>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ context: {
79
+ currentProject?: string | undefined;
80
+ recentTopics?: string[] | undefined;
81
+ activeFiles?: string[] | undefined;
82
+ contextText?: string | undefined;
83
+ teamContext?: string | undefined;
84
+ };
85
+ userId: string;
86
+ limit: number;
87
+ minConfidence: number;
88
+ includeSerendipity: boolean;
89
+ timeWindowDays: number;
90
+ responseFormat: "json" | "markdown";
91
+ memoryTypes?: ("context" | "project" | "knowledge" | "reference" | "personal" | "workflow")[] | undefined;
92
+ }, {
93
+ context: {
94
+ currentProject?: string | undefined;
95
+ recentTopics?: string[] | undefined;
96
+ activeFiles?: string[] | undefined;
97
+ contextText?: string | undefined;
98
+ teamContext?: string | undefined;
99
+ };
100
+ userId: string;
101
+ limit?: number | undefined;
102
+ minConfidence?: number | undefined;
103
+ includeSerendipity?: boolean | undefined;
104
+ memoryTypes?: ("context" | "project" | "knowledge" | "reference" | "personal" | "workflow")[] | undefined;
105
+ timeWindowDays?: number | undefined;
106
+ responseFormat?: "json" | "markdown" | undefined;
107
+ }>;
108
+ /**
109
+ * Individual scoring factors for a prediction
110
+ */
111
+ export interface PredictionScoreBreakdown {
112
+ /** Semantic similarity to current context (0-100) */
113
+ semanticScore: number;
114
+ /** Temporal relevance based on age (0-100) */
115
+ temporalScore: number;
116
+ /** Usage frequency of similar content (0-100) */
117
+ frequencyScore: number;
118
+ /** Serendipity/surprise factor (0-100) */
119
+ serendipityScore: number;
120
+ /** Weighted combination (0-100) */
121
+ combinedScore: number;
122
+ }
123
+ /**
124
+ * Reason why a memory was predicted
125
+ */
126
+ export type PredictionReason = "semantic_match" | "recent_related" | "team_trending" | "pattern_match" | "adjacent_discovery" | "expert_topic" | "prerequisite" | "frequently_used";
127
+ /**
128
+ * A single predicted memory with confidence and explanation
129
+ */
130
+ export interface PredictedMemory {
131
+ /** Memory ID */
132
+ id: string;
133
+ /** Memory title */
134
+ title: string;
135
+ /** Memory type */
136
+ type: MemoryTypeValue;
137
+ /** Memory tags */
138
+ tags: string[];
139
+ /** Content preview (first 300 chars) */
140
+ contentPreview: string;
141
+ /** Confidence score (0-100) */
142
+ confidence: number;
143
+ /** Human-readable explanation of why this was predicted */
144
+ reason: string;
145
+ /** Structured reason type */
146
+ reasonType: PredictionReason;
147
+ /** Detailed score breakdown */
148
+ scoreBreakdown: PredictionScoreBreakdown;
149
+ /** Days since memory was created */
150
+ daysSinceCreated: number;
151
+ /** Days since memory was last accessed */
152
+ daysSinceAccessed?: number;
153
+ /** Suggested action for the user */
154
+ suggestedAction: "review" | "apply" | "reference" | "explore";
155
+ /** Related topic clusters */
156
+ relatedTopics?: string[];
157
+ }
158
+ /**
159
+ * Result of predictive recall operation
160
+ */
161
+ export interface PredictiveRecallResult {
162
+ /** Predicted memories ranked by confidence */
163
+ predictions: PredictedMemory[];
164
+ /** Total predictions returned */
165
+ totalPredictions: number;
166
+ /** Total memories analyzed */
167
+ memoriesAnalyzed: number;
168
+ /** Context that was used for prediction */
169
+ contextUsed: {
170
+ projectContext: boolean;
171
+ topicsContext: boolean;
172
+ filesContext: boolean;
173
+ textContext: boolean;
174
+ teamContext: boolean;
175
+ };
176
+ /** Scoring weights used */
177
+ scoringWeights: {
178
+ semantic: number;
179
+ temporal: number;
180
+ frequency: number;
181
+ serendipity: number;
182
+ };
183
+ /** Algorithm metadata */
184
+ algorithmInfo: {
185
+ version: string;
186
+ embeddingModel: string;
187
+ timeWindowDays: number;
188
+ };
189
+ /** Timestamp of prediction */
190
+ generatedAt: string;
191
+ }
192
+ /**
193
+ * Internal memory representation with embedding for scoring
194
+ */
195
+ export interface ScoredMemoryCandidate {
196
+ id: string;
197
+ title: string;
198
+ content: string;
199
+ type: MemoryTypeValue;
200
+ tags: string[];
201
+ embedding: number[];
202
+ createdAt: Date;
203
+ updatedAt: Date;
204
+ metadata?: Record<string, any>;
205
+ accessCount?: number;
206
+ }
207
+ /**
208
+ * Scoring configuration (tunable weights)
209
+ */
210
+ export interface PredictionScoringConfig {
211
+ /** Weight for semantic similarity (default: 0.40) */
212
+ semanticWeight: number;
213
+ /** Weight for temporal relevance (default: 0.30) */
214
+ temporalWeight: number;
215
+ /** Weight for usage frequency (default: 0.20) */
216
+ frequencyWeight: number;
217
+ /** Weight for serendipity (default: 0.10) */
218
+ serendipityWeight: number;
219
+ /** Decay rate for temporal scoring (half-life in days) */
220
+ temporalDecayHalfLife: number;
221
+ /** Similarity threshold for semantic matching */
222
+ semanticThreshold: number;
223
+ /** Serendipity similarity range (min-max for "adjacent" topics) */
224
+ serendipityRange: {
225
+ min: number;
226
+ max: number;
227
+ };
228
+ }
229
+ /**
230
+ * Default scoring configuration
231
+ */
232
+ export declare const DEFAULT_SCORING_CONFIG: PredictionScoringConfig;
233
+ /**
234
+ * User feedback on a prediction
235
+ */
236
+ export interface PredictionFeedback {
237
+ /** Prediction/memory ID */
238
+ memoryId: string;
239
+ /** User ID */
240
+ userId: string;
241
+ /** Was this prediction useful? */
242
+ useful: boolean;
243
+ /** Action taken */
244
+ action: "clicked" | "saved" | "dismissed" | "ignored";
245
+ /** Optional reason for dismissal */
246
+ dismissReason?: "not_relevant" | "already_know" | "not_now" | "other";
247
+ /** Timestamp */
248
+ timestamp: string;
249
+ }
250
+ /**
251
+ * Aggregated feedback for model improvement
252
+ */
253
+ export interface PredictionAccuracyMetrics {
254
+ /** Total predictions made */
255
+ totalPredictions: number;
256
+ /** Predictions marked as useful */
257
+ usefulPredictions: number;
258
+ /** Predictions clicked/engaged */
259
+ engagedPredictions: number;
260
+ /** Accuracy rate (useful / total) */
261
+ accuracyRate: number;
262
+ /** Engagement rate (engaged / total) */
263
+ engagementRate: number;
264
+ /** Time period analyzed */
265
+ timePeriod: {
266
+ start: string;
267
+ end: string;
268
+ };
269
+ }
270
+ //# sourceMappingURL=prediction-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prediction-types.d.ts","sourceRoot":"","sources":["../../src/core/prediction-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMjE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,qCAAqC;IACrC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IAExB,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB,iEAAiE;IACjE,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc;IAC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B;IACxC,6BAA6B;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IAEzB,mCAAmC;IACnC,iBAAiB,EAAE,MAAM,CAAC;IAE1B,kCAAkC;IAClC,kBAAkB,EAAE,MAAM,CAAC;IAE3B,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IAErB,wCAAwC;IACxC,cAAc,EAAE,MAAM,CAAC;IAEvB,2BAA2B;IAC3B,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;CACH"}
@@ -12,7 +12,10 @@ export type MemoryTypeValue = z.infer<typeof MemoryType>;
12
12
  export type ProcessingMode = 'api' | 'offline-fallback';
13
13
  export interface MemoryIntelligenceConfig {
14
14
  apiUrl?: string;
15
- apiKey: string;
15
+ apiKey?: string;
16
+ authToken?: string;
17
+ authType?: 'apiKey' | 'bearer';
18
+ allowMissingAuth?: boolean;
16
19
  timeout?: number;
17
20
  responseFormat?: ResponseFormatType;
18
21
  headers?: Record<string, string>;
@@ -135,56 +138,76 @@ export interface RelatedMemoriesResult {
135
138
  related_memories: RelatedMemory[];
136
139
  total_found: number;
137
140
  }
138
- export interface DuplicatePair {
139
- memory_1: {
140
- id: string;
141
- title: string;
142
- created_at: string;
143
- };
144
- memory_2: {
145
- id: string;
146
- title: string;
147
- created_at: string;
148
- };
141
+ export interface DuplicateEntry {
142
+ id: string;
143
+ title: string;
144
+ similarity: number;
145
+ created_at: string;
146
+ }
147
+ export interface DuplicateGroup {
148
+ primary_id: string;
149
+ primary_title: string;
150
+ duplicates: DuplicateEntry[];
149
151
  similarity_score: number;
150
- recommendation: "keep_newer" | "keep_older" | "merge" | "review_manually";
151
- reasoning: string;
152
152
  }
153
153
  export interface DuplicatesResult {
154
- total_memories_analyzed: number;
155
- duplicate_pairs_found: number;
156
- duplicate_pairs: DuplicatePair[];
157
- estimated_storage_savings: string;
154
+ duplicate_groups: DuplicateGroup[];
155
+ total_groups: number;
156
+ total_duplicates: number;
157
+ detection_method: "semantic" | "text";
158
+ threshold_used: number;
159
+ memories_analyzed: number;
160
+ potential_storage_savings: string;
158
161
  }
159
162
  export interface Insight {
160
- category: "pattern" | "learning" | "opportunity" | "risk" | "action_item";
161
- title: string;
162
- description: string;
163
+ type: "themes" | "connections" | "gaps" | "actions" | "summary";
164
+ content: string;
163
165
  confidence: number;
164
- supporting_memories: string[];
166
+ related_memory_ids: string[];
165
167
  }
166
168
  export interface InsightsResult {
167
- total_memories_analyzed: number;
168
169
  insights: Insight[];
169
- summary: string;
170
- topic_filter?: string;
171
- type_filter?: string;
170
+ overall_summary: string;
171
+ memories_analyzed: number;
172
+ insight_types: string[];
173
+ topic_filter?: string | null;
174
+ generated_at: string;
175
+ }
176
+ export interface HealthScoreBreakdown {
177
+ organization: number;
178
+ tagging: number;
179
+ recency: number;
180
+ completeness: number;
181
+ diversity: number;
182
+ }
183
+ export interface HealthScore {
184
+ overall: number;
185
+ breakdown: HealthScoreBreakdown;
186
+ }
187
+ export interface HealthStatistics {
188
+ total_memories: number;
189
+ active_memories: number;
190
+ archived_memories: number;
191
+ memories_with_tags: number;
192
+ unique_tags: number;
193
+ memory_types: number;
194
+ recent_memories_30d: number;
195
+ stale_memories_90d: number;
196
+ }
197
+ export interface HealthIssue {
198
+ severity: "high" | "medium" | "low";
199
+ category: string;
200
+ description: string;
201
+ affected_count: number;
202
+ recommendation: string;
172
203
  }
173
204
  export interface MemoryHealth {
174
- user_id: string;
175
- health_score: number;
176
- metrics: {
177
- total_memories: number;
178
- memories_with_embeddings: number;
179
- embedding_coverage_percentage: number;
180
- memories_with_tags: number;
181
- tagging_percentage: number;
182
- average_tags_per_memory: number;
183
- memories_by_type: Record<string, number>;
184
- };
185
- issues: string[];
205
+ health_score: HealthScore;
206
+ status: "excellent" | "good" | "needs_attention" | "poor";
207
+ statistics: HealthStatistics;
208
+ issues: HealthIssue[];
186
209
  recommendations: string[];
187
- analysis_date: string;
210
+ generated_at: string;
188
211
  }
189
212
  export interface MemoryEntry {
190
213
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc;;;CAGjB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAGtF,eAAO,MAAM,UAAU,qFAOrB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAGzD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,kBAAkB,CAAC;AAGxD,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,kBAAkB,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;IACF,KAAK,CAAC,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,SAAS,CAAC,EAAE;QACV,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AC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,WAAW,CAAC;IAC1B,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,iBAAiB,GAAG,MAAM,CAAC;IAC1D,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB;AAGD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAGD,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B"}
package/dist/index.cjs CHANGED
@@ -157,23 +157,48 @@ var HttpClient = class {
157
157
  processingMode;
158
158
  cache;
159
159
  constructor(config) {
160
- if (!config.apiKey) {
161
- throw new ConfigurationError("API key is required");
162
- }
163
- if (!config.apiKey.startsWith("lano_")) {
160
+ this.apiUrl = config.apiUrl.replace(/\/$/, "");
161
+ let authType;
162
+ if (config.authType) {
163
+ authType = config.authType;
164
+ } else if (config.apiKey) {
165
+ authType = "apiKey";
166
+ } else if (config.authToken) {
167
+ authType = "bearer";
168
+ } else if (config.allowMissingAuth) {
169
+ authType = "apiKey";
170
+ } else {
164
171
  throw new ConfigurationError(
165
- "Invalid API key format. API key should start with 'lano_'"
172
+ "Authentication required: provide apiKey, authToken, or set allowMissingAuth to true"
166
173
  );
167
174
  }
168
- this.apiUrl = config.apiUrl.replace(/\/$/, "");
175
+ const allowMissingAuth = Boolean(config.allowMissingAuth);
176
+ if (authType === "apiKey") {
177
+ if (!config.apiKey && !allowMissingAuth) {
178
+ throw new ConfigurationError("API key is required when authType is 'apiKey'");
179
+ }
180
+ if (config.apiKey && !config.apiKey.startsWith("lano_")) {
181
+ throw new ConfigurationError(
182
+ "Invalid API key format. API key should start with 'lano_'"
183
+ );
184
+ }
185
+ } else if (!config.authToken && !allowMissingAuth) {
186
+ throw new ConfigurationError("Bearer token is required when authType is 'bearer'");
187
+ }
169
188
  this.apiKey = config.apiKey;
170
189
  this.timeout = config.timeout || 3e4;
171
190
  this.processingMode = config.processingMode || "api";
172
- this.headers = {
191
+ const baseHeaders = {
173
192
  "Content-Type": "application/json",
174
- "X-API-Key": this.apiKey,
175
193
  ...config.headers
176
194
  };
195
+ if (authType === "apiKey" && this.apiKey && !("X-API-Key" in baseHeaders)) {
196
+ baseHeaders["X-API-Key"] = this.apiKey;
197
+ }
198
+ if (authType === "bearer" && config.authToken && !("Authorization" in baseHeaders)) {
199
+ baseHeaders["Authorization"] = `Bearer ${config.authToken}`;
200
+ }
201
+ this.headers = baseHeaders;
177
202
  if (config.enableCache !== false && this.processingMode === "offline-fallback") {
178
203
  this.cache = new ResponseCache(config.cacheTTL || 3e5);
179
204
  } else {
@@ -333,15 +358,14 @@ var MemoryIntelligenceClient = class {
333
358
  defaultResponseFormat;
334
359
  processingMode;
335
360
  constructor(config) {
336
- if (!config.apiKey) {
337
- throw new ConfigurationError(
338
- "Missing required configuration: apiKey is required (format: lano_xxxxxxxxxx)"
339
- );
340
- }
341
361
  this.processingMode = config.processingMode || "api";
362
+ const authType = config.authType || (config.apiKey ? "apiKey" : "bearer");
342
363
  this.httpClient = new HttpClient({
343
364
  apiUrl: config.apiUrl || DEFAULT_API_URL,
344
365
  apiKey: config.apiKey,
366
+ authToken: config.authToken,
367
+ authType,
368
+ allowMissingAuth: config.allowMissingAuth,
345
369
  timeout: config.timeout,
346
370
  headers: config.headers,
347
371
  processingMode: this.processingMode,
@@ -521,6 +545,75 @@ var MemoryIntelligenceClient = class {
521
545
  fromCache: response.fromCache
522
546
  };
523
547
  }
548
+ /**
549
+ * Predictive Memory Recall - AI that anticipates what you need
550
+ *
551
+ * Uses a weighted scoring algorithm:
552
+ * - Semantic similarity to current context (40%)
553
+ * - Temporal relevance (recency decay curve) (30%)
554
+ * - Usage frequency (20%)
555
+ * - Serendipity factor (adjacent discoveries) (10%)
556
+ *
557
+ * @example
558
+ * ```typescript
559
+ * const result = await client.predictiveRecall({
560
+ * userId: "user-123",
561
+ * context: {
562
+ * currentProject: "Building dashboard components",
563
+ * recentTopics: ["React", "performance", "hooks"],
564
+ * contextText: "Optimizing render performance for data tables"
565
+ * },
566
+ * limit: 5,
567
+ * minConfidence: 50
568
+ * });
569
+ *
570
+ * for (const prediction of result.data.predictions) {
571
+ * console.log(`[${prediction.confidence}%] ${prediction.title}`);
572
+ * console.log(` Reason: ${prediction.reason}`);
573
+ * console.log(` Action: ${prediction.suggestedAction}`);
574
+ * }
575
+ * ```
576
+ */
577
+ async predictiveRecall(params) {
578
+ const response = await this.httpClient.postEnhanced(
579
+ "/intelligence/predictive-recall",
580
+ {
581
+ userId: params.userId,
582
+ context: params.context,
583
+ limit: params.limit || 5,
584
+ minConfidence: params.minConfidence || 40,
585
+ includeSerendipity: params.includeSerendipity !== false,
586
+ memoryTypes: params.memoryTypes,
587
+ timeWindowDays: params.timeWindowDays || 90,
588
+ responseFormat: params.responseFormat || this.defaultResponseFormat
589
+ }
590
+ );
591
+ if (response.error) {
592
+ throw new DatabaseError(`Failed to get predictions: ${response.error.message}`);
593
+ }
594
+ return {
595
+ data: response.data,
596
+ usage: response.usage,
597
+ tier_info: response.tier_info,
598
+ fromCache: response.fromCache
599
+ };
600
+ }
601
+ /**
602
+ * Record feedback on a prediction (for improving accuracy over time)
603
+ *
604
+ * @example
605
+ * ```typescript
606
+ * await client.recordPredictionFeedback({
607
+ * memoryId: "mem-123",
608
+ * userId: "user-123",
609
+ * useful: true,
610
+ * action: "clicked"
611
+ * });
612
+ * ```
613
+ */
614
+ async recordPredictionFeedback(params) {
615
+ await this.httpClient.post("/intelligence/prediction-feedback", params);
616
+ }
524
617
  };
525
618
  var ResponseFormat = {
526
619
  JSON: "json",