@prmichaelsen/remember-mcp 1.0.4 → 1.0.5
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 +99 -105
- package/dist/server.js +99 -105
- package/package.json +1 -1
- package/src/tools/search-memory.ts +10 -9
package/dist/server-factory.js
CHANGED
|
@@ -1407,103 +1407,6 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1407
1407
|
}
|
|
1408
1408
|
}
|
|
1409
1409
|
|
|
1410
|
-
// src/utils/weaviate-filters.ts
|
|
1411
|
-
import { Filters } from "weaviate-client";
|
|
1412
|
-
function buildCombinedSearchFilters(collection, filters) {
|
|
1413
|
-
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1414
|
-
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1415
|
-
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1416
|
-
if (validFilters.length === 0) {
|
|
1417
|
-
return void 0;
|
|
1418
|
-
} else if (validFilters.length === 1) {
|
|
1419
|
-
return validFilters[0];
|
|
1420
|
-
} else {
|
|
1421
|
-
return combineFiltersWithOr(validFilters);
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
function buildDocTypeFilters(collection, docType, filters) {
|
|
1425
|
-
const filterList = [];
|
|
1426
|
-
filterList.push(
|
|
1427
|
-
collection.filter.byProperty("doc_type").equal(docType)
|
|
1428
|
-
);
|
|
1429
|
-
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1430
|
-
if (filters.types.length === 1) {
|
|
1431
|
-
filterList.push(
|
|
1432
|
-
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1433
|
-
);
|
|
1434
|
-
} else {
|
|
1435
|
-
filterList.push(
|
|
1436
|
-
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1437
|
-
);
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
if (filters?.weight_min !== void 0) {
|
|
1441
|
-
filterList.push(
|
|
1442
|
-
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1443
|
-
);
|
|
1444
|
-
}
|
|
1445
|
-
if (filters?.weight_max !== void 0) {
|
|
1446
|
-
filterList.push(
|
|
1447
|
-
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1448
|
-
);
|
|
1449
|
-
}
|
|
1450
|
-
if (filters?.trust_min !== void 0) {
|
|
1451
|
-
filterList.push(
|
|
1452
|
-
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1453
|
-
);
|
|
1454
|
-
}
|
|
1455
|
-
if (filters?.trust_max !== void 0) {
|
|
1456
|
-
filterList.push(
|
|
1457
|
-
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1458
|
-
);
|
|
1459
|
-
}
|
|
1460
|
-
if (filters?.date_from) {
|
|
1461
|
-
filterList.push(
|
|
1462
|
-
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1463
|
-
);
|
|
1464
|
-
}
|
|
1465
|
-
if (filters?.date_to) {
|
|
1466
|
-
filterList.push(
|
|
1467
|
-
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1468
|
-
);
|
|
1469
|
-
}
|
|
1470
|
-
if (filters?.tags && filters.tags.length > 0) {
|
|
1471
|
-
if (filters.tags.length === 1) {
|
|
1472
|
-
filterList.push(
|
|
1473
|
-
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1474
|
-
);
|
|
1475
|
-
} else {
|
|
1476
|
-
filterList.push(
|
|
1477
|
-
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1478
|
-
);
|
|
1479
|
-
}
|
|
1480
|
-
}
|
|
1481
|
-
return combineFiltersWithAnd(filterList);
|
|
1482
|
-
}
|
|
1483
|
-
function buildMemoryOnlyFilters(collection, filters) {
|
|
1484
|
-
return buildDocTypeFilters(collection, "memory", filters);
|
|
1485
|
-
}
|
|
1486
|
-
function combineFiltersWithAnd(filters) {
|
|
1487
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1488
|
-
if (validFilters.length === 0) {
|
|
1489
|
-
return void 0;
|
|
1490
|
-
}
|
|
1491
|
-
if (validFilters.length === 1) {
|
|
1492
|
-
return validFilters[0];
|
|
1493
|
-
}
|
|
1494
|
-
return Filters.and(...validFilters);
|
|
1495
|
-
}
|
|
1496
|
-
function combineFiltersWithOr(filters) {
|
|
1497
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1498
|
-
if (validFilters.length === 0) {
|
|
1499
|
-
return void 0;
|
|
1500
|
-
}
|
|
1501
|
-
if (validFilters.length === 1) {
|
|
1502
|
-
return validFilters[0];
|
|
1503
|
-
}
|
|
1504
|
-
return Filters.or(...validFilters);
|
|
1505
|
-
}
|
|
1506
|
-
|
|
1507
1410
|
// src/tools/search-memory.ts
|
|
1508
1411
|
var searchMemoryTool = {
|
|
1509
1412
|
name: "remember_search_memory",
|
|
@@ -1607,19 +1510,15 @@ async function handleSearchMemory(args, userId) {
|
|
|
1607
1510
|
const alpha = args.alpha ?? 0.7;
|
|
1608
1511
|
const limit = args.limit ?? 10;
|
|
1609
1512
|
const offset = args.offset ?? 0;
|
|
1610
|
-
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1611
1513
|
const searchOptions = {
|
|
1612
1514
|
alpha,
|
|
1613
1515
|
limit: limit + offset
|
|
1614
1516
|
// Get extra for offset
|
|
1615
1517
|
};
|
|
1616
|
-
if (filters) {
|
|
1617
|
-
searchOptions.filters = filters;
|
|
1618
|
-
}
|
|
1619
1518
|
logger.info("Weaviate query", {
|
|
1620
1519
|
query: args.query,
|
|
1621
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1622
|
-
hasFilters: !!filters
|
|
1520
|
+
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1521
|
+
// hasFilters: !!filters,
|
|
1623
1522
|
});
|
|
1624
1523
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1625
1524
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1652,8 +1551,9 @@ async function handleSearchMemory(args, userId) {
|
|
|
1652
1551
|
});
|
|
1653
1552
|
return JSON.stringify(searchResult, null, 2);
|
|
1654
1553
|
} catch (error) {
|
|
1655
|
-
|
|
1656
|
-
|
|
1554
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1555
|
+
logger.error("Failed to search memories:", { error: errorMessage, userId, query: args.query });
|
|
1556
|
+
throw new Error(`Failed to search memories: ${errorMessage}`);
|
|
1657
1557
|
}
|
|
1658
1558
|
}
|
|
1659
1559
|
|
|
@@ -2012,6 +1912,100 @@ async function handleFindSimilar(args, userId) {
|
|
|
2012
1912
|
}
|
|
2013
1913
|
}
|
|
2014
1914
|
|
|
1915
|
+
// src/utils/weaviate-filters.ts
|
|
1916
|
+
import { Filters } from "weaviate-client";
|
|
1917
|
+
function buildCombinedSearchFilters(collection, filters) {
|
|
1918
|
+
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1919
|
+
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1920
|
+
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1921
|
+
if (validFilters.length === 0) {
|
|
1922
|
+
return void 0;
|
|
1923
|
+
} else if (validFilters.length === 1) {
|
|
1924
|
+
return validFilters[0];
|
|
1925
|
+
} else {
|
|
1926
|
+
return combineFiltersWithOr(validFilters);
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
function buildDocTypeFilters(collection, docType, filters) {
|
|
1930
|
+
const filterList = [];
|
|
1931
|
+
filterList.push(
|
|
1932
|
+
collection.filter.byProperty("doc_type").equal(docType)
|
|
1933
|
+
);
|
|
1934
|
+
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1935
|
+
if (filters.types.length === 1) {
|
|
1936
|
+
filterList.push(
|
|
1937
|
+
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1938
|
+
);
|
|
1939
|
+
} else {
|
|
1940
|
+
filterList.push(
|
|
1941
|
+
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
if (filters?.weight_min !== void 0) {
|
|
1946
|
+
filterList.push(
|
|
1947
|
+
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1948
|
+
);
|
|
1949
|
+
}
|
|
1950
|
+
if (filters?.weight_max !== void 0) {
|
|
1951
|
+
filterList.push(
|
|
1952
|
+
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1953
|
+
);
|
|
1954
|
+
}
|
|
1955
|
+
if (filters?.trust_min !== void 0) {
|
|
1956
|
+
filterList.push(
|
|
1957
|
+
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1958
|
+
);
|
|
1959
|
+
}
|
|
1960
|
+
if (filters?.trust_max !== void 0) {
|
|
1961
|
+
filterList.push(
|
|
1962
|
+
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
if (filters?.date_from) {
|
|
1966
|
+
filterList.push(
|
|
1967
|
+
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
if (filters?.date_to) {
|
|
1971
|
+
filterList.push(
|
|
1972
|
+
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1973
|
+
);
|
|
1974
|
+
}
|
|
1975
|
+
if (filters?.tags && filters.tags.length > 0) {
|
|
1976
|
+
if (filters.tags.length === 1) {
|
|
1977
|
+
filterList.push(
|
|
1978
|
+
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1979
|
+
);
|
|
1980
|
+
} else {
|
|
1981
|
+
filterList.push(
|
|
1982
|
+
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
return combineFiltersWithAnd(filterList);
|
|
1987
|
+
}
|
|
1988
|
+
function combineFiltersWithAnd(filters) {
|
|
1989
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1990
|
+
if (validFilters.length === 0) {
|
|
1991
|
+
return void 0;
|
|
1992
|
+
}
|
|
1993
|
+
if (validFilters.length === 1) {
|
|
1994
|
+
return validFilters[0];
|
|
1995
|
+
}
|
|
1996
|
+
return Filters.and(...validFilters);
|
|
1997
|
+
}
|
|
1998
|
+
function combineFiltersWithOr(filters) {
|
|
1999
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
2000
|
+
if (validFilters.length === 0) {
|
|
2001
|
+
return void 0;
|
|
2002
|
+
}
|
|
2003
|
+
if (validFilters.length === 1) {
|
|
2004
|
+
return validFilters[0];
|
|
2005
|
+
}
|
|
2006
|
+
return Filters.or(...validFilters);
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2015
2009
|
// src/tools/query-memory.ts
|
|
2016
2010
|
var queryMemoryTool = {
|
|
2017
2011
|
name: "remember_query_memory",
|
package/dist/server.js
CHANGED
|
@@ -1336,103 +1336,6 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1336
1336
|
}
|
|
1337
1337
|
}
|
|
1338
1338
|
|
|
1339
|
-
// src/utils/weaviate-filters.ts
|
|
1340
|
-
import { Filters } from "weaviate-client";
|
|
1341
|
-
function buildCombinedSearchFilters(collection, filters) {
|
|
1342
|
-
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1343
|
-
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1344
|
-
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1345
|
-
if (validFilters.length === 0) {
|
|
1346
|
-
return void 0;
|
|
1347
|
-
} else if (validFilters.length === 1) {
|
|
1348
|
-
return validFilters[0];
|
|
1349
|
-
} else {
|
|
1350
|
-
return combineFiltersWithOr(validFilters);
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
function buildDocTypeFilters(collection, docType, filters) {
|
|
1354
|
-
const filterList = [];
|
|
1355
|
-
filterList.push(
|
|
1356
|
-
collection.filter.byProperty("doc_type").equal(docType)
|
|
1357
|
-
);
|
|
1358
|
-
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1359
|
-
if (filters.types.length === 1) {
|
|
1360
|
-
filterList.push(
|
|
1361
|
-
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1362
|
-
);
|
|
1363
|
-
} else {
|
|
1364
|
-
filterList.push(
|
|
1365
|
-
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1366
|
-
);
|
|
1367
|
-
}
|
|
1368
|
-
}
|
|
1369
|
-
if (filters?.weight_min !== void 0) {
|
|
1370
|
-
filterList.push(
|
|
1371
|
-
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1372
|
-
);
|
|
1373
|
-
}
|
|
1374
|
-
if (filters?.weight_max !== void 0) {
|
|
1375
|
-
filterList.push(
|
|
1376
|
-
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1377
|
-
);
|
|
1378
|
-
}
|
|
1379
|
-
if (filters?.trust_min !== void 0) {
|
|
1380
|
-
filterList.push(
|
|
1381
|
-
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1382
|
-
);
|
|
1383
|
-
}
|
|
1384
|
-
if (filters?.trust_max !== void 0) {
|
|
1385
|
-
filterList.push(
|
|
1386
|
-
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1387
|
-
);
|
|
1388
|
-
}
|
|
1389
|
-
if (filters?.date_from) {
|
|
1390
|
-
filterList.push(
|
|
1391
|
-
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1392
|
-
);
|
|
1393
|
-
}
|
|
1394
|
-
if (filters?.date_to) {
|
|
1395
|
-
filterList.push(
|
|
1396
|
-
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1397
|
-
);
|
|
1398
|
-
}
|
|
1399
|
-
if (filters?.tags && filters.tags.length > 0) {
|
|
1400
|
-
if (filters.tags.length === 1) {
|
|
1401
|
-
filterList.push(
|
|
1402
|
-
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1403
|
-
);
|
|
1404
|
-
} else {
|
|
1405
|
-
filterList.push(
|
|
1406
|
-
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1407
|
-
);
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
return combineFiltersWithAnd(filterList);
|
|
1411
|
-
}
|
|
1412
|
-
function buildMemoryOnlyFilters(collection, filters) {
|
|
1413
|
-
return buildDocTypeFilters(collection, "memory", filters);
|
|
1414
|
-
}
|
|
1415
|
-
function combineFiltersWithAnd(filters) {
|
|
1416
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1417
|
-
if (validFilters.length === 0) {
|
|
1418
|
-
return void 0;
|
|
1419
|
-
}
|
|
1420
|
-
if (validFilters.length === 1) {
|
|
1421
|
-
return validFilters[0];
|
|
1422
|
-
}
|
|
1423
|
-
return Filters.and(...validFilters);
|
|
1424
|
-
}
|
|
1425
|
-
function combineFiltersWithOr(filters) {
|
|
1426
|
-
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1427
|
-
if (validFilters.length === 0) {
|
|
1428
|
-
return void 0;
|
|
1429
|
-
}
|
|
1430
|
-
if (validFilters.length === 1) {
|
|
1431
|
-
return validFilters[0];
|
|
1432
|
-
}
|
|
1433
|
-
return Filters.or(...validFilters);
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
1339
|
// src/tools/search-memory.ts
|
|
1437
1340
|
var searchMemoryTool = {
|
|
1438
1341
|
name: "remember_search_memory",
|
|
@@ -1536,19 +1439,15 @@ async function handleSearchMemory(args, userId) {
|
|
|
1536
1439
|
const alpha = args.alpha ?? 0.7;
|
|
1537
1440
|
const limit = args.limit ?? 10;
|
|
1538
1441
|
const offset = args.offset ?? 0;
|
|
1539
|
-
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1540
1442
|
const searchOptions = {
|
|
1541
1443
|
alpha,
|
|
1542
1444
|
limit: limit + offset
|
|
1543
1445
|
// Get extra for offset
|
|
1544
1446
|
};
|
|
1545
|
-
if (filters) {
|
|
1546
|
-
searchOptions.filters = filters;
|
|
1547
|
-
}
|
|
1548
1447
|
logger.info("Weaviate query", {
|
|
1549
1448
|
query: args.query,
|
|
1550
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1551
|
-
hasFilters: !!filters
|
|
1449
|
+
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1450
|
+
// hasFilters: !!filters,
|
|
1552
1451
|
});
|
|
1553
1452
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1554
1453
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1581,8 +1480,9 @@ async function handleSearchMemory(args, userId) {
|
|
|
1581
1480
|
});
|
|
1582
1481
|
return JSON.stringify(searchResult, null, 2);
|
|
1583
1482
|
} catch (error) {
|
|
1584
|
-
|
|
1585
|
-
|
|
1483
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1484
|
+
logger.error("Failed to search memories:", { error: errorMessage, userId, query: args.query });
|
|
1485
|
+
throw new Error(`Failed to search memories: ${errorMessage}`);
|
|
1586
1486
|
}
|
|
1587
1487
|
}
|
|
1588
1488
|
|
|
@@ -1941,6 +1841,100 @@ async function handleFindSimilar(args, userId) {
|
|
|
1941
1841
|
}
|
|
1942
1842
|
}
|
|
1943
1843
|
|
|
1844
|
+
// src/utils/weaviate-filters.ts
|
|
1845
|
+
import { Filters } from "weaviate-client";
|
|
1846
|
+
function buildCombinedSearchFilters(collection, filters) {
|
|
1847
|
+
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1848
|
+
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1849
|
+
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1850
|
+
if (validFilters.length === 0) {
|
|
1851
|
+
return void 0;
|
|
1852
|
+
} else if (validFilters.length === 1) {
|
|
1853
|
+
return validFilters[0];
|
|
1854
|
+
} else {
|
|
1855
|
+
return combineFiltersWithOr(validFilters);
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
function buildDocTypeFilters(collection, docType, filters) {
|
|
1859
|
+
const filterList = [];
|
|
1860
|
+
filterList.push(
|
|
1861
|
+
collection.filter.byProperty("doc_type").equal(docType)
|
|
1862
|
+
);
|
|
1863
|
+
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1864
|
+
if (filters.types.length === 1) {
|
|
1865
|
+
filterList.push(
|
|
1866
|
+
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1867
|
+
);
|
|
1868
|
+
} else {
|
|
1869
|
+
filterList.push(
|
|
1870
|
+
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
if (filters?.weight_min !== void 0) {
|
|
1875
|
+
filterList.push(
|
|
1876
|
+
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1877
|
+
);
|
|
1878
|
+
}
|
|
1879
|
+
if (filters?.weight_max !== void 0) {
|
|
1880
|
+
filterList.push(
|
|
1881
|
+
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1882
|
+
);
|
|
1883
|
+
}
|
|
1884
|
+
if (filters?.trust_min !== void 0) {
|
|
1885
|
+
filterList.push(
|
|
1886
|
+
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1887
|
+
);
|
|
1888
|
+
}
|
|
1889
|
+
if (filters?.trust_max !== void 0) {
|
|
1890
|
+
filterList.push(
|
|
1891
|
+
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1892
|
+
);
|
|
1893
|
+
}
|
|
1894
|
+
if (filters?.date_from) {
|
|
1895
|
+
filterList.push(
|
|
1896
|
+
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1897
|
+
);
|
|
1898
|
+
}
|
|
1899
|
+
if (filters?.date_to) {
|
|
1900
|
+
filterList.push(
|
|
1901
|
+
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1902
|
+
);
|
|
1903
|
+
}
|
|
1904
|
+
if (filters?.tags && filters.tags.length > 0) {
|
|
1905
|
+
if (filters.tags.length === 1) {
|
|
1906
|
+
filterList.push(
|
|
1907
|
+
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1908
|
+
);
|
|
1909
|
+
} else {
|
|
1910
|
+
filterList.push(
|
|
1911
|
+
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1912
|
+
);
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
return combineFiltersWithAnd(filterList);
|
|
1916
|
+
}
|
|
1917
|
+
function combineFiltersWithAnd(filters) {
|
|
1918
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1919
|
+
if (validFilters.length === 0) {
|
|
1920
|
+
return void 0;
|
|
1921
|
+
}
|
|
1922
|
+
if (validFilters.length === 1) {
|
|
1923
|
+
return validFilters[0];
|
|
1924
|
+
}
|
|
1925
|
+
return Filters.and(...validFilters);
|
|
1926
|
+
}
|
|
1927
|
+
function combineFiltersWithOr(filters) {
|
|
1928
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1929
|
+
if (validFilters.length === 0) {
|
|
1930
|
+
return void 0;
|
|
1931
|
+
}
|
|
1932
|
+
if (validFilters.length === 1) {
|
|
1933
|
+
return validFilters[0];
|
|
1934
|
+
}
|
|
1935
|
+
return Filters.or(...validFilters);
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1944
1938
|
// src/tools/query-memory.ts
|
|
1945
1939
|
var queryMemoryTool = {
|
|
1946
1940
|
name: "remember_query_memory",
|
package/package.json
CHANGED
|
@@ -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
|
-
const filters = includeRelationships
|
|
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
|
-
if (filters) {
|
|
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
|
-
hasFilters: !!filters,
|
|
149
|
+
// hasFilters: !!filters,
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
// Perform hybrid search with Weaviate v3 API
|
|
@@ -191,7 +191,8 @@ export async function handleSearchMemory(
|
|
|
191
191
|
|
|
192
192
|
return JSON.stringify(searchResult, null, 2);
|
|
193
193
|
} catch (error) {
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
195
|
+
logger.error('Failed to search memories:', { error: errorMessage, userId, query: args.query });
|
|
196
|
+
throw new Error(`Failed to search memories: ${errorMessage}`);
|
|
196
197
|
}
|
|
197
198
|
}
|