@prmichaelsen/remember-mcp 1.0.6 → 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/dist/server-factory.js +190 -349
- package/dist/server.js +103 -96
- package/package.json +1 -1
- package/src/server-factory.ts +0 -64
- package/src/tools/search-memory.ts +7 -7
package/dist/server-factory.js
CHANGED
|
@@ -12,16 +12,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
12
12
|
return require.apply(this, arguments);
|
|
13
13
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
14
|
});
|
|
15
|
-
var __esm = (fn, res) => function __init() {
|
|
16
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
17
|
-
};
|
|
18
15
|
var __commonJS = (cb, mod) => function __require2() {
|
|
19
16
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
20
17
|
};
|
|
21
|
-
var __export = (target, all) => {
|
|
22
|
-
for (var name in all)
|
|
23
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
-
};
|
|
25
18
|
var __copyProps = (to, from, except, desc) => {
|
|
26
19
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
20
|
for (let key of __getOwnPropNames(from))
|
|
@@ -397,56 +390,98 @@ var require_main = __commonJS({
|
|
|
397
390
|
}
|
|
398
391
|
});
|
|
399
392
|
|
|
393
|
+
// src/server-factory.ts
|
|
394
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
395
|
+
import {
|
|
396
|
+
CallToolRequestSchema,
|
|
397
|
+
ListToolsRequestSchema,
|
|
398
|
+
ErrorCode,
|
|
399
|
+
McpError
|
|
400
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
401
|
+
|
|
400
402
|
// src/config.ts
|
|
401
|
-
var import_dotenv,
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
403
|
+
var import_dotenv = __toESM(require_main(), 1);
|
|
404
|
+
import_dotenv.default.config();
|
|
405
|
+
var config = {
|
|
406
|
+
// Weaviate
|
|
407
|
+
weaviate: {
|
|
408
|
+
url: process.env.WEAVIATE_REST_URL || "http://localhost:8080",
|
|
409
|
+
apiKey: process.env.WEAVIATE_API_KEY || ""
|
|
410
|
+
},
|
|
411
|
+
// OpenAI (for embeddings)
|
|
412
|
+
openai: {
|
|
413
|
+
apiKey: process.env.OPENAI_EMBEDDINGS_API_KEY || process.env.OPENAI_APIKEY || ""
|
|
414
|
+
},
|
|
415
|
+
// Firebase (using firebase-admin-sdk-v8)
|
|
416
|
+
firebase: {
|
|
417
|
+
serviceAccount: process.env.FIREBASE_ADMIN_SERVICE_ACCOUNT_KEY || "",
|
|
418
|
+
projectId: process.env.FIREBASE_PROJECT_ID || ""
|
|
419
|
+
},
|
|
420
|
+
// Server
|
|
421
|
+
server: {
|
|
422
|
+
port: parseInt(process.env.PORT || "3000", 10),
|
|
423
|
+
nodeEnv: process.env.NODE_ENV || "development",
|
|
424
|
+
logLevel: process.env.LOG_LEVEL || "info"
|
|
425
|
+
},
|
|
426
|
+
// MCP
|
|
427
|
+
mcp: {
|
|
428
|
+
transport: process.env.MCP_TRANSPORT || "sse"
|
|
429
|
+
}
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
// src/utils/logger.ts
|
|
433
|
+
var LOG_LEVELS = {
|
|
434
|
+
debug: 0,
|
|
435
|
+
info: 1,
|
|
436
|
+
warn: 2,
|
|
437
|
+
error: 3
|
|
438
|
+
};
|
|
439
|
+
var currentLevel = LOG_LEVELS[config.server.logLevel] ?? LOG_LEVELS.info;
|
|
440
|
+
function shouldLog(level) {
|
|
441
|
+
return LOG_LEVELS[level] >= currentLevel;
|
|
442
|
+
}
|
|
443
|
+
var logger = {
|
|
444
|
+
debug: (message, data) => {
|
|
445
|
+
if (shouldLog("debug")) {
|
|
446
|
+
if (data) {
|
|
447
|
+
console.debug(JSON.stringify({ level: "DEBUG", message, ...data }));
|
|
448
|
+
} else {
|
|
449
|
+
console.debug(`[DEBUG] ${message}`);
|
|
431
450
|
}
|
|
432
|
-
}
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
info: (message, data) => {
|
|
454
|
+
if (shouldLog("info")) {
|
|
455
|
+
if (data) {
|
|
456
|
+
console.info(JSON.stringify({ level: "INFO", message, ...data }));
|
|
457
|
+
} else {
|
|
458
|
+
console.info(`[INFO] ${message}`);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
warn: (message, data) => {
|
|
463
|
+
if (shouldLog("warn")) {
|
|
464
|
+
if (data) {
|
|
465
|
+
console.warn(JSON.stringify({ level: "WARN", message, ...data }));
|
|
466
|
+
} else {
|
|
467
|
+
console.warn(`[WARN] ${message}`);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
error: (message, data) => {
|
|
472
|
+
if (shouldLog("error")) {
|
|
473
|
+
if (data) {
|
|
474
|
+
console.error(JSON.stringify({ level: "ERROR", message, ...data }));
|
|
475
|
+
} else {
|
|
476
|
+
console.error(`[ERROR] ${message}`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
433
479
|
}
|
|
434
|
-
}
|
|
480
|
+
};
|
|
435
481
|
|
|
436
482
|
// src/weaviate/client.ts
|
|
437
|
-
var client_exports = {};
|
|
438
|
-
__export(client_exports, {
|
|
439
|
-
closeWeaviateClient: () => closeWeaviateClient,
|
|
440
|
-
collectionExists: () => collectionExists,
|
|
441
|
-
getAuditCollectionName: () => getAuditCollectionName,
|
|
442
|
-
getMemoryCollectionName: () => getMemoryCollectionName,
|
|
443
|
-
getTemplateCollectionName: () => getTemplateCollectionName,
|
|
444
|
-
getWeaviateClient: () => getWeaviateClient,
|
|
445
|
-
initWeaviateClient: () => initWeaviateClient,
|
|
446
|
-
sanitizeUserId: () => sanitizeUserId,
|
|
447
|
-
testWeaviateConnection: () => testWeaviateConnection
|
|
448
|
-
});
|
|
449
483
|
import weaviate from "weaviate-client";
|
|
484
|
+
var client = null;
|
|
450
485
|
async function initWeaviateClient() {
|
|
451
486
|
if (client) {
|
|
452
487
|
return client;
|
|
@@ -483,17 +518,6 @@ function getWeaviateClient() {
|
|
|
483
518
|
}
|
|
484
519
|
return client;
|
|
485
520
|
}
|
|
486
|
-
async function testWeaviateConnection() {
|
|
487
|
-
try {
|
|
488
|
-
const weaviateClient = getWeaviateClient();
|
|
489
|
-
const isReady = await weaviateClient.isReady();
|
|
490
|
-
console.log("[Weaviate] Connection successful, ready:", isReady);
|
|
491
|
-
return isReady;
|
|
492
|
-
} catch (error) {
|
|
493
|
-
console.error("[Weaviate] Connection failed:", error);
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
521
|
function sanitizeUserId(userId) {
|
|
498
522
|
let sanitized = userId.replace(/[^a-zA-Z0-9]/g, "_");
|
|
499
523
|
if (/^[0-9]/.test(sanitized)) {
|
|
@@ -501,56 +525,8 @@ function sanitizeUserId(userId) {
|
|
|
501
525
|
}
|
|
502
526
|
return sanitized.charAt(0).toUpperCase() + sanitized.slice(1);
|
|
503
527
|
}
|
|
504
|
-
function getMemoryCollectionName(userId) {
|
|
505
|
-
return `Memory_${sanitizeUserId(userId)}`;
|
|
506
|
-
}
|
|
507
|
-
function getTemplateCollectionName(userId) {
|
|
508
|
-
return `Template_${sanitizeUserId(userId)}`;
|
|
509
|
-
}
|
|
510
|
-
function getAuditCollectionName(userId) {
|
|
511
|
-
return `Audit_${sanitizeUserId(userId)}`;
|
|
512
|
-
}
|
|
513
|
-
async function collectionExists(collectionName) {
|
|
514
|
-
try {
|
|
515
|
-
const weaviateClient = getWeaviateClient();
|
|
516
|
-
const exists = await weaviateClient.collections.exists(collectionName);
|
|
517
|
-
return exists;
|
|
518
|
-
} catch (error) {
|
|
519
|
-
console.error(`[Weaviate] Error checking collection ${collectionName}:`, error);
|
|
520
|
-
return false;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
async function closeWeaviateClient() {
|
|
524
|
-
if (client) {
|
|
525
|
-
client = null;
|
|
526
|
-
console.log("[Weaviate] Client closed");
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
var client;
|
|
530
|
-
var init_client = __esm({
|
|
531
|
-
"src/weaviate/client.ts"() {
|
|
532
|
-
"use strict";
|
|
533
|
-
init_config();
|
|
534
|
-
client = null;
|
|
535
|
-
}
|
|
536
|
-
});
|
|
537
528
|
|
|
538
529
|
// src/firestore/init.ts
|
|
539
|
-
var init_exports = {};
|
|
540
|
-
__export(init_exports, {
|
|
541
|
-
FieldValue: () => FieldValue,
|
|
542
|
-
addDocument: () => addDocument,
|
|
543
|
-
batchWrite: () => batchWrite,
|
|
544
|
-
deleteDocument: () => deleteDocument,
|
|
545
|
-
getDocument: () => getDocument,
|
|
546
|
-
initFirestore: () => initFirestore,
|
|
547
|
-
isFirestoreInitialized: () => isFirestoreInitialized,
|
|
548
|
-
queryDocuments: () => queryDocuments,
|
|
549
|
-
setDocument: () => setDocument,
|
|
550
|
-
testFirestoreConnection: () => testFirestoreConnection,
|
|
551
|
-
updateDocument: () => updateDocument,
|
|
552
|
-
verifyIdToken: () => verifyIdToken
|
|
553
|
-
});
|
|
554
530
|
import { initializeApp } from "@prmichaelsen/firebase-admin-sdk-v8";
|
|
555
531
|
import {
|
|
556
532
|
getDocument,
|
|
@@ -563,6 +539,7 @@ import {
|
|
|
563
539
|
FieldValue,
|
|
564
540
|
verifyIdToken
|
|
565
541
|
} from "@prmichaelsen/firebase-admin-sdk-v8";
|
|
542
|
+
var initialized = false;
|
|
566
543
|
function initFirestore() {
|
|
567
544
|
if (initialized) {
|
|
568
545
|
return;
|
|
@@ -582,98 +559,8 @@ function initFirestore() {
|
|
|
582
559
|
throw error;
|
|
583
560
|
}
|
|
584
561
|
}
|
|
585
|
-
function isFirestoreInitialized() {
|
|
586
|
-
return initialized;
|
|
587
|
-
}
|
|
588
|
-
async function testFirestoreConnection() {
|
|
589
|
-
try {
|
|
590
|
-
if (!initialized) {
|
|
591
|
-
throw new Error("Firestore not initialized");
|
|
592
|
-
}
|
|
593
|
-
const { getDocument: getDocument2 } = await import("@prmichaelsen/firebase-admin-sdk-v8");
|
|
594
|
-
await getDocument2("_health_check", "test");
|
|
595
|
-
console.log("[Firestore] Connection successful");
|
|
596
|
-
return true;
|
|
597
|
-
} catch (error) {
|
|
598
|
-
console.error("[Firestore] Connection test failed:", error);
|
|
599
|
-
return false;
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
var initialized;
|
|
603
|
-
var init_init = __esm({
|
|
604
|
-
"src/firestore/init.ts"() {
|
|
605
|
-
"use strict";
|
|
606
|
-
init_config();
|
|
607
|
-
initialized = false;
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
// src/server-factory.ts
|
|
612
|
-
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
613
|
-
import {
|
|
614
|
-
CallToolRequestSchema,
|
|
615
|
-
ListToolsRequestSchema,
|
|
616
|
-
ErrorCode,
|
|
617
|
-
McpError
|
|
618
|
-
} from "@modelcontextprotocol/sdk/types.js";
|
|
619
|
-
|
|
620
|
-
// src/utils/logger.ts
|
|
621
|
-
init_config();
|
|
622
|
-
var LOG_LEVELS = {
|
|
623
|
-
debug: 0,
|
|
624
|
-
info: 1,
|
|
625
|
-
warn: 2,
|
|
626
|
-
error: 3
|
|
627
|
-
};
|
|
628
|
-
var currentLevel = LOG_LEVELS[config.server.logLevel] ?? LOG_LEVELS.info;
|
|
629
|
-
function shouldLog(level) {
|
|
630
|
-
return LOG_LEVELS[level] >= currentLevel;
|
|
631
|
-
}
|
|
632
|
-
var logger = {
|
|
633
|
-
debug: (message, data) => {
|
|
634
|
-
if (shouldLog("debug")) {
|
|
635
|
-
if (data) {
|
|
636
|
-
console.debug(JSON.stringify({ level: "DEBUG", message, ...data }));
|
|
637
|
-
} else {
|
|
638
|
-
console.debug(`[DEBUG] ${message}`);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
},
|
|
642
|
-
info: (message, data) => {
|
|
643
|
-
if (shouldLog("info")) {
|
|
644
|
-
if (data) {
|
|
645
|
-
console.info(JSON.stringify({ level: "INFO", message, ...data }));
|
|
646
|
-
} else {
|
|
647
|
-
console.info(`[INFO] ${message}`);
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
warn: (message, data) => {
|
|
652
|
-
if (shouldLog("warn")) {
|
|
653
|
-
if (data) {
|
|
654
|
-
console.warn(JSON.stringify({ level: "WARN", message, ...data }));
|
|
655
|
-
} else {
|
|
656
|
-
console.warn(`[WARN] ${message}`);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
},
|
|
660
|
-
error: (message, data) => {
|
|
661
|
-
if (shouldLog("error")) {
|
|
662
|
-
if (data) {
|
|
663
|
-
console.error(JSON.stringify({ level: "ERROR", message, ...data }));
|
|
664
|
-
} else {
|
|
665
|
-
console.error(`[ERROR] ${message}`);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
|
|
671
|
-
// src/server-factory.ts
|
|
672
|
-
init_client();
|
|
673
|
-
init_init();
|
|
674
562
|
|
|
675
563
|
// src/weaviate/schema.ts
|
|
676
|
-
init_client();
|
|
677
564
|
import weaviate2 from "weaviate-client";
|
|
678
565
|
async function createMemoryCollection(userId) {
|
|
679
566
|
const client2 = getWeaviateClient();
|
|
@@ -1409,6 +1296,103 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1409
1296
|
}
|
|
1410
1297
|
}
|
|
1411
1298
|
|
|
1299
|
+
// src/utils/weaviate-filters.ts
|
|
1300
|
+
import { Filters } from "weaviate-client";
|
|
1301
|
+
function buildCombinedSearchFilters(collection, filters) {
|
|
1302
|
+
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1303
|
+
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1304
|
+
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1305
|
+
if (validFilters.length === 0) {
|
|
1306
|
+
return void 0;
|
|
1307
|
+
} else if (validFilters.length === 1) {
|
|
1308
|
+
return validFilters[0];
|
|
1309
|
+
} else {
|
|
1310
|
+
return combineFiltersWithOr(validFilters);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
function buildDocTypeFilters(collection, docType, filters) {
|
|
1314
|
+
const filterList = [];
|
|
1315
|
+
filterList.push(
|
|
1316
|
+
collection.filter.byProperty("doc_type").equal(docType)
|
|
1317
|
+
);
|
|
1318
|
+
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1319
|
+
if (filters.types.length === 1) {
|
|
1320
|
+
filterList.push(
|
|
1321
|
+
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1322
|
+
);
|
|
1323
|
+
} else {
|
|
1324
|
+
filterList.push(
|
|
1325
|
+
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
if (filters?.weight_min !== void 0) {
|
|
1330
|
+
filterList.push(
|
|
1331
|
+
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
if (filters?.weight_max !== void 0) {
|
|
1335
|
+
filterList.push(
|
|
1336
|
+
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
if (filters?.trust_min !== void 0) {
|
|
1340
|
+
filterList.push(
|
|
1341
|
+
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1342
|
+
);
|
|
1343
|
+
}
|
|
1344
|
+
if (filters?.trust_max !== void 0) {
|
|
1345
|
+
filterList.push(
|
|
1346
|
+
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
if (filters?.date_from) {
|
|
1350
|
+
filterList.push(
|
|
1351
|
+
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1352
|
+
);
|
|
1353
|
+
}
|
|
1354
|
+
if (filters?.date_to) {
|
|
1355
|
+
filterList.push(
|
|
1356
|
+
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1357
|
+
);
|
|
1358
|
+
}
|
|
1359
|
+
if (filters?.tags && filters.tags.length > 0) {
|
|
1360
|
+
if (filters.tags.length === 1) {
|
|
1361
|
+
filterList.push(
|
|
1362
|
+
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1363
|
+
);
|
|
1364
|
+
} else {
|
|
1365
|
+
filterList.push(
|
|
1366
|
+
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
return combineFiltersWithAnd(filterList);
|
|
1371
|
+
}
|
|
1372
|
+
function buildMemoryOnlyFilters(collection, filters) {
|
|
1373
|
+
return buildDocTypeFilters(collection, "memory", filters);
|
|
1374
|
+
}
|
|
1375
|
+
function combineFiltersWithAnd(filters) {
|
|
1376
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1377
|
+
if (validFilters.length === 0) {
|
|
1378
|
+
return void 0;
|
|
1379
|
+
}
|
|
1380
|
+
if (validFilters.length === 1) {
|
|
1381
|
+
return validFilters[0];
|
|
1382
|
+
}
|
|
1383
|
+
return Filters.and(...validFilters);
|
|
1384
|
+
}
|
|
1385
|
+
function combineFiltersWithOr(filters) {
|
|
1386
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1387
|
+
if (validFilters.length === 0) {
|
|
1388
|
+
return void 0;
|
|
1389
|
+
}
|
|
1390
|
+
if (validFilters.length === 1) {
|
|
1391
|
+
return validFilters[0];
|
|
1392
|
+
}
|
|
1393
|
+
return Filters.or(...validFilters);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1412
1396
|
// src/tools/search-memory.ts
|
|
1413
1397
|
var searchMemoryTool = {
|
|
1414
1398
|
name: "remember_search_memory",
|
|
@@ -1512,15 +1496,19 @@ async function handleSearchMemory(args, userId) {
|
|
|
1512
1496
|
const alpha = args.alpha ?? 0.7;
|
|
1513
1497
|
const limit = args.limit ?? 10;
|
|
1514
1498
|
const offset = args.offset ?? 0;
|
|
1499
|
+
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1515
1500
|
const searchOptions = {
|
|
1516
1501
|
alpha,
|
|
1517
1502
|
limit: limit + offset
|
|
1518
1503
|
// Get extra for offset
|
|
1519
1504
|
};
|
|
1505
|
+
if (filters) {
|
|
1506
|
+
searchOptions.filters = filters;
|
|
1507
|
+
}
|
|
1520
1508
|
logger.info("Weaviate query", {
|
|
1521
1509
|
query: args.query,
|
|
1522
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1523
|
-
|
|
1510
|
+
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
1511
|
+
hasFilters: !!filters
|
|
1524
1512
|
});
|
|
1525
1513
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1526
1514
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1914,100 +1902,6 @@ async function handleFindSimilar(args, userId) {
|
|
|
1914
1902
|
}
|
|
1915
1903
|
}
|
|
1916
1904
|
|
|
1917
|
-
// src/utils/weaviate-filters.ts
|
|
1918
|
-
import { Filters } from "weaviate-client";
|
|
1919
|
-
function buildCombinedSearchFilters(collection, filters) {
|
|
1920
|
-
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1921
|
-
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1922
|
-
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1923
|
-
if (validFilters.length === 0) {
|
|
1924
|
-
return void 0;
|
|
1925
|
-
} else if (validFilters.length === 1) {
|
|
1926
|
-
return validFilters[0];
|
|
1927
|
-
} else {
|
|
1928
|
-
return combineFiltersWithOr(validFilters);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
function buildDocTypeFilters(collection, docType, filters) {
|
|
1932
|
-
const filterList = [];
|
|
1933
|
-
filterList.push(
|
|
1934
|
-
collection.filter.byProperty("doc_type").equal(docType)
|
|
1935
|
-
);
|
|
1936
|
-
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1937
|
-
if (filters.types.length === 1) {
|
|
1938
|
-
filterList.push(
|
|
1939
|
-
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1940
|
-
);
|
|
1941
|
-
} else {
|
|
1942
|
-
filterList.push(
|
|
1943
|
-
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1944
|
-
);
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
if (filters?.weight_min !== void 0) {
|
|
1948
|
-
filterList.push(
|
|
1949
|
-
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1950
|
-
);
|
|
1951
|
-
}
|
|
1952
|
-
if (filters?.weight_max !== void 0) {
|
|
1953
|
-
filterList.push(
|
|
1954
|
-
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1955
|
-
);
|
|
1956
|
-
}
|
|
1957
|
-
if (filters?.trust_min !== void 0) {
|
|
1958
|
-
filterList.push(
|
|
1959
|
-
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1960
|
-
);
|
|
1961
|
-
}
|
|
1962
|
-
if (filters?.trust_max !== void 0) {
|
|
1963
|
-
filterList.push(
|
|
1964
|
-
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1965
|
-
);
|
|
1966
|
-
}
|
|
1967
|
-
if (filters?.date_from) {
|
|
1968
|
-
filterList.push(
|
|
1969
|
-
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1970
|
-
);
|
|
1971
|
-
}
|
|
1972
|
-
if (filters?.date_to) {
|
|
1973
|
-
filterList.push(
|
|
1974
|
-
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1975
|
-
);
|
|
1976
|
-
}
|
|
1977
|
-
if (filters?.tags && filters.tags.length > 0) {
|
|
1978
|
-
if (filters.tags.length === 1) {
|
|
1979
|
-
filterList.push(
|
|
1980
|
-
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1981
|
-
);
|
|
1982
|
-
} else {
|
|
1983
|
-
filterList.push(
|
|
1984
|
-
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1985
|
-
);
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
return combineFiltersWithAnd(filterList);
|
|
1989
|
-
}
|
|
1990
|
-
function combineFiltersWithAnd(filters) {
|
|
1991
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1992
|
-
if (validFilters.length === 0) {
|
|
1993
|
-
return void 0;
|
|
1994
|
-
}
|
|
1995
|
-
if (validFilters.length === 1) {
|
|
1996
|
-
return validFilters[0];
|
|
1997
|
-
}
|
|
1998
|
-
return Filters.and(...validFilters);
|
|
1999
|
-
}
|
|
2000
|
-
function combineFiltersWithOr(filters) {
|
|
2001
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
2002
|
-
if (validFilters.length === 0) {
|
|
2003
|
-
return void 0;
|
|
2004
|
-
}
|
|
2005
|
-
if (validFilters.length === 1) {
|
|
2006
|
-
return validFilters[0];
|
|
2007
|
-
}
|
|
2008
|
-
return Filters.or(...validFilters);
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
1905
|
// src/tools/query-memory.ts
|
|
2012
1906
|
var queryMemoryTool = {
|
|
2013
1907
|
name: "remember_query_memory",
|
|
@@ -2733,9 +2627,6 @@ async function handleDeleteRelationship(args, userId) {
|
|
|
2733
2627
|
}
|
|
2734
2628
|
}
|
|
2735
2629
|
|
|
2736
|
-
// src/services/preferences-database.service.ts
|
|
2737
|
-
init_init();
|
|
2738
|
-
|
|
2739
2630
|
// src/firestore/paths.ts
|
|
2740
2631
|
var APP_NAME = "remember-mcp";
|
|
2741
2632
|
function getBasePrefix() {
|
|
@@ -3220,14 +3111,6 @@ function registerHandlers(server, userId, accessToken) {
|
|
|
3220
3111
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
3221
3112
|
return {
|
|
3222
3113
|
tools: [
|
|
3223
|
-
{
|
|
3224
|
-
name: "health_check",
|
|
3225
|
-
description: "Check server health and database connections",
|
|
3226
|
-
inputSchema: {
|
|
3227
|
-
type: "object",
|
|
3228
|
-
properties: {}
|
|
3229
|
-
}
|
|
3230
|
-
},
|
|
3231
3114
|
// Memory tools
|
|
3232
3115
|
createMemoryTool,
|
|
3233
3116
|
searchMemoryTool,
|
|
@@ -3251,9 +3134,6 @@ function registerHandlers(server, userId, accessToken) {
|
|
|
3251
3134
|
try {
|
|
3252
3135
|
let result;
|
|
3253
3136
|
switch (name) {
|
|
3254
|
-
case "health_check":
|
|
3255
|
-
result = await handleHealthCheck(userId);
|
|
3256
|
-
break;
|
|
3257
3137
|
case "remember_create_memory":
|
|
3258
3138
|
result = await handleCreateMemory(args, userId);
|
|
3259
3139
|
break;
|
|
@@ -3316,45 +3196,6 @@ function registerHandlers(server, userId, accessToken) {
|
|
|
3316
3196
|
}
|
|
3317
3197
|
});
|
|
3318
3198
|
}
|
|
3319
|
-
async function handleHealthCheck(userId) {
|
|
3320
|
-
const health = {
|
|
3321
|
-
status: "healthy",
|
|
3322
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3323
|
-
userId,
|
|
3324
|
-
server: {
|
|
3325
|
-
name: "remember-mcp",
|
|
3326
|
-
version: "0.1.0"
|
|
3327
|
-
},
|
|
3328
|
-
databases: {
|
|
3329
|
-
weaviate: {
|
|
3330
|
-
connected: false,
|
|
3331
|
-
userCollection: `Memory_${userId}`
|
|
3332
|
-
},
|
|
3333
|
-
firestore: {
|
|
3334
|
-
connected: false,
|
|
3335
|
-
userPath: `users/${userId}`
|
|
3336
|
-
}
|
|
3337
|
-
}
|
|
3338
|
-
};
|
|
3339
|
-
try {
|
|
3340
|
-
const { getWeaviateClient: getWeaviateClient2 } = await Promise.resolve().then(() => (init_client(), client_exports));
|
|
3341
|
-
const weaviateClient = getWeaviateClient2();
|
|
3342
|
-
health.databases.weaviate.connected = await weaviateClient.isReady();
|
|
3343
|
-
} catch (error) {
|
|
3344
|
-
logger.error("Weaviate health check failed:", error);
|
|
3345
|
-
health.databases.weaviate.connected = false;
|
|
3346
|
-
}
|
|
3347
|
-
try {
|
|
3348
|
-
const { testFirestoreConnection: testFirestoreConnection2 } = await Promise.resolve().then(() => (init_init(), init_exports));
|
|
3349
|
-
health.databases.firestore.connected = await testFirestoreConnection2();
|
|
3350
|
-
} catch (error) {
|
|
3351
|
-
logger.error("Firestore health check failed:", error);
|
|
3352
|
-
health.databases.firestore.connected = false;
|
|
3353
|
-
}
|
|
3354
|
-
const allHealthy = health.databases.weaviate.connected && health.databases.firestore.connected;
|
|
3355
|
-
health.status = allHealthy ? "healthy" : "degraded";
|
|
3356
|
-
return JSON.stringify(health, null, 2);
|
|
3357
|
-
}
|
|
3358
3199
|
export {
|
|
3359
3200
|
createServer
|
|
3360
3201
|
};
|
package/dist/server.js
CHANGED
|
@@ -1338,6 +1338,103 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1338
1338
|
}
|
|
1339
1339
|
}
|
|
1340
1340
|
|
|
1341
|
+
// src/utils/weaviate-filters.ts
|
|
1342
|
+
import { Filters } from "weaviate-client";
|
|
1343
|
+
function buildCombinedSearchFilters(collection, filters) {
|
|
1344
|
+
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1345
|
+
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1346
|
+
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1347
|
+
if (validFilters.length === 0) {
|
|
1348
|
+
return void 0;
|
|
1349
|
+
} else if (validFilters.length === 1) {
|
|
1350
|
+
return validFilters[0];
|
|
1351
|
+
} else {
|
|
1352
|
+
return combineFiltersWithOr(validFilters);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
function buildDocTypeFilters(collection, docType, filters) {
|
|
1356
|
+
const filterList = [];
|
|
1357
|
+
filterList.push(
|
|
1358
|
+
collection.filter.byProperty("doc_type").equal(docType)
|
|
1359
|
+
);
|
|
1360
|
+
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1361
|
+
if (filters.types.length === 1) {
|
|
1362
|
+
filterList.push(
|
|
1363
|
+
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1364
|
+
);
|
|
1365
|
+
} else {
|
|
1366
|
+
filterList.push(
|
|
1367
|
+
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1368
|
+
);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
if (filters?.weight_min !== void 0) {
|
|
1372
|
+
filterList.push(
|
|
1373
|
+
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1374
|
+
);
|
|
1375
|
+
}
|
|
1376
|
+
if (filters?.weight_max !== void 0) {
|
|
1377
|
+
filterList.push(
|
|
1378
|
+
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
if (filters?.trust_min !== void 0) {
|
|
1382
|
+
filterList.push(
|
|
1383
|
+
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1384
|
+
);
|
|
1385
|
+
}
|
|
1386
|
+
if (filters?.trust_max !== void 0) {
|
|
1387
|
+
filterList.push(
|
|
1388
|
+
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
if (filters?.date_from) {
|
|
1392
|
+
filterList.push(
|
|
1393
|
+
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
if (filters?.date_to) {
|
|
1397
|
+
filterList.push(
|
|
1398
|
+
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1399
|
+
);
|
|
1400
|
+
}
|
|
1401
|
+
if (filters?.tags && filters.tags.length > 0) {
|
|
1402
|
+
if (filters.tags.length === 1) {
|
|
1403
|
+
filterList.push(
|
|
1404
|
+
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1405
|
+
);
|
|
1406
|
+
} else {
|
|
1407
|
+
filterList.push(
|
|
1408
|
+
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
return combineFiltersWithAnd(filterList);
|
|
1413
|
+
}
|
|
1414
|
+
function buildMemoryOnlyFilters(collection, filters) {
|
|
1415
|
+
return buildDocTypeFilters(collection, "memory", filters);
|
|
1416
|
+
}
|
|
1417
|
+
function combineFiltersWithAnd(filters) {
|
|
1418
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1419
|
+
if (validFilters.length === 0) {
|
|
1420
|
+
return void 0;
|
|
1421
|
+
}
|
|
1422
|
+
if (validFilters.length === 1) {
|
|
1423
|
+
return validFilters[0];
|
|
1424
|
+
}
|
|
1425
|
+
return Filters.and(...validFilters);
|
|
1426
|
+
}
|
|
1427
|
+
function combineFiltersWithOr(filters) {
|
|
1428
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1429
|
+
if (validFilters.length === 0) {
|
|
1430
|
+
return void 0;
|
|
1431
|
+
}
|
|
1432
|
+
if (validFilters.length === 1) {
|
|
1433
|
+
return validFilters[0];
|
|
1434
|
+
}
|
|
1435
|
+
return Filters.or(...validFilters);
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1341
1438
|
// src/tools/search-memory.ts
|
|
1342
1439
|
var searchMemoryTool = {
|
|
1343
1440
|
name: "remember_search_memory",
|
|
@@ -1441,15 +1538,19 @@ async function handleSearchMemory(args, userId) {
|
|
|
1441
1538
|
const alpha = args.alpha ?? 0.7;
|
|
1442
1539
|
const limit = args.limit ?? 10;
|
|
1443
1540
|
const offset = args.offset ?? 0;
|
|
1541
|
+
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1444
1542
|
const searchOptions = {
|
|
1445
1543
|
alpha,
|
|
1446
1544
|
limit: limit + offset
|
|
1447
1545
|
// Get extra for offset
|
|
1448
1546
|
};
|
|
1547
|
+
if (filters) {
|
|
1548
|
+
searchOptions.filters = filters;
|
|
1549
|
+
}
|
|
1449
1550
|
logger.info("Weaviate query", {
|
|
1450
1551
|
query: args.query,
|
|
1451
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1452
|
-
|
|
1552
|
+
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
1553
|
+
hasFilters: !!filters
|
|
1453
1554
|
});
|
|
1454
1555
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1455
1556
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1843,100 +1944,6 @@ async function handleFindSimilar(args, userId) {
|
|
|
1843
1944
|
}
|
|
1844
1945
|
}
|
|
1845
1946
|
|
|
1846
|
-
// src/utils/weaviate-filters.ts
|
|
1847
|
-
import { Filters } from "weaviate-client";
|
|
1848
|
-
function buildCombinedSearchFilters(collection, filters) {
|
|
1849
|
-
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1850
|
-
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1851
|
-
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1852
|
-
if (validFilters.length === 0) {
|
|
1853
|
-
return void 0;
|
|
1854
|
-
} else if (validFilters.length === 1) {
|
|
1855
|
-
return validFilters[0];
|
|
1856
|
-
} else {
|
|
1857
|
-
return combineFiltersWithOr(validFilters);
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
function buildDocTypeFilters(collection, docType, filters) {
|
|
1861
|
-
const filterList = [];
|
|
1862
|
-
filterList.push(
|
|
1863
|
-
collection.filter.byProperty("doc_type").equal(docType)
|
|
1864
|
-
);
|
|
1865
|
-
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1866
|
-
if (filters.types.length === 1) {
|
|
1867
|
-
filterList.push(
|
|
1868
|
-
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1869
|
-
);
|
|
1870
|
-
} else {
|
|
1871
|
-
filterList.push(
|
|
1872
|
-
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1873
|
-
);
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
if (filters?.weight_min !== void 0) {
|
|
1877
|
-
filterList.push(
|
|
1878
|
-
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1879
|
-
);
|
|
1880
|
-
}
|
|
1881
|
-
if (filters?.weight_max !== void 0) {
|
|
1882
|
-
filterList.push(
|
|
1883
|
-
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1884
|
-
);
|
|
1885
|
-
}
|
|
1886
|
-
if (filters?.trust_min !== void 0) {
|
|
1887
|
-
filterList.push(
|
|
1888
|
-
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1889
|
-
);
|
|
1890
|
-
}
|
|
1891
|
-
if (filters?.trust_max !== void 0) {
|
|
1892
|
-
filterList.push(
|
|
1893
|
-
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1894
|
-
);
|
|
1895
|
-
}
|
|
1896
|
-
if (filters?.date_from) {
|
|
1897
|
-
filterList.push(
|
|
1898
|
-
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1899
|
-
);
|
|
1900
|
-
}
|
|
1901
|
-
if (filters?.date_to) {
|
|
1902
|
-
filterList.push(
|
|
1903
|
-
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1904
|
-
);
|
|
1905
|
-
}
|
|
1906
|
-
if (filters?.tags && filters.tags.length > 0) {
|
|
1907
|
-
if (filters.tags.length === 1) {
|
|
1908
|
-
filterList.push(
|
|
1909
|
-
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1910
|
-
);
|
|
1911
|
-
} else {
|
|
1912
|
-
filterList.push(
|
|
1913
|
-
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1914
|
-
);
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
return combineFiltersWithAnd(filterList);
|
|
1918
|
-
}
|
|
1919
|
-
function combineFiltersWithAnd(filters) {
|
|
1920
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1921
|
-
if (validFilters.length === 0) {
|
|
1922
|
-
return void 0;
|
|
1923
|
-
}
|
|
1924
|
-
if (validFilters.length === 1) {
|
|
1925
|
-
return validFilters[0];
|
|
1926
|
-
}
|
|
1927
|
-
return Filters.and(...validFilters);
|
|
1928
|
-
}
|
|
1929
|
-
function combineFiltersWithOr(filters) {
|
|
1930
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1931
|
-
if (validFilters.length === 0) {
|
|
1932
|
-
return void 0;
|
|
1933
|
-
}
|
|
1934
|
-
if (validFilters.length === 1) {
|
|
1935
|
-
return validFilters[0];
|
|
1936
|
-
}
|
|
1937
|
-
return Filters.or(...validFilters);
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
1947
|
// src/tools/query-memory.ts
|
|
1941
1948
|
var queryMemoryTool = {
|
|
1942
1949
|
name: "remember_query_memory",
|
package/package.json
CHANGED
package/src/server-factory.ts
CHANGED
|
@@ -158,14 +158,6 @@ function registerHandlers(server: Server, userId: string, accessToken: string):
|
|
|
158
158
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
159
159
|
return {
|
|
160
160
|
tools: [
|
|
161
|
-
{
|
|
162
|
-
name: 'health_check',
|
|
163
|
-
description: 'Check server health and database connections',
|
|
164
|
-
inputSchema: {
|
|
165
|
-
type: 'object',
|
|
166
|
-
properties: {},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
161
|
// Memory tools
|
|
170
162
|
createMemoryTool,
|
|
171
163
|
searchMemoryTool,
|
|
@@ -193,10 +185,6 @@ function registerHandlers(server: Server, userId: string, accessToken: string):
|
|
|
193
185
|
let result: string;
|
|
194
186
|
|
|
195
187
|
switch (name) {
|
|
196
|
-
case 'health_check':
|
|
197
|
-
result = await handleHealthCheck(userId);
|
|
198
|
-
break;
|
|
199
|
-
|
|
200
188
|
case 'remember_create_memory':
|
|
201
189
|
result = await handleCreateMemory(args as any, userId);
|
|
202
190
|
break;
|
|
@@ -274,55 +262,3 @@ function registerHandlers(server: Server, userId: string, accessToken: string):
|
|
|
274
262
|
});
|
|
275
263
|
}
|
|
276
264
|
|
|
277
|
-
/**
|
|
278
|
-
* Health check handler (scoped to userId)
|
|
279
|
-
*/
|
|
280
|
-
async function handleHealthCheck(userId: string): Promise<string> {
|
|
281
|
-
const health = {
|
|
282
|
-
status: 'healthy',
|
|
283
|
-
timestamp: new Date().toISOString(),
|
|
284
|
-
userId: userId,
|
|
285
|
-
server: {
|
|
286
|
-
name: 'remember-mcp',
|
|
287
|
-
version: '0.1.0',
|
|
288
|
-
},
|
|
289
|
-
databases: {
|
|
290
|
-
weaviate: {
|
|
291
|
-
connected: false,
|
|
292
|
-
userCollection: `Memory_${userId}`,
|
|
293
|
-
},
|
|
294
|
-
firestore: {
|
|
295
|
-
connected: false,
|
|
296
|
-
userPath: `users/${userId}`,
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
};
|
|
300
|
-
|
|
301
|
-
try {
|
|
302
|
-
// Test Weaviate connection
|
|
303
|
-
const { getWeaviateClient } = await import('./weaviate/client.js');
|
|
304
|
-
const weaviateClient = getWeaviateClient();
|
|
305
|
-
health.databases.weaviate.connected = await weaviateClient.isReady();
|
|
306
|
-
} catch (error) {
|
|
307
|
-
logger.error('Weaviate health check failed:', error);
|
|
308
|
-
health.databases.weaviate.connected = false;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
try {
|
|
312
|
-
// Test Firestore connection
|
|
313
|
-
const { testFirestoreConnection } = await import('./firestore/init.js');
|
|
314
|
-
health.databases.firestore.connected = await testFirestoreConnection();
|
|
315
|
-
} catch (error) {
|
|
316
|
-
logger.error('Firestore health check failed:', error);
|
|
317
|
-
health.databases.firestore.connected = false;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// Overall status
|
|
321
|
-
const allHealthy =
|
|
322
|
-
health.databases.weaviate.connected &&
|
|
323
|
-
health.databases.firestore.connected;
|
|
324
|
-
|
|
325
|
-
health.status = allHealthy ? 'healthy' : 'degraded';
|
|
326
|
-
|
|
327
|
-
return JSON.stringify(health, null, 2);
|
|
328
|
-
}
|
|
@@ -127,9 +127,9 @@ export async function handleSearchMemory(
|
|
|
127
127
|
|
|
128
128
|
// Build filters using v3 API
|
|
129
129
|
// Use OR logic to search both memories and relationships
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
const filters = includeRelationships
|
|
131
|
+
? buildCombinedSearchFilters(collection, args.filters)
|
|
132
|
+
: buildMemoryOnlyFilters(collection, args.filters);
|
|
133
133
|
|
|
134
134
|
// Build search options
|
|
135
135
|
const searchOptions: any = {
|
|
@@ -138,15 +138,15 @@ export async function handleSearchMemory(
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
// Add filters if present
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
141
|
+
if (filters) {
|
|
142
|
+
searchOptions.filters = filters;
|
|
143
|
+
}
|
|
144
144
|
|
|
145
145
|
// Log the query for debugging
|
|
146
146
|
logger.info('Weaviate query', {
|
|
147
147
|
query: args.query,
|
|
148
148
|
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
149
|
-
|
|
149
|
+
hasFilters: !!filters,
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
// Perform hybrid search with Weaviate v3 API
|