@lanonasis/mem-intel-sdk 1.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 +28 -0
- package/LICENSE +21 -0
- package/README.md +490 -0
- package/dist/core/client.d.ts +43 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/errors.d.ts +24 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/index.cjs +310 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +300 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/types.d.ts +171 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index-sdk.d.ts +8 -0
- package/dist/index-sdk.d.ts.map +1 -0
- package/dist/index.cjs +310 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +300 -0
- package/dist/index.js.map +1 -0
- package/dist/node/client.d.ts +22 -0
- package/dist/node/client.d.ts.map +1 -0
- package/dist/node/index.cjs +331 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.ts +7 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +321 -0
- package/dist/node/index.js.map +1 -0
- package/dist/react/context/MemoryIntelligenceProvider.d.ts +18 -0
- package/dist/react/context/MemoryIntelligenceProvider.d.ts.map +1 -0
- package/dist/react/hooks/useMemoryIntelligence.d.ts +115 -0
- package/dist/react/hooks/useMemoryIntelligence.d.ts.map +1 -0
- package/dist/react/index.cjs +399 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +377 -0
- package/dist/react/index.js.map +1 -0
- package/dist/server/index.cjs +802 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +792 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/mcp-server.d.ts +7 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/utils/embeddings.d.ts +13 -0
- package/dist/utils/embeddings.d.ts.map +1 -0
- package/dist/utils/formatting.d.ts +13 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/http-client.d.ts +31 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/similarity.d.ts +8 -0
- package/dist/utils/similarity.d.ts.map +1 -0
- package/dist/vue/composables/useMemoryIntelligence.d.ts +24 -0
- package/dist/vue/composables/useMemoryIntelligence.d.ts.map +1 -0
- package/dist/vue/index.cjs +132 -0
- package/dist/vue/index.cjs.map +1 -0
- package/dist/vue/index.d.ts +7 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +115 -0
- package/dist/vue/index.js.map +1 -0
- package/package.json +144 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2024-12-17
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of `@lanonasis/mem-intel-sdk`
|
|
12
|
+
- Core `MemoryIntelligenceClient` with API-based architecture
|
|
13
|
+
- Framework integrations:
|
|
14
|
+
- React hooks with React Query integration (`/react`)
|
|
15
|
+
- Vue composables (`/vue`)
|
|
16
|
+
- Node.js optimized client (`/node`)
|
|
17
|
+
- MCP Server creation (`/server`)
|
|
18
|
+
- Memory intelligence features:
|
|
19
|
+
- `analyzePatterns` - Analyze usage patterns and trends
|
|
20
|
+
- `suggestTags` - AI-powered tag suggestions
|
|
21
|
+
- `findRelated` - Semantic similarity search
|
|
22
|
+
- `detectDuplicates` - Duplicate memory detection
|
|
23
|
+
- `extractInsights` - Extract insights from memories
|
|
24
|
+
- `healthCheck` - Memory collection health analysis
|
|
25
|
+
- TypeScript support with full type definitions
|
|
26
|
+
- Support for both ESM and CommonJS
|
|
27
|
+
- Comprehensive error handling with custom error classes
|
|
28
|
+
- Dual response format support (JSON and Markdown)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Lanonasis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
# Memory Intelligence SDK 🧠✨
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@lanonasis/mem-intel-sdk)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
An AI-powered memory intelligence SDK for the LanOnasis Memory-as-a-Service platform. Provides advanced analytics, insights, and intelligent organization features.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Pattern Recognition** - Understand usage trends and productivity patterns
|
|
11
|
+
- **Smart Organization** - AI-powered tag suggestions and duplicate detection
|
|
12
|
+
- **Semantic Intelligence** - Find related memories using vector similarity
|
|
13
|
+
- **Actionable Insights** - Extract key learnings and opportunities from your knowledge base
|
|
14
|
+
- **Health Monitoring** - Ensure your memory database stays organized and healthy
|
|
15
|
+
|
|
16
|
+
## Platform Support
|
|
17
|
+
|
|
18
|
+
- ✅ **Node.js** - Full support with environment variable configuration
|
|
19
|
+
- ✅ **Browser** - Universal client for web applications
|
|
20
|
+
- ✅ **React** - Hooks with React Query integration
|
|
21
|
+
- ✅ **Vue 3** - Composables for Vue applications
|
|
22
|
+
- ✅ **MCP Server** - Create Model Context Protocol servers
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# npm
|
|
28
|
+
npm install @lanonasis/mem-intel-sdk
|
|
29
|
+
|
|
30
|
+
# yarn
|
|
31
|
+
yarn add @lanonasis/mem-intel-sdk
|
|
32
|
+
|
|
33
|
+
# pnpm
|
|
34
|
+
pnpm add @lanonasis/mem-intel-sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Framework-specific peer dependencies
|
|
38
|
+
|
|
39
|
+
For React applications:
|
|
40
|
+
```bash
|
|
41
|
+
npm install react @tanstack/react-query
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For Vue applications:
|
|
45
|
+
```bash
|
|
46
|
+
npm install vue
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
For MCP Server:
|
|
50
|
+
```bash
|
|
51
|
+
npm install @modelcontextprotocol/sdk
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
### Basic Usage
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { MemoryIntelligenceClient } from '@lanonasis/mem-intel-sdk';
|
|
60
|
+
|
|
61
|
+
const client = new MemoryIntelligenceClient({
|
|
62
|
+
apiKey: 'lano_xxxxxxxxxx', // Your Lanonasis API key
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Analyze memory patterns
|
|
66
|
+
const analysis = await client.analyzePatterns({
|
|
67
|
+
userId: 'user-123',
|
|
68
|
+
timeRangeDays: 30,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
console.log(`Total memories: ${analysis.total_memories}`);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Node.js with Environment Variables
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { NodeMemoryIntelligenceClient } from '@lanonasis/mem-intel-sdk/node';
|
|
78
|
+
|
|
79
|
+
// Automatically reads LANONASIS_API_KEY from environment
|
|
80
|
+
const client = NodeMemoryIntelligenceClient.fromEnv();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### React Integration
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { MemoryIntelligenceProvider, usePatternAnalysis } from '@lanonasis/mem-intel-sdk/react';
|
|
87
|
+
|
|
88
|
+
// Wrap your app
|
|
89
|
+
function App() {
|
|
90
|
+
return (
|
|
91
|
+
<MemoryIntelligenceProvider config={{ apiKey: 'lano_xxx' }}>
|
|
92
|
+
<Dashboard />
|
|
93
|
+
</MemoryIntelligenceProvider>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Use hooks in components
|
|
98
|
+
function Dashboard() {
|
|
99
|
+
const { data, isLoading } = usePatternAnalysis({
|
|
100
|
+
userId: 'user-123',
|
|
101
|
+
timeRangeDays: 30,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
if (isLoading) return <div>Loading...</div>;
|
|
105
|
+
return <div>Total: {data?.total_memories}</div>;
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Vue Integration
|
|
110
|
+
|
|
111
|
+
```vue
|
|
112
|
+
<script setup>
|
|
113
|
+
import { usePatternAnalysis } from '@lanonasis/mem-intel-sdk/vue';
|
|
114
|
+
|
|
115
|
+
const { data, loading, execute } = usePatternAnalysis();
|
|
116
|
+
|
|
117
|
+
onMounted(() => {
|
|
118
|
+
execute({ userId: 'user-123', timeRangeDays: 30 });
|
|
119
|
+
});
|
|
120
|
+
</script>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Overview
|
|
124
|
+
|
|
125
|
+
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:
|
|
126
|
+
|
|
127
|
+
- **Pattern Recognition** - Understand usage trends and productivity patterns
|
|
128
|
+
- **Smart Organization** - AI-powered tag suggestions and duplicate detection
|
|
129
|
+
- **Semantic Intelligence** - Find related memories using vector similarity
|
|
130
|
+
- **Actionable Insights** - Extract key learnings and opportunities from your knowledge base
|
|
131
|
+
- **Health Monitoring** - Ensure your memory database stays organized and healthy
|
|
132
|
+
|
|
133
|
+
## Why This SDK?
|
|
134
|
+
|
|
135
|
+
### Modern MCP Patterns
|
|
136
|
+
Uses the latest `server.registerTool()` API with:
|
|
137
|
+
- Zod schema validation
|
|
138
|
+
- Structured content output
|
|
139
|
+
- Proper tool annotations
|
|
140
|
+
- Both JSON and Markdown response formats
|
|
141
|
+
|
|
142
|
+
### Single Responsibility
|
|
143
|
+
Unlike monolithic servers, this focuses solely on intelligence features, making it:
|
|
144
|
+
- Easier to maintain
|
|
145
|
+
- More composable
|
|
146
|
+
- Better suited for specific use cases
|
|
147
|
+
|
|
148
|
+
### Production-Ready
|
|
149
|
+
- Streamable HTTP transport support
|
|
150
|
+
- Proper error handling with actionable messages
|
|
151
|
+
- Character limit enforcement
|
|
152
|
+
- Comprehensive logging
|
|
153
|
+
|
|
154
|
+
## MCP Server Setup
|
|
155
|
+
|
|
156
|
+
For standalone MCP server usage:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Clone the repository
|
|
160
|
+
git clone https://github.com/lanonasis/memory-intelligence-engine.git
|
|
161
|
+
cd memory-intelligence-engine/mem-intel-mcp-server
|
|
162
|
+
|
|
163
|
+
# Install dependencies
|
|
164
|
+
npm install
|
|
165
|
+
|
|
166
|
+
# Build the project
|
|
167
|
+
npm run build
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Configuration
|
|
171
|
+
|
|
172
|
+
Create a `.env` file with your existing LanOnasis credentials:
|
|
173
|
+
|
|
174
|
+
```env
|
|
175
|
+
# Required - Same as your @lanonasis/mcp-core
|
|
176
|
+
ONASIS_SUPABASE_URL=your_supabase_url
|
|
177
|
+
ONASIS_SUPABASE_SERVICE_KEY=your_service_key
|
|
178
|
+
OPENAI_API_KEY=your_openai_key
|
|
179
|
+
|
|
180
|
+
# Optional
|
|
181
|
+
TRANSPORT=stdio # or 'http' for HTTP mode
|
|
182
|
+
PORT=3010 # HTTP port (default: 3010)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Usage
|
|
186
|
+
|
|
187
|
+
### Stdio Mode (Default)
|
|
188
|
+
```bash
|
|
189
|
+
# Development
|
|
190
|
+
npm run dev
|
|
191
|
+
|
|
192
|
+
# Production
|
|
193
|
+
npm start
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### HTTP Mode
|
|
197
|
+
```bash
|
|
198
|
+
# Development
|
|
199
|
+
npm run dev:http
|
|
200
|
+
|
|
201
|
+
# Production
|
|
202
|
+
npm run start:http
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Available Tools
|
|
206
|
+
|
|
207
|
+
### 1. `memory_analyze_patterns`
|
|
208
|
+
Analyze usage patterns and trends in your memory collection.
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"user_id": "uuid",
|
|
213
|
+
"time_range_days": 30,
|
|
214
|
+
"response_format": "markdown"
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Returns:**
|
|
219
|
+
- Memory distribution by type and time
|
|
220
|
+
- Peak activity periods
|
|
221
|
+
- Tag frequency analysis
|
|
222
|
+
- AI-generated productivity insights
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### 2. `memory_suggest_tags`
|
|
227
|
+
Get AI-powered tag suggestions for a memory.
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"memory_id": "uuid",
|
|
232
|
+
"user_id": "uuid",
|
|
233
|
+
"max_suggestions": 5,
|
|
234
|
+
"include_existing_tags": true
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Returns:**
|
|
239
|
+
- Tag suggestions with confidence scores
|
|
240
|
+
- Reasoning for each suggestion
|
|
241
|
+
- Consistency with existing tag vocabulary
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
### 3. `memory_find_related`
|
|
246
|
+
Find semantically related memories using vector similarity.
|
|
247
|
+
|
|
248
|
+
```json
|
|
249
|
+
{
|
|
250
|
+
"memory_id": "uuid",
|
|
251
|
+
"user_id": "uuid",
|
|
252
|
+
"limit": 10,
|
|
253
|
+
"similarity_threshold": 0.7
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Returns:**
|
|
258
|
+
- Related memories ranked by similarity
|
|
259
|
+
- Shared tags between memories
|
|
260
|
+
- Content previews
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### 4. `memory_detect_duplicates`
|
|
265
|
+
Identify potential duplicate or near-duplicate memories.
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"user_id": "uuid",
|
|
270
|
+
"similarity_threshold": 0.9,
|
|
271
|
+
"max_pairs": 20
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Returns:**
|
|
276
|
+
- Duplicate pairs with similarity scores
|
|
277
|
+
- Recommendations (keep_newer, merge, etc.)
|
|
278
|
+
- Estimated storage savings
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
### 5. `memory_extract_insights`
|
|
283
|
+
Extract key insights and patterns from your knowledge base.
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"user_id": "uuid",
|
|
288
|
+
"topic": "optional focus area",
|
|
289
|
+
"memory_type": "project",
|
|
290
|
+
"max_memories": 20
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Returns:**
|
|
295
|
+
- Categorized insights (patterns, learnings, opportunities, risks, action items)
|
|
296
|
+
- Supporting evidence from memories
|
|
297
|
+
- Confidence scores
|
|
298
|
+
- Executive summary
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
### 6. `memory_health_check`
|
|
303
|
+
Analyze the organization quality of your memory collection.
|
|
304
|
+
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"user_id": "uuid",
|
|
308
|
+
"response_format": "markdown"
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Returns:**
|
|
313
|
+
- Overall health score (0-100)
|
|
314
|
+
- Embedding coverage
|
|
315
|
+
- Tagging consistency
|
|
316
|
+
- Type balance analysis
|
|
317
|
+
- Actionable recommendations
|
|
318
|
+
|
|
319
|
+
## Integration with @lanonasis/mcp-core
|
|
320
|
+
|
|
321
|
+
This server is designed to work alongside your existing infrastructure:
|
|
322
|
+
|
|
323
|
+
```
|
|
324
|
+
┌─────────────────────────┐ ┌──────────────────────────┐
|
|
325
|
+
│ @lanonasis/mcp-core │ │ memory-intelligence-mcp │
|
|
326
|
+
│ │ │ │
|
|
327
|
+
│ ✅ create_memory │ ←── │ 🧠 memory_analyze_patterns │
|
|
328
|
+
│ ✅ search_memories │ │ 🏷️ memory_suggest_tags │
|
|
329
|
+
│ ✅ update_memory │ ←── │ 🔗 memory_find_related │
|
|
330
|
+
│ ✅ delete_memory │ │ 🔍 memory_detect_duplicates│
|
|
331
|
+
│ ✅ list_memories │ ←── │ 💡 memory_extract_insights │
|
|
332
|
+
│ ✅ API key management │ │ 🏥 memory_health_check │
|
|
333
|
+
└─────────────────────────┘ └──────────────────────────┘
|
|
334
|
+
│ │
|
|
335
|
+
└───────────┬───────────────────────┘
|
|
336
|
+
▼
|
|
337
|
+
┌─────────────────┐
|
|
338
|
+
│ Supabase │
|
|
339
|
+
│ (Shared DB) │
|
|
340
|
+
└─────────────────┘
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Example Workflow
|
|
344
|
+
|
|
345
|
+
1. **Create memory** using `@lanonasis/mcp-core`
|
|
346
|
+
2. **Get tag suggestions** from `memory_suggest_tags`
|
|
347
|
+
3. **Update memory** with suggested tags using core server
|
|
348
|
+
4. **Find related memories** to build knowledge connections
|
|
349
|
+
5. **Extract insights** periodically to surface learnings
|
|
350
|
+
6. **Run health checks** to maintain organization quality
|
|
351
|
+
|
|
352
|
+
## Claude Desktop Integration
|
|
353
|
+
|
|
354
|
+
Add to your `claude_desktop_config.json`:
|
|
355
|
+
|
|
356
|
+
```json
|
|
357
|
+
{
|
|
358
|
+
"mcpServers": {
|
|
359
|
+
"lanonasis-core": {
|
|
360
|
+
"command": "node",
|
|
361
|
+
"args": ["/path/to/mcp-core/dist/index.js"],
|
|
362
|
+
"env": {
|
|
363
|
+
"ONASIS_SUPABASE_URL": "...",
|
|
364
|
+
"ONASIS_SUPABASE_SERVICE_KEY": "...",
|
|
365
|
+
"OPENAI_API_KEY": "..."
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"memory-intelligence": {
|
|
369
|
+
"command": "node",
|
|
370
|
+
"args": ["/path/to/memory-intelligence-mcp-server/dist/index.js"],
|
|
371
|
+
"env": {
|
|
372
|
+
"ONASIS_SUPABASE_URL": "...",
|
|
373
|
+
"ONASIS_SUPABASE_SERVICE_KEY": "...",
|
|
374
|
+
"OPENAI_API_KEY": "..."
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Testing with MCP Inspector
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
npx @modelcontextprotocol/inspector dist/index.js
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
## Response Formats
|
|
388
|
+
|
|
389
|
+
All tools support both `markdown` (human-readable) and `json` (machine-readable) formats:
|
|
390
|
+
|
|
391
|
+
```json
|
|
392
|
+
// Request with JSON format
|
|
393
|
+
{
|
|
394
|
+
"user_id": "...",
|
|
395
|
+
"response_format": "json"
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Returns structured data
|
|
399
|
+
{
|
|
400
|
+
"content": [{ "type": "text", "text": "{...}" }],
|
|
401
|
+
"structuredContent": { /* typed object */ }
|
|
402
|
+
}
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
## Error Handling
|
|
406
|
+
|
|
407
|
+
Tools return actionable error messages:
|
|
408
|
+
|
|
409
|
+
```json
|
|
410
|
+
{
|
|
411
|
+
"isError": true,
|
|
412
|
+
"content": [{
|
|
413
|
+
"type": "text",
|
|
414
|
+
"text": "Error analyzing patterns: Database connection failed. Try checking your ONASIS_SUPABASE_URL environment variable."
|
|
415
|
+
}]
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
## Performance Considerations
|
|
420
|
+
|
|
421
|
+
- **Duplicate detection**: Limited to 500 memories for performance
|
|
422
|
+
- **Insight extraction**: Uses GPT-4o-mini for cost efficiency
|
|
423
|
+
- **Vector search**: Requires embeddings in your memory_entries table
|
|
424
|
+
- **Response truncation**: Automatic at 50,000 characters
|
|
425
|
+
|
|
426
|
+
## Prerequisites
|
|
427
|
+
|
|
428
|
+
Your Supabase database must have:
|
|
429
|
+
1. `memory_entries` table with `embedding` column (vector)
|
|
430
|
+
2. `match_memories` RPC function for vector similarity search
|
|
431
|
+
3. Standard LanOnasis schema (id, title, content, type, tags, etc.)
|
|
432
|
+
|
|
433
|
+
## Architecture Benefits
|
|
434
|
+
|
|
435
|
+
### vs. Embedding in Core Server
|
|
436
|
+
|
|
437
|
+
| Aspect | Monolithic | Intelligence Server |
|
|
438
|
+
|--------|-----------|---------------------|
|
|
439
|
+
| **Deployment** | Single point of failure | Independent scaling |
|
|
440
|
+
| **Updates** | Risk to core functionality | Safe to iterate |
|
|
441
|
+
| **Resource Usage** | Shared memory/CPU | Dedicated resources |
|
|
442
|
+
| **Testing** | Complex integration tests | Focused unit tests |
|
|
443
|
+
| **Reusability** | Tied to LanOnasis | Portable to other projects |
|
|
444
|
+
|
|
445
|
+
## Future Enhancements
|
|
446
|
+
|
|
447
|
+
- [ ] Memory clustering with topic detection
|
|
448
|
+
- [ ] Automatic summarization of memory collections
|
|
449
|
+
- [ ] Knowledge graph visualization
|
|
450
|
+
- [ ] Anomaly detection in memory patterns
|
|
451
|
+
- [ ] Content quality scoring
|
|
452
|
+
- [ ] Multi-language support
|
|
453
|
+
|
|
454
|
+
## Publishing
|
|
455
|
+
|
|
456
|
+
### npm Publishing
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
# Build and verify the package
|
|
460
|
+
npm run publish:dry-run
|
|
461
|
+
|
|
462
|
+
# Publish to npm (requires npm login)
|
|
463
|
+
npm run publish:npm
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### GitHub Packages Publishing
|
|
467
|
+
|
|
468
|
+
To publish to GitHub Packages, update `.npmrc`:
|
|
469
|
+
|
|
470
|
+
```
|
|
471
|
+
@lanonasis:registry=https://npm.pkg.github.com
|
|
472
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Then publish:
|
|
476
|
+
```bash
|
|
477
|
+
npm publish --access public
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## Contributing
|
|
481
|
+
|
|
482
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
483
|
+
|
|
484
|
+
## License
|
|
485
|
+
|
|
486
|
+
MIT License - See [LICENSE](./LICENSE) for details.
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
Built with ❤️ for the LanOnasis platform by following MCP best practices.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Memory Intelligence Client
|
|
3
|
+
*/
|
|
4
|
+
import { MemoryIntelligenceConfig, AnalyzePatternsParams, PatternAnalysis, SuggestTagsParams, TagSuggestionsResult, FindRelatedParams, RelatedMemoriesResult, DetectDuplicatesParams, DuplicatesResult, ExtractInsightsParams, InsightsResult, HealthCheckParams, MemoryHealth, QueryMemoriesOptions, MemoryEntry } from "./types";
|
|
5
|
+
import { HttpClient } from "../utils/http-client";
|
|
6
|
+
export declare class MemoryIntelligenceClient {
|
|
7
|
+
private httpClient;
|
|
8
|
+
private defaultResponseFormat;
|
|
9
|
+
constructor(config: MemoryIntelligenceConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Get HTTP client for direct API access
|
|
12
|
+
*/
|
|
13
|
+
getHttpClient(): HttpClient;
|
|
14
|
+
/**
|
|
15
|
+
* Query memories from the API
|
|
16
|
+
*/
|
|
17
|
+
queryMemories(userId: string, options?: QueryMemoriesOptions): Promise<MemoryEntry[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Analyze usage patterns and trends in memory collection
|
|
20
|
+
*/
|
|
21
|
+
analyzePatterns(params: AnalyzePatternsParams): Promise<PatternAnalysis>;
|
|
22
|
+
/**
|
|
23
|
+
* Get AI-powered tag suggestions for a memory
|
|
24
|
+
*/
|
|
25
|
+
suggestTags(params: SuggestTagsParams): Promise<TagSuggestionsResult>;
|
|
26
|
+
/**
|
|
27
|
+
* Find semantically related memories using vector similarity
|
|
28
|
+
*/
|
|
29
|
+
findRelated(params: FindRelatedParams): Promise<RelatedMemoriesResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Detect potential duplicate memories
|
|
32
|
+
*/
|
|
33
|
+
detectDuplicates(params: DetectDuplicatesParams): Promise<DuplicatesResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Extract insights and patterns from memories
|
|
36
|
+
*/
|
|
37
|
+
extractInsights(params: ExtractInsightsParams): Promise<InsightsResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Check the health and organization quality of memories
|
|
40
|
+
*/
|
|
41
|
+
healthCheck(params: HealthCheckParams): Promise<MemoryHealth>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;GAEG;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,EACZ,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD,qBAAa,wBAAwB;IACnC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,qBAAqB,CAAsB;gBAEvC,MAAM,EAAE,wBAAwB;IAkB5C;;OAEG;IACI,aAAa,IAAI,UAAU;IAIlC;;OAEG;IACU,aAAa,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,WAAW,EAAE,CAAC;IAwBzB;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC;IAgB9E;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAgB3E;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAgB5E;;OAEG;IACG,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgBjF;;OAEG;IACG,eAAe,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC;IAgB7E;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;CAepE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK-specific error classes
|
|
3
|
+
*/
|
|
4
|
+
export declare class MemoryIntelligenceError extends Error {
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class ConfigurationError extends MemoryIntelligenceError {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class MemoryNotFoundError extends MemoryIntelligenceError {
|
|
11
|
+
constructor(memoryId: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class DatabaseError extends MemoryIntelligenceError {
|
|
14
|
+
originalError?: Error | undefined;
|
|
15
|
+
constructor(message: string, originalError?: Error | undefined);
|
|
16
|
+
}
|
|
17
|
+
export declare class EmbeddingError extends MemoryIntelligenceError {
|
|
18
|
+
originalError?: Error | undefined;
|
|
19
|
+
constructor(message: string, originalError?: Error | undefined);
|
|
20
|
+
}
|
|
21
|
+
export declare class ValidationError extends MemoryIntelligenceError {
|
|
22
|
+
constructor(message: string);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,uBAAuB;gBACjD,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,mBAAoB,SAAQ,uBAAuB;gBAClD,QAAQ,EAAE,MAAM;CAI7B;AAED,qBAAa,aAAc,SAAQ,uBAAuB;IACpB,aAAa,CAAC,EAAE,KAAK;gBAA7C,OAAO,EAAE,MAAM,EAAS,aAAa,CAAC,EAAE,KAAK,YAAA;CAI1D;AAED,qBAAa,cAAe,SAAQ,uBAAuB;IACrB,aAAa,CAAC,EAAE,KAAK;gBAA7C,OAAO,EAAE,MAAM,EAAS,aAAa,CAAC,EAAE,KAAK,YAAA;CAI1D;AAED,qBAAa,eAAgB,SAAQ,uBAAuB;gBAC9C,OAAO,EAAE,MAAM;CAI5B"}
|