@prmichaelsen/remember-mcp 1.0.5 → 1.0.7
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 +109 -98
- package/dist/server.js +109 -98
- package/package.json +1 -1
- package/src/tools/create-memory.ts +5 -2
- package/src/tools/create-relationship.ts +5 -2
- package/src/tools/search-memory.ts +7 -7
package/dist/server-factory.js
CHANGED
|
@@ -1393,7 +1393,9 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1393
1393
|
base_weight: args.weight ?? 0.5,
|
|
1394
1394
|
computed_weight: args.weight ?? 0.5
|
|
1395
1395
|
};
|
|
1396
|
-
const result = await collection.data.insert(
|
|
1396
|
+
const result = await collection.data.insert({
|
|
1397
|
+
properties: memory
|
|
1398
|
+
});
|
|
1397
1399
|
logger.info("Memory created successfully", { memoryId: result, userId });
|
|
1398
1400
|
const response = {
|
|
1399
1401
|
memory_id: result,
|
|
@@ -1407,6 +1409,103 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1407
1409
|
}
|
|
1408
1410
|
}
|
|
1409
1411
|
|
|
1412
|
+
// src/utils/weaviate-filters.ts
|
|
1413
|
+
import { Filters } from "weaviate-client";
|
|
1414
|
+
function buildCombinedSearchFilters(collection, filters) {
|
|
1415
|
+
const memoryFilters = buildDocTypeFilters(collection, "memory", filters);
|
|
1416
|
+
const relationshipFilters = buildDocTypeFilters(collection, "relationship", filters);
|
|
1417
|
+
const validFilters = [memoryFilters, relationshipFilters].filter((f) => f !== void 0 && f !== null);
|
|
1418
|
+
if (validFilters.length === 0) {
|
|
1419
|
+
return void 0;
|
|
1420
|
+
} else if (validFilters.length === 1) {
|
|
1421
|
+
return validFilters[0];
|
|
1422
|
+
} else {
|
|
1423
|
+
return combineFiltersWithOr(validFilters);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
function buildDocTypeFilters(collection, docType, filters) {
|
|
1427
|
+
const filterList = [];
|
|
1428
|
+
filterList.push(
|
|
1429
|
+
collection.filter.byProperty("doc_type").equal(docType)
|
|
1430
|
+
);
|
|
1431
|
+
if (docType === "memory" && filters?.types && filters.types.length > 0) {
|
|
1432
|
+
if (filters.types.length === 1) {
|
|
1433
|
+
filterList.push(
|
|
1434
|
+
collection.filter.byProperty("type").equal(filters.types[0])
|
|
1435
|
+
);
|
|
1436
|
+
} else {
|
|
1437
|
+
filterList.push(
|
|
1438
|
+
collection.filter.byProperty("type").containsAny(filters.types)
|
|
1439
|
+
);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
if (filters?.weight_min !== void 0) {
|
|
1443
|
+
filterList.push(
|
|
1444
|
+
collection.filter.byProperty("weight").greaterThanOrEqual(filters.weight_min)
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
if (filters?.weight_max !== void 0) {
|
|
1448
|
+
filterList.push(
|
|
1449
|
+
collection.filter.byProperty("weight").lessThanOrEqual(filters.weight_max)
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
if (filters?.trust_min !== void 0) {
|
|
1453
|
+
filterList.push(
|
|
1454
|
+
collection.filter.byProperty("trust").greaterThanOrEqual(filters.trust_min)
|
|
1455
|
+
);
|
|
1456
|
+
}
|
|
1457
|
+
if (filters?.trust_max !== void 0) {
|
|
1458
|
+
filterList.push(
|
|
1459
|
+
collection.filter.byProperty("trust").lessThanOrEqual(filters.trust_max)
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
if (filters?.date_from) {
|
|
1463
|
+
filterList.push(
|
|
1464
|
+
collection.filter.byProperty("created_at").greaterThanOrEqual(new Date(filters.date_from))
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
if (filters?.date_to) {
|
|
1468
|
+
filterList.push(
|
|
1469
|
+
collection.filter.byProperty("created_at").lessThanOrEqual(new Date(filters.date_to))
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
if (filters?.tags && filters.tags.length > 0) {
|
|
1473
|
+
if (filters.tags.length === 1) {
|
|
1474
|
+
filterList.push(
|
|
1475
|
+
collection.filter.byProperty("tags").containsAny([filters.tags[0]])
|
|
1476
|
+
);
|
|
1477
|
+
} else {
|
|
1478
|
+
filterList.push(
|
|
1479
|
+
collection.filter.byProperty("tags").containsAny(filters.tags)
|
|
1480
|
+
);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
return combineFiltersWithAnd(filterList);
|
|
1484
|
+
}
|
|
1485
|
+
function buildMemoryOnlyFilters(collection, filters) {
|
|
1486
|
+
return buildDocTypeFilters(collection, "memory", filters);
|
|
1487
|
+
}
|
|
1488
|
+
function combineFiltersWithAnd(filters) {
|
|
1489
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1490
|
+
if (validFilters.length === 0) {
|
|
1491
|
+
return void 0;
|
|
1492
|
+
}
|
|
1493
|
+
if (validFilters.length === 1) {
|
|
1494
|
+
return validFilters[0];
|
|
1495
|
+
}
|
|
1496
|
+
return Filters.and(...validFilters);
|
|
1497
|
+
}
|
|
1498
|
+
function combineFiltersWithOr(filters) {
|
|
1499
|
+
const validFilters = filters.filter((f) => f !== void 0 && f !== null);
|
|
1500
|
+
if (validFilters.length === 0) {
|
|
1501
|
+
return void 0;
|
|
1502
|
+
}
|
|
1503
|
+
if (validFilters.length === 1) {
|
|
1504
|
+
return validFilters[0];
|
|
1505
|
+
}
|
|
1506
|
+
return Filters.or(...validFilters);
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1410
1509
|
// src/tools/search-memory.ts
|
|
1411
1510
|
var searchMemoryTool = {
|
|
1412
1511
|
name: "remember_search_memory",
|
|
@@ -1510,15 +1609,19 @@ async function handleSearchMemory(args, userId) {
|
|
|
1510
1609
|
const alpha = args.alpha ?? 0.7;
|
|
1511
1610
|
const limit = args.limit ?? 10;
|
|
1512
1611
|
const offset = args.offset ?? 0;
|
|
1612
|
+
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1513
1613
|
const searchOptions = {
|
|
1514
1614
|
alpha,
|
|
1515
1615
|
limit: limit + offset
|
|
1516
1616
|
// Get extra for offset
|
|
1517
1617
|
};
|
|
1618
|
+
if (filters) {
|
|
1619
|
+
searchOptions.filters = filters;
|
|
1620
|
+
}
|
|
1518
1621
|
logger.info("Weaviate query", {
|
|
1519
1622
|
query: args.query,
|
|
1520
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1521
|
-
|
|
1623
|
+
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
1624
|
+
hasFilters: !!filters
|
|
1522
1625
|
});
|
|
1523
1626
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1524
1627
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1912,100 +2015,6 @@ async function handleFindSimilar(args, userId) {
|
|
|
1912
2015
|
}
|
|
1913
2016
|
}
|
|
1914
2017
|
|
|
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
|
-
|
|
2009
2018
|
// src/tools/query-memory.ts
|
|
2010
2019
|
var queryMemoryTool = {
|
|
2011
2020
|
name: "remember_query_memory",
|
|
@@ -2292,7 +2301,9 @@ async function handleCreateRelationship(args, userId, context) {
|
|
|
2292
2301
|
version: 1,
|
|
2293
2302
|
tags: args.tags || []
|
|
2294
2303
|
};
|
|
2295
|
-
const relationshipId = await collection.data.insert(
|
|
2304
|
+
const relationshipId = await collection.data.insert({
|
|
2305
|
+
properties: relationship
|
|
2306
|
+
});
|
|
2296
2307
|
logger.info("Relationship created, updating connected memories", {
|
|
2297
2308
|
relationshipId,
|
|
2298
2309
|
userId
|
package/dist/server.js
CHANGED
|
@@ -1322,7 +1322,9 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1322
1322
|
base_weight: args.weight ?? 0.5,
|
|
1323
1323
|
computed_weight: args.weight ?? 0.5
|
|
1324
1324
|
};
|
|
1325
|
-
const result = await collection.data.insert(
|
|
1325
|
+
const result = await collection.data.insert({
|
|
1326
|
+
properties: memory
|
|
1327
|
+
});
|
|
1326
1328
|
logger.info("Memory created successfully", { memoryId: result, userId });
|
|
1327
1329
|
const response = {
|
|
1328
1330
|
memory_id: result,
|
|
@@ -1336,6 +1338,103 @@ async function handleCreateMemory(args, userId, context) {
|
|
|
1336
1338
|
}
|
|
1337
1339
|
}
|
|
1338
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
|
+
|
|
1339
1438
|
// src/tools/search-memory.ts
|
|
1340
1439
|
var searchMemoryTool = {
|
|
1341
1440
|
name: "remember_search_memory",
|
|
@@ -1439,15 +1538,19 @@ async function handleSearchMemory(args, userId) {
|
|
|
1439
1538
|
const alpha = args.alpha ?? 0.7;
|
|
1440
1539
|
const limit = args.limit ?? 10;
|
|
1441
1540
|
const offset = args.offset ?? 0;
|
|
1541
|
+
const filters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
|
|
1442
1542
|
const searchOptions = {
|
|
1443
1543
|
alpha,
|
|
1444
1544
|
limit: limit + offset
|
|
1445
1545
|
// Get extra for offset
|
|
1446
1546
|
};
|
|
1547
|
+
if (filters) {
|
|
1548
|
+
searchOptions.filters = filters;
|
|
1549
|
+
}
|
|
1447
1550
|
logger.info("Weaviate query", {
|
|
1448
1551
|
query: args.query,
|
|
1449
|
-
searchOptions: JSON.stringify(searchOptions, null, 2)
|
|
1450
|
-
|
|
1552
|
+
searchOptions: JSON.stringify(searchOptions, null, 2),
|
|
1553
|
+
hasFilters: !!filters
|
|
1451
1554
|
});
|
|
1452
1555
|
const results = await collection.query.hybrid(args.query, searchOptions);
|
|
1453
1556
|
const paginatedResults = results.objects.slice(offset);
|
|
@@ -1841,100 +1944,6 @@ async function handleFindSimilar(args, userId) {
|
|
|
1841
1944
|
}
|
|
1842
1945
|
}
|
|
1843
1946
|
|
|
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
|
-
|
|
1938
1947
|
// src/tools/query-memory.ts
|
|
1939
1948
|
var queryMemoryTool = {
|
|
1940
1949
|
name: "remember_query_memory",
|
|
@@ -2221,7 +2230,9 @@ async function handleCreateRelationship(args, userId, context) {
|
|
|
2221
2230
|
version: 1,
|
|
2222
2231
|
tags: args.tags || []
|
|
2223
2232
|
};
|
|
2224
|
-
const relationshipId = await collection.data.insert(
|
|
2233
|
+
const relationshipId = await collection.data.insert({
|
|
2234
|
+
properties: relationship
|
|
2235
|
+
});
|
|
2225
2236
|
logger.info("Relationship created, updating connected memories", {
|
|
2226
2237
|
relationshipId,
|
|
2227
2238
|
userId
|
package/package.json
CHANGED
|
@@ -180,8 +180,11 @@ export async function handleCreateMemory(
|
|
|
180
180
|
computed_weight: args.weight ?? 0.5,
|
|
181
181
|
};
|
|
182
182
|
|
|
183
|
-
// Insert into Weaviate
|
|
184
|
-
|
|
183
|
+
// Insert into Weaviate v3 API
|
|
184
|
+
// v3 expects: { properties: {...} }
|
|
185
|
+
const result = await collection.data.insert({
|
|
186
|
+
properties: memory as any,
|
|
187
|
+
});
|
|
185
188
|
|
|
186
189
|
logger.info('Memory created successfully', { memoryId: result, userId });
|
|
187
190
|
|
|
@@ -182,8 +182,11 @@ export async function handleCreateRelationship(
|
|
|
182
182
|
tags: args.tags || [],
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
// Insert relationship into Weaviate
|
|
186
|
-
|
|
185
|
+
// Insert relationship into Weaviate v3 API
|
|
186
|
+
// v3 expects: { properties: {...} }
|
|
187
|
+
const relationshipId = await collection.data.insert({
|
|
188
|
+
properties: relationship as any,
|
|
189
|
+
});
|
|
187
190
|
|
|
188
191
|
logger.info('Relationship created, updating connected memories', {
|
|
189
192
|
relationshipId,
|
|
@@ -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
|