@anuma/sdk 7.0.4-next.20261015012621 → 7.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/expo/index.cjs +68 -224
- package/dist/expo/index.d.mts +4 -24
- package/dist/expo/index.d.ts +4 -24
- package/dist/expo/index.mjs +68 -224
- package/dist/memory/context.d.mts +0 -1
- package/dist/memory/context.d.ts +0 -1
- package/dist/react/index.cjs +68 -229
- package/dist/react/index.d.mts +4 -24
- package/dist/react/index.d.ts +4 -24
- package/dist/react/index.mjs +68 -229
- package/dist/server/index.cjs +28 -144
- package/dist/server/index.d.mts +2 -22
- package/dist/server/index.d.ts +2 -22
- package/dist/server/index.mjs +28 -144
- package/package.json +1 -1
package/dist/expo/index.mjs
CHANGED
|
@@ -11131,11 +11131,6 @@ import { Q as Q5 } from "@nozbe/watermelondb";
|
|
|
11131
11131
|
|
|
11132
11132
|
// src/lib/db/entities/operations.ts
|
|
11133
11133
|
import { Q as Q4 } from "@nozbe/watermelondb";
|
|
11134
|
-
async function assertCanWrite(ctx) {
|
|
11135
|
-
if (ctx.canWrite && !await ctx.canWrite()) {
|
|
11136
|
-
throw new Error("Memory source is no longer eligible");
|
|
11137
|
-
}
|
|
11138
|
-
}
|
|
11139
11134
|
function entityToStored(e) {
|
|
11140
11135
|
return {
|
|
11141
11136
|
uniqueId: e.id,
|
|
@@ -11276,7 +11271,6 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
|
|
|
11276
11271
|
let skipped = false;
|
|
11277
11272
|
let entities = [];
|
|
11278
11273
|
await ctx.database.write(async () => {
|
|
11279
|
-
await assertCanWrite(ctx);
|
|
11280
11274
|
const {
|
|
11281
11275
|
entities: byName,
|
|
11282
11276
|
operations: entityOps,
|
|
@@ -11352,7 +11346,6 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
|
|
|
11352
11346
|
let skipped = false;
|
|
11353
11347
|
let entities = [];
|
|
11354
11348
|
await ctx.database.write(async () => {
|
|
11355
|
-
await assertCanWrite(ctx);
|
|
11356
11349
|
const vaultRow = await findVaultRowInWrite(ctx, memoryId);
|
|
11357
11350
|
if (options.guarded && autoLinkBlocked(vaultRow)) {
|
|
11358
11351
|
skipped = true;
|
|
@@ -11413,7 +11406,6 @@ async function unlinkMemoryEntitiesOp(ctx, memoryIds) {
|
|
|
11413
11406
|
const links = await ctx.memoryEntityCollection.query(Q4.where("memory_id", Q4.oneOf(Array.from(memoryIds)))).fetch();
|
|
11414
11407
|
if (links.length === 0) return;
|
|
11415
11408
|
await ctx.database.write(async () => {
|
|
11416
|
-
await assertCanWrite(ctx);
|
|
11417
11409
|
await ctx.database.batch(...links.map((l) => l.prepareDestroyPermanently()));
|
|
11418
11410
|
});
|
|
11419
11411
|
}
|
|
@@ -11422,7 +11414,6 @@ async function unlinkAllMemoryEntitiesForUserOp(ctx, userId) {
|
|
|
11422
11414
|
const links = await ctx.memoryEntityCollection.query(Q4.where("user_id", userId)).fetch();
|
|
11423
11415
|
if (links.length === 0) return;
|
|
11424
11416
|
await ctx.database.write(async () => {
|
|
11425
|
-
await assertCanWrite(ctx);
|
|
11426
11417
|
await ctx.database.batch(...links.map((l) => l.prepareDestroyPermanently()));
|
|
11427
11418
|
});
|
|
11428
11419
|
}
|
|
@@ -11586,11 +11577,6 @@ function visibilityConditions(requested) {
|
|
|
11586
11577
|
function isKinded(record2) {
|
|
11587
11578
|
return record2.kind !== null && record2.kind !== void 0;
|
|
11588
11579
|
}
|
|
11589
|
-
async function assertCanWrite2(ctx) {
|
|
11590
|
-
if (ctx.canWrite && !await ctx.canWrite()) {
|
|
11591
|
-
throw new Error("Memory source is no longer eligible");
|
|
11592
|
-
}
|
|
11593
|
-
}
|
|
11594
11580
|
function assertValidKindLevel(kind, level) {
|
|
11595
11581
|
const hasKind = kind !== null && kind !== void 0;
|
|
11596
11582
|
if (hasKind && !MEMORY_KINDS.includes(kind)) {
|
|
@@ -11771,7 +11757,8 @@ async function createVaultMemoryOp(ctx, opts) {
|
|
|
11771
11757
|
ctx.embeddedWalletSigner
|
|
11772
11758
|
) : opts.content;
|
|
11773
11759
|
const created = await ctx.database.write(async () => {
|
|
11774
|
-
await
|
|
11760
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
11761
|
+
throw new Error("Memory source is no longer eligible");
|
|
11775
11762
|
return ctx.vaultMemoryCollection.create(
|
|
11776
11763
|
(record2) => populateNewVaultMemory(record2, ctx, opts, encryptedContent, encryptedKindValue)
|
|
11777
11764
|
);
|
|
@@ -11790,7 +11777,8 @@ async function createSupersedingMemoryOp(ctx, opts, targetId) {
|
|
|
11790
11777
|
) : opts.content;
|
|
11791
11778
|
let createdRecord = null;
|
|
11792
11779
|
await ctx.database.write(async () => {
|
|
11793
|
-
await
|
|
11780
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
11781
|
+
throw new Error("Memory source is no longer eligible");
|
|
11794
11782
|
let target;
|
|
11795
11783
|
try {
|
|
11796
11784
|
target = await ctx.vaultMemoryCollection.find(targetId);
|
|
@@ -11882,7 +11870,8 @@ async function createVaultMemoriesBatchOp(ctx, optionsArray) {
|
|
|
11882
11870
|
})
|
|
11883
11871
|
);
|
|
11884
11872
|
const created = await ctx.database.write(async () => {
|
|
11885
|
-
await
|
|
11873
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
11874
|
+
throw new Error("Memory source is no longer eligible");
|
|
11886
11875
|
const prepared = optionsArray.map(
|
|
11887
11876
|
(opts, i) => ctx.vaultMemoryCollection.prepareCreate(
|
|
11888
11877
|
(record2) => populateNewVaultMemory(record2, ctx, opts, encryptedContents[i], encryptedKindValues[i])
|
|
@@ -12187,7 +12176,8 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
12187
12176
|
const record2 = probe;
|
|
12188
12177
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
12189
12178
|
await ctx.database.write(async () => {
|
|
12190
|
-
await
|
|
12179
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
12180
|
+
throw new Error("Memory source is no longer eligible");
|
|
12191
12181
|
if (record2.isDeleted || record2.supersededBy || !isOwnedByCtxUser(ctx, record2) || opts.freeFormOnly && isKinded(record2)) {
|
|
12192
12182
|
stale = true;
|
|
12193
12183
|
return;
|
|
@@ -12298,7 +12288,6 @@ async function setMemoryEntitiesOp(ctx, memoryId, entities) {
|
|
|
12298
12288
|
let stale = false;
|
|
12299
12289
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
12300
12290
|
await ctx.database.write(async (writer) => {
|
|
12301
|
-
await assertCanWrite2(ctx);
|
|
12302
12291
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
12303
12292
|
stale = true;
|
|
12304
12293
|
return;
|
|
@@ -12340,7 +12329,6 @@ async function clearMemoryTopicsOverrideOp(ctx, memoryId, options) {
|
|
|
12340
12329
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
12341
12330
|
let cleared = false;
|
|
12342
12331
|
await ctx.database.write(async () => {
|
|
12343
|
-
await assertCanWrite2(ctx);
|
|
12344
12332
|
if (options?.unlessTopicsRecorded && parseTopics(record2.topics) !== null) return;
|
|
12345
12333
|
cleared = true;
|
|
12346
12334
|
await record2.update((r) => {
|
|
@@ -12364,7 +12352,6 @@ async function setMemoryVisibilityOp(ctx, id, opts) {
|
|
|
12364
12352
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return null;
|
|
12365
12353
|
let stale = false;
|
|
12366
12354
|
await ctx.database.write(async () => {
|
|
12367
|
-
await assertCanWrite2(ctx);
|
|
12368
12355
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
12369
12356
|
stale = true;
|
|
12370
12357
|
return;
|
|
@@ -12393,7 +12380,6 @@ async function deleteVaultMemoryOp(ctx, id) {
|
|
|
12393
12380
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return false;
|
|
12394
12381
|
let stale = false;
|
|
12395
12382
|
await ctx.database.write(async () => {
|
|
12396
|
-
await assertCanWrite2(ctx);
|
|
12397
12383
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
12398
12384
|
stale = true;
|
|
12399
12385
|
return;
|
|
@@ -12431,7 +12417,8 @@ async function supersedeVaultMemoryOp(ctx, id, supersededById) {
|
|
|
12431
12417
|
}
|
|
12432
12418
|
let stale = false;
|
|
12433
12419
|
await ctx.database.write(async () => {
|
|
12434
|
-
await
|
|
12420
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
12421
|
+
throw new Error("Memory source is no longer eligible");
|
|
12435
12422
|
if (record2.isDeleted || record2.supersededBy || !isOwnedByCtxUser(ctx, record2)) {
|
|
12436
12423
|
stale = true;
|
|
12437
12424
|
return;
|
|
@@ -12593,7 +12580,6 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
|
|
|
12593
12580
|
for (let i = 0; i < uniqueIds.length; i += CHUNK) {
|
|
12594
12581
|
const chunkIds = uniqueIds.slice(i, i + CHUNK);
|
|
12595
12582
|
await ctx.database.write(async () => {
|
|
12596
|
-
await assertCanWrite2(ctx);
|
|
12597
12583
|
const records = [];
|
|
12598
12584
|
for (const id of chunkIds) {
|
|
12599
12585
|
try {
|
|
@@ -12627,7 +12613,6 @@ async function relinkMemoryTopicsOp(ctx, memoryIds) {
|
|
|
12627
12613
|
for (const id of Array.from(new Set(memoryIds))) {
|
|
12628
12614
|
try {
|
|
12629
12615
|
await ctx.database.write(async (writer) => {
|
|
12630
|
-
await assertCanWrite2(ctx);
|
|
12631
12616
|
let record2;
|
|
12632
12617
|
try {
|
|
12633
12618
|
record2 = await ctx.vaultMemoryCollection.find(id);
|
|
@@ -12658,7 +12643,6 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
|
|
|
12658
12643
|
for (let i = 0; i < uniqueIds.length; i += CHUNK) {
|
|
12659
12644
|
const chunkIds = uniqueIds.slice(i, i + CHUNK);
|
|
12660
12645
|
await ctx.database.write(async () => {
|
|
12661
|
-
await assertCanWrite2(ctx);
|
|
12662
12646
|
const writes = [];
|
|
12663
12647
|
for (const id of chunkIds) {
|
|
12664
12648
|
let record2;
|
|
@@ -12691,7 +12675,6 @@ async function deleteAllVaultMemoriesForUserOp(ctx, userId) {
|
|
|
12691
12675
|
const records = await ctx.vaultMemoryCollection.query(Q5.where("user_id", userId), Q5.where("is_deleted", false)).fetch();
|
|
12692
12676
|
if (records.length === 0) return 0;
|
|
12693
12677
|
await ctx.database.write(async () => {
|
|
12694
|
-
await assertCanWrite2(ctx);
|
|
12695
12678
|
const prepared = records.map(
|
|
12696
12679
|
(record2) => record2.prepareUpdate((r) => {
|
|
12697
12680
|
r._setRaw("is_deleted", true);
|
|
@@ -12746,7 +12729,6 @@ async function archiveVaultMemoryOp(ctx, id, opts) {
|
|
|
12746
12729
|
let stale = false;
|
|
12747
12730
|
const archivedAtValue = opts?.now ?? Date.now();
|
|
12748
12731
|
await ctx.database.write(async () => {
|
|
12749
|
-
await assertCanWrite2(ctx);
|
|
12750
12732
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2) || record2.archivedAt !== null) {
|
|
12751
12733
|
stale = true;
|
|
12752
12734
|
return;
|
|
@@ -12770,7 +12752,6 @@ async function restoreVaultMemoryOp(ctx, id) {
|
|
|
12770
12752
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return false;
|
|
12771
12753
|
let stale = false;
|
|
12772
12754
|
await ctx.database.write(async () => {
|
|
12773
|
-
await assertCanWrite2(ctx);
|
|
12774
12755
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
12775
12756
|
stale = true;
|
|
12776
12757
|
return;
|
|
@@ -12791,7 +12772,6 @@ async function hardDeleteDecayedOp(ctx, id, opts) {
|
|
|
12791
12772
|
const now = opts.now ?? Date.now();
|
|
12792
12773
|
let stale = false;
|
|
12793
12774
|
await ctx.database.write(async () => {
|
|
12794
|
-
await assertCanWrite2(ctx);
|
|
12795
12775
|
const archivedAt = record2.archivedAt;
|
|
12796
12776
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2) || archivedAt === null || now - archivedAt <= opts.hardDeleteWindowMs) {
|
|
12797
12777
|
stale = true;
|
|
@@ -12831,7 +12811,6 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding2, embeddingModel,
|
|
|
12831
12811
|
}
|
|
12832
12812
|
let written = false;
|
|
12833
12813
|
await ctx.database.write(async () => {
|
|
12834
|
-
await assertCanWrite2(ctx);
|
|
12835
12814
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return;
|
|
12836
12815
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
12837
12816
|
if (originalUpdatedAt !== readUpdatedAt || record2._getRaw("content") !== readStoredContent)
|
|
@@ -16344,13 +16323,6 @@ function restoreCandidates(candidates, redactor, ownNames) {
|
|
|
16344
16323
|
).map((c) => c.candidate);
|
|
16345
16324
|
}
|
|
16346
16325
|
async function extractAndRetain(messages, retainCtx, options) {
|
|
16347
|
-
const { memoryStore, signal } = options;
|
|
16348
|
-
if (memoryStore === null) throw new Error("Memory store is not ready");
|
|
16349
|
-
if (memoryStore && options.folderId !== void 0 && options.folderId !== null)
|
|
16350
|
-
throw new Error("Remote memory extraction does not support folders");
|
|
16351
|
-
if (memoryStore && options.extract.piiRedaction && !memoryStore.masksEmbeddingInput)
|
|
16352
|
-
throw new Error("PII-redacted extraction requires a memory store that masks embedding inputs");
|
|
16353
|
-
signal?.throwIfAborted();
|
|
16354
16326
|
const minConfidence = options.minConfidence ?? DEFAULT_MIN_CONFIDENCE;
|
|
16355
16327
|
const resolvedConsolidatePii = options.consolidateOptions?.piiRedaction ?? options.extract.piiRedaction;
|
|
16356
16328
|
const consolidateOptions = options.consolidateOptions !== void 0 ? {
|
|
@@ -16384,7 +16356,6 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
16384
16356
|
}
|
|
16385
16357
|
});
|
|
16386
16358
|
const extractMs = Date.now() - tExtract;
|
|
16387
|
-
signal?.throwIfAborted();
|
|
16388
16359
|
const filtered = candidates.filter((c) => c.confidence >= minConfidence);
|
|
16389
16360
|
const log = getLogger();
|
|
16390
16361
|
const screened = screenCandidatesForInjection(filtered);
|
|
@@ -16432,33 +16403,16 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
16432
16403
|
const results = [];
|
|
16433
16404
|
const quarantinedInfo = [];
|
|
16434
16405
|
let failedWrites = 0;
|
|
16435
|
-
let auditRows;
|
|
16436
16406
|
const tRetain = Date.now();
|
|
16437
16407
|
for (const { candidate, isQuarantined, reason, signature } of toRetain) {
|
|
16438
16408
|
try {
|
|
16439
|
-
signal?.throwIfAborted();
|
|
16440
16409
|
if (isQuarantined) {
|
|
16441
|
-
|
|
16442
|
-
|
|
16443
|
-
|
|
16444
|
-
|
|
16445
|
-
|
|
16446
|
-
|
|
16447
|
-
includeSuperseded: true
|
|
16448
|
-
}));
|
|
16449
|
-
const sourceKey = [...new Set(candidate.sourceMessageIds)].sort().join("\0");
|
|
16450
|
-
const normalize = (value) => value.normalize("NFKC").trim().replace(/\s+/g, " ").toLowerCase();
|
|
16451
|
-
existingId = (await auditRows).find(
|
|
16452
|
-
(row) => row.trustTier === "quarantined" && row.scope === (options.scope ?? "private") && [...new Set(row.sourceChunkIds ?? [])].sort().join("\0") === sourceKey && normalize(row.content) === normalize(candidate.content)
|
|
16453
|
-
)?.uniqueId ?? null;
|
|
16454
|
-
} else {
|
|
16455
|
-
existingId = await findQuarantinedDuplicateOp(
|
|
16456
|
-
retainCtx.vaultCtx,
|
|
16457
|
-
candidate.content,
|
|
16458
|
-
candidate.sourceMessageIds,
|
|
16459
|
-
{ scope: options.scope ?? "private", folderId: options.folderId ?? null }
|
|
16460
|
-
).catch(() => null);
|
|
16461
|
-
}
|
|
16410
|
+
const existingId = await findQuarantinedDuplicateOp(
|
|
16411
|
+
retainCtx.vaultCtx,
|
|
16412
|
+
candidate.content,
|
|
16413
|
+
candidate.sourceMessageIds,
|
|
16414
|
+
{ scope: options.scope ?? "private", folderId: options.folderId ?? null }
|
|
16415
|
+
).catch(() => null);
|
|
16462
16416
|
if (existingId) {
|
|
16463
16417
|
quarantinedInfo.push({
|
|
16464
16418
|
candidate,
|
|
@@ -16469,26 +16423,18 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
16469
16423
|
continue;
|
|
16470
16424
|
}
|
|
16471
16425
|
}
|
|
16472
|
-
const
|
|
16426
|
+
const result = await retain(candidate.content, retainCtx, {
|
|
16473
16427
|
source: "auto-extracted",
|
|
16474
16428
|
sourceChunkIds: candidate.sourceMessageIds,
|
|
16475
16429
|
respectTombstones: true,
|
|
16476
16430
|
...options.scope !== void 0 && { scope: options.scope },
|
|
16431
|
+
...options.folderId !== void 0 && { folderId: options.folderId },
|
|
16477
16432
|
...consolidateOptions !== void 0 && { consolidateOptions },
|
|
16478
16433
|
...candidate.eventTime !== null && { eventTime: candidate.eventTime },
|
|
16479
16434
|
factType: candidate.type,
|
|
16480
16435
|
...isQuarantined && { trustTier: "quarantined", enableAutoMerge: false }
|
|
16481
|
-
};
|
|
16482
|
-
const result = memoryStore ? await memoryStore.retain(candidate.content, {
|
|
16483
|
-
...retainOptions,
|
|
16484
|
-
canWrite: retainCtx.vaultCtx.canWrite,
|
|
16485
|
-
signal
|
|
16486
|
-
}) : await retain(candidate.content, retainCtx, {
|
|
16487
|
-
...retainOptions,
|
|
16488
|
-
...options.folderId !== void 0 && { folderId: options.folderId }
|
|
16489
16436
|
});
|
|
16490
16437
|
if (isQuarantined) {
|
|
16491
|
-
auditRows = void 0;
|
|
16492
16438
|
const info = {
|
|
16493
16439
|
candidate,
|
|
16494
16440
|
memoryId: result.memoryId,
|
|
@@ -16507,16 +16453,9 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
16507
16453
|
}
|
|
16508
16454
|
succeededCandidates.push(candidate);
|
|
16509
16455
|
results.push(result);
|
|
16510
|
-
if (result.action !== "suppressed" && candidate.entities.length > 0) {
|
|
16456
|
+
if (result.action !== "suppressed" && options.entityCtx && candidate.entities.length > 0) {
|
|
16511
16457
|
try {
|
|
16512
|
-
|
|
16513
|
-
if (memoryStore) {
|
|
16514
|
-
await memoryStore.addTopics(result.memoryId, candidate.entities, {
|
|
16515
|
-
unlessUserManaged: true,
|
|
16516
|
-
canWrite: retainCtx.vaultCtx.canWrite,
|
|
16517
|
-
signal
|
|
16518
|
-
});
|
|
16519
|
-
} else if (options.entityCtx && !await isMemoryTopicsUserManaged(options.entityCtx, result.memoryId)) {
|
|
16458
|
+
if (!await isMemoryTopicsUserManaged(options.entityCtx, result.memoryId)) {
|
|
16520
16459
|
await linkMemoryEntitiesOp(options.entityCtx, result.memoryId, candidate.entities, {
|
|
16521
16460
|
unlessTopicsUserManaged: true
|
|
16522
16461
|
});
|
|
@@ -16764,7 +16703,7 @@ function createAutoExtractor(options) {
|
|
|
16764
16703
|
};
|
|
16765
16704
|
const consolidateOptions = options.consolidate ? { ...options.consolidate, ...subPassAuth(options.consolidate.baseUrl) } : void 0;
|
|
16766
16705
|
const injectionClassifierOptions = options.injectionClassifier ? { ...options.injectionClassifier, ...subPassAuth(options.injectionClassifier.baseUrl) } : void 0;
|
|
16767
|
-
if (
|
|
16706
|
+
if (options.retainCtx.vaultCtx.entityCtx && !options.entityCtx) {
|
|
16768
16707
|
getLogger().warn(
|
|
16769
16708
|
"[memory/extract] retainCtx.vaultCtx.entityCtx is set but extractor was created without `entityCtx` \u2014 W5 graph lane will receive no writes"
|
|
16770
16709
|
);
|
|
@@ -16809,8 +16748,6 @@ function createAutoExtractor(options) {
|
|
|
16809
16748
|
try {
|
|
16810
16749
|
const { candidates, results, failedCount, outcome: outcome2, failure, funnel, timings, model } = await extractAndRetain(window2, retainCtx, {
|
|
16811
16750
|
extract,
|
|
16812
|
-
memoryStore: options.memoryStore,
|
|
16813
|
-
signal: options.signal,
|
|
16814
16751
|
...options.minConfidence !== void 0 && { minConfidence: options.minConfidence },
|
|
16815
16752
|
...options.entityCtx !== void 0 && { entityCtx: options.entityCtx },
|
|
16816
16753
|
...options.scope !== void 0 && { scope: options.scope },
|
|
@@ -18897,7 +18834,6 @@ function createLocalMemoryStore(options) {
|
|
|
18897
18834
|
database,
|
|
18898
18835
|
entityCollection: database.get("entity"),
|
|
18899
18836
|
memoryEntityCollection: database.get("memory_entity"),
|
|
18900
|
-
canWrite: options.canWrite,
|
|
18901
18837
|
...userId !== void 0 && { userId },
|
|
18902
18838
|
...options.allowUnscopedRows !== void 0 && {
|
|
18903
18839
|
allowUnscopedRows: options.allowUnscopedRows
|
|
@@ -18909,21 +18845,10 @@ function createLocalMemoryStore(options) {
|
|
|
18909
18845
|
walletAddress: options.walletAddress,
|
|
18910
18846
|
signMessage: options.signMessage,
|
|
18911
18847
|
embeddedWalletSigner: options.embeddedWalletSigner,
|
|
18912
|
-
canWrite: options.canWrite,
|
|
18913
18848
|
...userId !== void 0 && { userId },
|
|
18914
18849
|
...options.singleTenant !== void 0 && { singleTenant: options.singleTenant },
|
|
18915
18850
|
entityCtx
|
|
18916
18851
|
};
|
|
18917
|
-
const assertWrite = async (writeOptions) => {
|
|
18918
|
-
writeOptions?.signal?.throwIfAborted();
|
|
18919
|
-
if (writeOptions?.canWrite && !await writeOptions.canWrite()) {
|
|
18920
|
-
throw new Error("Memory source is no longer eligible");
|
|
18921
|
-
}
|
|
18922
|
-
if (options.canWrite && !await options.canWrite()) {
|
|
18923
|
-
throw new Error("Memory source is no longer eligible");
|
|
18924
|
-
}
|
|
18925
|
-
writeOptions?.signal?.throwIfAborted();
|
|
18926
|
-
};
|
|
18927
18852
|
const vaultCache = options.vaultCache ?? createVaultEmbeddingCache();
|
|
18928
18853
|
const ownedBy = userId !== void 0 ? [Q8.where("user_id", userId)] : [];
|
|
18929
18854
|
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [Q8.or(Q8.where("user_id", userId), Q8.where("user_id", null))] : [Q8.where("user_id", userId)];
|
|
@@ -19035,25 +18960,9 @@ function createLocalMemoryStore(options) {
|
|
|
19035
18960
|
archive: (id) => archiveVaultMemoryOp(vaultCtx, id),
|
|
19036
18961
|
restore: (id) => restoreVaultMemoryOp(vaultCtx, id),
|
|
19037
18962
|
setTopics: (memoryId, topics) => setMemoryEntitiesOp(vaultCtx, memoryId, topics),
|
|
19038
|
-
addTopics: (memoryId, topics
|
|
19039
|
-
await assertWrite(writeOptions);
|
|
18963
|
+
addTopics: (memoryId, topics) => database.write(async (writer) => {
|
|
19040
18964
|
const owned = await vaultCtx.vaultMemoryCollection.query(Q8.where("id", memoryId), Q8.where("is_deleted", false), ...ownedBy).fetchCount();
|
|
19041
|
-
return owned > 0 ? writer.callWriter(
|
|
19042
|
-
() => linkMemoryEntitiesOp(
|
|
19043
|
-
{
|
|
19044
|
-
...entityCtx,
|
|
19045
|
-
canWrite: async () => {
|
|
19046
|
-
await assertWrite(writeOptions);
|
|
19047
|
-
return true;
|
|
19048
|
-
}
|
|
19049
|
-
},
|
|
19050
|
-
memoryId,
|
|
19051
|
-
topics,
|
|
19052
|
-
{
|
|
19053
|
-
unlessTopicsUserManaged: writeOptions?.unlessUserManaged
|
|
19054
|
-
}
|
|
19055
|
-
)
|
|
19056
|
-
) : [];
|
|
18965
|
+
return owned > 0 ? writer.callWriter(() => linkMemoryEntitiesOp(entityCtx, memoryId, topics)) : [];
|
|
19057
18966
|
}),
|
|
19058
18967
|
setVisibility: (id, visibility, visibilityOptions) => setMemoryVisibilityOp(vaultCtx, id, { visibility, ...visibilityOptions }),
|
|
19059
18968
|
recall: (query, recallOptions) => recall(
|
|
@@ -19063,17 +18972,7 @@ function createLocalMemoryStore(options) {
|
|
|
19063
18972
|
),
|
|
19064
18973
|
retain: (content, retainOptions) => retain(
|
|
19065
18974
|
content,
|
|
19066
|
-
{
|
|
19067
|
-
vaultCtx: {
|
|
19068
|
-
...vaultCtx,
|
|
19069
|
-
canWrite: async () => {
|
|
19070
|
-
await assertWrite(retainOptions);
|
|
19071
|
-
return true;
|
|
19072
|
-
}
|
|
19073
|
-
},
|
|
19074
|
-
embeddingOptions: options.embeddingOptions,
|
|
19075
|
-
vaultCache
|
|
19076
|
-
},
|
|
18975
|
+
{ vaultCtx, embeddingOptions: options.embeddingOptions, vaultCache },
|
|
19077
18976
|
retainOptions
|
|
19078
18977
|
),
|
|
19079
18978
|
factSource: {
|
|
@@ -19719,14 +19618,7 @@ function stored(row) {
|
|
|
19719
19618
|
function createRemoteMemoryPipeline(options) {
|
|
19720
19619
|
const { persistence, embeddingOptions } = options;
|
|
19721
19620
|
const model = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
19722
|
-
const operation = (mode, queryOptions = embeddingOptions
|
|
19723
|
-
const signal = writeOptions?.signal;
|
|
19724
|
-
const assertWrite = async () => {
|
|
19725
|
-
signal?.throwIfAborted();
|
|
19726
|
-
if (writeOptions?.canWrite && !await writeOptions.canWrite())
|
|
19727
|
-
throw new Error("Memory source is no longer eligible");
|
|
19728
|
-
signal?.throwIfAborted();
|
|
19729
|
-
};
|
|
19621
|
+
const operation = (mode, queryOptions = embeddingOptions) => {
|
|
19730
19622
|
const rejectUndecryptable = (failed) => {
|
|
19731
19623
|
if (!failed.length) return;
|
|
19732
19624
|
if (mode === "retain")
|
|
@@ -19744,7 +19636,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
19744
19636
|
return items.map((item) => stored(item.memory));
|
|
19745
19637
|
};
|
|
19746
19638
|
const get = async (id) => {
|
|
19747
|
-
const snapshot = snapshots.get(id) ?? await
|
|
19639
|
+
const snapshot = snapshots.get(id) ?? await persistence.get(id);
|
|
19748
19640
|
if (!snapshot || snapshot.memory.is_deleted || snapshot.memory.superseded_by) return null;
|
|
19749
19641
|
snapshots.set(id, snapshot);
|
|
19750
19642
|
return stored(snapshot.memory);
|
|
@@ -19794,7 +19686,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
19794
19686
|
if (forced.size < 100 && temporal[i] !== void 0) forced.add(temporal[i]);
|
|
19795
19687
|
}
|
|
19796
19688
|
const forceIds = [...forced];
|
|
19797
|
-
const windowOptions = (i,
|
|
19689
|
+
const windowOptions = (i, signal) => ({
|
|
19798
19690
|
limit: Math.min(100, Math.max((search.limit ?? 8) * 3, 30)),
|
|
19799
19691
|
force_ids: i === 0 ? forceIds : [],
|
|
19800
19692
|
...search.scopes && { scopes: search.scopes },
|
|
@@ -19802,15 +19694,13 @@ function createRemoteMemoryPipeline(options) {
|
|
|
19802
19694
|
...search.memoryIds !== void 0 && { memory_ids: search.memoryIds },
|
|
19803
19695
|
include_archived: search.includeArchived,
|
|
19804
19696
|
embedding_model: model,
|
|
19805
|
-
...
|
|
19697
|
+
...signal && { signal }
|
|
19806
19698
|
});
|
|
19807
19699
|
const vectors = [queryEmbedding, ...facetEmbeddings];
|
|
19808
19700
|
let windows;
|
|
19809
19701
|
if (mode === "retain") {
|
|
19810
19702
|
windows = await Promise.all(
|
|
19811
|
-
vectors.map(
|
|
19812
|
-
(embedding2, i) => persistence.candidateSet(embedding2, windowOptions(i, signal))
|
|
19813
|
-
)
|
|
19703
|
+
vectors.map((embedding2, i) => persistence.candidateSet(embedding2, windowOptions(i)))
|
|
19814
19704
|
);
|
|
19815
19705
|
} else {
|
|
19816
19706
|
const deadline = new AbortController();
|
|
@@ -19898,15 +19788,12 @@ function createRemoteMemoryPipeline(options) {
|
|
|
19898
19788
|
twin_opt_in: false
|
|
19899
19789
|
};
|
|
19900
19790
|
};
|
|
19901
|
-
const write = async (memory, snapshot) =>
|
|
19902
|
-
await assertWrite();
|
|
19903
|
-
return remember([await persistence.put(memory, snapshot, signal)])[0];
|
|
19904
|
-
};
|
|
19791
|
+
const write = async (memory, snapshot) => remember([await persistence.put(memory, snapshot)])[0];
|
|
19905
19792
|
const port = {
|
|
19906
19793
|
prepare,
|
|
19907
19794
|
get,
|
|
19908
19795
|
getFresh: async (id) => {
|
|
19909
|
-
const current = await
|
|
19796
|
+
const current = await persistence.get(id);
|
|
19910
19797
|
return current && !current.memory.is_deleted && !current.memory.superseded_by ? stored(current.memory) : null;
|
|
19911
19798
|
},
|
|
19912
19799
|
tombstones: async (embedding2, embeddingModel, scope, folderId) => {
|
|
@@ -19917,8 +19804,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
19917
19804
|
embedding_model: embeddingModel,
|
|
19918
19805
|
strict_model: true,
|
|
19919
19806
|
include_deleted: true,
|
|
19920
|
-
deleted_only: true
|
|
19921
|
-
signal
|
|
19807
|
+
deleted_only: true
|
|
19922
19808
|
});
|
|
19923
19809
|
rejectUndecryptable(window2.failed);
|
|
19924
19810
|
return remember(window2.items);
|
|
@@ -19974,18 +19860,14 @@ function createRemoteMemoryPipeline(options) {
|
|
|
19974
19860
|
if (!target || !newer || id === successor) return false;
|
|
19975
19861
|
const old = snapshots.get(id);
|
|
19976
19862
|
const next = snapshots.get(successor);
|
|
19977
|
-
await assertWrite();
|
|
19978
19863
|
remember(
|
|
19979
|
-
await persistence.putMany(
|
|
19980
|
-
|
|
19981
|
-
{
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
],
|
|
19987
|
-
signal
|
|
19988
|
-
)
|
|
19864
|
+
await persistence.putMany([
|
|
19865
|
+
{
|
|
19866
|
+
memory: { ...old.memory, superseded_by: successor, superseded_at: Date.now() },
|
|
19867
|
+
expectedVersion: old
|
|
19868
|
+
},
|
|
19869
|
+
{ memory: next.memory, expectedVersion: next }
|
|
19870
|
+
])
|
|
19989
19871
|
);
|
|
19990
19872
|
return true;
|
|
19991
19873
|
},
|
|
@@ -19994,22 +19876,18 @@ function createRemoteMemoryPipeline(options) {
|
|
|
19994
19876
|
if (!target) return { created: null, retired: false };
|
|
19995
19877
|
const snapshot = snapshots.get(targetId);
|
|
19996
19878
|
const successor = createRow(input);
|
|
19997
|
-
await assertWrite();
|
|
19998
19879
|
const rows = remember(
|
|
19999
|
-
await persistence.putMany(
|
|
20000
|
-
|
|
20001
|
-
|
|
20002
|
-
{
|
|
20003
|
-
memory
|
|
20004
|
-
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
|
|
20008
|
-
|
|
20009
|
-
|
|
20010
|
-
],
|
|
20011
|
-
signal
|
|
20012
|
-
)
|
|
19880
|
+
await persistence.putMany([
|
|
19881
|
+
{ memory: successor, expectedVersion: 0 },
|
|
19882
|
+
{
|
|
19883
|
+
memory: {
|
|
19884
|
+
...snapshot.memory,
|
|
19885
|
+
superseded_by: successor.memory_id,
|
|
19886
|
+
superseded_at: Date.now()
|
|
19887
|
+
},
|
|
19888
|
+
expectedVersion: snapshot
|
|
19889
|
+
}
|
|
19890
|
+
])
|
|
20013
19891
|
);
|
|
20014
19892
|
return { created: rows[0], retired: true };
|
|
20015
19893
|
}
|
|
@@ -20044,7 +19922,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
20044
19922
|
factSource,
|
|
20045
19923
|
recall: async (query, recallOptions = {}) => recall(query, { embeddingOptions, factSource }, { ...recallOptions, types: ["fact"] }),
|
|
20046
19924
|
retain: async (content, retainOptions) => {
|
|
20047
|
-
const { port } = operation("retain"
|
|
19925
|
+
const { port } = operation("retain");
|
|
20048
19926
|
return retainWithPersistence(
|
|
20049
19927
|
content,
|
|
20050
19928
|
{
|
|
@@ -20626,21 +20504,16 @@ function createRemoteMemoryStore(options) {
|
|
|
20626
20504
|
const record2 = await persistence.get(id);
|
|
20627
20505
|
return record2 && !record2.memory.is_deleted ? record2 : null;
|
|
20628
20506
|
};
|
|
20629
|
-
const mutateLocked = async (id, change, edit
|
|
20630
|
-
|
|
20631
|
-
const record2 = writeOptions?.signal ? await persistence.get(id, writeOptions.signal) : await live(id);
|
|
20507
|
+
const mutateLocked = async (id, change, edit) => {
|
|
20508
|
+
const record2 = await live(id);
|
|
20632
20509
|
if (!record2) return null;
|
|
20633
|
-
if (record2.memory.is_deleted) return null;
|
|
20634
|
-
if (writeOptions?.canWrite && !await writeOptions.canWrite())
|
|
20635
|
-
throw new Error("Memory source is no longer eligible");
|
|
20636
|
-
writeOptions?.signal?.throwIfAborted();
|
|
20637
20510
|
const next = edit(structuredClone(record2.memory));
|
|
20638
20511
|
if (!next) return null;
|
|
20639
|
-
const saved =
|
|
20512
|
+
const saved = await persistence.put(next, record2);
|
|
20640
20513
|
notify(typeof change === "function" ? change(record2.memory) : change, [saved]);
|
|
20641
20514
|
return saved;
|
|
20642
20515
|
};
|
|
20643
|
-
const mutate = (id, change, edit
|
|
20516
|
+
const mutate = (id, change, edit) => serialized(id, () => mutateLocked(id, change, edit));
|
|
20644
20517
|
const serializedAll = (ids, task) => [...new Set(ids)].sort().reduceRight((inner, id) => () => serialized(id, inner), task)();
|
|
20645
20518
|
const mutateMany = async (ids, change, edit) => {
|
|
20646
20519
|
const saved = /* @__PURE__ */ new Map();
|
|
@@ -21153,21 +21026,13 @@ function createRemoteMemoryStore(options) {
|
|
|
21153
21026
|
}))
|
|
21154
21027
|
);
|
|
21155
21028
|
},
|
|
21156
|
-
addTopics: async (memoryId, topics
|
|
21029
|
+
addTopics: async (memoryId, topics) => {
|
|
21157
21030
|
const added = await withKnownKinds(topicInputs(topics, "auto"));
|
|
21158
|
-
const saved = await mutate(
|
|
21159
|
-
|
|
21160
|
-
|
|
21161
|
-
(
|
|
21162
|
-
|
|
21163
|
-
return {
|
|
21164
|
-
...memory,
|
|
21165
|
-
topics: serializeTopics(mergeTopics(parseTopics(memory.topics) ?? [], added)),
|
|
21166
|
-
topics_updated_at: Date.now()
|
|
21167
|
-
};
|
|
21168
|
-
},
|
|
21169
|
-
writeOptions
|
|
21170
|
-
);
|
|
21031
|
+
const saved = await mutate(memoryId, "edit", (memory) => ({
|
|
21032
|
+
...memory,
|
|
21033
|
+
topics: serializeTopics(mergeTopics(parseTopics(memory.topics) ?? [], added)),
|
|
21034
|
+
topics_updated_at: Date.now()
|
|
21035
|
+
}));
|
|
21171
21036
|
if (!saved) return [];
|
|
21172
21037
|
const now = /* @__PURE__ */ new Date();
|
|
21173
21038
|
return mergeTopics([], added).map(
|
|
@@ -22018,7 +21883,6 @@ function createDurableAutoExtractor(options) {
|
|
|
22018
21883
|
};
|
|
22019
21884
|
const folderId = options.folderId ?? null;
|
|
22020
21885
|
let disposed = false;
|
|
22021
|
-
let activeBatch = null;
|
|
22022
21886
|
let running = false;
|
|
22023
21887
|
let wakeRequested = false;
|
|
22024
21888
|
let timer;
|
|
@@ -22055,18 +21919,14 @@ function createDurableAutoExtractor(options) {
|
|
|
22055
21919
|
}, delay);
|
|
22056
21920
|
}
|
|
22057
21921
|
async function extractBatch(messages, conversationId, ids, jobScope, jobFolderId) {
|
|
22058
|
-
if (disposed) throw new Error("Extraction session was disposed");
|
|
22059
21922
|
let watchdog;
|
|
22060
21923
|
let cancelled = false;
|
|
22061
|
-
const controller = new AbortController();
|
|
22062
|
-
activeBatch = controller;
|
|
22063
21924
|
const model = options.modelForScope?.(jobScope) ?? options.extract.model;
|
|
22064
21925
|
try {
|
|
22065
21926
|
return await Promise.race([
|
|
22066
21927
|
new Promise((resolve, reject) => {
|
|
22067
21928
|
const worker = createAutoExtractor({
|
|
22068
21929
|
...options,
|
|
22069
|
-
signal: controller.signal,
|
|
22070
21930
|
retainCtx: {
|
|
22071
21931
|
...options.retainCtx,
|
|
22072
21932
|
vaultCtx: {
|
|
@@ -22095,8 +21955,6 @@ function createDurableAutoExtractor(options) {
|
|
|
22095
21955
|
]);
|
|
22096
21956
|
} finally {
|
|
22097
21957
|
cancelled = true;
|
|
22098
|
-
controller.abort();
|
|
22099
|
-
if (activeBatch === controller) activeBatch = null;
|
|
22100
21958
|
if (watchdog !== void 0) clearTimeout(watchdog);
|
|
22101
21959
|
}
|
|
22102
21960
|
}
|
|
@@ -22108,7 +21966,6 @@ function createDurableAutoExtractor(options) {
|
|
|
22108
21966
|
for (const message of loaded)
|
|
22109
21967
|
if (message && message.messageId > 0) sequences.set(message.uniqueId, message.messageId);
|
|
22110
21968
|
await database.write(async () => {
|
|
22111
|
-
if (disposed) return;
|
|
22112
21969
|
const current = idsOf(job);
|
|
22113
21970
|
const acknowledged = ids.filter((id) => current.includes(id));
|
|
22114
21971
|
if (!acknowledged.length) return;
|
|
@@ -22281,7 +22138,6 @@ function createDurableAutoExtractor(options) {
|
|
|
22281
22138
|
jobScope,
|
|
22282
22139
|
jobFolderId
|
|
22283
22140
|
);
|
|
22284
|
-
if (disposed) throw new Error("Extraction session was disposed");
|
|
22285
22141
|
options.onTurnComplete?.(result);
|
|
22286
22142
|
return result;
|
|
22287
22143
|
};
|
|
@@ -22318,7 +22174,6 @@ function createDurableAutoExtractor(options) {
|
|
|
22318
22174
|
);
|
|
22319
22175
|
scheduleAfterSuccess = true;
|
|
22320
22176
|
} catch (error) {
|
|
22321
|
-
if (disposed) break;
|
|
22322
22177
|
attempts.set(job.id, attempted + 1);
|
|
22323
22178
|
retry = true;
|
|
22324
22179
|
reportError(error, conversationId);
|
|
@@ -22341,14 +22196,6 @@ function createDurableAutoExtractor(options) {
|
|
|
22341
22196
|
schedule(retry ? options.retryDelayMs ?? 3e4 : 0);
|
|
22342
22197
|
}
|
|
22343
22198
|
}
|
|
22344
|
-
function dispose() {
|
|
22345
|
-
disposed = true;
|
|
22346
|
-
activeBatch?.abort(options.signal?.reason);
|
|
22347
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
22348
|
-
options.signal?.removeEventListener("abort", dispose);
|
|
22349
|
-
}
|
|
22350
|
-
if (options.signal?.aborted) dispose();
|
|
22351
|
-
else options.signal?.addEventListener("abort", dispose, { once: true });
|
|
22352
22199
|
schedule(0);
|
|
22353
22200
|
return {
|
|
22354
22201
|
processTurn(messages, conversationId) {
|
|
@@ -22428,7 +22275,10 @@ function createDurableAutoExtractor(options) {
|
|
|
22428
22275
|
return true;
|
|
22429
22276
|
},
|
|
22430
22277
|
isProcessing: () => running,
|
|
22431
|
-
dispose
|
|
22278
|
+
dispose() {
|
|
22279
|
+
disposed = true;
|
|
22280
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
22281
|
+
}
|
|
22432
22282
|
};
|
|
22433
22283
|
}
|
|
22434
22284
|
|
|
@@ -25677,7 +25527,6 @@ var CONVERSATION_REDACTOR_LIMIT = 50;
|
|
|
25677
25527
|
var NO_CONVERSATION_KEY = "__no_conversation__";
|
|
25678
25528
|
var NO_STORE_FOLDERS = "Folders are not supported with a memoryStore";
|
|
25679
25529
|
var NO_STORE_MASK = "piiRedaction needs a memoryStore built with embeddingOptions.maskInput";
|
|
25680
|
-
var MEMORY_STORE_NOT_READY = "Memory store is not ready";
|
|
25681
25530
|
var conversationRedactors = /* @__PURE__ */ new Map();
|
|
25682
25531
|
var clientToolFilterCache = /* @__PURE__ */ new Map();
|
|
25683
25532
|
function getConversationRedactor(conversationId, nerDetector) {
|
|
@@ -25822,7 +25671,7 @@ function useChatStorage(options) {
|
|
|
25822
25671
|
[resolvedPiiRedaction]
|
|
25823
25672
|
);
|
|
25824
25673
|
const maskEmbeddingInput = isPiiRedactor(resolvedPiiRedaction) ? maskForEmbedding : void 0;
|
|
25825
|
-
const storeMaskMissing = memoryStore !== void 0 &&
|
|
25674
|
+
const storeMaskMissing = memoryStore !== void 0 && maskEmbeddingInput !== void 0 && !memoryStore.masksEmbeddingInput;
|
|
25826
25675
|
const messagesCollection = useMemo(() => database.get("history"), [database]);
|
|
25827
25676
|
const conversationsCollection = useMemo(
|
|
25828
25677
|
() => database.get("conversations"),
|
|
@@ -26071,7 +25920,6 @@ function useChatStorage(options) {
|
|
|
26071
25920
|
}, [vaultEmbeddingCache]);
|
|
26072
25921
|
const retainVaultMemory = useCallback4(
|
|
26073
25922
|
async (input) => {
|
|
26074
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
26075
25923
|
if (memoryStore) {
|
|
26076
25924
|
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
26077
25925
|
if (input.folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
|
|
@@ -26117,7 +25965,6 @@ function useChatStorage(options) {
|
|
|
26117
25965
|
);
|
|
26118
25966
|
const createMemoryVaultTool2 = useCallback4(
|
|
26119
25967
|
(options2) => {
|
|
26120
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
26121
25968
|
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
26122
25969
|
return createMemoryVaultTool(
|
|
26123
25970
|
memoryStore ?? vaultCtx,
|
|
@@ -26128,7 +25975,6 @@ function useChatStorage(options) {
|
|
|
26128
25975
|
);
|
|
26129
25976
|
const createRecallTool2 = useCallback4(
|
|
26130
25977
|
(toolOptions, callbacks) => {
|
|
26131
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
26132
25978
|
if (!getToken && !memoryStore) {
|
|
26133
25979
|
throw new Error("getToken is required for recall tool");
|
|
26134
25980
|
}
|
|
@@ -26174,7 +26020,7 @@ function useChatStorage(options) {
|
|
|
26174
26020
|
);
|
|
26175
26021
|
const recallFn = useCallback4(
|
|
26176
26022
|
async (query, options2) => {
|
|
26177
|
-
if (
|
|
26023
|
+
if (!getToken && !memoryStore) {
|
|
26178
26024
|
return {
|
|
26179
26025
|
memories: [],
|
|
26180
26026
|
usedBudget: options2?.budget ?? "low",
|
|
@@ -26223,7 +26069,6 @@ function useChatStorage(options) {
|
|
|
26223
26069
|
);
|
|
26224
26070
|
const getVaultMemories = useCallback4(
|
|
26225
26071
|
(options2) => {
|
|
26226
|
-
if (memoryStore === null) return Promise.resolve([]);
|
|
26227
26072
|
if (!memoryStore) return getAllVaultMemoriesOp(vaultCtx, options2);
|
|
26228
26073
|
const { folderId, levels, kinds, ...listOptions } = options2 ?? {};
|
|
26229
26074
|
if (folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
|
|
@@ -26234,8 +26079,7 @@ function useChatStorage(options) {
|
|
|
26234
26079
|
[vaultCtx, memoryStore]
|
|
26235
26080
|
);
|
|
26236
26081
|
const deleteVaultMemory = useCallback4(
|
|
26237
|
-
|
|
26238
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
26082
|
+
(id) => {
|
|
26239
26083
|
return memoryStore ? memoryStore.delete(id) : deleteVaultMemoryOp(vaultCtx, id);
|
|
26240
26084
|
},
|
|
26241
26085
|
[vaultCtx, memoryStore]
|