@anuma/sdk 10.3.0 → 10.3.1
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 +55 -22
- package/dist/expo/index.mjs +55 -22
- package/dist/react/index.cjs +55 -22
- package/dist/react/index.mjs +55 -22
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -25944,7 +25944,7 @@ function createRemoteMemoryStore(options) {
|
|
|
25944
25944
|
};
|
|
25945
25945
|
const mutate = (id2, change, edit, writeOptions) => serialized(id2, () => mutateLocked(id2, change, edit, writeOptions));
|
|
25946
25946
|
const serializedAll = (ids, task) => [...new Set(ids)].sort().reduceRight((inner, id2) => () => serialized(id2, inner), task)();
|
|
25947
|
-
const mutateMany = async (ids, change, edit, leaseToken, signal) => {
|
|
25947
|
+
const mutateMany = async (ids, change, edit, leaseToken, signal, includeEmbeddings = false) => {
|
|
25948
25948
|
const saved = /* @__PURE__ */ new Map();
|
|
25949
25949
|
const failed = /* @__PURE__ */ new Map();
|
|
25950
25950
|
for (const slice of chunks2([...new Set(ids)], MAX_BATCH)) {
|
|
@@ -25953,7 +25953,7 @@ function createRemoteMemoryStore(options) {
|
|
|
25953
25953
|
const writes = [];
|
|
25954
25954
|
let read;
|
|
25955
25955
|
try {
|
|
25956
|
-
read = await readEveryState(slice, signal);
|
|
25956
|
+
read = await readEveryState(slice, signal, includeEmbeddings);
|
|
25957
25957
|
} catch (error) {
|
|
25958
25958
|
signal?.throwIfAborted();
|
|
25959
25959
|
for (const id2 of slice) failed.set(id2, error);
|
|
@@ -26012,21 +26012,55 @@ function createRemoteMemoryStore(options) {
|
|
|
26012
26012
|
}
|
|
26013
26013
|
return { saved, failed };
|
|
26014
26014
|
};
|
|
26015
|
-
const
|
|
26016
|
-
|
|
26017
|
-
|
|
26018
|
-
|
|
26019
|
-
|
|
26020
|
-
|
|
26021
|
-
const
|
|
26022
|
-
|
|
26023
|
-
|
|
26024
|
-
|
|
26025
|
-
|
|
26026
|
-
|
|
26027
|
-
|
|
26028
|
-
|
|
26029
|
-
|
|
26015
|
+
const pendingEmbeddings = /* @__PURE__ */ new Map();
|
|
26016
|
+
let embeddingActive = false;
|
|
26017
|
+
const drainEmbeddings = async () => {
|
|
26018
|
+
try {
|
|
26019
|
+
while (pendingEmbeddings.size) {
|
|
26020
|
+
const batch = /* @__PURE__ */ new Map();
|
|
26021
|
+
for (const [id2, content] of pendingEmbeddings) {
|
|
26022
|
+
pendingEmbeddings.delete(id2);
|
|
26023
|
+
batch.set(id2, content);
|
|
26024
|
+
if (batch.size === MAX_BATCH) break;
|
|
26025
|
+
}
|
|
26026
|
+
try {
|
|
26027
|
+
const vectors = await generateEmbeddings([...batch.values()], embeddingOptions);
|
|
26028
|
+
const embeddings2 = /* @__PURE__ */ new Map();
|
|
26029
|
+
[...batch.keys()].forEach((id2, i) => {
|
|
26030
|
+
try {
|
|
26031
|
+
embeddings2.set(id2, storedVector(vectors[i]));
|
|
26032
|
+
} catch (error) {
|
|
26033
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
26034
|
+
}
|
|
26035
|
+
});
|
|
26036
|
+
if (!embeddings2.size) continue;
|
|
26037
|
+
const { failed } = await mutateMany(
|
|
26038
|
+
[...embeddings2.keys()],
|
|
26039
|
+
() => "embedding",
|
|
26040
|
+
(memory) => memory.content !== batch.get(memory.memory_id) || memory.embedding?.length ? null : {
|
|
26041
|
+
...memory,
|
|
26042
|
+
embedding: embeddings2.get(memory.memory_id),
|
|
26043
|
+
embedding_model: model
|
|
26044
|
+
},
|
|
26045
|
+
void 0,
|
|
26046
|
+
void 0,
|
|
26047
|
+
true
|
|
26048
|
+
);
|
|
26049
|
+
for (const error of failed.values())
|
|
26050
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
26051
|
+
} catch (error) {
|
|
26052
|
+
getLogger().warn("[memory/remote-store] Failed to embed memories:", error);
|
|
26053
|
+
}
|
|
26054
|
+
}
|
|
26055
|
+
} finally {
|
|
26056
|
+
embeddingActive = false;
|
|
26057
|
+
}
|
|
26058
|
+
};
|
|
26059
|
+
const embedInBackground = (records) => {
|
|
26060
|
+
for (const { memory } of records) pendingEmbeddings.set(memory.memory_id, memory.content);
|
|
26061
|
+
if (embeddingActive || !pendingEmbeddings.size) return;
|
|
26062
|
+
embeddingActive = true;
|
|
26063
|
+
void drainEmbeddings();
|
|
26030
26064
|
};
|
|
26031
26065
|
const newRow = (input) => {
|
|
26032
26066
|
const now = Date.now();
|
|
@@ -26060,9 +26094,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26060
26094
|
};
|
|
26061
26095
|
};
|
|
26062
26096
|
const created = (records, inputs) => {
|
|
26063
|
-
records.
|
|
26064
|
-
if (inputs[i].embedding === void 0) embedInBackground(record2);
|
|
26065
|
-
});
|
|
26097
|
+
embedInBackground(records.filter((_, i) => inputs[i].embedding === void 0));
|
|
26066
26098
|
notify("membership", records);
|
|
26067
26099
|
return records.map((record2) => stored(record2.memory));
|
|
26068
26100
|
};
|
|
@@ -26092,7 +26124,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26092
26124
|
};
|
|
26093
26125
|
};
|
|
26094
26126
|
const withKnownKinds = async (topics) => topics.map(await knownKinds(topics));
|
|
26095
|
-
const readEveryState = async (ids, signal) => {
|
|
26127
|
+
const readEveryState = async (ids, signal, includeEmbeddings = false) => {
|
|
26096
26128
|
const records = /* @__PURE__ */ new Map();
|
|
26097
26129
|
const unreadable = /* @__PURE__ */ new Set();
|
|
26098
26130
|
for (const memory_ids of chunks2(ids, MAX_QUERY_IDS)) {
|
|
@@ -26104,6 +26136,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26104
26136
|
include_archived: true,
|
|
26105
26137
|
include_quarantined: true,
|
|
26106
26138
|
include_superseded: true,
|
|
26139
|
+
...includeEmbeddings && { include_embeddings: true },
|
|
26107
26140
|
limit: 200,
|
|
26108
26141
|
...signal && { signal },
|
|
26109
26142
|
...cursor2 && { cursor: cursor2 }
|
|
@@ -26766,7 +26799,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26766
26799
|
}
|
|
26767
26800
|
return memory;
|
|
26768
26801
|
});
|
|
26769
|
-
if (saved && patch.embedding === void 0) embedInBackground(saved);
|
|
26802
|
+
if (saved && patch.embedding === void 0) embedInBackground([saved]);
|
|
26770
26803
|
return asStored(saved);
|
|
26771
26804
|
},
|
|
26772
26805
|
delete: async (id2) => !!await mutate(id2, "membership", (memory) => ({ ...memory, is_deleted: true })),
|
package/dist/expo/index.mjs
CHANGED
|
@@ -24231,7 +24231,7 @@ function createRemoteMemoryStore(options) {
|
|
|
24231
24231
|
};
|
|
24232
24232
|
const mutate = (id2, change, edit, writeOptions) => serialized(id2, () => mutateLocked(id2, change, edit, writeOptions));
|
|
24233
24233
|
const serializedAll = (ids, task) => [...new Set(ids)].sort().reduceRight((inner, id2) => () => serialized(id2, inner), task)();
|
|
24234
|
-
const mutateMany = async (ids, change, edit, leaseToken, signal) => {
|
|
24234
|
+
const mutateMany = async (ids, change, edit, leaseToken, signal, includeEmbeddings = false) => {
|
|
24235
24235
|
const saved = /* @__PURE__ */ new Map();
|
|
24236
24236
|
const failed = /* @__PURE__ */ new Map();
|
|
24237
24237
|
for (const slice of chunks2([...new Set(ids)], MAX_BATCH)) {
|
|
@@ -24240,7 +24240,7 @@ function createRemoteMemoryStore(options) {
|
|
|
24240
24240
|
const writes = [];
|
|
24241
24241
|
let read;
|
|
24242
24242
|
try {
|
|
24243
|
-
read = await readEveryState(slice, signal);
|
|
24243
|
+
read = await readEveryState(slice, signal, includeEmbeddings);
|
|
24244
24244
|
} catch (error) {
|
|
24245
24245
|
signal?.throwIfAborted();
|
|
24246
24246
|
for (const id2 of slice) failed.set(id2, error);
|
|
@@ -24299,21 +24299,55 @@ function createRemoteMemoryStore(options) {
|
|
|
24299
24299
|
}
|
|
24300
24300
|
return { saved, failed };
|
|
24301
24301
|
};
|
|
24302
|
-
const
|
|
24303
|
-
|
|
24304
|
-
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
const
|
|
24309
|
-
|
|
24310
|
-
|
|
24311
|
-
|
|
24312
|
-
|
|
24313
|
-
|
|
24314
|
-
|
|
24315
|
-
|
|
24316
|
-
|
|
24302
|
+
const pendingEmbeddings = /* @__PURE__ */ new Map();
|
|
24303
|
+
let embeddingActive = false;
|
|
24304
|
+
const drainEmbeddings = async () => {
|
|
24305
|
+
try {
|
|
24306
|
+
while (pendingEmbeddings.size) {
|
|
24307
|
+
const batch = /* @__PURE__ */ new Map();
|
|
24308
|
+
for (const [id2, content] of pendingEmbeddings) {
|
|
24309
|
+
pendingEmbeddings.delete(id2);
|
|
24310
|
+
batch.set(id2, content);
|
|
24311
|
+
if (batch.size === MAX_BATCH) break;
|
|
24312
|
+
}
|
|
24313
|
+
try {
|
|
24314
|
+
const vectors = await generateEmbeddings([...batch.values()], embeddingOptions);
|
|
24315
|
+
const embeddings2 = /* @__PURE__ */ new Map();
|
|
24316
|
+
[...batch.keys()].forEach((id2, i) => {
|
|
24317
|
+
try {
|
|
24318
|
+
embeddings2.set(id2, storedVector(vectors[i]));
|
|
24319
|
+
} catch (error) {
|
|
24320
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
24321
|
+
}
|
|
24322
|
+
});
|
|
24323
|
+
if (!embeddings2.size) continue;
|
|
24324
|
+
const { failed } = await mutateMany(
|
|
24325
|
+
[...embeddings2.keys()],
|
|
24326
|
+
() => "embedding",
|
|
24327
|
+
(memory) => memory.content !== batch.get(memory.memory_id) || memory.embedding?.length ? null : {
|
|
24328
|
+
...memory,
|
|
24329
|
+
embedding: embeddings2.get(memory.memory_id),
|
|
24330
|
+
embedding_model: model
|
|
24331
|
+
},
|
|
24332
|
+
void 0,
|
|
24333
|
+
void 0,
|
|
24334
|
+
true
|
|
24335
|
+
);
|
|
24336
|
+
for (const error of failed.values())
|
|
24337
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
24338
|
+
} catch (error) {
|
|
24339
|
+
getLogger().warn("[memory/remote-store] Failed to embed memories:", error);
|
|
24340
|
+
}
|
|
24341
|
+
}
|
|
24342
|
+
} finally {
|
|
24343
|
+
embeddingActive = false;
|
|
24344
|
+
}
|
|
24345
|
+
};
|
|
24346
|
+
const embedInBackground = (records) => {
|
|
24347
|
+
for (const { memory } of records) pendingEmbeddings.set(memory.memory_id, memory.content);
|
|
24348
|
+
if (embeddingActive || !pendingEmbeddings.size) return;
|
|
24349
|
+
embeddingActive = true;
|
|
24350
|
+
void drainEmbeddings();
|
|
24317
24351
|
};
|
|
24318
24352
|
const newRow = (input) => {
|
|
24319
24353
|
const now = Date.now();
|
|
@@ -24347,9 +24381,7 @@ function createRemoteMemoryStore(options) {
|
|
|
24347
24381
|
};
|
|
24348
24382
|
};
|
|
24349
24383
|
const created = (records, inputs) => {
|
|
24350
|
-
records.
|
|
24351
|
-
if (inputs[i].embedding === void 0) embedInBackground(record2);
|
|
24352
|
-
});
|
|
24384
|
+
embedInBackground(records.filter((_, i) => inputs[i].embedding === void 0));
|
|
24353
24385
|
notify("membership", records);
|
|
24354
24386
|
return records.map((record2) => stored(record2.memory));
|
|
24355
24387
|
};
|
|
@@ -24379,7 +24411,7 @@ function createRemoteMemoryStore(options) {
|
|
|
24379
24411
|
};
|
|
24380
24412
|
};
|
|
24381
24413
|
const withKnownKinds = async (topics) => topics.map(await knownKinds(topics));
|
|
24382
|
-
const readEveryState = async (ids, signal) => {
|
|
24414
|
+
const readEveryState = async (ids, signal, includeEmbeddings = false) => {
|
|
24383
24415
|
const records = /* @__PURE__ */ new Map();
|
|
24384
24416
|
const unreadable = /* @__PURE__ */ new Set();
|
|
24385
24417
|
for (const memory_ids of chunks2(ids, MAX_QUERY_IDS)) {
|
|
@@ -24391,6 +24423,7 @@ function createRemoteMemoryStore(options) {
|
|
|
24391
24423
|
include_archived: true,
|
|
24392
24424
|
include_quarantined: true,
|
|
24393
24425
|
include_superseded: true,
|
|
24426
|
+
...includeEmbeddings && { include_embeddings: true },
|
|
24394
24427
|
limit: 200,
|
|
24395
24428
|
...signal && { signal },
|
|
24396
24429
|
...cursor2 && { cursor: cursor2 }
|
|
@@ -25053,7 +25086,7 @@ function createRemoteMemoryStore(options) {
|
|
|
25053
25086
|
}
|
|
25054
25087
|
return memory;
|
|
25055
25088
|
});
|
|
25056
|
-
if (saved && patch.embedding === void 0) embedInBackground(saved);
|
|
25089
|
+
if (saved && patch.embedding === void 0) embedInBackground([saved]);
|
|
25057
25090
|
return asStored(saved);
|
|
25058
25091
|
},
|
|
25059
25092
|
delete: async (id2) => !!await mutate(id2, "membership", (memory) => ({ ...memory, is_deleted: true })),
|
package/dist/react/index.cjs
CHANGED
|
@@ -28274,7 +28274,7 @@ function createRemoteMemoryStore(options) {
|
|
|
28274
28274
|
};
|
|
28275
28275
|
const mutate = (id2, change, edit, writeOptions) => serialized(id2, () => mutateLocked(id2, change, edit, writeOptions));
|
|
28276
28276
|
const serializedAll = (ids, task) => [...new Set(ids)].sort().reduceRight((inner, id2) => () => serialized(id2, inner), task)();
|
|
28277
|
-
const mutateMany = async (ids, change, edit, leaseToken, signal) => {
|
|
28277
|
+
const mutateMany = async (ids, change, edit, leaseToken, signal, includeEmbeddings = false) => {
|
|
28278
28278
|
const saved = /* @__PURE__ */ new Map();
|
|
28279
28279
|
const failed = /* @__PURE__ */ new Map();
|
|
28280
28280
|
for (const slice of chunks2([...new Set(ids)], MAX_BATCH)) {
|
|
@@ -28283,7 +28283,7 @@ function createRemoteMemoryStore(options) {
|
|
|
28283
28283
|
const writes = [];
|
|
28284
28284
|
let read;
|
|
28285
28285
|
try {
|
|
28286
|
-
read = await readEveryState(slice, signal);
|
|
28286
|
+
read = await readEveryState(slice, signal, includeEmbeddings);
|
|
28287
28287
|
} catch (error) {
|
|
28288
28288
|
signal?.throwIfAborted();
|
|
28289
28289
|
for (const id2 of slice) failed.set(id2, error);
|
|
@@ -28342,21 +28342,55 @@ function createRemoteMemoryStore(options) {
|
|
|
28342
28342
|
}
|
|
28343
28343
|
return { saved, failed };
|
|
28344
28344
|
};
|
|
28345
|
-
const
|
|
28346
|
-
|
|
28347
|
-
|
|
28348
|
-
|
|
28349
|
-
|
|
28350
|
-
|
|
28351
|
-
const
|
|
28352
|
-
|
|
28353
|
-
|
|
28354
|
-
|
|
28355
|
-
|
|
28356
|
-
|
|
28357
|
-
|
|
28358
|
-
|
|
28359
|
-
|
|
28345
|
+
const pendingEmbeddings = /* @__PURE__ */ new Map();
|
|
28346
|
+
let embeddingActive = false;
|
|
28347
|
+
const drainEmbeddings = async () => {
|
|
28348
|
+
try {
|
|
28349
|
+
while (pendingEmbeddings.size) {
|
|
28350
|
+
const batch = /* @__PURE__ */ new Map();
|
|
28351
|
+
for (const [id2, content] of pendingEmbeddings) {
|
|
28352
|
+
pendingEmbeddings.delete(id2);
|
|
28353
|
+
batch.set(id2, content);
|
|
28354
|
+
if (batch.size === MAX_BATCH) break;
|
|
28355
|
+
}
|
|
28356
|
+
try {
|
|
28357
|
+
const vectors = await generateEmbeddings([...batch.values()], embeddingOptions);
|
|
28358
|
+
const embeddings2 = /* @__PURE__ */ new Map();
|
|
28359
|
+
[...batch.keys()].forEach((id2, i) => {
|
|
28360
|
+
try {
|
|
28361
|
+
embeddings2.set(id2, storedVector(vectors[i]));
|
|
28362
|
+
} catch (error) {
|
|
28363
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
28364
|
+
}
|
|
28365
|
+
});
|
|
28366
|
+
if (!embeddings2.size) continue;
|
|
28367
|
+
const { failed } = await mutateMany(
|
|
28368
|
+
[...embeddings2.keys()],
|
|
28369
|
+
() => "embedding",
|
|
28370
|
+
(memory) => memory.content !== batch.get(memory.memory_id) || memory.embedding?.length ? null : {
|
|
28371
|
+
...memory,
|
|
28372
|
+
embedding: embeddings2.get(memory.memory_id),
|
|
28373
|
+
embedding_model: model
|
|
28374
|
+
},
|
|
28375
|
+
void 0,
|
|
28376
|
+
void 0,
|
|
28377
|
+
true
|
|
28378
|
+
);
|
|
28379
|
+
for (const error of failed.values())
|
|
28380
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
28381
|
+
} catch (error) {
|
|
28382
|
+
getLogger().warn("[memory/remote-store] Failed to embed memories:", error);
|
|
28383
|
+
}
|
|
28384
|
+
}
|
|
28385
|
+
} finally {
|
|
28386
|
+
embeddingActive = false;
|
|
28387
|
+
}
|
|
28388
|
+
};
|
|
28389
|
+
const embedInBackground = (records) => {
|
|
28390
|
+
for (const { memory } of records) pendingEmbeddings.set(memory.memory_id, memory.content);
|
|
28391
|
+
if (embeddingActive || !pendingEmbeddings.size) return;
|
|
28392
|
+
embeddingActive = true;
|
|
28393
|
+
void drainEmbeddings();
|
|
28360
28394
|
};
|
|
28361
28395
|
const newRow = (input) => {
|
|
28362
28396
|
const now = Date.now();
|
|
@@ -28390,9 +28424,7 @@ function createRemoteMemoryStore(options) {
|
|
|
28390
28424
|
};
|
|
28391
28425
|
};
|
|
28392
28426
|
const created = (records, inputs) => {
|
|
28393
|
-
records.
|
|
28394
|
-
if (inputs[i].embedding === void 0) embedInBackground(record2);
|
|
28395
|
-
});
|
|
28427
|
+
embedInBackground(records.filter((_, i) => inputs[i].embedding === void 0));
|
|
28396
28428
|
notify("membership", records);
|
|
28397
28429
|
return records.map((record2) => stored(record2.memory));
|
|
28398
28430
|
};
|
|
@@ -28422,7 +28454,7 @@ function createRemoteMemoryStore(options) {
|
|
|
28422
28454
|
};
|
|
28423
28455
|
};
|
|
28424
28456
|
const withKnownKinds = async (topics) => topics.map(await knownKinds(topics));
|
|
28425
|
-
const readEveryState = async (ids, signal) => {
|
|
28457
|
+
const readEveryState = async (ids, signal, includeEmbeddings = false) => {
|
|
28426
28458
|
const records = /* @__PURE__ */ new Map();
|
|
28427
28459
|
const unreadable = /* @__PURE__ */ new Set();
|
|
28428
28460
|
for (const memory_ids of chunks2(ids, MAX_QUERY_IDS)) {
|
|
@@ -28434,6 +28466,7 @@ function createRemoteMemoryStore(options) {
|
|
|
28434
28466
|
include_archived: true,
|
|
28435
28467
|
include_quarantined: true,
|
|
28436
28468
|
include_superseded: true,
|
|
28469
|
+
...includeEmbeddings && { include_embeddings: true },
|
|
28437
28470
|
limit: 200,
|
|
28438
28471
|
...signal && { signal },
|
|
28439
28472
|
...cursor2 && { cursor: cursor2 }
|
|
@@ -29096,7 +29129,7 @@ function createRemoteMemoryStore(options) {
|
|
|
29096
29129
|
}
|
|
29097
29130
|
return memory;
|
|
29098
29131
|
});
|
|
29099
|
-
if (saved && patch.embedding === void 0) embedInBackground(saved);
|
|
29132
|
+
if (saved && patch.embedding === void 0) embedInBackground([saved]);
|
|
29100
29133
|
return asStored(saved);
|
|
29101
29134
|
},
|
|
29102
29135
|
delete: async (id2) => !!await mutate(id2, "membership", (memory) => ({ ...memory, is_deleted: true })),
|
package/dist/react/index.mjs
CHANGED
|
@@ -26353,7 +26353,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26353
26353
|
};
|
|
26354
26354
|
const mutate = (id2, change, edit, writeOptions) => serialized(id2, () => mutateLocked(id2, change, edit, writeOptions));
|
|
26355
26355
|
const serializedAll = (ids, task) => [...new Set(ids)].sort().reduceRight((inner, id2) => () => serialized(id2, inner), task)();
|
|
26356
|
-
const mutateMany = async (ids, change, edit, leaseToken, signal) => {
|
|
26356
|
+
const mutateMany = async (ids, change, edit, leaseToken, signal, includeEmbeddings = false) => {
|
|
26357
26357
|
const saved = /* @__PURE__ */ new Map();
|
|
26358
26358
|
const failed = /* @__PURE__ */ new Map();
|
|
26359
26359
|
for (const slice of chunks2([...new Set(ids)], MAX_BATCH)) {
|
|
@@ -26362,7 +26362,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26362
26362
|
const writes = [];
|
|
26363
26363
|
let read;
|
|
26364
26364
|
try {
|
|
26365
|
-
read = await readEveryState(slice, signal);
|
|
26365
|
+
read = await readEveryState(slice, signal, includeEmbeddings);
|
|
26366
26366
|
} catch (error) {
|
|
26367
26367
|
signal?.throwIfAborted();
|
|
26368
26368
|
for (const id2 of slice) failed.set(id2, error);
|
|
@@ -26421,21 +26421,55 @@ function createRemoteMemoryStore(options) {
|
|
|
26421
26421
|
}
|
|
26422
26422
|
return { saved, failed };
|
|
26423
26423
|
};
|
|
26424
|
-
const
|
|
26425
|
-
|
|
26426
|
-
|
|
26427
|
-
|
|
26428
|
-
|
|
26429
|
-
|
|
26430
|
-
const
|
|
26431
|
-
|
|
26432
|
-
|
|
26433
|
-
|
|
26434
|
-
|
|
26435
|
-
|
|
26436
|
-
|
|
26437
|
-
|
|
26438
|
-
|
|
26424
|
+
const pendingEmbeddings = /* @__PURE__ */ new Map();
|
|
26425
|
+
let embeddingActive = false;
|
|
26426
|
+
const drainEmbeddings = async () => {
|
|
26427
|
+
try {
|
|
26428
|
+
while (pendingEmbeddings.size) {
|
|
26429
|
+
const batch = /* @__PURE__ */ new Map();
|
|
26430
|
+
for (const [id2, content] of pendingEmbeddings) {
|
|
26431
|
+
pendingEmbeddings.delete(id2);
|
|
26432
|
+
batch.set(id2, content);
|
|
26433
|
+
if (batch.size === MAX_BATCH) break;
|
|
26434
|
+
}
|
|
26435
|
+
try {
|
|
26436
|
+
const vectors = await generateEmbeddings([...batch.values()], embeddingOptions);
|
|
26437
|
+
const embeddings2 = /* @__PURE__ */ new Map();
|
|
26438
|
+
[...batch.keys()].forEach((id2, i) => {
|
|
26439
|
+
try {
|
|
26440
|
+
embeddings2.set(id2, storedVector(vectors[i]));
|
|
26441
|
+
} catch (error) {
|
|
26442
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
26443
|
+
}
|
|
26444
|
+
});
|
|
26445
|
+
if (!embeddings2.size) continue;
|
|
26446
|
+
const { failed } = await mutateMany(
|
|
26447
|
+
[...embeddings2.keys()],
|
|
26448
|
+
() => "embedding",
|
|
26449
|
+
(memory) => memory.content !== batch.get(memory.memory_id) || memory.embedding?.length ? null : {
|
|
26450
|
+
...memory,
|
|
26451
|
+
embedding: embeddings2.get(memory.memory_id),
|
|
26452
|
+
embedding_model: model
|
|
26453
|
+
},
|
|
26454
|
+
void 0,
|
|
26455
|
+
void 0,
|
|
26456
|
+
true
|
|
26457
|
+
);
|
|
26458
|
+
for (const error of failed.values())
|
|
26459
|
+
getLogger().warn("[memory/remote-store] Failed to embed memory:", error);
|
|
26460
|
+
} catch (error) {
|
|
26461
|
+
getLogger().warn("[memory/remote-store] Failed to embed memories:", error);
|
|
26462
|
+
}
|
|
26463
|
+
}
|
|
26464
|
+
} finally {
|
|
26465
|
+
embeddingActive = false;
|
|
26466
|
+
}
|
|
26467
|
+
};
|
|
26468
|
+
const embedInBackground = (records) => {
|
|
26469
|
+
for (const { memory } of records) pendingEmbeddings.set(memory.memory_id, memory.content);
|
|
26470
|
+
if (embeddingActive || !pendingEmbeddings.size) return;
|
|
26471
|
+
embeddingActive = true;
|
|
26472
|
+
void drainEmbeddings();
|
|
26439
26473
|
};
|
|
26440
26474
|
const newRow = (input) => {
|
|
26441
26475
|
const now = Date.now();
|
|
@@ -26469,9 +26503,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26469
26503
|
};
|
|
26470
26504
|
};
|
|
26471
26505
|
const created = (records, inputs) => {
|
|
26472
|
-
records.
|
|
26473
|
-
if (inputs[i].embedding === void 0) embedInBackground(record2);
|
|
26474
|
-
});
|
|
26506
|
+
embedInBackground(records.filter((_, i) => inputs[i].embedding === void 0));
|
|
26475
26507
|
notify("membership", records);
|
|
26476
26508
|
return records.map((record2) => stored(record2.memory));
|
|
26477
26509
|
};
|
|
@@ -26501,7 +26533,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26501
26533
|
};
|
|
26502
26534
|
};
|
|
26503
26535
|
const withKnownKinds = async (topics) => topics.map(await knownKinds(topics));
|
|
26504
|
-
const readEveryState = async (ids, signal) => {
|
|
26536
|
+
const readEveryState = async (ids, signal, includeEmbeddings = false) => {
|
|
26505
26537
|
const records = /* @__PURE__ */ new Map();
|
|
26506
26538
|
const unreadable = /* @__PURE__ */ new Set();
|
|
26507
26539
|
for (const memory_ids of chunks2(ids, MAX_QUERY_IDS)) {
|
|
@@ -26513,6 +26545,7 @@ function createRemoteMemoryStore(options) {
|
|
|
26513
26545
|
include_archived: true,
|
|
26514
26546
|
include_quarantined: true,
|
|
26515
26547
|
include_superseded: true,
|
|
26548
|
+
...includeEmbeddings && { include_embeddings: true },
|
|
26516
26549
|
limit: 200,
|
|
26517
26550
|
...signal && { signal },
|
|
26518
26551
|
...cursor2 && { cursor: cursor2 }
|
|
@@ -27175,7 +27208,7 @@ function createRemoteMemoryStore(options) {
|
|
|
27175
27208
|
}
|
|
27176
27209
|
return memory;
|
|
27177
27210
|
});
|
|
27178
|
-
if (saved && patch.embedding === void 0) embedInBackground(saved);
|
|
27211
|
+
if (saved && patch.embedding === void 0) embedInBackground([saved]);
|
|
27179
27212
|
return asStored(saved);
|
|
27180
27213
|
},
|
|
27181
27214
|
delete: async (id2) => !!await mutate(id2, "membership", (memory) => ({ ...memory, is_deleted: true })),
|