@anuma/sdk 6.43.1 → 6.44.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/expo/index.cjs +37 -13
- package/dist/expo/index.d.mts +4 -2
- package/dist/expo/index.d.ts +4 -2
- package/dist/expo/index.mjs +37 -13
- package/dist/react/index.cjs +37 -13
- package/dist/react/index.d.mts +4 -2
- package/dist/react/index.d.ts +4 -2
- package/dist/react/index.mjs +37 -13
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -21533,6 +21533,7 @@ var MAX_BATCH = 50;
|
|
|
21533
21533
|
var MAX_QUERY_IDS = 1e3;
|
|
21534
21534
|
var MAX_QUERY_TOPICS = 100;
|
|
21535
21535
|
var MAX_QUERY_FILTER = 20;
|
|
21536
|
+
var GRAPH_LANE_ROWS = 256;
|
|
21536
21537
|
var RemoteMemoryPartialCreateError = class extends Error {
|
|
21537
21538
|
constructor(created, cause) {
|
|
21538
21539
|
super(`createMany stored ${created.length} memories before a batch failed`);
|
|
@@ -21628,7 +21629,11 @@ function createRemoteMemoryStore(options) {
|
|
|
21628
21629
|
const { persistence, embeddingOptions } = options;
|
|
21629
21630
|
const model = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
21630
21631
|
const pollIntervalMs = options.pollIntervalMs ?? 6e4;
|
|
21631
|
-
const pipeline = createRemoteMemoryPipeline(
|
|
21632
|
+
const pipeline = createRemoteMemoryPipeline({
|
|
21633
|
+
...options,
|
|
21634
|
+
graphRanking: options.graphRanking ?? ((query, _traverse, recallOptions) => topicGraphRanking(query, recallOptions)),
|
|
21635
|
+
temporalRanking: options.temporalRanking ?? (() => Promise.resolve([]))
|
|
21636
|
+
});
|
|
21632
21637
|
const subscribers = /* @__PURE__ */ new Set();
|
|
21633
21638
|
const seen = /* @__PURE__ */ new Map();
|
|
21634
21639
|
let timer;
|
|
@@ -21660,6 +21665,36 @@ function createRemoteMemoryStore(options) {
|
|
|
21660
21665
|
const decrypted = (options2) => persistence.query(options2);
|
|
21661
21666
|
const metadata2 = (options2) => persistence.queryMetadata(options2);
|
|
21662
21667
|
const enumerate = (filters, max = Infinity) => pages(decrypted, filters, max);
|
|
21668
|
+
const memoriesByTopics = async (names) => {
|
|
21669
|
+
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
21670
|
+
const out = /* @__PURE__ */ new Map();
|
|
21671
|
+
const pages2 = await Promise.all(
|
|
21672
|
+
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
21673
|
+
);
|
|
21674
|
+
for (const { memory } of pages2.flat()) {
|
|
21675
|
+
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
21676
|
+
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
21677
|
+
}
|
|
21678
|
+
return out;
|
|
21679
|
+
};
|
|
21680
|
+
const topicGraphRanking = async (query, recallOptions = {}) => {
|
|
21681
|
+
const wanted = new Set(extractQueryEntities(query).map(normalizeEntityName).filter(Boolean));
|
|
21682
|
+
if (wanted.size === 0 || recallOptions.memoryIds?.length === 0) return [];
|
|
21683
|
+
const rows = await pages(
|
|
21684
|
+
metadata2,
|
|
21685
|
+
{
|
|
21686
|
+
topics: [...wanted].slice(0, MAX_QUERY_TOPICS),
|
|
21687
|
+
...recallOptions.scopes && { scopes: recallOptions.scopes },
|
|
21688
|
+
...recallOptions.factTypes && { fact_types: recallOptions.factTypes },
|
|
21689
|
+
...recallOptions.memoryIds && { memory_ids: recallOptions.memoryIds }
|
|
21690
|
+
},
|
|
21691
|
+
GRAPH_LANE_ROWS
|
|
21692
|
+
);
|
|
21693
|
+
return rows.map(({ memory }) => ({
|
|
21694
|
+
memoryId: memory.memory_id,
|
|
21695
|
+
matched: [...canonicalTopics(memory)].filter((name) => wanted.has(name)).length
|
|
21696
|
+
})).filter((row) => row.matched > 0).sort((a, b) => b.matched - a.matched).slice(0, NODE_BUDGET).map((row) => row.memoryId);
|
|
21697
|
+
};
|
|
21663
21698
|
const enumerateIds = async (read, ids, filters) => (await Promise.all(
|
|
21664
21699
|
chunks2([...new Set(ids)], MAX_QUERY_IDS).map(
|
|
21665
21700
|
(memory_ids) => pages(read, { ...filters, memory_ids })
|
|
@@ -22100,18 +22135,7 @@ function createRemoteMemoryStore(options) {
|
|
|
22100
22135
|
listArchived: async () => (await enumerate({ archived_only: true, order: "archived", include_embeddings: true })).map(
|
|
22101
22136
|
(record2) => stored(record2.memory)
|
|
22102
22137
|
),
|
|
22103
|
-
memoriesByTopics
|
|
22104
|
-
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
22105
|
-
const out = /* @__PURE__ */ new Map();
|
|
22106
|
-
const pages2 = await Promise.all(
|
|
22107
|
-
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
22108
|
-
);
|
|
22109
|
-
for (const { memory } of pages2.flat()) {
|
|
22110
|
-
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
22111
|
-
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
22112
|
-
}
|
|
22113
|
-
return out;
|
|
22114
|
-
},
|
|
22138
|
+
memoriesByTopics,
|
|
22115
22139
|
topicsByMemories: async (memoryIds) => {
|
|
22116
22140
|
const out = /* @__PURE__ */ new Map();
|
|
22117
22141
|
for (const { memory } of await enumerateIds(decrypted, memoryIds, {
|
package/dist/expo/index.d.mts
CHANGED
|
@@ -9793,8 +9793,10 @@ declare function createRemoteMemoryPipeline(options: RemoteMemoryPipelineOptions
|
|
|
9793
9793
|
interface RemoteMemoryStoreOptions {
|
|
9794
9794
|
persistence: RemoteMemoryPersistence;
|
|
9795
9795
|
embeddingOptions: EmbeddingOptions;
|
|
9796
|
-
|
|
9797
|
-
|
|
9796
|
+
/** Defaults to ranking memories by how many query entities their topics name. */
|
|
9797
|
+
graphRanking?: RecallFactSource["graphRanking"];
|
|
9798
|
+
/** Defaults to no temporal lane: nearby has no event-time filter yet. */
|
|
9799
|
+
temporalRanking?: RecallFactSource["temporalRanking"];
|
|
9798
9800
|
pollIntervalMs?: number;
|
|
9799
9801
|
}
|
|
9800
9802
|
declare class RemoteMemoryPartialCreateError extends Error {
|
package/dist/expo/index.d.ts
CHANGED
|
@@ -9793,8 +9793,10 @@ declare function createRemoteMemoryPipeline(options: RemoteMemoryPipelineOptions
|
|
|
9793
9793
|
interface RemoteMemoryStoreOptions {
|
|
9794
9794
|
persistence: RemoteMemoryPersistence;
|
|
9795
9795
|
embeddingOptions: EmbeddingOptions;
|
|
9796
|
-
|
|
9797
|
-
|
|
9796
|
+
/** Defaults to ranking memories by how many query entities their topics name. */
|
|
9797
|
+
graphRanking?: RecallFactSource["graphRanking"];
|
|
9798
|
+
/** Defaults to no temporal lane: nearby has no event-time filter yet. */
|
|
9799
|
+
temporalRanking?: RecallFactSource["temporalRanking"];
|
|
9798
9800
|
pollIntervalMs?: number;
|
|
9799
9801
|
}
|
|
9800
9802
|
declare class RemoteMemoryPartialCreateError extends Error {
|
package/dist/expo/index.mjs
CHANGED
|
@@ -19896,6 +19896,7 @@ var MAX_BATCH = 50;
|
|
|
19896
19896
|
var MAX_QUERY_IDS = 1e3;
|
|
19897
19897
|
var MAX_QUERY_TOPICS = 100;
|
|
19898
19898
|
var MAX_QUERY_FILTER = 20;
|
|
19899
|
+
var GRAPH_LANE_ROWS = 256;
|
|
19899
19900
|
var RemoteMemoryPartialCreateError = class extends Error {
|
|
19900
19901
|
constructor(created, cause) {
|
|
19901
19902
|
super(`createMany stored ${created.length} memories before a batch failed`);
|
|
@@ -19991,7 +19992,11 @@ function createRemoteMemoryStore(options) {
|
|
|
19991
19992
|
const { persistence, embeddingOptions } = options;
|
|
19992
19993
|
const model = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
19993
19994
|
const pollIntervalMs = options.pollIntervalMs ?? 6e4;
|
|
19994
|
-
const pipeline = createRemoteMemoryPipeline(
|
|
19995
|
+
const pipeline = createRemoteMemoryPipeline({
|
|
19996
|
+
...options,
|
|
19997
|
+
graphRanking: options.graphRanking ?? ((query, _traverse, recallOptions) => topicGraphRanking(query, recallOptions)),
|
|
19998
|
+
temporalRanking: options.temporalRanking ?? (() => Promise.resolve([]))
|
|
19999
|
+
});
|
|
19995
20000
|
const subscribers = /* @__PURE__ */ new Set();
|
|
19996
20001
|
const seen = /* @__PURE__ */ new Map();
|
|
19997
20002
|
let timer;
|
|
@@ -20023,6 +20028,36 @@ function createRemoteMemoryStore(options) {
|
|
|
20023
20028
|
const decrypted = (options2) => persistence.query(options2);
|
|
20024
20029
|
const metadata2 = (options2) => persistence.queryMetadata(options2);
|
|
20025
20030
|
const enumerate = (filters, max = Infinity) => pages(decrypted, filters, max);
|
|
20031
|
+
const memoriesByTopics = async (names) => {
|
|
20032
|
+
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
20033
|
+
const out = /* @__PURE__ */ new Map();
|
|
20034
|
+
const pages2 = await Promise.all(
|
|
20035
|
+
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
20036
|
+
);
|
|
20037
|
+
for (const { memory } of pages2.flat()) {
|
|
20038
|
+
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
20039
|
+
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
20040
|
+
}
|
|
20041
|
+
return out;
|
|
20042
|
+
};
|
|
20043
|
+
const topicGraphRanking = async (query, recallOptions = {}) => {
|
|
20044
|
+
const wanted = new Set(extractQueryEntities(query).map(normalizeEntityName).filter(Boolean));
|
|
20045
|
+
if (wanted.size === 0 || recallOptions.memoryIds?.length === 0) return [];
|
|
20046
|
+
const rows = await pages(
|
|
20047
|
+
metadata2,
|
|
20048
|
+
{
|
|
20049
|
+
topics: [...wanted].slice(0, MAX_QUERY_TOPICS),
|
|
20050
|
+
...recallOptions.scopes && { scopes: recallOptions.scopes },
|
|
20051
|
+
...recallOptions.factTypes && { fact_types: recallOptions.factTypes },
|
|
20052
|
+
...recallOptions.memoryIds && { memory_ids: recallOptions.memoryIds }
|
|
20053
|
+
},
|
|
20054
|
+
GRAPH_LANE_ROWS
|
|
20055
|
+
);
|
|
20056
|
+
return rows.map(({ memory }) => ({
|
|
20057
|
+
memoryId: memory.memory_id,
|
|
20058
|
+
matched: [...canonicalTopics(memory)].filter((name) => wanted.has(name)).length
|
|
20059
|
+
})).filter((row) => row.matched > 0).sort((a, b) => b.matched - a.matched).slice(0, NODE_BUDGET).map((row) => row.memoryId);
|
|
20060
|
+
};
|
|
20026
20061
|
const enumerateIds = async (read, ids, filters) => (await Promise.all(
|
|
20027
20062
|
chunks2([...new Set(ids)], MAX_QUERY_IDS).map(
|
|
20028
20063
|
(memory_ids) => pages(read, { ...filters, memory_ids })
|
|
@@ -20463,18 +20498,7 @@ function createRemoteMemoryStore(options) {
|
|
|
20463
20498
|
listArchived: async () => (await enumerate({ archived_only: true, order: "archived", include_embeddings: true })).map(
|
|
20464
20499
|
(record2) => stored(record2.memory)
|
|
20465
20500
|
),
|
|
20466
|
-
memoriesByTopics
|
|
20467
|
-
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
20468
|
-
const out = /* @__PURE__ */ new Map();
|
|
20469
|
-
const pages2 = await Promise.all(
|
|
20470
|
-
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
20471
|
-
);
|
|
20472
|
-
for (const { memory } of pages2.flat()) {
|
|
20473
|
-
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
20474
|
-
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
20475
|
-
}
|
|
20476
|
-
return out;
|
|
20477
|
-
},
|
|
20501
|
+
memoriesByTopics,
|
|
20478
20502
|
topicsByMemories: async (memoryIds) => {
|
|
20479
20503
|
const out = /* @__PURE__ */ new Map();
|
|
20480
20504
|
for (const { memory } of await enumerateIds(decrypted, memoryIds, {
|
package/dist/react/index.cjs
CHANGED
|
@@ -24906,6 +24906,7 @@ var MAX_BATCH = 50;
|
|
|
24906
24906
|
var MAX_QUERY_IDS = 1e3;
|
|
24907
24907
|
var MAX_QUERY_TOPICS = 100;
|
|
24908
24908
|
var MAX_QUERY_FILTER = 20;
|
|
24909
|
+
var GRAPH_LANE_ROWS = 256;
|
|
24909
24910
|
var RemoteMemoryPartialCreateError = class extends Error {
|
|
24910
24911
|
constructor(created, cause) {
|
|
24911
24912
|
super(`createMany stored ${created.length} memories before a batch failed`);
|
|
@@ -25001,7 +25002,11 @@ function createRemoteMemoryStore(options) {
|
|
|
25001
25002
|
const { persistence, embeddingOptions } = options;
|
|
25002
25003
|
const model = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
25003
25004
|
const pollIntervalMs = options.pollIntervalMs ?? 6e4;
|
|
25004
|
-
const pipeline = createRemoteMemoryPipeline(
|
|
25005
|
+
const pipeline = createRemoteMemoryPipeline({
|
|
25006
|
+
...options,
|
|
25007
|
+
graphRanking: options.graphRanking ?? ((query, _traverse, recallOptions) => topicGraphRanking(query, recallOptions)),
|
|
25008
|
+
temporalRanking: options.temporalRanking ?? (() => Promise.resolve([]))
|
|
25009
|
+
});
|
|
25005
25010
|
const subscribers = /* @__PURE__ */ new Set();
|
|
25006
25011
|
const seen = /* @__PURE__ */ new Map();
|
|
25007
25012
|
let timer;
|
|
@@ -25033,6 +25038,36 @@ function createRemoteMemoryStore(options) {
|
|
|
25033
25038
|
const decrypted = (options2) => persistence.query(options2);
|
|
25034
25039
|
const metadata2 = (options2) => persistence.queryMetadata(options2);
|
|
25035
25040
|
const enumerate = (filters, max = Infinity) => pages(decrypted, filters, max);
|
|
25041
|
+
const memoriesByTopics = async (names) => {
|
|
25042
|
+
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
25043
|
+
const out = /* @__PURE__ */ new Map();
|
|
25044
|
+
const pages2 = await Promise.all(
|
|
25045
|
+
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
25046
|
+
);
|
|
25047
|
+
for (const { memory } of pages2.flat()) {
|
|
25048
|
+
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
25049
|
+
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
25050
|
+
}
|
|
25051
|
+
return out;
|
|
25052
|
+
};
|
|
25053
|
+
const topicGraphRanking = async (query, recallOptions = {}) => {
|
|
25054
|
+
const wanted = new Set(extractQueryEntities(query).map(normalizeEntityName).filter(Boolean));
|
|
25055
|
+
if (wanted.size === 0 || recallOptions.memoryIds?.length === 0) return [];
|
|
25056
|
+
const rows = await pages(
|
|
25057
|
+
metadata2,
|
|
25058
|
+
{
|
|
25059
|
+
topics: [...wanted].slice(0, MAX_QUERY_TOPICS),
|
|
25060
|
+
...recallOptions.scopes && { scopes: recallOptions.scopes },
|
|
25061
|
+
...recallOptions.factTypes && { fact_types: recallOptions.factTypes },
|
|
25062
|
+
...recallOptions.memoryIds && { memory_ids: recallOptions.memoryIds }
|
|
25063
|
+
},
|
|
25064
|
+
GRAPH_LANE_ROWS
|
|
25065
|
+
);
|
|
25066
|
+
return rows.map(({ memory }) => ({
|
|
25067
|
+
memoryId: memory.memory_id,
|
|
25068
|
+
matched: [...canonicalTopics(memory)].filter((name) => wanted.has(name)).length
|
|
25069
|
+
})).filter((row) => row.matched > 0).sort((a, b) => b.matched - a.matched).slice(0, NODE_BUDGET).map((row) => row.memoryId);
|
|
25070
|
+
};
|
|
25036
25071
|
const enumerateIds = async (read, ids, filters) => (await Promise.all(
|
|
25037
25072
|
chunks2([...new Set(ids)], MAX_QUERY_IDS).map(
|
|
25038
25073
|
(memory_ids) => pages(read, { ...filters, memory_ids })
|
|
@@ -25473,18 +25508,7 @@ function createRemoteMemoryStore(options) {
|
|
|
25473
25508
|
listArchived: async () => (await enumerate({ archived_only: true, order: "archived", include_embeddings: true })).map(
|
|
25474
25509
|
(record2) => stored(record2.memory)
|
|
25475
25510
|
),
|
|
25476
|
-
memoriesByTopics
|
|
25477
|
-
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
25478
|
-
const out = /* @__PURE__ */ new Map();
|
|
25479
|
-
const pages2 = await Promise.all(
|
|
25480
|
-
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
25481
|
-
);
|
|
25482
|
-
for (const { memory } of pages2.flat()) {
|
|
25483
|
-
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
25484
|
-
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
25485
|
-
}
|
|
25486
|
-
return out;
|
|
25487
|
-
},
|
|
25511
|
+
memoriesByTopics,
|
|
25488
25512
|
topicsByMemories: async (memoryIds) => {
|
|
25489
25513
|
const out = /* @__PURE__ */ new Map();
|
|
25490
25514
|
for (const { memory } of await enumerateIds(decrypted, memoryIds, {
|
package/dist/react/index.d.mts
CHANGED
|
@@ -12029,8 +12029,10 @@ declare function createRemoteMemoryPipeline(options: RemoteMemoryPipelineOptions
|
|
|
12029
12029
|
interface RemoteMemoryStoreOptions {
|
|
12030
12030
|
persistence: RemoteMemoryPersistence;
|
|
12031
12031
|
embeddingOptions: EmbeddingOptions;
|
|
12032
|
-
|
|
12033
|
-
|
|
12032
|
+
/** Defaults to ranking memories by how many query entities their topics name. */
|
|
12033
|
+
graphRanking?: RecallFactSource["graphRanking"];
|
|
12034
|
+
/** Defaults to no temporal lane: nearby has no event-time filter yet. */
|
|
12035
|
+
temporalRanking?: RecallFactSource["temporalRanking"];
|
|
12034
12036
|
pollIntervalMs?: number;
|
|
12035
12037
|
}
|
|
12036
12038
|
declare class RemoteMemoryPartialCreateError extends Error {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -12029,8 +12029,10 @@ declare function createRemoteMemoryPipeline(options: RemoteMemoryPipelineOptions
|
|
|
12029
12029
|
interface RemoteMemoryStoreOptions {
|
|
12030
12030
|
persistence: RemoteMemoryPersistence;
|
|
12031
12031
|
embeddingOptions: EmbeddingOptions;
|
|
12032
|
-
|
|
12033
|
-
|
|
12032
|
+
/** Defaults to ranking memories by how many query entities their topics name. */
|
|
12033
|
+
graphRanking?: RecallFactSource["graphRanking"];
|
|
12034
|
+
/** Defaults to no temporal lane: nearby has no event-time filter yet. */
|
|
12035
|
+
temporalRanking?: RecallFactSource["temporalRanking"];
|
|
12034
12036
|
pollIntervalMs?: number;
|
|
12035
12037
|
}
|
|
12036
12038
|
declare class RemoteMemoryPartialCreateError extends Error {
|
package/dist/react/index.mjs
CHANGED
|
@@ -22998,6 +22998,7 @@ var MAX_BATCH = 50;
|
|
|
22998
22998
|
var MAX_QUERY_IDS = 1e3;
|
|
22999
22999
|
var MAX_QUERY_TOPICS = 100;
|
|
23000
23000
|
var MAX_QUERY_FILTER = 20;
|
|
23001
|
+
var GRAPH_LANE_ROWS = 256;
|
|
23001
23002
|
var RemoteMemoryPartialCreateError = class extends Error {
|
|
23002
23003
|
constructor(created, cause) {
|
|
23003
23004
|
super(`createMany stored ${created.length} memories before a batch failed`);
|
|
@@ -23093,7 +23094,11 @@ function createRemoteMemoryStore(options) {
|
|
|
23093
23094
|
const { persistence, embeddingOptions } = options;
|
|
23094
23095
|
const model = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
23095
23096
|
const pollIntervalMs = options.pollIntervalMs ?? 6e4;
|
|
23096
|
-
const pipeline = createRemoteMemoryPipeline(
|
|
23097
|
+
const pipeline = createRemoteMemoryPipeline({
|
|
23098
|
+
...options,
|
|
23099
|
+
graphRanking: options.graphRanking ?? ((query, _traverse, recallOptions) => topicGraphRanking(query, recallOptions)),
|
|
23100
|
+
temporalRanking: options.temporalRanking ?? (() => Promise.resolve([]))
|
|
23101
|
+
});
|
|
23097
23102
|
const subscribers = /* @__PURE__ */ new Set();
|
|
23098
23103
|
const seen = /* @__PURE__ */ new Map();
|
|
23099
23104
|
let timer;
|
|
@@ -23125,6 +23130,36 @@ function createRemoteMemoryStore(options) {
|
|
|
23125
23130
|
const decrypted = (options2) => persistence.query(options2);
|
|
23126
23131
|
const metadata2 = (options2) => persistence.queryMetadata(options2);
|
|
23127
23132
|
const enumerate = (filters, max = Infinity) => pages(decrypted, filters, max);
|
|
23133
|
+
const memoriesByTopics = async (names) => {
|
|
23134
|
+
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
23135
|
+
const out = /* @__PURE__ */ new Map();
|
|
23136
|
+
const pages2 = await Promise.all(
|
|
23137
|
+
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
23138
|
+
);
|
|
23139
|
+
for (const { memory } of pages2.flat()) {
|
|
23140
|
+
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
23141
|
+
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
23142
|
+
}
|
|
23143
|
+
return out;
|
|
23144
|
+
};
|
|
23145
|
+
const topicGraphRanking = async (query, recallOptions = {}) => {
|
|
23146
|
+
const wanted = new Set(extractQueryEntities(query).map(normalizeEntityName).filter(Boolean));
|
|
23147
|
+
if (wanted.size === 0 || recallOptions.memoryIds?.length === 0) return [];
|
|
23148
|
+
const rows = await pages(
|
|
23149
|
+
metadata2,
|
|
23150
|
+
{
|
|
23151
|
+
topics: [...wanted].slice(0, MAX_QUERY_TOPICS),
|
|
23152
|
+
...recallOptions.scopes && { scopes: recallOptions.scopes },
|
|
23153
|
+
...recallOptions.factTypes && { fact_types: recallOptions.factTypes },
|
|
23154
|
+
...recallOptions.memoryIds && { memory_ids: recallOptions.memoryIds }
|
|
23155
|
+
},
|
|
23156
|
+
GRAPH_LANE_ROWS
|
|
23157
|
+
);
|
|
23158
|
+
return rows.map(({ memory }) => ({
|
|
23159
|
+
memoryId: memory.memory_id,
|
|
23160
|
+
matched: [...canonicalTopics(memory)].filter((name) => wanted.has(name)).length
|
|
23161
|
+
})).filter((row) => row.matched > 0).sort((a, b) => b.matched - a.matched).slice(0, NODE_BUDGET).map((row) => row.memoryId);
|
|
23162
|
+
};
|
|
23128
23163
|
const enumerateIds = async (read, ids, filters) => (await Promise.all(
|
|
23129
23164
|
chunks2([...new Set(ids)], MAX_QUERY_IDS).map(
|
|
23130
23165
|
(memory_ids) => pages(read, { ...filters, memory_ids })
|
|
@@ -23565,18 +23600,7 @@ function createRemoteMemoryStore(options) {
|
|
|
23565
23600
|
listArchived: async () => (await enumerate({ archived_only: true, order: "archived", include_embeddings: true })).map(
|
|
23566
23601
|
(record2) => stored(record2.memory)
|
|
23567
23602
|
),
|
|
23568
|
-
memoriesByTopics
|
|
23569
|
-
const wanted = new Set(names.map(normalizeEntityName).filter(Boolean));
|
|
23570
|
-
const out = /* @__PURE__ */ new Map();
|
|
23571
|
-
const pages2 = await Promise.all(
|
|
23572
|
-
chunks2([...wanted], MAX_QUERY_TOPICS).map((topics) => enumerate({ topics }))
|
|
23573
|
-
);
|
|
23574
|
-
for (const { memory } of pages2.flat()) {
|
|
23575
|
-
const matched = [...canonicalTopics(memory)].filter((name) => wanted.has(name));
|
|
23576
|
-
if (matched.length) out.set(memory.memory_id, new Set(matched));
|
|
23577
|
-
}
|
|
23578
|
-
return out;
|
|
23579
|
-
},
|
|
23603
|
+
memoriesByTopics,
|
|
23580
23604
|
topicsByMemories: async (memoryIds) => {
|
|
23581
23605
|
const out = /* @__PURE__ */ new Map();
|
|
23582
23606
|
for (const { memory } of await enumerateIds(decrypted, memoryIds, {
|