@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.cjs
CHANGED
|
@@ -12722,11 +12722,6 @@ init_logger();
|
|
|
12722
12722
|
|
|
12723
12723
|
// src/lib/db/entities/operations.ts
|
|
12724
12724
|
var import_watermelondb19 = require("@nozbe/watermelondb");
|
|
12725
|
-
async function assertCanWrite(ctx) {
|
|
12726
|
-
if (ctx.canWrite && !await ctx.canWrite()) {
|
|
12727
|
-
throw new Error("Memory source is no longer eligible");
|
|
12728
|
-
}
|
|
12729
|
-
}
|
|
12730
12725
|
function entityToStored(e) {
|
|
12731
12726
|
return {
|
|
12732
12727
|
uniqueId: e.id,
|
|
@@ -12867,7 +12862,6 @@ async function linkMemoryEntitiesOp(ctx, memoryId, entityInputs, options) {
|
|
|
12867
12862
|
let skipped = false;
|
|
12868
12863
|
let entities = [];
|
|
12869
12864
|
await ctx.database.write(async () => {
|
|
12870
|
-
await assertCanWrite(ctx);
|
|
12871
12865
|
const {
|
|
12872
12866
|
entities: byName,
|
|
12873
12867
|
operations: entityOps,
|
|
@@ -12943,7 +12937,6 @@ async function replaceMemoryEntities(ctx, memoryId, entityInputs, options) {
|
|
|
12943
12937
|
let skipped = false;
|
|
12944
12938
|
let entities = [];
|
|
12945
12939
|
await ctx.database.write(async () => {
|
|
12946
|
-
await assertCanWrite(ctx);
|
|
12947
12940
|
const vaultRow = await findVaultRowInWrite(ctx, memoryId);
|
|
12948
12941
|
if (options.guarded && autoLinkBlocked(vaultRow)) {
|
|
12949
12942
|
skipped = true;
|
|
@@ -13004,7 +12997,6 @@ async function unlinkMemoryEntitiesOp(ctx, memoryIds) {
|
|
|
13004
12997
|
const links = await ctx.memoryEntityCollection.query(import_watermelondb19.Q.where("memory_id", import_watermelondb19.Q.oneOf(Array.from(memoryIds)))).fetch();
|
|
13005
12998
|
if (links.length === 0) return;
|
|
13006
12999
|
await ctx.database.write(async () => {
|
|
13007
|
-
await assertCanWrite(ctx);
|
|
13008
13000
|
await ctx.database.batch(...links.map((l) => l.prepareDestroyPermanently()));
|
|
13009
13001
|
});
|
|
13010
13002
|
}
|
|
@@ -13013,7 +13005,6 @@ async function unlinkAllMemoryEntitiesForUserOp(ctx, userId) {
|
|
|
13013
13005
|
const links = await ctx.memoryEntityCollection.query(import_watermelondb19.Q.where("user_id", userId)).fetch();
|
|
13014
13006
|
if (links.length === 0) return;
|
|
13015
13007
|
await ctx.database.write(async () => {
|
|
13016
|
-
await assertCanWrite(ctx);
|
|
13017
13008
|
await ctx.database.batch(...links.map((l) => l.prepareDestroyPermanently()));
|
|
13018
13009
|
});
|
|
13019
13010
|
}
|
|
@@ -13178,11 +13169,6 @@ function visibilityConditions(requested) {
|
|
|
13178
13169
|
function isKinded(record2) {
|
|
13179
13170
|
return record2.kind !== null && record2.kind !== void 0;
|
|
13180
13171
|
}
|
|
13181
|
-
async function assertCanWrite2(ctx) {
|
|
13182
|
-
if (ctx.canWrite && !await ctx.canWrite()) {
|
|
13183
|
-
throw new Error("Memory source is no longer eligible");
|
|
13184
|
-
}
|
|
13185
|
-
}
|
|
13186
13172
|
function assertValidKindLevel(kind, level) {
|
|
13187
13173
|
const hasKind = kind !== null && kind !== void 0;
|
|
13188
13174
|
if (hasKind && !MEMORY_KINDS.includes(kind)) {
|
|
@@ -13363,7 +13349,8 @@ async function createVaultMemoryOp(ctx, opts) {
|
|
|
13363
13349
|
ctx.embeddedWalletSigner
|
|
13364
13350
|
) : opts.content;
|
|
13365
13351
|
const created = await ctx.database.write(async () => {
|
|
13366
|
-
await
|
|
13352
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
13353
|
+
throw new Error("Memory source is no longer eligible");
|
|
13367
13354
|
return ctx.vaultMemoryCollection.create(
|
|
13368
13355
|
(record2) => populateNewVaultMemory(record2, ctx, opts, encryptedContent, encryptedKindValue)
|
|
13369
13356
|
);
|
|
@@ -13382,7 +13369,8 @@ async function createSupersedingMemoryOp(ctx, opts, targetId) {
|
|
|
13382
13369
|
) : opts.content;
|
|
13383
13370
|
let createdRecord = null;
|
|
13384
13371
|
await ctx.database.write(async () => {
|
|
13385
|
-
await
|
|
13372
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
13373
|
+
throw new Error("Memory source is no longer eligible");
|
|
13386
13374
|
let target;
|
|
13387
13375
|
try {
|
|
13388
13376
|
target = await ctx.vaultMemoryCollection.find(targetId);
|
|
@@ -13474,7 +13462,8 @@ async function createVaultMemoriesBatchOp(ctx, optionsArray) {
|
|
|
13474
13462
|
})
|
|
13475
13463
|
);
|
|
13476
13464
|
const created = await ctx.database.write(async () => {
|
|
13477
|
-
await
|
|
13465
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
13466
|
+
throw new Error("Memory source is no longer eligible");
|
|
13478
13467
|
const prepared = optionsArray.map(
|
|
13479
13468
|
(opts, i) => ctx.vaultMemoryCollection.prepareCreate(
|
|
13480
13469
|
(record2) => populateNewVaultMemory(record2, ctx, opts, encryptedContents[i], encryptedKindValues[i])
|
|
@@ -13779,7 +13768,8 @@ async function updateVaultMemoryOp(ctx, id, opts) {
|
|
|
13779
13768
|
const record2 = probe;
|
|
13780
13769
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
13781
13770
|
await ctx.database.write(async () => {
|
|
13782
|
-
await
|
|
13771
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
13772
|
+
throw new Error("Memory source is no longer eligible");
|
|
13783
13773
|
if (record2.isDeleted || record2.supersededBy || !isOwnedByCtxUser(ctx, record2) || opts.freeFormOnly && isKinded(record2)) {
|
|
13784
13774
|
stale = true;
|
|
13785
13775
|
return;
|
|
@@ -13890,7 +13880,6 @@ async function setMemoryEntitiesOp(ctx, memoryId, entities) {
|
|
|
13890
13880
|
let stale = false;
|
|
13891
13881
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
13892
13882
|
await ctx.database.write(async (writer) => {
|
|
13893
|
-
await assertCanWrite2(ctx);
|
|
13894
13883
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
13895
13884
|
stale = true;
|
|
13896
13885
|
return;
|
|
@@ -13932,7 +13921,6 @@ async function clearMemoryTopicsOverrideOp(ctx, memoryId, options) {
|
|
|
13932
13921
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
13933
13922
|
let cleared = false;
|
|
13934
13923
|
await ctx.database.write(async () => {
|
|
13935
|
-
await assertCanWrite2(ctx);
|
|
13936
13924
|
if (options?.unlessTopicsRecorded && parseTopics(record2.topics) !== null) return;
|
|
13937
13925
|
cleared = true;
|
|
13938
13926
|
await record2.update((r) => {
|
|
@@ -13956,7 +13944,6 @@ async function setMemoryVisibilityOp(ctx, id, opts) {
|
|
|
13956
13944
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return null;
|
|
13957
13945
|
let stale = false;
|
|
13958
13946
|
await ctx.database.write(async () => {
|
|
13959
|
-
await assertCanWrite2(ctx);
|
|
13960
13947
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
13961
13948
|
stale = true;
|
|
13962
13949
|
return;
|
|
@@ -13985,7 +13972,6 @@ async function deleteVaultMemoryOp(ctx, id) {
|
|
|
13985
13972
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return false;
|
|
13986
13973
|
let stale = false;
|
|
13987
13974
|
await ctx.database.write(async () => {
|
|
13988
|
-
await assertCanWrite2(ctx);
|
|
13989
13975
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
13990
13976
|
stale = true;
|
|
13991
13977
|
return;
|
|
@@ -14023,7 +14009,8 @@ async function supersedeVaultMemoryOp(ctx, id, supersededById) {
|
|
|
14023
14009
|
}
|
|
14024
14010
|
let stale = false;
|
|
14025
14011
|
await ctx.database.write(async () => {
|
|
14026
|
-
await
|
|
14012
|
+
if (ctx.canWrite && !await ctx.canWrite())
|
|
14013
|
+
throw new Error("Memory source is no longer eligible");
|
|
14027
14014
|
if (record2.isDeleted || record2.supersededBy || !isOwnedByCtxUser(ctx, record2)) {
|
|
14028
14015
|
stale = true;
|
|
14029
14016
|
return;
|
|
@@ -14185,7 +14172,6 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
|
|
|
14185
14172
|
for (let i = 0; i < uniqueIds.length; i += CHUNK) {
|
|
14186
14173
|
const chunkIds = uniqueIds.slice(i, i + CHUNK);
|
|
14187
14174
|
await ctx.database.write(async () => {
|
|
14188
|
-
await assertCanWrite2(ctx);
|
|
14189
14175
|
const records = [];
|
|
14190
14176
|
for (const id of chunkIds) {
|
|
14191
14177
|
try {
|
|
@@ -14219,7 +14205,6 @@ async function relinkMemoryTopicsOp(ctx, memoryIds) {
|
|
|
14219
14205
|
for (const id of Array.from(new Set(memoryIds))) {
|
|
14220
14206
|
try {
|
|
14221
14207
|
await ctx.database.write(async (writer) => {
|
|
14222
|
-
await assertCanWrite2(ctx);
|
|
14223
14208
|
let record2;
|
|
14224
14209
|
try {
|
|
14225
14210
|
record2 = await ctx.vaultMemoryCollection.find(id);
|
|
@@ -14250,7 +14235,6 @@ async function backfillMemoryTopicsOp(ctx, memoryIds) {
|
|
|
14250
14235
|
for (let i = 0; i < uniqueIds.length; i += CHUNK) {
|
|
14251
14236
|
const chunkIds = uniqueIds.slice(i, i + CHUNK);
|
|
14252
14237
|
await ctx.database.write(async () => {
|
|
14253
|
-
await assertCanWrite2(ctx);
|
|
14254
14238
|
const writes = [];
|
|
14255
14239
|
for (const id of chunkIds) {
|
|
14256
14240
|
let record2;
|
|
@@ -14283,7 +14267,6 @@ async function deleteAllVaultMemoriesForUserOp(ctx, userId) {
|
|
|
14283
14267
|
const records = await ctx.vaultMemoryCollection.query(import_watermelondb20.Q.where("user_id", userId), import_watermelondb20.Q.where("is_deleted", false)).fetch();
|
|
14284
14268
|
if (records.length === 0) return 0;
|
|
14285
14269
|
await ctx.database.write(async () => {
|
|
14286
|
-
await assertCanWrite2(ctx);
|
|
14287
14270
|
const prepared = records.map(
|
|
14288
14271
|
(record2) => record2.prepareUpdate((r) => {
|
|
14289
14272
|
r._setRaw("is_deleted", true);
|
|
@@ -14338,7 +14321,6 @@ async function archiveVaultMemoryOp(ctx, id, opts) {
|
|
|
14338
14321
|
let stale = false;
|
|
14339
14322
|
const archivedAtValue = opts?.now ?? Date.now();
|
|
14340
14323
|
await ctx.database.write(async () => {
|
|
14341
|
-
await assertCanWrite2(ctx);
|
|
14342
14324
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2) || record2.archivedAt !== null) {
|
|
14343
14325
|
stale = true;
|
|
14344
14326
|
return;
|
|
@@ -14362,7 +14344,6 @@ async function restoreVaultMemoryOp(ctx, id) {
|
|
|
14362
14344
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return false;
|
|
14363
14345
|
let stale = false;
|
|
14364
14346
|
await ctx.database.write(async () => {
|
|
14365
|
-
await assertCanWrite2(ctx);
|
|
14366
14347
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) {
|
|
14367
14348
|
stale = true;
|
|
14368
14349
|
return;
|
|
@@ -14383,7 +14364,6 @@ async function hardDeleteDecayedOp(ctx, id, opts) {
|
|
|
14383
14364
|
const now = opts.now ?? Date.now();
|
|
14384
14365
|
let stale = false;
|
|
14385
14366
|
await ctx.database.write(async () => {
|
|
14386
|
-
await assertCanWrite2(ctx);
|
|
14387
14367
|
const archivedAt = record2.archivedAt;
|
|
14388
14368
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2) || archivedAt === null || now - archivedAt <= opts.hardDeleteWindowMs) {
|
|
14389
14369
|
stale = true;
|
|
@@ -14423,7 +14403,6 @@ async function updateVaultMemoryEmbeddingOp(ctx, id, embedding2, embeddingModel,
|
|
|
14423
14403
|
}
|
|
14424
14404
|
let written = false;
|
|
14425
14405
|
await ctx.database.write(async () => {
|
|
14426
|
-
await assertCanWrite2(ctx);
|
|
14427
14406
|
if (record2.isDeleted || !isOwnedByCtxUser(ctx, record2)) return;
|
|
14428
14407
|
const originalUpdatedAt = record2.updatedAt.getTime();
|
|
14429
14408
|
if (originalUpdatedAt !== readUpdatedAt || record2._getRaw("content") !== readStoredContent)
|
|
@@ -17960,13 +17939,6 @@ function restoreCandidates(candidates, redactor, ownNames) {
|
|
|
17960
17939
|
).map((c) => c.candidate);
|
|
17961
17940
|
}
|
|
17962
17941
|
async function extractAndRetain(messages, retainCtx, options) {
|
|
17963
|
-
const { memoryStore, signal } = options;
|
|
17964
|
-
if (memoryStore === null) throw new Error("Memory store is not ready");
|
|
17965
|
-
if (memoryStore && options.folderId !== void 0 && options.folderId !== null)
|
|
17966
|
-
throw new Error("Remote memory extraction does not support folders");
|
|
17967
|
-
if (memoryStore && options.extract.piiRedaction && !memoryStore.masksEmbeddingInput)
|
|
17968
|
-
throw new Error("PII-redacted extraction requires a memory store that masks embedding inputs");
|
|
17969
|
-
signal?.throwIfAborted();
|
|
17970
17942
|
const minConfidence = options.minConfidence ?? DEFAULT_MIN_CONFIDENCE;
|
|
17971
17943
|
const resolvedConsolidatePii = options.consolidateOptions?.piiRedaction ?? options.extract.piiRedaction;
|
|
17972
17944
|
const consolidateOptions = options.consolidateOptions !== void 0 ? {
|
|
@@ -18000,7 +17972,6 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
18000
17972
|
}
|
|
18001
17973
|
});
|
|
18002
17974
|
const extractMs = Date.now() - tExtract;
|
|
18003
|
-
signal?.throwIfAborted();
|
|
18004
17975
|
const filtered = candidates.filter((c) => c.confidence >= minConfidence);
|
|
18005
17976
|
const log = getLogger();
|
|
18006
17977
|
const screened = screenCandidatesForInjection(filtered);
|
|
@@ -18048,33 +18019,16 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
18048
18019
|
const results = [];
|
|
18049
18020
|
const quarantinedInfo = [];
|
|
18050
18021
|
let failedWrites = 0;
|
|
18051
|
-
let auditRows;
|
|
18052
18022
|
const tRetain = Date.now();
|
|
18053
18023
|
for (const { candidate, isQuarantined, reason, signature } of toRetain) {
|
|
18054
18024
|
try {
|
|
18055
|
-
signal?.throwIfAborted();
|
|
18056
18025
|
if (isQuarantined) {
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18060
|
-
|
|
18061
|
-
|
|
18062
|
-
|
|
18063
|
-
includeSuperseded: true
|
|
18064
|
-
}));
|
|
18065
|
-
const sourceKey = [...new Set(candidate.sourceMessageIds)].sort().join("\0");
|
|
18066
|
-
const normalize = (value) => value.normalize("NFKC").trim().replace(/\s+/g, " ").toLowerCase();
|
|
18067
|
-
existingId = (await auditRows).find(
|
|
18068
|
-
(row) => row.trustTier === "quarantined" && row.scope === (options.scope ?? "private") && [...new Set(row.sourceChunkIds ?? [])].sort().join("\0") === sourceKey && normalize(row.content) === normalize(candidate.content)
|
|
18069
|
-
)?.uniqueId ?? null;
|
|
18070
|
-
} else {
|
|
18071
|
-
existingId = await findQuarantinedDuplicateOp(
|
|
18072
|
-
retainCtx.vaultCtx,
|
|
18073
|
-
candidate.content,
|
|
18074
|
-
candidate.sourceMessageIds,
|
|
18075
|
-
{ scope: options.scope ?? "private", folderId: options.folderId ?? null }
|
|
18076
|
-
).catch(() => null);
|
|
18077
|
-
}
|
|
18026
|
+
const existingId = await findQuarantinedDuplicateOp(
|
|
18027
|
+
retainCtx.vaultCtx,
|
|
18028
|
+
candidate.content,
|
|
18029
|
+
candidate.sourceMessageIds,
|
|
18030
|
+
{ scope: options.scope ?? "private", folderId: options.folderId ?? null }
|
|
18031
|
+
).catch(() => null);
|
|
18078
18032
|
if (existingId) {
|
|
18079
18033
|
quarantinedInfo.push({
|
|
18080
18034
|
candidate,
|
|
@@ -18085,26 +18039,18 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
18085
18039
|
continue;
|
|
18086
18040
|
}
|
|
18087
18041
|
}
|
|
18088
|
-
const
|
|
18042
|
+
const result = await retain(candidate.content, retainCtx, {
|
|
18089
18043
|
source: "auto-extracted",
|
|
18090
18044
|
sourceChunkIds: candidate.sourceMessageIds,
|
|
18091
18045
|
respectTombstones: true,
|
|
18092
18046
|
...options.scope !== void 0 && { scope: options.scope },
|
|
18047
|
+
...options.folderId !== void 0 && { folderId: options.folderId },
|
|
18093
18048
|
...consolidateOptions !== void 0 && { consolidateOptions },
|
|
18094
18049
|
...candidate.eventTime !== null && { eventTime: candidate.eventTime },
|
|
18095
18050
|
factType: candidate.type,
|
|
18096
18051
|
...isQuarantined && { trustTier: "quarantined", enableAutoMerge: false }
|
|
18097
|
-
};
|
|
18098
|
-
const result = memoryStore ? await memoryStore.retain(candidate.content, {
|
|
18099
|
-
...retainOptions,
|
|
18100
|
-
canWrite: retainCtx.vaultCtx.canWrite,
|
|
18101
|
-
signal
|
|
18102
|
-
}) : await retain(candidate.content, retainCtx, {
|
|
18103
|
-
...retainOptions,
|
|
18104
|
-
...options.folderId !== void 0 && { folderId: options.folderId }
|
|
18105
18052
|
});
|
|
18106
18053
|
if (isQuarantined) {
|
|
18107
|
-
auditRows = void 0;
|
|
18108
18054
|
const info = {
|
|
18109
18055
|
candidate,
|
|
18110
18056
|
memoryId: result.memoryId,
|
|
@@ -18123,16 +18069,9 @@ async function extractAndRetain(messages, retainCtx, options) {
|
|
|
18123
18069
|
}
|
|
18124
18070
|
succeededCandidates.push(candidate);
|
|
18125
18071
|
results.push(result);
|
|
18126
|
-
if (result.action !== "suppressed" && candidate.entities.length > 0) {
|
|
18072
|
+
if (result.action !== "suppressed" && options.entityCtx && candidate.entities.length > 0) {
|
|
18127
18073
|
try {
|
|
18128
|
-
|
|
18129
|
-
if (memoryStore) {
|
|
18130
|
-
await memoryStore.addTopics(result.memoryId, candidate.entities, {
|
|
18131
|
-
unlessUserManaged: true,
|
|
18132
|
-
canWrite: retainCtx.vaultCtx.canWrite,
|
|
18133
|
-
signal
|
|
18134
|
-
});
|
|
18135
|
-
} else if (options.entityCtx && !await isMemoryTopicsUserManaged(options.entityCtx, result.memoryId)) {
|
|
18074
|
+
if (!await isMemoryTopicsUserManaged(options.entityCtx, result.memoryId)) {
|
|
18136
18075
|
await linkMemoryEntitiesOp(options.entityCtx, result.memoryId, candidate.entities, {
|
|
18137
18076
|
unlessTopicsUserManaged: true
|
|
18138
18077
|
});
|
|
@@ -18382,7 +18321,7 @@ function createAutoExtractor(options) {
|
|
|
18382
18321
|
};
|
|
18383
18322
|
const consolidateOptions = options.consolidate ? { ...options.consolidate, ...subPassAuth(options.consolidate.baseUrl) } : void 0;
|
|
18384
18323
|
const injectionClassifierOptions = options.injectionClassifier ? { ...options.injectionClassifier, ...subPassAuth(options.injectionClassifier.baseUrl) } : void 0;
|
|
18385
|
-
if (
|
|
18324
|
+
if (options.retainCtx.vaultCtx.entityCtx && !options.entityCtx) {
|
|
18386
18325
|
getLogger().warn(
|
|
18387
18326
|
"[memory/extract] retainCtx.vaultCtx.entityCtx is set but extractor was created without `entityCtx` \u2014 W5 graph lane will receive no writes"
|
|
18388
18327
|
);
|
|
@@ -18427,8 +18366,6 @@ function createAutoExtractor(options) {
|
|
|
18427
18366
|
try {
|
|
18428
18367
|
const { candidates, results, failedCount, outcome: outcome2, failure, funnel, timings, model } = await extractAndRetain(window2, retainCtx, {
|
|
18429
18368
|
extract,
|
|
18430
|
-
memoryStore: options.memoryStore,
|
|
18431
|
-
signal: options.signal,
|
|
18432
18369
|
...options.minConfidence !== void 0 && { minConfidence: options.minConfidence },
|
|
18433
18370
|
...options.entityCtx !== void 0 && { entityCtx: options.entityCtx },
|
|
18434
18371
|
...options.scope !== void 0 && { scope: options.scope },
|
|
@@ -20534,7 +20471,6 @@ function createLocalMemoryStore(options) {
|
|
|
20534
20471
|
database,
|
|
20535
20472
|
entityCollection: database.get("entity"),
|
|
20536
20473
|
memoryEntityCollection: database.get("memory_entity"),
|
|
20537
|
-
canWrite: options.canWrite,
|
|
20538
20474
|
...userId !== void 0 && { userId },
|
|
20539
20475
|
...options.allowUnscopedRows !== void 0 && {
|
|
20540
20476
|
allowUnscopedRows: options.allowUnscopedRows
|
|
@@ -20546,21 +20482,10 @@ function createLocalMemoryStore(options) {
|
|
|
20546
20482
|
walletAddress: options.walletAddress,
|
|
20547
20483
|
signMessage: options.signMessage,
|
|
20548
20484
|
embeddedWalletSigner: options.embeddedWalletSigner,
|
|
20549
|
-
canWrite: options.canWrite,
|
|
20550
20485
|
...userId !== void 0 && { userId },
|
|
20551
20486
|
...options.singleTenant !== void 0 && { singleTenant: options.singleTenant },
|
|
20552
20487
|
entityCtx
|
|
20553
20488
|
};
|
|
20554
|
-
const assertWrite = async (writeOptions) => {
|
|
20555
|
-
writeOptions?.signal?.throwIfAborted();
|
|
20556
|
-
if (writeOptions?.canWrite && !await writeOptions.canWrite()) {
|
|
20557
|
-
throw new Error("Memory source is no longer eligible");
|
|
20558
|
-
}
|
|
20559
|
-
if (options.canWrite && !await options.canWrite()) {
|
|
20560
|
-
throw new Error("Memory source is no longer eligible");
|
|
20561
|
-
}
|
|
20562
|
-
writeOptions?.signal?.throwIfAborted();
|
|
20563
|
-
};
|
|
20564
20489
|
const vaultCache = options.vaultCache ?? createVaultEmbeddingCache();
|
|
20565
20490
|
const ownedBy = userId !== void 0 ? [import_watermelondb23.Q.where("user_id", userId)] : [];
|
|
20566
20491
|
const linksOwnedBy = userId === void 0 ? [] : options.allowUnscopedRows ? [import_watermelondb23.Q.or(import_watermelondb23.Q.where("user_id", userId), import_watermelondb23.Q.where("user_id", null))] : [import_watermelondb23.Q.where("user_id", userId)];
|
|
@@ -20672,25 +20597,9 @@ function createLocalMemoryStore(options) {
|
|
|
20672
20597
|
archive: (id) => archiveVaultMemoryOp(vaultCtx, id),
|
|
20673
20598
|
restore: (id) => restoreVaultMemoryOp(vaultCtx, id),
|
|
20674
20599
|
setTopics: (memoryId, topics) => setMemoryEntitiesOp(vaultCtx, memoryId, topics),
|
|
20675
|
-
addTopics: (memoryId, topics
|
|
20676
|
-
await assertWrite(writeOptions);
|
|
20600
|
+
addTopics: (memoryId, topics) => database.write(async (writer) => {
|
|
20677
20601
|
const owned = await vaultCtx.vaultMemoryCollection.query(import_watermelondb23.Q.where("id", memoryId), import_watermelondb23.Q.where("is_deleted", false), ...ownedBy).fetchCount();
|
|
20678
|
-
return owned > 0 ? writer.callWriter(
|
|
20679
|
-
() => linkMemoryEntitiesOp(
|
|
20680
|
-
{
|
|
20681
|
-
...entityCtx,
|
|
20682
|
-
canWrite: async () => {
|
|
20683
|
-
await assertWrite(writeOptions);
|
|
20684
|
-
return true;
|
|
20685
|
-
}
|
|
20686
|
-
},
|
|
20687
|
-
memoryId,
|
|
20688
|
-
topics,
|
|
20689
|
-
{
|
|
20690
|
-
unlessTopicsUserManaged: writeOptions?.unlessUserManaged
|
|
20691
|
-
}
|
|
20692
|
-
)
|
|
20693
|
-
) : [];
|
|
20602
|
+
return owned > 0 ? writer.callWriter(() => linkMemoryEntitiesOp(entityCtx, memoryId, topics)) : [];
|
|
20694
20603
|
}),
|
|
20695
20604
|
setVisibility: (id, visibility, visibilityOptions) => setMemoryVisibilityOp(vaultCtx, id, { visibility, ...visibilityOptions }),
|
|
20696
20605
|
recall: (query, recallOptions) => recall(
|
|
@@ -20700,17 +20609,7 @@ function createLocalMemoryStore(options) {
|
|
|
20700
20609
|
),
|
|
20701
20610
|
retain: (content, retainOptions) => retain(
|
|
20702
20611
|
content,
|
|
20703
|
-
{
|
|
20704
|
-
vaultCtx: {
|
|
20705
|
-
...vaultCtx,
|
|
20706
|
-
canWrite: async () => {
|
|
20707
|
-
await assertWrite(retainOptions);
|
|
20708
|
-
return true;
|
|
20709
|
-
}
|
|
20710
|
-
},
|
|
20711
|
-
embeddingOptions: options.embeddingOptions,
|
|
20712
|
-
vaultCache
|
|
20713
|
-
},
|
|
20612
|
+
{ vaultCtx, embeddingOptions: options.embeddingOptions, vaultCache },
|
|
20714
20613
|
retainOptions
|
|
20715
20614
|
),
|
|
20716
20615
|
factSource: {
|
|
@@ -21358,14 +21257,7 @@ function stored(row) {
|
|
|
21358
21257
|
function createRemoteMemoryPipeline(options) {
|
|
21359
21258
|
const { persistence, embeddingOptions } = options;
|
|
21360
21259
|
const model = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
21361
|
-
const operation = (mode, queryOptions = embeddingOptions
|
|
21362
|
-
const signal = writeOptions?.signal;
|
|
21363
|
-
const assertWrite = async () => {
|
|
21364
|
-
signal?.throwIfAborted();
|
|
21365
|
-
if (writeOptions?.canWrite && !await writeOptions.canWrite())
|
|
21366
|
-
throw new Error("Memory source is no longer eligible");
|
|
21367
|
-
signal?.throwIfAborted();
|
|
21368
|
-
};
|
|
21260
|
+
const operation = (mode, queryOptions = embeddingOptions) => {
|
|
21369
21261
|
const rejectUndecryptable = (failed) => {
|
|
21370
21262
|
if (!failed.length) return;
|
|
21371
21263
|
if (mode === "retain")
|
|
@@ -21383,7 +21275,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21383
21275
|
return items.map((item) => stored(item.memory));
|
|
21384
21276
|
};
|
|
21385
21277
|
const get = async (id) => {
|
|
21386
|
-
const snapshot = snapshots.get(id) ?? await
|
|
21278
|
+
const snapshot = snapshots.get(id) ?? await persistence.get(id);
|
|
21387
21279
|
if (!snapshot || snapshot.memory.is_deleted || snapshot.memory.superseded_by) return null;
|
|
21388
21280
|
snapshots.set(id, snapshot);
|
|
21389
21281
|
return stored(snapshot.memory);
|
|
@@ -21433,7 +21325,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21433
21325
|
if (forced.size < 100 && temporal[i] !== void 0) forced.add(temporal[i]);
|
|
21434
21326
|
}
|
|
21435
21327
|
const forceIds = [...forced];
|
|
21436
|
-
const windowOptions = (i,
|
|
21328
|
+
const windowOptions = (i, signal) => ({
|
|
21437
21329
|
limit: Math.min(100, Math.max((search.limit ?? 8) * 3, 30)),
|
|
21438
21330
|
force_ids: i === 0 ? forceIds : [],
|
|
21439
21331
|
...search.scopes && { scopes: search.scopes },
|
|
@@ -21441,15 +21333,13 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21441
21333
|
...search.memoryIds !== void 0 && { memory_ids: search.memoryIds },
|
|
21442
21334
|
include_archived: search.includeArchived,
|
|
21443
21335
|
embedding_model: model,
|
|
21444
|
-
...
|
|
21336
|
+
...signal && { signal }
|
|
21445
21337
|
});
|
|
21446
21338
|
const vectors = [queryEmbedding, ...facetEmbeddings];
|
|
21447
21339
|
let windows;
|
|
21448
21340
|
if (mode === "retain") {
|
|
21449
21341
|
windows = await Promise.all(
|
|
21450
|
-
vectors.map(
|
|
21451
|
-
(embedding2, i) => persistence.candidateSet(embedding2, windowOptions(i, signal))
|
|
21452
|
-
)
|
|
21342
|
+
vectors.map((embedding2, i) => persistence.candidateSet(embedding2, windowOptions(i)))
|
|
21453
21343
|
);
|
|
21454
21344
|
} else {
|
|
21455
21345
|
const deadline = new AbortController();
|
|
@@ -21537,15 +21427,12 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21537
21427
|
twin_opt_in: false
|
|
21538
21428
|
};
|
|
21539
21429
|
};
|
|
21540
|
-
const write = async (memory, snapshot) =>
|
|
21541
|
-
await assertWrite();
|
|
21542
|
-
return remember([await persistence.put(memory, snapshot, signal)])[0];
|
|
21543
|
-
};
|
|
21430
|
+
const write = async (memory, snapshot) => remember([await persistence.put(memory, snapshot)])[0];
|
|
21544
21431
|
const port = {
|
|
21545
21432
|
prepare,
|
|
21546
21433
|
get,
|
|
21547
21434
|
getFresh: async (id) => {
|
|
21548
|
-
const current = await
|
|
21435
|
+
const current = await persistence.get(id);
|
|
21549
21436
|
return current && !current.memory.is_deleted && !current.memory.superseded_by ? stored(current.memory) : null;
|
|
21550
21437
|
},
|
|
21551
21438
|
tombstones: async (embedding2, embeddingModel, scope, folderId) => {
|
|
@@ -21556,8 +21443,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21556
21443
|
embedding_model: embeddingModel,
|
|
21557
21444
|
strict_model: true,
|
|
21558
21445
|
include_deleted: true,
|
|
21559
|
-
deleted_only: true
|
|
21560
|
-
signal
|
|
21446
|
+
deleted_only: true
|
|
21561
21447
|
});
|
|
21562
21448
|
rejectUndecryptable(window2.failed);
|
|
21563
21449
|
return remember(window2.items);
|
|
@@ -21613,18 +21499,14 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21613
21499
|
if (!target || !newer || id === successor) return false;
|
|
21614
21500
|
const old = snapshots.get(id);
|
|
21615
21501
|
const next = snapshots.get(successor);
|
|
21616
|
-
await assertWrite();
|
|
21617
21502
|
remember(
|
|
21618
|
-
await persistence.putMany(
|
|
21619
|
-
|
|
21620
|
-
{
|
|
21621
|
-
|
|
21622
|
-
|
|
21623
|
-
|
|
21624
|
-
|
|
21625
|
-
],
|
|
21626
|
-
signal
|
|
21627
|
-
)
|
|
21503
|
+
await persistence.putMany([
|
|
21504
|
+
{
|
|
21505
|
+
memory: { ...old.memory, superseded_by: successor, superseded_at: Date.now() },
|
|
21506
|
+
expectedVersion: old
|
|
21507
|
+
},
|
|
21508
|
+
{ memory: next.memory, expectedVersion: next }
|
|
21509
|
+
])
|
|
21628
21510
|
);
|
|
21629
21511
|
return true;
|
|
21630
21512
|
},
|
|
@@ -21633,22 +21515,18 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21633
21515
|
if (!target) return { created: null, retired: false };
|
|
21634
21516
|
const snapshot = snapshots.get(targetId);
|
|
21635
21517
|
const successor = createRow(input);
|
|
21636
|
-
await assertWrite();
|
|
21637
21518
|
const rows = remember(
|
|
21638
|
-
await persistence.putMany(
|
|
21639
|
-
|
|
21640
|
-
|
|
21641
|
-
{
|
|
21642
|
-
memory
|
|
21643
|
-
|
|
21644
|
-
|
|
21645
|
-
|
|
21646
|
-
|
|
21647
|
-
|
|
21648
|
-
|
|
21649
|
-
],
|
|
21650
|
-
signal
|
|
21651
|
-
)
|
|
21519
|
+
await persistence.putMany([
|
|
21520
|
+
{ memory: successor, expectedVersion: 0 },
|
|
21521
|
+
{
|
|
21522
|
+
memory: {
|
|
21523
|
+
...snapshot.memory,
|
|
21524
|
+
superseded_by: successor.memory_id,
|
|
21525
|
+
superseded_at: Date.now()
|
|
21526
|
+
},
|
|
21527
|
+
expectedVersion: snapshot
|
|
21528
|
+
}
|
|
21529
|
+
])
|
|
21652
21530
|
);
|
|
21653
21531
|
return { created: rows[0], retired: true };
|
|
21654
21532
|
}
|
|
@@ -21683,7 +21561,7 @@ function createRemoteMemoryPipeline(options) {
|
|
|
21683
21561
|
factSource,
|
|
21684
21562
|
recall: async (query, recallOptions = {}) => recall(query, { embeddingOptions, factSource }, { ...recallOptions, types: ["fact"] }),
|
|
21685
21563
|
retain: async (content, retainOptions) => {
|
|
21686
|
-
const { port } = operation("retain"
|
|
21564
|
+
const { port } = operation("retain");
|
|
21687
21565
|
return retainWithPersistence(
|
|
21688
21566
|
content,
|
|
21689
21567
|
{
|
|
@@ -22266,21 +22144,16 @@ function createRemoteMemoryStore(options) {
|
|
|
22266
22144
|
const record2 = await persistence.get(id);
|
|
22267
22145
|
return record2 && !record2.memory.is_deleted ? record2 : null;
|
|
22268
22146
|
};
|
|
22269
|
-
const mutateLocked = async (id, change, edit
|
|
22270
|
-
|
|
22271
|
-
const record2 = writeOptions?.signal ? await persistence.get(id, writeOptions.signal) : await live(id);
|
|
22147
|
+
const mutateLocked = async (id, change, edit) => {
|
|
22148
|
+
const record2 = await live(id);
|
|
22272
22149
|
if (!record2) return null;
|
|
22273
|
-
if (record2.memory.is_deleted) return null;
|
|
22274
|
-
if (writeOptions?.canWrite && !await writeOptions.canWrite())
|
|
22275
|
-
throw new Error("Memory source is no longer eligible");
|
|
22276
|
-
writeOptions?.signal?.throwIfAborted();
|
|
22277
22150
|
const next = edit(structuredClone(record2.memory));
|
|
22278
22151
|
if (!next) return null;
|
|
22279
|
-
const saved =
|
|
22152
|
+
const saved = await persistence.put(next, record2);
|
|
22280
22153
|
notify(typeof change === "function" ? change(record2.memory) : change, [saved]);
|
|
22281
22154
|
return saved;
|
|
22282
22155
|
};
|
|
22283
|
-
const mutate = (id, change, edit
|
|
22156
|
+
const mutate = (id, change, edit) => serialized(id, () => mutateLocked(id, change, edit));
|
|
22284
22157
|
const serializedAll = (ids, task) => [...new Set(ids)].sort().reduceRight((inner, id) => () => serialized(id, inner), task)();
|
|
22285
22158
|
const mutateMany = async (ids, change, edit) => {
|
|
22286
22159
|
const saved = /* @__PURE__ */ new Map();
|
|
@@ -22793,21 +22666,13 @@ function createRemoteMemoryStore(options) {
|
|
|
22793
22666
|
}))
|
|
22794
22667
|
);
|
|
22795
22668
|
},
|
|
22796
|
-
addTopics: async (memoryId, topics
|
|
22669
|
+
addTopics: async (memoryId, topics) => {
|
|
22797
22670
|
const added = await withKnownKinds(topicInputs(topics, "auto"));
|
|
22798
|
-
const saved = await mutate(
|
|
22799
|
-
|
|
22800
|
-
|
|
22801
|
-
(
|
|
22802
|
-
|
|
22803
|
-
return {
|
|
22804
|
-
...memory,
|
|
22805
|
-
topics: serializeTopics(mergeTopics(parseTopics(memory.topics) ?? [], added)),
|
|
22806
|
-
topics_updated_at: Date.now()
|
|
22807
|
-
};
|
|
22808
|
-
},
|
|
22809
|
-
writeOptions
|
|
22810
|
-
);
|
|
22671
|
+
const saved = await mutate(memoryId, "edit", (memory) => ({
|
|
22672
|
+
...memory,
|
|
22673
|
+
topics: serializeTopics(mergeTopics(parseTopics(memory.topics) ?? [], added)),
|
|
22674
|
+
topics_updated_at: Date.now()
|
|
22675
|
+
}));
|
|
22811
22676
|
if (!saved) return [];
|
|
22812
22677
|
const now = /* @__PURE__ */ new Date();
|
|
22813
22678
|
return mergeTopics([], added).map(
|
|
@@ -23660,7 +23525,6 @@ function createDurableAutoExtractor(options) {
|
|
|
23660
23525
|
};
|
|
23661
23526
|
const folderId = options.folderId ?? null;
|
|
23662
23527
|
let disposed = false;
|
|
23663
|
-
let activeBatch = null;
|
|
23664
23528
|
let running = false;
|
|
23665
23529
|
let wakeRequested = false;
|
|
23666
23530
|
let timer;
|
|
@@ -23697,18 +23561,14 @@ function createDurableAutoExtractor(options) {
|
|
|
23697
23561
|
}, delay);
|
|
23698
23562
|
}
|
|
23699
23563
|
async function extractBatch(messages, conversationId, ids, jobScope, jobFolderId) {
|
|
23700
|
-
if (disposed) throw new Error("Extraction session was disposed");
|
|
23701
23564
|
let watchdog;
|
|
23702
23565
|
let cancelled = false;
|
|
23703
|
-
const controller = new AbortController();
|
|
23704
|
-
activeBatch = controller;
|
|
23705
23566
|
const model = options.modelForScope?.(jobScope) ?? options.extract.model;
|
|
23706
23567
|
try {
|
|
23707
23568
|
return await Promise.race([
|
|
23708
23569
|
new Promise((resolve, reject) => {
|
|
23709
23570
|
const worker = createAutoExtractor({
|
|
23710
23571
|
...options,
|
|
23711
|
-
signal: controller.signal,
|
|
23712
23572
|
retainCtx: {
|
|
23713
23573
|
...options.retainCtx,
|
|
23714
23574
|
vaultCtx: {
|
|
@@ -23737,8 +23597,6 @@ function createDurableAutoExtractor(options) {
|
|
|
23737
23597
|
]);
|
|
23738
23598
|
} finally {
|
|
23739
23599
|
cancelled = true;
|
|
23740
|
-
controller.abort();
|
|
23741
|
-
if (activeBatch === controller) activeBatch = null;
|
|
23742
23600
|
if (watchdog !== void 0) clearTimeout(watchdog);
|
|
23743
23601
|
}
|
|
23744
23602
|
}
|
|
@@ -23750,7 +23608,6 @@ function createDurableAutoExtractor(options) {
|
|
|
23750
23608
|
for (const message of loaded)
|
|
23751
23609
|
if (message && message.messageId > 0) sequences.set(message.uniqueId, message.messageId);
|
|
23752
23610
|
await database.write(async () => {
|
|
23753
|
-
if (disposed) return;
|
|
23754
23611
|
const current = idsOf(job);
|
|
23755
23612
|
const acknowledged = ids.filter((id) => current.includes(id));
|
|
23756
23613
|
if (!acknowledged.length) return;
|
|
@@ -23923,7 +23780,6 @@ function createDurableAutoExtractor(options) {
|
|
|
23923
23780
|
jobScope,
|
|
23924
23781
|
jobFolderId
|
|
23925
23782
|
);
|
|
23926
|
-
if (disposed) throw new Error("Extraction session was disposed");
|
|
23927
23783
|
options.onTurnComplete?.(result);
|
|
23928
23784
|
return result;
|
|
23929
23785
|
};
|
|
@@ -23960,7 +23816,6 @@ function createDurableAutoExtractor(options) {
|
|
|
23960
23816
|
);
|
|
23961
23817
|
scheduleAfterSuccess = true;
|
|
23962
23818
|
} catch (error) {
|
|
23963
|
-
if (disposed) break;
|
|
23964
23819
|
attempts.set(job.id, attempted + 1);
|
|
23965
23820
|
retry = true;
|
|
23966
23821
|
reportError(error, conversationId);
|
|
@@ -23983,14 +23838,6 @@ function createDurableAutoExtractor(options) {
|
|
|
23983
23838
|
schedule(retry ? options.retryDelayMs ?? 3e4 : 0);
|
|
23984
23839
|
}
|
|
23985
23840
|
}
|
|
23986
|
-
function dispose() {
|
|
23987
|
-
disposed = true;
|
|
23988
|
-
activeBatch?.abort(options.signal?.reason);
|
|
23989
|
-
if (timer !== void 0) clearTimeout(timer);
|
|
23990
|
-
options.signal?.removeEventListener("abort", dispose);
|
|
23991
|
-
}
|
|
23992
|
-
if (options.signal?.aborted) dispose();
|
|
23993
|
-
else options.signal?.addEventListener("abort", dispose, { once: true });
|
|
23994
23841
|
schedule(0);
|
|
23995
23842
|
return {
|
|
23996
23843
|
processTurn(messages, conversationId) {
|
|
@@ -24070,7 +23917,10 @@ function createDurableAutoExtractor(options) {
|
|
|
24070
23917
|
return true;
|
|
24071
23918
|
},
|
|
24072
23919
|
isProcessing: () => running,
|
|
24073
|
-
dispose
|
|
23920
|
+
dispose() {
|
|
23921
|
+
disposed = true;
|
|
23922
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
23923
|
+
}
|
|
24074
23924
|
};
|
|
24075
23925
|
}
|
|
24076
23926
|
|
|
@@ -27342,7 +27192,6 @@ var CONVERSATION_REDACTOR_LIMIT = 50;
|
|
|
27342
27192
|
var NO_CONVERSATION_KEY = "__no_conversation__";
|
|
27343
27193
|
var NO_STORE_FOLDERS = "Folders are not supported with a memoryStore";
|
|
27344
27194
|
var NO_STORE_MASK = "piiRedaction needs a memoryStore built with embeddingOptions.maskInput";
|
|
27345
|
-
var MEMORY_STORE_NOT_READY = "Memory store is not ready";
|
|
27346
27195
|
var conversationRedactors = /* @__PURE__ */ new Map();
|
|
27347
27196
|
var clientToolFilterCache = /* @__PURE__ */ new Map();
|
|
27348
27197
|
function getConversationRedactor(conversationId, nerDetector) {
|
|
@@ -27487,7 +27336,7 @@ function useChatStorage(options) {
|
|
|
27487
27336
|
[resolvedPiiRedaction]
|
|
27488
27337
|
);
|
|
27489
27338
|
const maskEmbeddingInput = isPiiRedactor(resolvedPiiRedaction) ? maskForEmbedding : void 0;
|
|
27490
|
-
const storeMaskMissing = memoryStore !== void 0 &&
|
|
27339
|
+
const storeMaskMissing = memoryStore !== void 0 && maskEmbeddingInput !== void 0 && !memoryStore.masksEmbeddingInput;
|
|
27491
27340
|
const messagesCollection = (0, import_react5.useMemo)(() => database.get("history"), [database]);
|
|
27492
27341
|
const conversationsCollection = (0, import_react5.useMemo)(
|
|
27493
27342
|
() => database.get("conversations"),
|
|
@@ -27736,7 +27585,6 @@ function useChatStorage(options) {
|
|
|
27736
27585
|
}, [vaultEmbeddingCache]);
|
|
27737
27586
|
const retainVaultMemory = (0, import_react5.useCallback)(
|
|
27738
27587
|
async (input) => {
|
|
27739
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
27740
27588
|
if (memoryStore) {
|
|
27741
27589
|
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
27742
27590
|
if (input.folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
|
|
@@ -27782,7 +27630,6 @@ function useChatStorage(options) {
|
|
|
27782
27630
|
);
|
|
27783
27631
|
const createMemoryVaultTool2 = (0, import_react5.useCallback)(
|
|
27784
27632
|
(options2) => {
|
|
27785
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
27786
27633
|
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
27787
27634
|
return createMemoryVaultTool(
|
|
27788
27635
|
memoryStore ?? vaultCtx,
|
|
@@ -27793,7 +27640,6 @@ function useChatStorage(options) {
|
|
|
27793
27640
|
);
|
|
27794
27641
|
const createRecallTool2 = (0, import_react5.useCallback)(
|
|
27795
27642
|
(toolOptions, callbacks) => {
|
|
27796
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
27797
27643
|
if (!getToken && !memoryStore) {
|
|
27798
27644
|
throw new Error("getToken is required for recall tool");
|
|
27799
27645
|
}
|
|
@@ -27839,7 +27685,7 @@ function useChatStorage(options) {
|
|
|
27839
27685
|
);
|
|
27840
27686
|
const recallFn = (0, import_react5.useCallback)(
|
|
27841
27687
|
async (query, options2) => {
|
|
27842
|
-
if (
|
|
27688
|
+
if (!getToken && !memoryStore) {
|
|
27843
27689
|
return {
|
|
27844
27690
|
memories: [],
|
|
27845
27691
|
usedBudget: options2?.budget ?? "low",
|
|
@@ -27888,7 +27734,6 @@ function useChatStorage(options) {
|
|
|
27888
27734
|
);
|
|
27889
27735
|
const getVaultMemories = (0, import_react5.useCallback)(
|
|
27890
27736
|
(options2) => {
|
|
27891
|
-
if (memoryStore === null) return Promise.resolve([]);
|
|
27892
27737
|
if (!memoryStore) return getAllVaultMemoriesOp(vaultCtx, options2);
|
|
27893
27738
|
const { folderId, levels, kinds, ...listOptions } = options2 ?? {};
|
|
27894
27739
|
if (folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
|
|
@@ -27899,8 +27744,7 @@ function useChatStorage(options) {
|
|
|
27899
27744
|
[vaultCtx, memoryStore]
|
|
27900
27745
|
);
|
|
27901
27746
|
const deleteVaultMemory = (0, import_react5.useCallback)(
|
|
27902
|
-
|
|
27903
|
-
if (memoryStore === null) throw new Error(MEMORY_STORE_NOT_READY);
|
|
27747
|
+
(id) => {
|
|
27904
27748
|
return memoryStore ? memoryStore.delete(id) : deleteVaultMemoryOp(vaultCtx, id);
|
|
27905
27749
|
},
|
|
27906
27750
|
[vaultCtx, memoryStore]
|