@stackmemoryai/stackmemory 0.5.61 → 0.5.62
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/dist/scripts/initialize.js +68 -1
- package/dist/scripts/initialize.js.map +2 -2
- package/dist/src/core/retrieval/index.js +2 -0
- package/dist/src/core/retrieval/index.js.map +2 -2
- package/dist/src/core/retrieval/privacy-filter.js +129 -0
- package/dist/src/core/retrieval/privacy-filter.js.map +7 -0
- package/dist/src/core/retrieval/unified-context-assembler.js +273 -0
- package/dist/src/core/retrieval/unified-context-assembler.js.map +7 -0
- package/dist/src/hooks/diffmem-hooks.js +377 -0
- package/dist/src/hooks/diffmem-hooks.js.map +7 -0
- package/dist/src/integrations/diffmem/client.js +209 -0
- package/dist/src/integrations/diffmem/client.js.map +7 -0
- package/dist/src/integrations/diffmem/config.js +15 -0
- package/dist/src/integrations/diffmem/config.js.map +7 -0
- package/dist/src/integrations/diffmem/index.js +12 -0
- package/dist/src/integrations/diffmem/index.js.map +7 -0
- package/dist/src/integrations/diffmem/types.js +5 -0
- package/dist/src/integrations/diffmem/types.js.map +7 -0
- package/dist/src/integrations/mcp/handlers/diffmem-handlers.js +456 -0
- package/dist/src/integrations/mcp/handlers/diffmem-handlers.js.map +7 -0
- package/dist/src/integrations/mcp/server.js +121 -0
- package/dist/src/integrations/mcp/server.js.map +2 -2
- package/package.json +3 -1
- package/scripts/initialize.ts +83 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/integrations/diffmem/config.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * DiffMem Integration Configuration\n */\n\nexport interface DiffMemIntegrationConfig {\n endpoint: string;\n userId: string;\n timeout: number;\n maxRetries: number;\n enabled: boolean;\n}\n\nexport const DEFAULT_DIFFMEM_CONFIG: DiffMemIntegrationConfig = {\n endpoint: process.env.DIFFMEM_ENDPOINT || 'http://localhost:8000',\n userId: process.env.DIFFMEM_USER_ID || 'default',\n timeout: 5000,\n maxRetries: 3,\n enabled:\n process.env.DIFFMEM_ENABLED === 'true' || !!process.env.DIFFMEM_ENDPOINT,\n};\n"],
|
|
5
|
+
"mappings": ";;;;AAYO,MAAM,yBAAmD;AAAA,EAC9D,UAAU,QAAQ,IAAI,oBAAoB;AAAA,EAC1C,QAAQ,QAAQ,IAAI,mBAAmB;AAAA,EACvC,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,SACE,QAAQ,IAAI,oBAAoB,UAAU,CAAC,CAAC,QAAQ,IAAI;AAC5D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
+
import { dirname as __pathDirname } from 'path';
|
|
3
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = __pathDirname(__filename);
|
|
5
|
+
import { DEFAULT_DIFFMEM_CONFIG } from "./config.js";
|
|
6
|
+
import { DiffMemClient, DiffMemClientError } from "./client.js";
|
|
7
|
+
export {
|
|
8
|
+
DEFAULT_DIFFMEM_CONFIG,
|
|
9
|
+
DiffMemClient,
|
|
10
|
+
DiffMemClientError
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/integrations/diffmem/index.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * DiffMem Integration\n * User memory management for StackMemory\n */\n\nexport type {\n UserMemory,\n MemoryQuery,\n LearnedInsight,\n DiffMemStatus,\n} from './types.js';\n\nexport type { DiffMemIntegrationConfig } from './config.js';\nexport { DEFAULT_DIFFMEM_CONFIG } from './config.js';\n\nexport { DiffMemClient, DiffMemClientError } from './client.js';\n"],
|
|
5
|
+
"mappings": ";;;;AAaA,SAAS,8BAA8B;AAEvC,SAAS,eAAe,0BAA0B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
+
import { dirname as __pathDirname } from 'path';
|
|
3
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = __pathDirname(__filename);
|
|
5
|
+
import {
|
|
6
|
+
DEFAULT_DIFFMEM_CONFIG
|
|
7
|
+
} from "../../diffmem/config.js";
|
|
8
|
+
import { logger } from "../../../core/monitoring/logger.js";
|
|
9
|
+
class DiffMemHandlers {
|
|
10
|
+
config;
|
|
11
|
+
cache = /* @__PURE__ */ new Map();
|
|
12
|
+
cacheTTL = 5 * 60 * 1e3;
|
|
13
|
+
// 5 minutes
|
|
14
|
+
constructor(deps) {
|
|
15
|
+
this.config = { ...DEFAULT_DIFFMEM_CONFIG, ...deps?.config };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get tool definitions for DiffMem tools
|
|
19
|
+
*/
|
|
20
|
+
getToolDefinitions() {
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
name: "diffmem_get_user_context",
|
|
24
|
+
description: "Fetch user knowledge and preferences from memory. Use to personalize responses based on learned user patterns.",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
categories: {
|
|
29
|
+
type: "array",
|
|
30
|
+
items: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: [
|
|
33
|
+
"preference",
|
|
34
|
+
"expertise",
|
|
35
|
+
"project_knowledge",
|
|
36
|
+
"pattern",
|
|
37
|
+
"correction"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
description: "Filter by memory categories"
|
|
41
|
+
},
|
|
42
|
+
limit: {
|
|
43
|
+
type: "number",
|
|
44
|
+
default: 10,
|
|
45
|
+
description: "Maximum memories to return"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "diffmem_store_learning",
|
|
52
|
+
description: "Store a new insight about the user (preference, expertise, pattern, or correction)",
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
content: {
|
|
57
|
+
type: "string",
|
|
58
|
+
description: "The insight to store"
|
|
59
|
+
},
|
|
60
|
+
category: {
|
|
61
|
+
type: "string",
|
|
62
|
+
enum: [
|
|
63
|
+
"preference",
|
|
64
|
+
"expertise",
|
|
65
|
+
"project_knowledge",
|
|
66
|
+
"pattern",
|
|
67
|
+
"correction"
|
|
68
|
+
],
|
|
69
|
+
description: "Category of the insight"
|
|
70
|
+
},
|
|
71
|
+
confidence: {
|
|
72
|
+
type: "number",
|
|
73
|
+
minimum: 0,
|
|
74
|
+
maximum: 1,
|
|
75
|
+
default: 0.7,
|
|
76
|
+
description: "Confidence level (0-1)"
|
|
77
|
+
},
|
|
78
|
+
context: {
|
|
79
|
+
type: "object",
|
|
80
|
+
description: "Additional context for the insight"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
required: ["content", "category"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "diffmem_search",
|
|
88
|
+
description: "Semantic search across user memories. Find relevant past insights and preferences.",
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
query: {
|
|
93
|
+
type: "string",
|
|
94
|
+
description: "Search query"
|
|
95
|
+
},
|
|
96
|
+
timeRange: {
|
|
97
|
+
type: "string",
|
|
98
|
+
enum: ["day", "week", "month", "all"],
|
|
99
|
+
default: "all",
|
|
100
|
+
description: "Time range filter"
|
|
101
|
+
},
|
|
102
|
+
minConfidence: {
|
|
103
|
+
type: "number",
|
|
104
|
+
minimum: 0,
|
|
105
|
+
maximum: 1,
|
|
106
|
+
default: 0.5,
|
|
107
|
+
description: "Minimum confidence threshold"
|
|
108
|
+
},
|
|
109
|
+
limit: {
|
|
110
|
+
type: "number",
|
|
111
|
+
default: 10,
|
|
112
|
+
description: "Maximum results"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
required: ["query"]
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "diffmem_status",
|
|
120
|
+
description: "Check DiffMem connection status and memory statistics",
|
|
121
|
+
inputSchema: {
|
|
122
|
+
type: "object",
|
|
123
|
+
properties: {}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Fetch user context/memories with optional category filter
|
|
130
|
+
*/
|
|
131
|
+
async handleGetUserContext(args) {
|
|
132
|
+
const { categories, limit = 10 } = args;
|
|
133
|
+
try {
|
|
134
|
+
const cacheKey = `context:${JSON.stringify(categories)}:${limit}`;
|
|
135
|
+
const cached = this.getFromCache(cacheKey);
|
|
136
|
+
if (cached) {
|
|
137
|
+
logger.debug("DiffMem cache hit", { cacheKey });
|
|
138
|
+
return this.formatMemoriesResponse(cached, true);
|
|
139
|
+
}
|
|
140
|
+
const query = { limit };
|
|
141
|
+
if (categories?.length) {
|
|
142
|
+
query.categories = categories;
|
|
143
|
+
}
|
|
144
|
+
const memories = await this.fetchMemories(query);
|
|
145
|
+
this.setCache(cacheKey, memories);
|
|
146
|
+
return this.formatMemoriesResponse(memories, false);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return this.handleError("getUserContext", error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Store a new learning/insight
|
|
153
|
+
*/
|
|
154
|
+
async handleStoreLearning(args) {
|
|
155
|
+
const { content, category, confidence = 0.7, context } = args;
|
|
156
|
+
if (!content) {
|
|
157
|
+
return {
|
|
158
|
+
content: [{ type: "text", text: "Error: content is required" }],
|
|
159
|
+
metadata: { error: true }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (!category) {
|
|
163
|
+
return {
|
|
164
|
+
content: [{ type: "text", text: "Error: category is required" }],
|
|
165
|
+
metadata: { error: true }
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
try {
|
|
169
|
+
const insight = {
|
|
170
|
+
content,
|
|
171
|
+
category,
|
|
172
|
+
confidence,
|
|
173
|
+
source: "stackmemory",
|
|
174
|
+
timestamp: Date.now(),
|
|
175
|
+
context
|
|
176
|
+
};
|
|
177
|
+
await this.storeInsight(insight);
|
|
178
|
+
this.invalidateCacheByPrefix("context:");
|
|
179
|
+
logger.info("Stored DiffMem insight", { category, confidence });
|
|
180
|
+
return {
|
|
181
|
+
content: [
|
|
182
|
+
{
|
|
183
|
+
type: "text",
|
|
184
|
+
text: `Stored ${category} insight: "${content.substring(0, 50)}${content.length > 50 ? "..." : ""}"`
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
metadata: {
|
|
188
|
+
stored: true,
|
|
189
|
+
category,
|
|
190
|
+
confidence
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
} catch (error) {
|
|
194
|
+
return this.handleError("storeLearning", error);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Semantic search across memories
|
|
199
|
+
*/
|
|
200
|
+
async handleSearch(args) {
|
|
201
|
+
const { query, timeRange = "all", minConfidence = 0.5, limit = 10 } = args;
|
|
202
|
+
if (!query) {
|
|
203
|
+
return {
|
|
204
|
+
content: [{ type: "text", text: "Error: query is required" }],
|
|
205
|
+
metadata: { error: true }
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
const searchQuery = {
|
|
210
|
+
query,
|
|
211
|
+
timeRange,
|
|
212
|
+
minConfidence,
|
|
213
|
+
limit
|
|
214
|
+
};
|
|
215
|
+
const results = await this.searchMemories(searchQuery);
|
|
216
|
+
if (results.length === 0) {
|
|
217
|
+
return {
|
|
218
|
+
content: [
|
|
219
|
+
{
|
|
220
|
+
type: "text",
|
|
221
|
+
text: `No memories found matching "${query}"`
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
metadata: {
|
|
225
|
+
query,
|
|
226
|
+
resultCount: 0
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
const formattedResults = results.map(
|
|
231
|
+
(m, i) => `${i + 1}. [${m.category}] ${m.content} (confidence: ${(m.confidence * 100).toFixed(0)}%)`
|
|
232
|
+
).join("\n");
|
|
233
|
+
return {
|
|
234
|
+
content: [
|
|
235
|
+
{
|
|
236
|
+
type: "text",
|
|
237
|
+
text: `Search results for "${query}":
|
|
238
|
+
${formattedResults}`
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
metadata: {
|
|
242
|
+
query,
|
|
243
|
+
resultCount: results.length,
|
|
244
|
+
results: results.map((m) => ({
|
|
245
|
+
id: m.id,
|
|
246
|
+
category: m.category,
|
|
247
|
+
confidence: m.confidence
|
|
248
|
+
}))
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
} catch (error) {
|
|
252
|
+
return this.handleError("search", error);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get DiffMem connection status
|
|
257
|
+
*/
|
|
258
|
+
async handleStatus() {
|
|
259
|
+
try {
|
|
260
|
+
const status = await this.getStatus();
|
|
261
|
+
const statusText = status.connected ? `DiffMem Status:
|
|
262
|
+
- Connected: Yes
|
|
263
|
+
- Memories: ${status.memoryCount}
|
|
264
|
+
- Last sync: ${status.lastSync ? new Date(status.lastSync).toISOString() : "Never"}
|
|
265
|
+
- Version: ${status.version || "Unknown"}` : `DiffMem Status:
|
|
266
|
+
- Connected: No
|
|
267
|
+
- Endpoint: ${this.config.endpoint}
|
|
268
|
+
- Enabled: ${this.config.enabled}`;
|
|
269
|
+
return {
|
|
270
|
+
content: [{ type: "text", text: statusText }],
|
|
271
|
+
metadata: status
|
|
272
|
+
};
|
|
273
|
+
} catch (error) {
|
|
274
|
+
return this.handleError("status", error);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Private helper methods
|
|
278
|
+
formatMemoriesResponse(memories, fromCache) {
|
|
279
|
+
if (memories.length === 0) {
|
|
280
|
+
return {
|
|
281
|
+
content: [
|
|
282
|
+
{
|
|
283
|
+
type: "text",
|
|
284
|
+
text: "No user context memories found."
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
metadata: { fromCache, count: 0 }
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
const byCategory = memories.reduce(
|
|
291
|
+
(acc, m) => {
|
|
292
|
+
if (!acc[m.category]) {
|
|
293
|
+
acc[m.category] = [];
|
|
294
|
+
}
|
|
295
|
+
acc[m.category].push(m);
|
|
296
|
+
return acc;
|
|
297
|
+
},
|
|
298
|
+
{}
|
|
299
|
+
);
|
|
300
|
+
const sections = Object.entries(byCategory).map(([category, mems]) => {
|
|
301
|
+
const items = mems.map(
|
|
302
|
+
(m) => ` - ${m.content} (${(m.confidence * 100).toFixed(0)}% confidence)`
|
|
303
|
+
).join("\n");
|
|
304
|
+
return `${category.toUpperCase()}:
|
|
305
|
+
${items}`;
|
|
306
|
+
}).join("\n\n");
|
|
307
|
+
return {
|
|
308
|
+
content: [
|
|
309
|
+
{
|
|
310
|
+
type: "text",
|
|
311
|
+
text: `User Context:
|
|
312
|
+
|
|
313
|
+
${sections}`
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
metadata: {
|
|
317
|
+
fromCache,
|
|
318
|
+
count: memories.length,
|
|
319
|
+
categories: Object.keys(byCategory)
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
handleError(operation, error) {
|
|
324
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
325
|
+
const isConnectionError = errorMessage.includes("ECONNREFUSED") || errorMessage.includes("fetch failed") || errorMessage.includes("network");
|
|
326
|
+
logger.warn(`DiffMem ${operation} failed`, { error: errorMessage });
|
|
327
|
+
if (isConnectionError) {
|
|
328
|
+
return {
|
|
329
|
+
content: [
|
|
330
|
+
{
|
|
331
|
+
type: "text",
|
|
332
|
+
text: `DiffMem unavailable (${operation}). Session continues without user memory.`
|
|
333
|
+
}
|
|
334
|
+
],
|
|
335
|
+
metadata: {
|
|
336
|
+
error: true,
|
|
337
|
+
unavailable: true,
|
|
338
|
+
operation
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
return {
|
|
343
|
+
content: [
|
|
344
|
+
{
|
|
345
|
+
type: "text",
|
|
346
|
+
text: `DiffMem ${operation} error: ${errorMessage}`
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
metadata: {
|
|
350
|
+
error: true,
|
|
351
|
+
operation,
|
|
352
|
+
message: errorMessage
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
getFromCache(key) {
|
|
357
|
+
const entry = this.cache.get(key);
|
|
358
|
+
if (!entry) return void 0;
|
|
359
|
+
if (Date.now() - entry.timestamp > this.cacheTTL) {
|
|
360
|
+
this.cache.delete(key);
|
|
361
|
+
return void 0;
|
|
362
|
+
}
|
|
363
|
+
return entry.data;
|
|
364
|
+
}
|
|
365
|
+
setCache(key, data) {
|
|
366
|
+
this.cache.set(key, { data, timestamp: Date.now() });
|
|
367
|
+
}
|
|
368
|
+
invalidateCacheByPrefix(prefix) {
|
|
369
|
+
for (const key of this.cache.keys()) {
|
|
370
|
+
if (key.startsWith(prefix)) {
|
|
371
|
+
this.cache.delete(key);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
// API interaction methods (with graceful degradation)
|
|
376
|
+
async fetchMemories(query) {
|
|
377
|
+
if (!this.config.enabled) {
|
|
378
|
+
return [];
|
|
379
|
+
}
|
|
380
|
+
const response = await fetch(`${this.config.endpoint}/memories`, {
|
|
381
|
+
method: "POST",
|
|
382
|
+
headers: { "Content-Type": "application/json" },
|
|
383
|
+
body: JSON.stringify(query),
|
|
384
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
385
|
+
});
|
|
386
|
+
if (!response.ok) {
|
|
387
|
+
throw new Error(`DiffMem API error: ${response.status}`);
|
|
388
|
+
}
|
|
389
|
+
const data = await response.json();
|
|
390
|
+
return data.memories || [];
|
|
391
|
+
}
|
|
392
|
+
async searchMemories(query) {
|
|
393
|
+
if (!this.config.enabled) {
|
|
394
|
+
return [];
|
|
395
|
+
}
|
|
396
|
+
const response = await fetch(`${this.config.endpoint}/search`, {
|
|
397
|
+
method: "POST",
|
|
398
|
+
headers: { "Content-Type": "application/json" },
|
|
399
|
+
body: JSON.stringify(query),
|
|
400
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
401
|
+
});
|
|
402
|
+
if (!response.ok) {
|
|
403
|
+
throw new Error(`DiffMem API error: ${response.status}`);
|
|
404
|
+
}
|
|
405
|
+
const data = await response.json();
|
|
406
|
+
return data.results || [];
|
|
407
|
+
}
|
|
408
|
+
async storeInsight(insight) {
|
|
409
|
+
if (!this.config.enabled) {
|
|
410
|
+
logger.debug("DiffMem disabled, skipping store");
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
const response = await fetch(`${this.config.endpoint}/insights`, {
|
|
414
|
+
method: "POST",
|
|
415
|
+
headers: { "Content-Type": "application/json" },
|
|
416
|
+
body: JSON.stringify(insight),
|
|
417
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
418
|
+
});
|
|
419
|
+
if (!response.ok) {
|
|
420
|
+
throw new Error(`DiffMem API error: ${response.status}`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
async getStatus() {
|
|
424
|
+
if (!this.config.enabled) {
|
|
425
|
+
return {
|
|
426
|
+
connected: false,
|
|
427
|
+
memoryCount: 0,
|
|
428
|
+
lastSync: null
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
const response = await fetch(`${this.config.endpoint}/status`, {
|
|
433
|
+
method: "GET",
|
|
434
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
435
|
+
});
|
|
436
|
+
if (!response.ok) {
|
|
437
|
+
return {
|
|
438
|
+
connected: false,
|
|
439
|
+
memoryCount: 0,
|
|
440
|
+
lastSync: null
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
return await response.json();
|
|
444
|
+
} catch {
|
|
445
|
+
return {
|
|
446
|
+
connected: false,
|
|
447
|
+
memoryCount: 0,
|
|
448
|
+
lastSync: null
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
export {
|
|
454
|
+
DiffMemHandlers
|
|
455
|
+
};
|
|
456
|
+
//# sourceMappingURL=diffmem-handlers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/integrations/mcp/handlers/diffmem-handlers.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * DiffMem MCP Tool Handlers\n * Handles user memory management via DiffMem integration\n */\n\nimport {\n UserMemory,\n MemoryQuery,\n LearnedInsight,\n DiffMemStatus,\n} from '../../diffmem/types.js';\nimport {\n DiffMemIntegrationConfig,\n DEFAULT_DIFFMEM_CONFIG,\n} from '../../diffmem/config.js';\nimport { logger } from '../../../core/monitoring/logger.js';\nimport { MCPToolDefinition } from '../tool-definitions.js';\n\ninterface MCPResponse {\n content: Array<{ type: string; text: string }>;\n metadata?: Record<string, unknown>;\n}\n\ninterface CacheEntry<T> {\n data: T;\n timestamp: number;\n}\n\nexport interface DiffMemHandlerDependencies {\n config?: Partial<DiffMemIntegrationConfig>;\n}\n\nexport class DiffMemHandlers {\n private config: DiffMemIntegrationConfig;\n private cache: Map<string, CacheEntry<unknown>> = new Map();\n private cacheTTL: number = 5 * 60 * 1000; // 5 minutes\n\n constructor(deps?: DiffMemHandlerDependencies) {\n this.config = { ...DEFAULT_DIFFMEM_CONFIG, ...deps?.config };\n }\n\n /**\n * Get tool definitions for DiffMem tools\n */\n getToolDefinitions(): MCPToolDefinition[] {\n return [\n {\n name: 'diffmem_get_user_context',\n description:\n 'Fetch user knowledge and preferences from memory. Use to personalize responses based on learned user patterns.',\n inputSchema: {\n type: 'object',\n properties: {\n categories: {\n type: 'array',\n items: {\n type: 'string',\n enum: [\n 'preference',\n 'expertise',\n 'project_knowledge',\n 'pattern',\n 'correction',\n ],\n },\n description: 'Filter by memory categories',\n },\n limit: {\n type: 'number',\n default: 10,\n description: 'Maximum memories to return',\n },\n },\n },\n },\n {\n name: 'diffmem_store_learning',\n description:\n 'Store a new insight about the user (preference, expertise, pattern, or correction)',\n inputSchema: {\n type: 'object',\n properties: {\n content: {\n type: 'string',\n description: 'The insight to store',\n },\n category: {\n type: 'string',\n enum: [\n 'preference',\n 'expertise',\n 'project_knowledge',\n 'pattern',\n 'correction',\n ],\n description: 'Category of the insight',\n },\n confidence: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n default: 0.7,\n description: 'Confidence level (0-1)',\n },\n context: {\n type: 'object',\n description: 'Additional context for the insight',\n },\n },\n required: ['content', 'category'],\n },\n },\n {\n name: 'diffmem_search',\n description:\n 'Semantic search across user memories. Find relevant past insights and preferences.',\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'string',\n description: 'Search query',\n },\n timeRange: {\n type: 'string',\n enum: ['day', 'week', 'month', 'all'],\n default: 'all',\n description: 'Time range filter',\n },\n minConfidence: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n default: 0.5,\n description: 'Minimum confidence threshold',\n },\n limit: {\n type: 'number',\n default: 10,\n description: 'Maximum results',\n },\n },\n required: ['query'],\n },\n },\n {\n name: 'diffmem_status',\n description: 'Check DiffMem connection status and memory statistics',\n inputSchema: {\n type: 'object',\n properties: {},\n },\n },\n ];\n }\n\n /**\n * Fetch user context/memories with optional category filter\n */\n async handleGetUserContext(args: {\n categories?: string[];\n limit?: number;\n }): Promise<MCPResponse> {\n const { categories, limit = 10 } = args;\n\n try {\n const cacheKey = `context:${JSON.stringify(categories)}:${limit}`;\n const cached = this.getFromCache<UserMemory[]>(cacheKey);\n\n if (cached) {\n logger.debug('DiffMem cache hit', { cacheKey });\n return this.formatMemoriesResponse(cached, true);\n }\n\n const query: MemoryQuery = { limit };\n if (categories?.length) {\n query.categories = categories;\n }\n\n const memories = await this.fetchMemories(query);\n this.setCache(cacheKey, memories);\n\n return this.formatMemoriesResponse(memories, false);\n } catch (error) {\n return this.handleError('getUserContext', error);\n }\n }\n\n /**\n * Store a new learning/insight\n */\n async handleStoreLearning(args: {\n content: string;\n category: UserMemory['category'];\n confidence?: number;\n context?: Record<string, unknown>;\n }): Promise<MCPResponse> {\n const { content, category, confidence = 0.7, context } = args;\n\n if (!content) {\n return {\n content: [{ type: 'text', text: 'Error: content is required' }],\n metadata: { error: true },\n };\n }\n\n if (!category) {\n return {\n content: [{ type: 'text', text: 'Error: category is required' }],\n metadata: { error: true },\n };\n }\n\n try {\n const insight: LearnedInsight = {\n content,\n category,\n confidence,\n source: 'stackmemory',\n timestamp: Date.now(),\n context,\n };\n\n await this.storeInsight(insight);\n\n // Invalidate relevant cache entries\n this.invalidateCacheByPrefix('context:');\n\n logger.info('Stored DiffMem insight', { category, confidence });\n\n return {\n content: [\n {\n type: 'text',\n text: `Stored ${category} insight: \"${content.substring(0, 50)}${content.length > 50 ? '...' : ''}\"`,\n },\n ],\n metadata: {\n stored: true,\n category,\n confidence,\n },\n };\n } catch (error) {\n return this.handleError('storeLearning', error);\n }\n }\n\n /**\n * Semantic search across memories\n */\n async handleSearch(args: {\n query: string;\n timeRange?: MemoryQuery['timeRange'];\n minConfidence?: number;\n limit?: number;\n }): Promise<MCPResponse> {\n const { query, timeRange = 'all', minConfidence = 0.5, limit = 10 } = args;\n\n if (!query) {\n return {\n content: [{ type: 'text', text: 'Error: query is required' }],\n metadata: { error: true },\n };\n }\n\n try {\n const searchQuery: MemoryQuery = {\n query,\n timeRange,\n minConfidence,\n limit,\n };\n\n const results = await this.searchMemories(searchQuery);\n\n if (results.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: `No memories found matching \"${query}\"`,\n },\n ],\n metadata: {\n query,\n resultCount: 0,\n },\n };\n }\n\n const formattedResults = results\n .map(\n (m, i) =>\n `${i + 1}. [${m.category}] ${m.content} (confidence: ${(m.confidence * 100).toFixed(0)}%)`\n )\n .join('\\n');\n\n return {\n content: [\n {\n type: 'text',\n text: `Search results for \"${query}\":\\n${formattedResults}`,\n },\n ],\n metadata: {\n query,\n resultCount: results.length,\n results: results.map((m) => ({\n id: m.id,\n category: m.category,\n confidence: m.confidence,\n })),\n },\n };\n } catch (error) {\n return this.handleError('search', error);\n }\n }\n\n /**\n * Get DiffMem connection status\n */\n async handleStatus(): Promise<MCPResponse> {\n try {\n const status = await this.getStatus();\n\n const statusText = status.connected\n ? `DiffMem Status:\n- Connected: Yes\n- Memories: ${status.memoryCount}\n- Last sync: ${status.lastSync ? new Date(status.lastSync).toISOString() : 'Never'}\n- Version: ${status.version || 'Unknown'}`\n : `DiffMem Status:\n- Connected: No\n- Endpoint: ${this.config.endpoint}\n- Enabled: ${this.config.enabled}`;\n\n return {\n content: [{ type: 'text', text: statusText }],\n metadata: status,\n };\n } catch (error) {\n return this.handleError('status', error);\n }\n }\n\n // Private helper methods\n\n private formatMemoriesResponse(\n memories: UserMemory[],\n fromCache: boolean\n ): MCPResponse {\n if (memories.length === 0) {\n return {\n content: [\n {\n type: 'text',\n text: 'No user context memories found.',\n },\n ],\n metadata: { fromCache, count: 0 },\n };\n }\n\n // Group by category\n const byCategory = memories.reduce(\n (acc, m) => {\n if (!acc[m.category]) {\n acc[m.category] = [];\n }\n acc[m.category].push(m);\n return acc;\n },\n {} as Record<string, UserMemory[]>\n );\n\n const sections = Object.entries(byCategory)\n .map(([category, mems]) => {\n const items = mems\n .map(\n (m) =>\n ` - ${m.content} (${(m.confidence * 100).toFixed(0)}% confidence)`\n )\n .join('\\n');\n return `${category.toUpperCase()}:\\n${items}`;\n })\n .join('\\n\\n');\n\n return {\n content: [\n {\n type: 'text',\n text: `User Context:\\n\\n${sections}`,\n },\n ],\n metadata: {\n fromCache,\n count: memories.length,\n categories: Object.keys(byCategory),\n },\n };\n }\n\n private handleError(operation: string, error: unknown): MCPResponse {\n const errorMessage = error instanceof Error ? error.message : String(error);\n const isConnectionError =\n errorMessage.includes('ECONNREFUSED') ||\n errorMessage.includes('fetch failed') ||\n errorMessage.includes('network');\n\n logger.warn(`DiffMem ${operation} failed`, { error: errorMessage });\n\n if (isConnectionError) {\n return {\n content: [\n {\n type: 'text',\n text: `DiffMem unavailable (${operation}). Session continues without user memory.`,\n },\n ],\n metadata: {\n error: true,\n unavailable: true,\n operation,\n },\n };\n }\n\n return {\n content: [\n {\n type: 'text',\n text: `DiffMem ${operation} error: ${errorMessage}`,\n },\n ],\n metadata: {\n error: true,\n operation,\n message: errorMessage,\n },\n };\n }\n\n private getFromCache<T>(key: string): T | undefined {\n const entry = this.cache.get(key) as CacheEntry<T> | undefined;\n if (!entry) return undefined;\n\n if (Date.now() - entry.timestamp > this.cacheTTL) {\n this.cache.delete(key);\n return undefined;\n }\n\n return entry.data;\n }\n\n private setCache<T>(key: string, data: T): void {\n this.cache.set(key, { data, timestamp: Date.now() });\n }\n\n private invalidateCacheByPrefix(prefix: string): void {\n for (const key of this.cache.keys()) {\n if (key.startsWith(prefix)) {\n this.cache.delete(key);\n }\n }\n }\n\n // API interaction methods (with graceful degradation)\n\n private async fetchMemories(query: MemoryQuery): Promise<UserMemory[]> {\n if (!this.config.enabled) {\n return [];\n }\n\n const response = await fetch(`${this.config.endpoint}/memories`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(query),\n signal: AbortSignal.timeout(this.config.timeout),\n });\n\n if (!response.ok) {\n throw new Error(`DiffMem API error: ${response.status}`);\n }\n\n const data = await response.json();\n return data.memories || [];\n }\n\n private async searchMemories(query: MemoryQuery): Promise<UserMemory[]> {\n if (!this.config.enabled) {\n return [];\n }\n\n const response = await fetch(`${this.config.endpoint}/search`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(query),\n signal: AbortSignal.timeout(this.config.timeout),\n });\n\n if (!response.ok) {\n throw new Error(`DiffMem API error: ${response.status}`);\n }\n\n const data = await response.json();\n return data.results || [];\n }\n\n private async storeInsight(insight: LearnedInsight): Promise<void> {\n if (!this.config.enabled) {\n logger.debug('DiffMem disabled, skipping store');\n return;\n }\n\n const response = await fetch(`${this.config.endpoint}/insights`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(insight),\n signal: AbortSignal.timeout(this.config.timeout),\n });\n\n if (!response.ok) {\n throw new Error(`DiffMem API error: ${response.status}`);\n }\n }\n\n private async getStatus(): Promise<DiffMemStatus> {\n if (!this.config.enabled) {\n return {\n connected: false,\n memoryCount: 0,\n lastSync: null,\n };\n }\n\n try {\n const response = await fetch(`${this.config.endpoint}/status`, {\n method: 'GET',\n signal: AbortSignal.timeout(this.config.timeout),\n });\n\n if (!response.ok) {\n return {\n connected: false,\n memoryCount: 0,\n lastSync: null,\n };\n }\n\n return await response.json();\n } catch {\n return {\n connected: false,\n memoryCount: 0,\n lastSync: null,\n };\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAWA;AAAA,EAEE;AAAA,OACK;AACP,SAAS,cAAc;AAiBhB,MAAM,gBAAgB;AAAA,EACnB;AAAA,EACA,QAA0C,oBAAI,IAAI;AAAA,EAClD,WAAmB,IAAI,KAAK;AAAA;AAAA,EAEpC,YAAY,MAAmC;AAC7C,SAAK,SAAS,EAAE,GAAG,wBAAwB,GAAG,MAAM,OAAO;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA,EAKA,qBAA0C;AACxC,WAAO;AAAA,MACL;AAAA,QACE,MAAM;AAAA,QACN,aACE;AAAA,QACF,aAAa;AAAA,UACX,MAAM;AAAA,UACN,YAAY;AAAA,YACV,YAAY;AAAA,cACV,MAAM;AAAA,cACN,OAAO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