@lanonasis/mem-intel-sdk 2.0.5 → 2.1.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 +24 -0
- package/dist/core/behavior-types.d.ts +55 -19
- package/dist/core/client.d.ts +6 -6
- package/dist/core/index.cjs +74 -16
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +73 -17
- package/dist/core/index.js.map +1 -1
- package/dist/core/prediction-types.d.ts +14 -7
- package/dist/core/types.d.ts +19 -6
- package/dist/index.cjs +74 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +73 -17
- package/dist/index.js.map +1 -1
- package/dist/node/index.cjs +57 -11
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +57 -12
- package/dist/node/index.js.map +1 -1
- package/dist/react/index.cjs +57 -11
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +57 -12
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.cjs +105 -15
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js +105 -16
- package/dist/server/index.js.map +1 -1
- package/dist/vue/index.cjs +7 -0
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +7 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -241,11 +241,12 @@ var HttpClient = class {
|
|
|
241
241
|
clearTimeout(timeoutId);
|
|
242
242
|
const responseData = await response.json();
|
|
243
243
|
if (!response.ok) {
|
|
244
|
+
const errorMessage = responseData?.message || responseData?.error?.message || (typeof responseData?.error === "string" ? responseData.error : void 0) || "Request failed";
|
|
244
245
|
return {
|
|
245
246
|
status: response.status,
|
|
246
247
|
error: {
|
|
247
|
-
message:
|
|
248
|
-
code: responseData?.code
|
|
248
|
+
message: errorMessage,
|
|
249
|
+
code: responseData?.code || responseData?.error?.code
|
|
249
250
|
}
|
|
250
251
|
};
|
|
251
252
|
}
|
|
@@ -354,6 +355,20 @@ var HttpClient = class {
|
|
|
354
355
|
|
|
355
356
|
// src/core/client.ts
|
|
356
357
|
var DEFAULT_API_URL = "https://api.lanonasis.com/api/v1";
|
|
358
|
+
function appendQueryContext(params, context) {
|
|
359
|
+
if (context.organizationId) {
|
|
360
|
+
params.append("organization_id", context.organizationId);
|
|
361
|
+
}
|
|
362
|
+
if (context.topicId) {
|
|
363
|
+
params.append("topic_id", context.topicId);
|
|
364
|
+
}
|
|
365
|
+
if (context.queryScope) {
|
|
366
|
+
params.append("query_scope", context.queryScope);
|
|
367
|
+
}
|
|
368
|
+
for (const memoryType of context.memoryTypes || []) {
|
|
369
|
+
params.append("memory_types", memoryType);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
357
372
|
var MemoryIntelligenceClient = class {
|
|
358
373
|
httpClient;
|
|
359
374
|
defaultResponseFormat;
|
|
@@ -403,7 +418,15 @@ var MemoryIntelligenceClient = class {
|
|
|
403
418
|
* Query memories from the API
|
|
404
419
|
*/
|
|
405
420
|
async queryMemories(userId, options = {}) {
|
|
406
|
-
const {
|
|
421
|
+
const {
|
|
422
|
+
type,
|
|
423
|
+
limit = 100,
|
|
424
|
+
offset = 0,
|
|
425
|
+
organizationId,
|
|
426
|
+
topicId,
|
|
427
|
+
memoryTypes,
|
|
428
|
+
queryScope
|
|
429
|
+
} = options;
|
|
407
430
|
const params = new URLSearchParams({
|
|
408
431
|
user_id: userId,
|
|
409
432
|
limit: limit.toString(),
|
|
@@ -412,7 +435,13 @@ var MemoryIntelligenceClient = class {
|
|
|
412
435
|
if (type) {
|
|
413
436
|
params.append("type", type);
|
|
414
437
|
}
|
|
415
|
-
|
|
438
|
+
appendQueryContext(params, {
|
|
439
|
+
organizationId,
|
|
440
|
+
topicId,
|
|
441
|
+
memoryTypes,
|
|
442
|
+
queryScope
|
|
443
|
+
});
|
|
444
|
+
const response = await this.httpClient.getEnhanced(
|
|
416
445
|
`/intelligence/memories?${params.toString()}`
|
|
417
446
|
);
|
|
418
447
|
if (response.error) {
|
|
@@ -580,6 +609,9 @@ var MemoryIntelligenceClient = class {
|
|
|
580
609
|
"/intelligence/predictive-recall",
|
|
581
610
|
{
|
|
582
611
|
userId: params.userId,
|
|
612
|
+
organizationId: params.organizationId,
|
|
613
|
+
topicId: params.topicId,
|
|
614
|
+
queryScope: params.queryScope,
|
|
583
615
|
context: params.context,
|
|
584
616
|
limit: params.limit || 5,
|
|
585
617
|
minConfidence: params.minConfidence || 40,
|
|
@@ -636,11 +668,11 @@ var MemoryIntelligenceClient = class {
|
|
|
636
668
|
* active_files: ["src/components/DataTable.tsx"]
|
|
637
669
|
* },
|
|
638
670
|
* actions: [
|
|
639
|
-
* { tool: "read_file",
|
|
640
|
-
* { tool: "analyze_code",
|
|
641
|
-
* { tool: "edit_file",
|
|
671
|
+
* { tool: "read_file", parameters: { path: "src/components/DataTable.tsx" }, outcome: "success" },
|
|
672
|
+
* { tool: "analyze_code", parameters: { focus: "class_components" }, outcome: "success" },
|
|
673
|
+
* { tool: "edit_file", parameters: { path: "src/components/DataTable.tsx" }, outcome: "success" }
|
|
642
674
|
* ],
|
|
643
|
-
* final_outcome: "
|
|
675
|
+
* final_outcome: "success"
|
|
644
676
|
* });
|
|
645
677
|
*
|
|
646
678
|
* if (result.data.was_duplicate) {
|
|
@@ -649,13 +681,20 @@ var MemoryIntelligenceClient = class {
|
|
|
649
681
|
* ```
|
|
650
682
|
*/
|
|
651
683
|
async recordBehavior(params) {
|
|
684
|
+
const actions = params.actions.map((action) => ({
|
|
685
|
+
tool: action.tool,
|
|
686
|
+
...action.parameters || action.params ? { parameters: action.parameters ?? action.params } : {},
|
|
687
|
+
...action.outcome ? { outcome: action.outcome } : {},
|
|
688
|
+
...action.timestamp ? { timestamp: action.timestamp } : {},
|
|
689
|
+
...action.duration_ms !== void 0 ? { duration_ms: action.duration_ms } : {}
|
|
690
|
+
}));
|
|
652
691
|
const response = await this.httpClient.postEnhanced(
|
|
653
692
|
"/intelligence/behavior-record",
|
|
654
693
|
{
|
|
655
694
|
user_id: params.user_id,
|
|
656
695
|
trigger: params.trigger,
|
|
657
696
|
context: params.context || {},
|
|
658
|
-
actions
|
|
697
|
+
actions,
|
|
659
698
|
final_outcome: params.final_outcome,
|
|
660
699
|
confidence: params.confidence ?? 0.7
|
|
661
700
|
}
|
|
@@ -732,8 +771,8 @@ var MemoryIntelligenceClient = class {
|
|
|
732
771
|
* current_state: {
|
|
733
772
|
* task_description: "Implementing user authentication with OAuth",
|
|
734
773
|
* completed_steps: [
|
|
735
|
-
*
|
|
736
|
-
*
|
|
774
|
+
* "create src/auth/oauth.ts",
|
|
775
|
+
* "inspect package.json"
|
|
737
776
|
* ]
|
|
738
777
|
* },
|
|
739
778
|
* max_suggestions: 3
|
|
@@ -798,6 +837,12 @@ var MemoryType = z.enum([
|
|
|
798
837
|
"personal",
|
|
799
838
|
"workflow"
|
|
800
839
|
]);
|
|
840
|
+
var QueryScope = z.enum([
|
|
841
|
+
"personal",
|
|
842
|
+
"team",
|
|
843
|
+
"organization",
|
|
844
|
+
"hybrid"
|
|
845
|
+
]);
|
|
801
846
|
|
|
802
847
|
// src/utils/formatting.ts
|
|
803
848
|
var CHARACTER_LIMIT = 5e4;
|
|
@@ -817,6 +862,15 @@ function truncateIfNeeded(text) {
|
|
|
817
862
|
}
|
|
818
863
|
|
|
819
864
|
// src/server/mcp-server.ts
|
|
865
|
+
var optionalContextFields = {
|
|
866
|
+
organization_id: z.string().uuid().optional(),
|
|
867
|
+
topic_id: z.string().optional(),
|
|
868
|
+
query_scope: QueryScope.optional()
|
|
869
|
+
};
|
|
870
|
+
var optionalCollectionContextFields = {
|
|
871
|
+
...optionalContextFields,
|
|
872
|
+
memory_types: z.array(MemoryType).optional()
|
|
873
|
+
};
|
|
820
874
|
function createMCPServer(config) {
|
|
821
875
|
const client = new MemoryIntelligenceClient(config);
|
|
822
876
|
const server = new McpServer({
|
|
@@ -831,6 +885,7 @@ function createMCPServer(config) {
|
|
|
831
885
|
inputSchema: z.object({
|
|
832
886
|
user_id: z.string().uuid(),
|
|
833
887
|
time_range_days: z.number().int().min(1).max(365).default(30),
|
|
888
|
+
...optionalCollectionContextFields,
|
|
834
889
|
response_format: z.enum([ResponseFormat.JSON, ResponseFormat.MARKDOWN]).default(ResponseFormat.MARKDOWN)
|
|
835
890
|
}).strict(),
|
|
836
891
|
annotations: {
|
|
@@ -845,6 +900,10 @@ function createMCPServer(config) {
|
|
|
845
900
|
const params = {
|
|
846
901
|
userId: rawParams.user_id,
|
|
847
902
|
timeRangeDays: rawParams.time_range_days,
|
|
903
|
+
organizationId: rawParams.organization_id,
|
|
904
|
+
topicId: rawParams.topic_id,
|
|
905
|
+
memoryTypes: rawParams.memory_types,
|
|
906
|
+
queryScope: rawParams.query_scope,
|
|
848
907
|
responseFormat: rawParams.response_format
|
|
849
908
|
};
|
|
850
909
|
const response = await client.analyzePatterns(params);
|
|
@@ -990,6 +1049,7 @@ function createMCPServer(config) {
|
|
|
990
1049
|
user_id: z.string().uuid(),
|
|
991
1050
|
limit: z.number().int().min(1).max(50).default(10),
|
|
992
1051
|
similarity_threshold: z.number().min(0).max(1).default(0.7),
|
|
1052
|
+
...optionalCollectionContextFields,
|
|
993
1053
|
response_format: z.enum([ResponseFormat.JSON, ResponseFormat.MARKDOWN]).default(ResponseFormat.MARKDOWN)
|
|
994
1054
|
}).strict(),
|
|
995
1055
|
annotations: {
|
|
@@ -1006,6 +1066,10 @@ function createMCPServer(config) {
|
|
|
1006
1066
|
userId: rawParams.user_id,
|
|
1007
1067
|
limit: rawParams.limit,
|
|
1008
1068
|
similarityThreshold: rawParams.similarity_threshold,
|
|
1069
|
+
organizationId: rawParams.organization_id,
|
|
1070
|
+
topicId: rawParams.topic_id,
|
|
1071
|
+
memoryTypes: rawParams.memory_types,
|
|
1072
|
+
queryScope: rawParams.query_scope,
|
|
1009
1073
|
responseFormat: rawParams.response_format
|
|
1010
1074
|
};
|
|
1011
1075
|
const response = await client.findRelated(params);
|
|
@@ -1063,6 +1127,7 @@ function createMCPServer(config) {
|
|
|
1063
1127
|
user_id: z.string().uuid(),
|
|
1064
1128
|
similarity_threshold: z.number().min(0.8).max(0.99).default(0.9),
|
|
1065
1129
|
max_pairs: z.number().int().min(1).max(100).default(20),
|
|
1130
|
+
...optionalCollectionContextFields,
|
|
1066
1131
|
response_format: z.enum([ResponseFormat.JSON, ResponseFormat.MARKDOWN]).default(ResponseFormat.MARKDOWN)
|
|
1067
1132
|
}).strict(),
|
|
1068
1133
|
annotations: {
|
|
@@ -1078,6 +1143,10 @@ function createMCPServer(config) {
|
|
|
1078
1143
|
userId: rawParams.user_id,
|
|
1079
1144
|
similarityThreshold: rawParams.similarity_threshold,
|
|
1080
1145
|
maxPairs: rawParams.max_pairs,
|
|
1146
|
+
organizationId: rawParams.organization_id,
|
|
1147
|
+
topicId: rawParams.topic_id,
|
|
1148
|
+
memoryTypes: rawParams.memory_types,
|
|
1149
|
+
queryScope: rawParams.query_scope,
|
|
1081
1150
|
responseFormat: rawParams.response_format
|
|
1082
1151
|
};
|
|
1083
1152
|
const response = await client.detectDuplicates(params);
|
|
@@ -1141,6 +1210,7 @@ function createMCPServer(config) {
|
|
|
1141
1210
|
topic: z.string().optional(),
|
|
1142
1211
|
memory_type: z.string().optional(),
|
|
1143
1212
|
max_memories: z.number().int().min(5).max(100).default(20),
|
|
1213
|
+
...optionalCollectionContextFields,
|
|
1144
1214
|
response_format: z.enum([ResponseFormat.JSON, ResponseFormat.MARKDOWN]).default(ResponseFormat.MARKDOWN)
|
|
1145
1215
|
}).strict(),
|
|
1146
1216
|
annotations: {
|
|
@@ -1157,6 +1227,10 @@ function createMCPServer(config) {
|
|
|
1157
1227
|
topic: rawParams.topic,
|
|
1158
1228
|
memoryType: rawParams.memory_type,
|
|
1159
1229
|
maxMemories: rawParams.max_memories,
|
|
1230
|
+
organizationId: rawParams.organization_id,
|
|
1231
|
+
topicId: rawParams.topic_id,
|
|
1232
|
+
memoryTypes: rawParams.memory_types,
|
|
1233
|
+
queryScope: rawParams.query_scope,
|
|
1160
1234
|
responseFormat: rawParams.response_format
|
|
1161
1235
|
};
|
|
1162
1236
|
const response = await client.extractInsights(params);
|
|
@@ -1224,6 +1298,7 @@ ${data.overall_summary}
|
|
|
1224
1298
|
description: `Analyze the health and organization quality of memories.`,
|
|
1225
1299
|
inputSchema: z.object({
|
|
1226
1300
|
user_id: z.string().uuid(),
|
|
1301
|
+
...optionalCollectionContextFields,
|
|
1227
1302
|
response_format: z.enum([ResponseFormat.JSON, ResponseFormat.MARKDOWN]).default(ResponseFormat.MARKDOWN)
|
|
1228
1303
|
}).strict(),
|
|
1229
1304
|
annotations: {
|
|
@@ -1237,6 +1312,10 @@ ${data.overall_summary}
|
|
|
1237
1312
|
try {
|
|
1238
1313
|
const params = {
|
|
1239
1314
|
userId: rawParams.user_id,
|
|
1315
|
+
organizationId: rawParams.organization_id,
|
|
1316
|
+
topicId: rawParams.topic_id,
|
|
1317
|
+
memoryTypes: rawParams.memory_types,
|
|
1318
|
+
queryScope: rawParams.query_scope,
|
|
1240
1319
|
responseFormat: rawParams.response_format
|
|
1241
1320
|
};
|
|
1242
1321
|
const response = await client.healthCheck(params);
|
|
@@ -1322,6 +1401,7 @@ ${data.overall_summary}
|
|
|
1322
1401
|
description: `AI-powered prediction of memories you'll need based on your current context. Uses semantic similarity, temporal relevance, usage patterns, and serendipity scoring to anticipate what you need before you realize it.`,
|
|
1323
1402
|
inputSchema: z.object({
|
|
1324
1403
|
user_id: z.string().uuid(),
|
|
1404
|
+
...optionalContextFields,
|
|
1325
1405
|
context: z.object({
|
|
1326
1406
|
current_project: z.string().optional().describe("Current project or task description"),
|
|
1327
1407
|
recent_topics: z.array(z.string()).optional().describe("Recent topics you've been working on"),
|
|
@@ -1347,6 +1427,9 @@ ${data.overall_summary}
|
|
|
1347
1427
|
try {
|
|
1348
1428
|
const params = {
|
|
1349
1429
|
userId: rawParams.user_id,
|
|
1430
|
+
organizationId: rawParams.organization_id,
|
|
1431
|
+
topicId: rawParams.topic_id,
|
|
1432
|
+
queryScope: rawParams.query_scope,
|
|
1350
1433
|
context: {
|
|
1351
1434
|
currentProject: rawParams.context?.current_project,
|
|
1352
1435
|
recentTopics: rawParams.context?.recent_topics,
|
|
@@ -1632,10 +1715,16 @@ Was duplicate: ${response.data.was_duplicate}`
|
|
|
1632
1715
|
user_id: z.string().uuid(),
|
|
1633
1716
|
current_state: z.object({
|
|
1634
1717
|
task_description: z.string().min(1, "Task description is required"),
|
|
1635
|
-
completed_steps: z.array(
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1718
|
+
completed_steps: z.array(
|
|
1719
|
+
z.union([
|
|
1720
|
+
z.string().min(1, "Completed step must be a non-empty string"),
|
|
1721
|
+
z.object({
|
|
1722
|
+
tool: z.string().min(1, "Legacy step objects must include tool"),
|
|
1723
|
+
params: z.record(z.unknown()).optional(),
|
|
1724
|
+
parameters: z.record(z.unknown()).optional()
|
|
1725
|
+
}).transform((step) => step.tool)
|
|
1726
|
+
])
|
|
1727
|
+
).optional()
|
|
1639
1728
|
}),
|
|
1640
1729
|
max_suggestions: z.number().int().min(1).max(10).default(3)
|
|
1641
1730
|
}).strict(),
|
|
@@ -1687,6 +1776,6 @@ Was duplicate: ${response.data.was_duplicate}`
|
|
|
1687
1776
|
return server;
|
|
1688
1777
|
}
|
|
1689
1778
|
|
|
1690
|
-
export { ConfigurationError, DatabaseError, EmbeddingError, MemoryIntelligenceError, MemoryNotFoundError, MemoryType, ResponseFormat, ValidationError, createMCPServer };
|
|
1779
|
+
export { ConfigurationError, DatabaseError, EmbeddingError, MemoryIntelligenceError, MemoryNotFoundError, MemoryType, QueryScope, ResponseFormat, ValidationError, createMCPServer };
|
|
1691
1780
|
//# sourceMappingURL=index.js.map
|
|
1692
1781
|
//# sourceMappingURL=index.js.map
|