@lanonasis/mem-intel-sdk 1.1.0 → 2.0.0
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.
- package/CHANGELOG.md +230 -15
- package/README.md +258 -4
- package/dist/core/client.d.ts +51 -0
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/index.cjs +109 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +108 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/prediction-types.d.ts +270 -0
- package/dist/core/prediction-types.d.ts.map +1 -0
- package/dist/core/types.d.ts +58 -38
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.cjs +69 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -1
- package/dist/node/index.cjs +69 -0
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +69 -0
- package/dist/node/index.js.map +1 -1
- package/dist/react/hooks/useMemoryIntelligence.d.ts +83 -0
- package/dist/react/hooks/useMemoryIntelligence.d.ts.map +1 -1
- package/dist/react/index.cjs +69 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +69 -0
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.cjs +306 -27
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +306 -27
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp-server.d.ts.map +1 -1
- package/dist/utils/prediction-engine.d.ts +90 -0
- package/dist/utils/prediction-engine.d.ts.map +1 -0
- package/dist/vue/composables/useMemoryIntelligence.d.ts +59 -0
- package/dist/vue/composables/useMemoryIntelligence.d.ts.map +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,171 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [2.0.0] - 2026-01-13
|
|
11
|
+
|
|
12
|
+
### The AI That Anticipates What You Need
|
|
13
|
+
|
|
14
|
+
This major release introduces the **Predictive Memory System** - the flagship Phase 2 feature that makes your memory system feel magical. Instead of just storing and retrieving memories, the SDK now **predicts what you'll need before you realize it**.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
#### Predictive Memory System (Phase 2A)
|
|
19
|
+
|
|
20
|
+
- **`predictiveRecall()`** - AI-powered prediction of memories based on current context
|
|
21
|
+
- **Weighted Scoring Algorithm**:
|
|
22
|
+
- Semantic similarity to current context (40%)
|
|
23
|
+
- Temporal relevance with Ebbinghaus decay curve (30%)
|
|
24
|
+
- Usage frequency, logarithmically scaled (20%)
|
|
25
|
+
- Serendipity factor for adjacent discoveries (10%)
|
|
26
|
+
- **Explainable Predictions** - Every prediction includes:
|
|
27
|
+
- Confidence score (0-100)
|
|
28
|
+
- Human-readable reason ("Highly relevant to your current work")
|
|
29
|
+
- Score breakdown for transparency
|
|
30
|
+
- Suggested action (apply, review, explore, reference)
|
|
31
|
+
|
|
32
|
+
#### Personalization
|
|
33
|
+
|
|
34
|
+
- **User Profile Integration** - Fetches first name, email, organization for personalized responses
|
|
35
|
+
- **Personalized Greetings** - "Sarah, here's what you might need" instead of generic messages
|
|
36
|
+
- **Contextual Feedback** - "Thanks Sarah! We'll use this to improve your predictions."
|
|
37
|
+
|
|
38
|
+
#### Premium Tier Gating
|
|
39
|
+
|
|
40
|
+
- **`checkPremiumAccess()`** - Validate feature access by subscription tier
|
|
41
|
+
- **Tier-Based Access Control** - Free, Pro, Business, Enterprise tiers
|
|
42
|
+
- **Feature Flags** - Granular per-feature access control
|
|
43
|
+
- **Graceful Degradation** - If checks fail, defaults to allowing access
|
|
44
|
+
|
|
45
|
+
#### Prediction Feedback Loop
|
|
46
|
+
|
|
47
|
+
- **`recordPredictionFeedback()`** - Track if predictions were useful
|
|
48
|
+
- **`getPredictionMetrics()`** - Dashboard metrics for prediction accuracy
|
|
49
|
+
- **Access Count Updates** - Predictions that get clicked/saved improve frequency scoring
|
|
50
|
+
|
|
51
|
+
#### MCP Tools
|
|
52
|
+
|
|
53
|
+
- **`memory_predictive_recall`** - Full MCP tool with markdown formatting
|
|
54
|
+
- **`memory_prediction_feedback`** - Record user feedback on predictions
|
|
55
|
+
|
|
56
|
+
#### React Integration
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
// New hooks for predictions
|
|
60
|
+
const { data } = usePredictiveRecall({
|
|
61
|
+
userId: "user-123",
|
|
62
|
+
context: {
|
|
63
|
+
currentProject: "Building dashboard",
|
|
64
|
+
recentTopics: ["React", "performance"]
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Feedback hook
|
|
69
|
+
const { mutate: recordFeedback } = usePredictionFeedback();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
#### Vue Integration
|
|
73
|
+
|
|
74
|
+
```vue
|
|
75
|
+
<script setup>
|
|
76
|
+
const { data, execute } = usePredictiveRecall();
|
|
77
|
+
const { execute: recordFeedback } = usePredictionFeedback();
|
|
78
|
+
</script>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Database Infrastructure
|
|
82
|
+
|
|
83
|
+
New migration file `supabase/migrations/20260113_prediction_system.sql` includes:
|
|
84
|
+
|
|
85
|
+
| Component | Purpose |
|
|
86
|
+
|-----------|---------|
|
|
87
|
+
| `prediction_feedback` table | Track prediction accuracy |
|
|
88
|
+
| `prediction_history` table | Audit log of predictions |
|
|
89
|
+
| `increment_access_count()` | Update frequency scores |
|
|
90
|
+
| `get_user_profile_for_predictions()` | Personalization data |
|
|
91
|
+
| `has_premium_feature()` | Tier-based access control |
|
|
92
|
+
| `get_prediction_accuracy()` | Metrics calculation |
|
|
93
|
+
|
|
94
|
+
### Changed
|
|
95
|
+
|
|
96
|
+
- **Version bump** - 1.1.0 → 2.0.0 (major version for significant new capabilities)
|
|
97
|
+
- **Package description** - Updated to highlight predictive recall
|
|
98
|
+
- **Keywords** - Added: predictive, predictions, embeddings, vector-search, personalization, machine-learning
|
|
99
|
+
|
|
100
|
+
### Technical Details
|
|
101
|
+
|
|
102
|
+
#### Prediction Algorithm
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
Combined Score = (Semantic × 40%) + (Temporal × 30%) + (Frequency × 20%) + (Serendipity × 10%)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- **Semantic**: Cosine similarity between context embedding and memory embedding
|
|
109
|
+
- **Temporal**: Exponential decay (Ebbinghaus forgetting curve, 14-day half-life)
|
|
110
|
+
- **Frequency**: Logarithmic scaling of access counts (prevents outliers from dominating)
|
|
111
|
+
- **Serendipity**: "Adjacent possible" - rewards nearby-but-not-identical topics (0.3-0.6 similarity range)
|
|
112
|
+
|
|
113
|
+
#### Context Types
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
interface PredictiveContext {
|
|
117
|
+
currentProject?: string; // "Building dashboard components"
|
|
118
|
+
recentTopics?: string[]; // ["React", "TypeScript", "performance"]
|
|
119
|
+
activeFiles?: string[]; // ["/src/Dashboard.tsx"]
|
|
120
|
+
contextText?: string; // Free-form: "Optimizing render performance"
|
|
121
|
+
teamContext?: string; // "Team discussing caching strategies"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Migration Guide
|
|
126
|
+
|
|
127
|
+
1. **Run database migration**:
|
|
128
|
+
```bash
|
|
129
|
+
# Copy SQL from supabase/migrations/20260113_prediction_system.sql
|
|
130
|
+
# Execute in Supabase SQL Editor
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
2. **Enable for users** (optional premium gating):
|
|
134
|
+
```sql
|
|
135
|
+
UPDATE profiles
|
|
136
|
+
SET subscription_tier = 'pro',
|
|
137
|
+
feature_flags = '{"predictive_recall": true}'::jsonb
|
|
138
|
+
WHERE id = 'user-uuid';
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
3. **Use new methods**:
|
|
142
|
+
```typescript
|
|
143
|
+
// Before (1.x) - manual search
|
|
144
|
+
const related = await client.findRelated({ memoryId, userId });
|
|
145
|
+
|
|
146
|
+
// After (2.x) - AI anticipates what you need
|
|
147
|
+
const predictions = await client.predictiveRecall({
|
|
148
|
+
userId,
|
|
149
|
+
context: { currentProject: "My current work" }
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## [1.1.0] - 2025-12-20
|
|
156
|
+
|
|
157
|
+
### Added
|
|
158
|
+
|
|
159
|
+
- **Behavioral Intelligence Foundation** (Context Patterns v2.0)
|
|
160
|
+
- `recordBehavior()` - Store workflow patterns
|
|
161
|
+
- `recallBehavior()` - Query patterns with local-first approach
|
|
162
|
+
- `suggestBehavior()` - AI-powered next action suggestions
|
|
163
|
+
- WorkflowPattern type with trigger, context, actions, outcome tracking
|
|
164
|
+
|
|
165
|
+
### Improved
|
|
166
|
+
|
|
167
|
+
- Enhanced offline-fallback caching
|
|
168
|
+
- Better error messages for API failures
|
|
169
|
+
- Response adapter handles both Edge Function envelope and direct responses
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
8
173
|
## [1.0.1] - 2025-12-18
|
|
9
174
|
|
|
10
175
|
### Fixed
|
|
@@ -20,25 +185,75 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
20
185
|
- Improved error messages in core error classes
|
|
21
186
|
- Better handling of OpenAI client initialization
|
|
22
187
|
|
|
188
|
+
---
|
|
189
|
+
|
|
23
190
|
## [1.0.0] - 2024-12-17
|
|
24
191
|
|
|
192
|
+
### Initial Release
|
|
193
|
+
|
|
194
|
+
The first release of `@lanonasis/mem-intel-sdk` - an AI-powered memory intelligence SDK for the LanOnasis Memory-as-a-Service platform.
|
|
195
|
+
|
|
25
196
|
### Added
|
|
26
197
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
198
|
+
#### Core Features
|
|
199
|
+
|
|
200
|
+
- **`MemoryIntelligenceClient`** - Universal API client with offline-fallback capability
|
|
201
|
+
- **Framework Integrations**:
|
|
202
|
+
- React hooks with React Query (`/react`)
|
|
31
203
|
- Vue composables (`/vue`)
|
|
32
204
|
- Node.js optimized client (`/node`)
|
|
33
205
|
- MCP Server creation (`/server`)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
206
|
+
|
|
207
|
+
#### Intelligence Tools
|
|
208
|
+
|
|
209
|
+
| Tool | Description |
|
|
210
|
+
|------|-------------|
|
|
211
|
+
| `analyzePatterns` | Understand usage trends and productivity patterns |
|
|
212
|
+
| `suggestTags` | AI-powered tag suggestions with confidence scores |
|
|
213
|
+
| `findRelated` | Find semantically related memories using vector similarity |
|
|
214
|
+
| `detectDuplicates` | Identify duplicate or near-duplicate memories |
|
|
215
|
+
| `extractInsights` | Extract key learnings from your knowledge base |
|
|
216
|
+
| `healthCheck` | Analyze organization quality with actionable recommendations |
|
|
217
|
+
|
|
218
|
+
#### Developer Experience
|
|
219
|
+
|
|
220
|
+
- Full TypeScript support with comprehensive type definitions
|
|
221
|
+
- Dual module support (ESM and CommonJS)
|
|
222
|
+
- Custom error classes for better debugging
|
|
223
|
+
- Dual response format (JSON and Markdown)
|
|
224
|
+
- Zod schema validation for MCP tools
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Roadmap
|
|
229
|
+
|
|
230
|
+
### Coming in 2.1.0 (Q1 2026)
|
|
231
|
+
|
|
232
|
+
- **Knowledge Gap Detection** - "What should I learn next?"
|
|
233
|
+
- Personalized learning paths based on your saved memories
|
|
234
|
+
- Integration with YouTube, Medium, Dev.to for resources
|
|
235
|
+
|
|
236
|
+
### Coming in 2.2.0 (Q2 2026)
|
|
237
|
+
|
|
238
|
+
- **Team Knowledge Graph** - "Who's the expert on X?"
|
|
239
|
+
- Privacy-first aggregation (no individual data exposed)
|
|
240
|
+
- Expert finder with topic expertise scoring
|
|
241
|
+
|
|
242
|
+
### Coming in 3.0.0 (Q3 2026)
|
|
243
|
+
|
|
244
|
+
- **Privacy-First Local Processing** - ONNX Runtime on-device
|
|
245
|
+
- **Autonomous Organization Agent** - Weekly AI cleanup
|
|
246
|
+
- **API Marketplace** - Developer ecosystem with 70/30 revenue share
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Links
|
|
251
|
+
|
|
252
|
+
- [GitHub Repository](https://github.com/lanonasis/memory-intelligence-engine)
|
|
253
|
+
- [npm Package](https://www.npmjs.com/package/@lanonasis/mem-intel-sdk)
|
|
254
|
+
- [Product Roadmap](./PRODUCT-ROADMAP-2025-2026.md)
|
|
255
|
+
- [Migration Guide](./supabase/migrations/20260113_prediction_system.sql)
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
Built with care by the LanOnasis team. We believe AI should anticipate your needs, not just respond to commands.
|
package/README.md
CHANGED
|
@@ -2,11 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@lanonasis/mem-intel-sdk)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://www.typescriptlang.org/)
|
|
6
|
+
[]()
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
**The AI that anticipates what you need before you realize it.**
|
|
9
|
+
|
|
10
|
+
An AI-powered memory intelligence SDK for the LanOnasis Memory-as-a-Service platform. Beyond storage and retrieval - this SDK **predicts** what memories you'll need based on your current context.
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// The magic moment
|
|
14
|
+
const predictions = await client.predictiveRecall({
|
|
15
|
+
userId: "user-123",
|
|
16
|
+
context: {
|
|
17
|
+
currentProject: "Building dashboard components",
|
|
18
|
+
recentTopics: ["React", "performance"]
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// "Sarah, here's what you might need"
|
|
23
|
+
// [92%] React Hooks Performance Optimization
|
|
24
|
+
// → Reason: Highly relevant to your current work
|
|
25
|
+
// → Action: Apply
|
|
26
|
+
```
|
|
7
27
|
|
|
8
28
|
## Features
|
|
9
29
|
|
|
30
|
+
### NEW in v2.0.0: Predictive Memory System
|
|
31
|
+
|
|
32
|
+
- **Predictive Recall** - AI anticipates what you'll need before you search
|
|
33
|
+
- **Personalized Responses** - "Sarah, here's what you might need"
|
|
34
|
+
- **Explainable Predictions** - Every suggestion includes confidence score and reasoning
|
|
35
|
+
- **Learning Loop** - Feedback improves future predictions
|
|
36
|
+
|
|
37
|
+
### Core Intelligence
|
|
38
|
+
|
|
10
39
|
- **Pattern Recognition** - Understand usage trends and productivity patterns
|
|
11
40
|
- **Smart Organization** - AI-powered tag suggestions and duplicate detection
|
|
12
41
|
- **Semantic Intelligence** - Find related memories using vector similarity
|
|
@@ -126,6 +155,129 @@ onMounted(() => {
|
|
|
126
155
|
</script>
|
|
127
156
|
```
|
|
128
157
|
|
|
158
|
+
## Predictive Memory System (v2.0.0)
|
|
159
|
+
|
|
160
|
+
The flagship feature that makes your memory system feel magical.
|
|
161
|
+
|
|
162
|
+
### How It Works
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Your Current Context
|
|
166
|
+
│
|
|
167
|
+
▼
|
|
168
|
+
┌──────────────────────────────────────────┐
|
|
169
|
+
│ PREDICTION ENGINE │
|
|
170
|
+
│ │
|
|
171
|
+
│ Semantic (40%) ─┐ │
|
|
172
|
+
│ Temporal (30%) ─┼──► Combined Score │
|
|
173
|
+
│ Frequency (20%) ─┤ │
|
|
174
|
+
│ Serendipity (10%)┘ │
|
|
175
|
+
└──────────────────────────────────────────┘
|
|
176
|
+
│
|
|
177
|
+
▼
|
|
178
|
+
"Here's what you'll need"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Basic Usage
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
const predictions = await client.predictiveRecall({
|
|
185
|
+
userId: "user-123",
|
|
186
|
+
context: {
|
|
187
|
+
currentProject: "Building dashboard components",
|
|
188
|
+
recentTopics: ["React", "TypeScript", "performance"],
|
|
189
|
+
activeFiles: ["/src/components/Dashboard.tsx"],
|
|
190
|
+
contextText: "Optimizing render performance for data tables"
|
|
191
|
+
},
|
|
192
|
+
limit: 5,
|
|
193
|
+
minConfidence: 50
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Each prediction includes:
|
|
197
|
+
for (const pred of predictions.data.predictions) {
|
|
198
|
+
console.log(`[${pred.confidence}%] ${pred.title}`);
|
|
199
|
+
console.log(` Why: ${pred.reason}`);
|
|
200
|
+
console.log(` Action: ${pred.suggestedAction}`);
|
|
201
|
+
console.log(` Scores: semantic=${pred.scoreBreakdown.semanticScore}, temporal=${pred.scoreBreakdown.temporalScore}`);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### With Personalization
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// Response includes personalized greeting
|
|
209
|
+
const result = await client.predictiveRecall({
|
|
210
|
+
userId: "user-123",
|
|
211
|
+
context: { currentProject: "My project" }
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
console.log(result.personalization?.greeting);
|
|
215
|
+
// → "Sarah, here's what you might need"
|
|
216
|
+
|
|
217
|
+
console.log(result.personalization?.tier);
|
|
218
|
+
// → "pro"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Recording Feedback (Improves Future Predictions)
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
// When user clicks on a prediction
|
|
225
|
+
await client.recordPredictionFeedback({
|
|
226
|
+
memoryId: prediction.id,
|
|
227
|
+
userId: "user-123",
|
|
228
|
+
useful: true,
|
|
229
|
+
action: "clicked"
|
|
230
|
+
});
|
|
231
|
+
// → { success: true, message: "Thanks Sarah! We'll use this to improve your predictions." }
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### React Hook
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { usePredictiveRecall, usePredictionFeedback } from "@lanonasis/mem-intel-sdk/react";
|
|
238
|
+
|
|
239
|
+
function PredictionsPanel({ userId }) {
|
|
240
|
+
const { data, isLoading } = usePredictiveRecall({
|
|
241
|
+
userId,
|
|
242
|
+
context: {
|
|
243
|
+
currentProject: "Dashboard",
|
|
244
|
+
recentTopics: ["React", "charts"]
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const { mutate: recordFeedback } = usePredictionFeedback();
|
|
249
|
+
|
|
250
|
+
if (isLoading) return <div>Finding relevant memories...</div>;
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<div>
|
|
254
|
+
<h2>{data?.personalization?.greeting}</h2>
|
|
255
|
+
{data?.predictions.map(pred => (
|
|
256
|
+
<div key={pred.id} onClick={() => recordFeedback({
|
|
257
|
+
memoryId: pred.id,
|
|
258
|
+
userId,
|
|
259
|
+
useful: true,
|
|
260
|
+
action: "clicked"
|
|
261
|
+
})}>
|
|
262
|
+
<span className="confidence">{pred.confidence}%</span>
|
|
263
|
+
<h3>{pred.title}</h3>
|
|
264
|
+
<p>{pred.reason}</p>
|
|
265
|
+
</div>
|
|
266
|
+
))}
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Scoring Algorithm
|
|
273
|
+
|
|
274
|
+
| Factor | Weight | Description |
|
|
275
|
+
|--------|--------|-------------|
|
|
276
|
+
| **Semantic** | 40% | Cosine similarity between context embedding and memory embedding |
|
|
277
|
+
| **Temporal** | 30% | Exponential decay (Ebbinghaus curve, 14-day half-life) |
|
|
278
|
+
| **Frequency** | 20% | Logarithmic scaling of access counts |
|
|
279
|
+
| **Serendipity** | 10% | Bonus for "adjacent possible" discoveries (0.3-0.6 similarity) |
|
|
280
|
+
|
|
129
281
|
## Overview
|
|
130
282
|
|
|
131
283
|
This SDK is designed to **complement** your existing `@lanonasis/mcp-core` infrastructure by adding an intelligence layer on top of basic memory CRUD operations. While your core server handles memory creation, storage, and retrieval, this SDK focuses on:
|
|
@@ -341,6 +493,54 @@ Analyze the organization quality of your memory collection.
|
|
|
341
493
|
- Type balance analysis
|
|
342
494
|
- Actionable recommendations
|
|
343
495
|
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
### 7. `memory_predictive_recall` (NEW in v2.0.0)
|
|
499
|
+
|
|
500
|
+
AI-powered prediction of memories you'll need based on current context.
|
|
501
|
+
|
|
502
|
+
```json
|
|
503
|
+
{
|
|
504
|
+
"user_id": "uuid",
|
|
505
|
+
"context": {
|
|
506
|
+
"current_project": "Building dashboard components",
|
|
507
|
+
"recent_topics": ["React", "performance"],
|
|
508
|
+
"context_text": "Optimizing render performance"
|
|
509
|
+
},
|
|
510
|
+
"limit": 5,
|
|
511
|
+
"min_confidence": 50,
|
|
512
|
+
"include_serendipity": true
|
|
513
|
+
}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
**Returns:**
|
|
517
|
+
|
|
518
|
+
- Predicted memories with confidence scores
|
|
519
|
+
- Human-readable explanations
|
|
520
|
+
- Score breakdown (semantic, temporal, frequency, serendipity)
|
|
521
|
+
- Suggested actions (apply, review, explore, reference)
|
|
522
|
+
- Personalized greeting with user's name
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
### 8. `memory_prediction_feedback` (NEW in v2.0.0)
|
|
527
|
+
|
|
528
|
+
Record feedback on predictions to improve accuracy over time.
|
|
529
|
+
|
|
530
|
+
```json
|
|
531
|
+
{
|
|
532
|
+
"memory_id": "uuid",
|
|
533
|
+
"user_id": "uuid",
|
|
534
|
+
"useful": true,
|
|
535
|
+
"action": "clicked"
|
|
536
|
+
}
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
**Returns:**
|
|
540
|
+
|
|
541
|
+
- Personalized thank you message
|
|
542
|
+
- Feedback confirmation
|
|
543
|
+
|
|
344
544
|
## Integration with @lanonasis/mcp-core
|
|
345
545
|
|
|
346
546
|
This server is designed to work alongside your existing infrastructure:
|
|
@@ -470,11 +670,30 @@ Your Supabase database must have:
|
|
|
470
670
|
| **Testing** | Complex integration tests | Focused unit tests |
|
|
471
671
|
| **Reusability** | Tied to LanOnasis | Portable to other projects |
|
|
472
672
|
|
|
473
|
-
##
|
|
673
|
+
## What's Next
|
|
674
|
+
|
|
675
|
+
### v2.1.0 - Knowledge Gap Detection (Q1 2026)
|
|
676
|
+
|
|
677
|
+
- [ ] "What should I learn next?" recommendations
|
|
678
|
+
- [ ] Personalized learning paths
|
|
679
|
+
- [ ] Integration with YouTube, Medium, Dev.to
|
|
680
|
+
|
|
681
|
+
### v2.2.0 - Team Knowledge Graph (Q2 2026)
|
|
682
|
+
|
|
683
|
+
- [ ] "Who's the expert on X?" finder
|
|
684
|
+
- [ ] Privacy-first team aggregation
|
|
685
|
+
- [ ] Expertise scoring and visualization
|
|
686
|
+
|
|
687
|
+
### v3.0.0 - Market Leadership (Q3 2026)
|
|
688
|
+
|
|
689
|
+
- [ ] Privacy-first local processing (ONNX Runtime)
|
|
690
|
+
- [ ] Autonomous organization agent
|
|
691
|
+
- [ ] API marketplace with 70/30 revenue share
|
|
692
|
+
|
|
693
|
+
### Backlog
|
|
474
694
|
|
|
475
695
|
- [ ] Memory clustering with topic detection
|
|
476
696
|
- [ ] Automatic summarization of memory collections
|
|
477
|
-
- [ ] Knowledge graph visualization
|
|
478
697
|
- [ ] Anomaly detection in memory patterns
|
|
479
698
|
- [ ] Content quality scoring
|
|
480
699
|
- [ ] Multi-language support
|
|
@@ -510,10 +729,45 @@ npm publish --access public
|
|
|
510
729
|
|
|
511
730
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
512
731
|
|
|
732
|
+
## Database Setup (v2.0.0)
|
|
733
|
+
|
|
734
|
+
For predictive recall features, run the migration:
|
|
735
|
+
|
|
736
|
+
```bash
|
|
737
|
+
# Option 1: Supabase CLI
|
|
738
|
+
supabase db push
|
|
739
|
+
|
|
740
|
+
# Option 2: Copy SQL to Supabase SQL Editor
|
|
741
|
+
# File: supabase/migrations/20260113_prediction_system.sql
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
This creates:
|
|
745
|
+
|
|
746
|
+
- `prediction_feedback` - Track prediction accuracy
|
|
747
|
+
- `prediction_history` - Audit log
|
|
748
|
+
- `increment_access_count()` - Frequency scoring
|
|
749
|
+
- `get_user_profile_for_predictions()` - Personalization
|
|
750
|
+
- `has_premium_feature()` - Premium tier gating
|
|
751
|
+
- `get_prediction_accuracy()` - Metrics
|
|
752
|
+
|
|
753
|
+
### Premium Tier Setup (Optional)
|
|
754
|
+
|
|
755
|
+
```sql
|
|
756
|
+
-- Enable predictive recall for a user
|
|
757
|
+
UPDATE profiles
|
|
758
|
+
SET subscription_tier = 'pro',
|
|
759
|
+
feature_flags = '{"predictive_recall": true}'::jsonb
|
|
760
|
+
WHERE id = 'user-uuid';
|
|
761
|
+
```
|
|
762
|
+
|
|
513
763
|
## License
|
|
514
764
|
|
|
515
765
|
MIT License - See [LICENSE](./LICENSE) for details.
|
|
516
766
|
|
|
517
767
|
---
|
|
518
768
|
|
|
519
|
-
Built with
|
|
769
|
+
**Built with care by the LanOnasis team.**
|
|
770
|
+
|
|
771
|
+
We believe AI should anticipate your needs, not just respond to commands.
|
|
772
|
+
|
|
773
|
+
[GitHub](https://github.com/lanonasis/memory-intelligence-engine) | [npm](https://www.npmjs.com/package/@lanonasis/mem-intel-sdk) | [Changelog](./CHANGELOG.md)
|
package/dist/core/client.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Supports API-first with offline-fallback capability
|
|
4
4
|
*/
|
|
5
5
|
import { MemoryIntelligenceConfig, AnalyzePatternsParams, PatternAnalysis, SuggestTagsParams, TagSuggestionsResult, FindRelatedParams, RelatedMemoriesResult, DetectDuplicatesParams, DuplicatesResult, ExtractInsightsParams, InsightsResult, HealthCheckParams, MemoryHealth, QueryMemoriesOptions, MemoryEntry, ProcessingMode } from "./types.js";
|
|
6
|
+
import { PredictiveRecallParams, PredictiveRecallResult } from "./prediction-types.js";
|
|
6
7
|
import { HttpClient } from "../utils/http-client.js";
|
|
7
8
|
import { UsageInfo, TierInfo } from "../utils/response-adapter.js";
|
|
8
9
|
export interface IntelligenceResponse<T> {
|
|
@@ -60,5 +61,55 @@ export declare class MemoryIntelligenceClient {
|
|
|
60
61
|
* Check the health and organization quality of memories
|
|
61
62
|
*/
|
|
62
63
|
healthCheck(params: HealthCheckParams): Promise<IntelligenceResponse<MemoryHealth>>;
|
|
64
|
+
/**
|
|
65
|
+
* Predictive Memory Recall - AI that anticipates what you need
|
|
66
|
+
*
|
|
67
|
+
* Uses a weighted scoring algorithm:
|
|
68
|
+
* - Semantic similarity to current context (40%)
|
|
69
|
+
* - Temporal relevance (recency decay curve) (30%)
|
|
70
|
+
* - Usage frequency (20%)
|
|
71
|
+
* - Serendipity factor (adjacent discoveries) (10%)
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const result = await client.predictiveRecall({
|
|
76
|
+
* userId: "user-123",
|
|
77
|
+
* context: {
|
|
78
|
+
* currentProject: "Building dashboard components",
|
|
79
|
+
* recentTopics: ["React", "performance", "hooks"],
|
|
80
|
+
* contextText: "Optimizing render performance for data tables"
|
|
81
|
+
* },
|
|
82
|
+
* limit: 5,
|
|
83
|
+
* minConfidence: 50
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* for (const prediction of result.data.predictions) {
|
|
87
|
+
* console.log(`[${prediction.confidence}%] ${prediction.title}`);
|
|
88
|
+
* console.log(` Reason: ${prediction.reason}`);
|
|
89
|
+
* console.log(` Action: ${prediction.suggestedAction}`);
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
predictiveRecall(params: PredictiveRecallParams): Promise<IntelligenceResponse<PredictiveRecallResult>>;
|
|
94
|
+
/**
|
|
95
|
+
* Record feedback on a prediction (for improving accuracy over time)
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* await client.recordPredictionFeedback({
|
|
100
|
+
* memoryId: "mem-123",
|
|
101
|
+
* userId: "user-123",
|
|
102
|
+
* useful: true,
|
|
103
|
+
* action: "clicked"
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
recordPredictionFeedback(params: {
|
|
108
|
+
memoryId: string;
|
|
109
|
+
userId: string;
|
|
110
|
+
useful: boolean;
|
|
111
|
+
action: "clicked" | "saved" | "dismissed" | "ignored";
|
|
112
|
+
dismissReason?: "not_relevant" | "already_know" | "not_now" | "other";
|
|
113
|
+
}): Promise<void>;
|
|
63
114
|
}
|
|
64
115
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,cAAc,EACf,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,i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