@anuma/sdk 6.38.0 → 6.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/index.cjs +192 -96
- package/dist/expo/index.d.mts +5653 -5644
- package/dist/expo/index.d.ts +5653 -5644
- package/dist/expo/index.mjs +192 -96
- package/dist/index.d.mts +62 -62
- package/dist/index.d.ts +62 -62
- package/dist/react/index.cjs +192 -91
- package/dist/react/index.d.mts +7032 -7023
- package/dist/react/index.d.ts +7032 -7023
- package/dist/react/index.mjs +192 -91
- package/dist/server/index.cjs +91 -39
- package/dist/server/index.d.mts +6173 -6167
- package/dist/server/index.d.ts +6173 -6167
- package/dist/server/index.mjs +91 -39
- package/package.json +1 -1
package/dist/expo/index.cjs
CHANGED
|
@@ -18705,7 +18705,6 @@ async function recall(query, ctx, options = {}) {
|
|
|
18705
18705
|
}
|
|
18706
18706
|
const needsChunkEmbedding = types.includes("chunk") && ctx.storageCtx;
|
|
18707
18707
|
const wantsTemporal = types.includes("fact") && (ctx.factSource || ctx.vaultCtx);
|
|
18708
|
-
const graphRefiner = flags.traverse && options.graphRefine && options.decomposeOptions ? createLlmNeighborRefiner(options.decomposeOptions) : void 0;
|
|
18709
18708
|
const queryEmbedTotalTimeoutMs = options.queryEmbedTotalTimeoutMs ?? DEFAULT_QUERY_EMBED_TOTAL_TIMEOUT_MS;
|
|
18710
18709
|
const prepStart = nowMs2();
|
|
18711
18710
|
let sharedEmbedMs = 0;
|
|
@@ -18734,13 +18733,12 @@ async function recall(query, ctx, options = {}) {
|
|
|
18734
18733
|
safeLane(
|
|
18735
18734
|
"graph",
|
|
18736
18735
|
() => graphLaneFailed = true,
|
|
18737
|
-
() => ctx.factSource ? ctx.factSource.graphRanking(query, flags.traverse, options) : buildGraphLaneRanking(
|
|
18738
|
-
|
|
18739
|
-
|
|
18740
|
-
|
|
18741
|
-
|
|
18742
|
-
|
|
18743
|
-
})
|
|
18736
|
+
() => ctx.factSource ? ctx.factSource.graphRanking(query, flags.traverse, options) : buildGraphLaneRanking(
|
|
18737
|
+
query,
|
|
18738
|
+
ctx,
|
|
18739
|
+
flags.traverse,
|
|
18740
|
+
graphTraversalOptions(options, flags.traverse)
|
|
18741
|
+
)
|
|
18744
18742
|
),
|
|
18745
18743
|
wantsTemporal ? safeLane(
|
|
18746
18744
|
"temporal",
|
|
@@ -18959,6 +18957,16 @@ function toFactMemory(r, now) {
|
|
|
18959
18957
|
updatedAt: r.updatedAt ?? /* @__PURE__ */ new Date(0)
|
|
18960
18958
|
};
|
|
18961
18959
|
}
|
|
18960
|
+
function graphTraversalOptions(options, traverse) {
|
|
18961
|
+
const refineNeighbors = traverse && options.graphRefine && options.decomposeOptions ? createLlmNeighborRefiner(options.decomposeOptions) : void 0;
|
|
18962
|
+
return {
|
|
18963
|
+
...options.maxHops !== void 0 && { maxHops: options.maxHops },
|
|
18964
|
+
...options.entityFanout !== void 0 && { entityFanout: options.entityFanout },
|
|
18965
|
+
...options.nodeBudget !== void 0 && { nodeBudget: options.nodeBudget },
|
|
18966
|
+
...options.rrfK !== void 0 && { rrfK: options.rrfK },
|
|
18967
|
+
...refineNeighbors && { refineNeighbors }
|
|
18968
|
+
};
|
|
18969
|
+
}
|
|
18962
18970
|
async function buildGraphLaneRanking(query, ctx, traverse = false, traversalOptions = {}) {
|
|
18963
18971
|
const entityCtx = ctx.entityCtx ?? ctx.vaultCtx?.entityCtx;
|
|
18964
18972
|
if (!entityCtx) return [];
|
|
@@ -19124,24 +19132,33 @@ function isDumpQuery(query) {
|
|
|
19124
19132
|
return false;
|
|
19125
19133
|
}
|
|
19126
19134
|
async function listRecentFacts(ctx, limit, toolOptions) {
|
|
19135
|
+
const store = toolOptions?.memoryStore;
|
|
19127
19136
|
const vaultCtx = ctx.vaultCtx;
|
|
19128
|
-
if (!vaultCtx) return [];
|
|
19129
|
-
const
|
|
19137
|
+
if (!vaultCtx && !store) return [];
|
|
19138
|
+
const read = (ids) => store ? store.list({ memoryIds: ids }) : getVaultMemoriesByIdsOp(vaultCtx, ids);
|
|
19139
|
+
const filters = {
|
|
19130
19140
|
...toolOptions?.scopes && { scopes: toolOptions.scopes },
|
|
19131
|
-
...toolOptions?.memoryIds !== void 0 && { memoryIds: toolOptions.memoryIds }
|
|
19141
|
+
...toolOptions?.memoryIds !== void 0 && { memoryIds: toolOptions.memoryIds }
|
|
19142
|
+
};
|
|
19143
|
+
const project = (size) => store ? store.listProjections({ ...filters, limit: size }) : getVaultRankingProjectionsOp(vaultCtx, {
|
|
19144
|
+
...filters,
|
|
19132
19145
|
...toolOptions?.folderId !== void 0 && { folderId: toolOptions.folderId }
|
|
19133
19146
|
});
|
|
19134
19147
|
const readable = [];
|
|
19135
|
-
|
|
19136
|
-
|
|
19137
|
-
const
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
const
|
|
19142
|
-
|
|
19143
|
-
|
|
19148
|
+
let start = 0;
|
|
19149
|
+
for (let size = limit; readable.length < limit; size *= 2) {
|
|
19150
|
+
const ordered = await project(size);
|
|
19151
|
+
for (let i = start; i < ordered.length && readable.length < limit; i += limit) {
|
|
19152
|
+
const batch = ordered.slice(i, i + limit).map((p) => p.uniqueId);
|
|
19153
|
+
const byId = new Map((await read(batch)).map((m) => [m.uniqueId, m]));
|
|
19154
|
+
for (const id of batch) {
|
|
19155
|
+
const m = byId.get(id);
|
|
19156
|
+
if (m && !isEncrypted(m.content)) readable.push(m);
|
|
19157
|
+
if (readable.length >= limit) break;
|
|
19158
|
+
}
|
|
19144
19159
|
}
|
|
19160
|
+
if (!store || ordered.length < size) break;
|
|
19161
|
+
start = ordered.length;
|
|
19145
19162
|
}
|
|
19146
19163
|
return readable.map((m) => ({
|
|
19147
19164
|
id: m.uniqueId,
|
|
@@ -19158,6 +19175,8 @@ async function listRecentFacts(ctx, limit, toolOptions) {
|
|
|
19158
19175
|
}));
|
|
19159
19176
|
}
|
|
19160
19177
|
function createRecallTool(ctx, toolOptions, callbacks) {
|
|
19178
|
+
if (toolOptions?.memoryStore && toolOptions.folderId !== void 0)
|
|
19179
|
+
throw new Error("Folders are not supported with a memoryStore");
|
|
19161
19180
|
const defaultTypes = toolOptions?.types ?? ["fact", "chunk"];
|
|
19162
19181
|
const defaultLimit = toolOptions?.limit ?? DEFAULT_LIMIT2;
|
|
19163
19182
|
const defaultBudget = toolOptions?.budget ?? DEFAULT_BUDGET2;
|
|
@@ -19229,7 +19248,7 @@ function createRecallTool(ctx, toolOptions, callbacks) {
|
|
|
19229
19248
|
let surfaced = 0;
|
|
19230
19249
|
try {
|
|
19231
19250
|
let recallDegraded = [];
|
|
19232
|
-
const wantsRecent = args.sort === "recent" && defaultTypes.includes("fact") && ctx.vaultCtx !== void 0;
|
|
19251
|
+
const wantsRecent = args.sort === "recent" && defaultTypes.includes("fact") && (ctx.vaultCtx !== void 0 || toolOptions?.memoryStore !== void 0);
|
|
19233
19252
|
let result;
|
|
19234
19253
|
if (wantsRecent) {
|
|
19235
19254
|
result = { memories: await listRecentFacts(ctx, effectiveLimit, toolOptions) };
|
|
@@ -19739,6 +19758,7 @@ function createLocalMemoryStore(options) {
|
|
|
19739
19758
|
});
|
|
19740
19759
|
};
|
|
19741
19760
|
return {
|
|
19761
|
+
masksEmbeddingInput: options.embeddingOptions.maskInput !== void 0,
|
|
19742
19762
|
list: (listOptions) => getAllVaultMemoriesOp(vaultCtx, listOptions),
|
|
19743
19763
|
get: (id) => getVaultMemoryOp(vaultCtx, id),
|
|
19744
19764
|
listArchived: async () => {
|
|
@@ -19820,6 +19840,22 @@ function createLocalMemoryStore(options) {
|
|
|
19820
19840
|
{ vaultCtx, embeddingOptions: options.embeddingOptions, vaultCache },
|
|
19821
19841
|
retainOptions
|
|
19822
19842
|
),
|
|
19843
|
+
factSource: {
|
|
19844
|
+
search: (query, searchOptions) => searchVaultMemoriesWithSize(
|
|
19845
|
+
query,
|
|
19846
|
+
vaultCtx,
|
|
19847
|
+
options.embeddingOptions,
|
|
19848
|
+
vaultCache,
|
|
19849
|
+
searchOptions
|
|
19850
|
+
),
|
|
19851
|
+
graphRanking: (query, traverse, recallOptions) => buildGraphLaneRanking(
|
|
19852
|
+
query,
|
|
19853
|
+
{ vaultCtx, entityCtx, embeddingOptions: options.embeddingOptions },
|
|
19854
|
+
traverse,
|
|
19855
|
+
graphTraversalOptions(recallOptions, traverse)
|
|
19856
|
+
),
|
|
19857
|
+
temporalRanking: (query, now) => buildTemporalLaneRanking(query, vaultCtx, now)
|
|
19858
|
+
},
|
|
19823
19859
|
subscribe: (onChange, subscribeOptions) => {
|
|
19824
19860
|
const afterFirst = () => {
|
|
19825
19861
|
let first = true;
|
|
@@ -20707,38 +20743,31 @@ function createRemoteMemoryPipeline(options) {
|
|
|
20707
20743
|
};
|
|
20708
20744
|
return { prepare, port };
|
|
20709
20745
|
};
|
|
20710
|
-
|
|
20711
|
-
|
|
20746
|
+
const factSource = {
|
|
20747
|
+
graphRanking: options.graphRanking,
|
|
20748
|
+
temporalRanking: options.temporalRanking,
|
|
20749
|
+
search: async (text13, searchOptions) => {
|
|
20712
20750
|
const { prepare } = operation("recall");
|
|
20713
|
-
|
|
20714
|
-
|
|
20715
|
-
|
|
20716
|
-
|
|
20717
|
-
|
|
20718
|
-
|
|
20719
|
-
temporalRanking: options.temporalRanking,
|
|
20720
|
-
search: async (text13, searchOptions) => {
|
|
20721
|
-
const prepared = await prepare(text13, searchOptions);
|
|
20722
|
-
const ranked = await rankPreparedVaultCandidates(
|
|
20723
|
-
text13,
|
|
20724
|
-
prepared,
|
|
20725
|
-
embeddingOptions,
|
|
20726
|
-
searchOptions
|
|
20727
|
-
);
|
|
20728
|
-
return {
|
|
20729
|
-
...ranked,
|
|
20730
|
-
rankedOnCosine: prepared.memories.length > 0 && !prepared.embeddingsUnavailable,
|
|
20731
|
-
decryptLast: true,
|
|
20732
|
-
rowsDecrypted: prepared.rowsDecrypted,
|
|
20733
|
-
queryEmbedMs: prepared.queryEmbedMs,
|
|
20734
|
-
rowsEmbedded: 0
|
|
20735
|
-
};
|
|
20736
|
-
}
|
|
20737
|
-
}
|
|
20738
|
-
},
|
|
20739
|
-
{ ...recallOptions, types: ["fact"] }
|
|
20751
|
+
const prepared = await prepare(text13, searchOptions);
|
|
20752
|
+
const ranked = await rankPreparedVaultCandidates(
|
|
20753
|
+
text13,
|
|
20754
|
+
prepared,
|
|
20755
|
+
embeddingOptions,
|
|
20756
|
+
searchOptions
|
|
20740
20757
|
);
|
|
20741
|
-
|
|
20758
|
+
return {
|
|
20759
|
+
...ranked,
|
|
20760
|
+
rankedOnCosine: prepared.memories.length > 0 && !prepared.embeddingsUnavailable,
|
|
20761
|
+
decryptLast: true,
|
|
20762
|
+
rowsDecrypted: prepared.rowsDecrypted,
|
|
20763
|
+
queryEmbedMs: prepared.queryEmbedMs,
|
|
20764
|
+
rowsEmbedded: 0
|
|
20765
|
+
};
|
|
20766
|
+
}
|
|
20767
|
+
};
|
|
20768
|
+
return {
|
|
20769
|
+
factSource,
|
|
20770
|
+
recall: async (query, recallOptions = {}) => recall(query, { embeddingOptions, factSource }, { ...recallOptions, types: ["fact"] }),
|
|
20742
20771
|
retain: async (content, retainOptions) => {
|
|
20743
20772
|
const { port } = operation("retain");
|
|
20744
20773
|
return retainWithPersistence(
|
|
@@ -21100,6 +21129,7 @@ function createRemoteMemoryStore(options) {
|
|
|
21100
21129
|
});
|
|
21101
21130
|
};
|
|
21102
21131
|
return {
|
|
21132
|
+
masksEmbeddingInput: embeddingOptions.maskInput !== void 0,
|
|
21103
21133
|
list: async (listOptions = {}) => (await listRows(decrypted, listOptions, listFilters(listOptions), maxOf(listOptions))).map(
|
|
21104
21134
|
(r) => stored(r.memory)
|
|
21105
21135
|
),
|
|
@@ -21295,6 +21325,7 @@ function createRemoteMemoryStore(options) {
|
|
|
21295
21325
|
})
|
|
21296
21326
|
),
|
|
21297
21327
|
recall: (query, recallOptions) => pipeline.recall(query, recallOptions),
|
|
21328
|
+
factSource: pipeline.factSource,
|
|
21298
21329
|
retain: async (content, retainOptions) => {
|
|
21299
21330
|
const result = await pipeline.retain(content, retainOptions);
|
|
21300
21331
|
if (result.action === "create" || result.action === "supersede") notify("membership");
|
|
@@ -23063,19 +23094,20 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
23063
23094
|
const budget = wantsDecompose ? "high" : searchOptions?.rerank ? "mid" : "low";
|
|
23064
23095
|
const folderId = searchOptions?.folderId ?? argFolderId;
|
|
23065
23096
|
if (searchOptions?.useFusion === false) {
|
|
23066
|
-
const
|
|
23097
|
+
const legacyOptions = {
|
|
23098
|
+
limit: requestLimit,
|
|
23099
|
+
minSimilarity,
|
|
23100
|
+
useFusion: false,
|
|
23101
|
+
...tuningForward,
|
|
23102
|
+
...folderId !== void 0 && { folderId },
|
|
23103
|
+
...searchOptions?.scopes && { scopes: searchOptions.scopes }
|
|
23104
|
+
};
|
|
23105
|
+
const { results: legacy, embeddingsUnavailable } = "retain" in vaultCtx ? await vaultCtx.factSource.search(query, legacyOptions) : await searchVaultMemoriesWithSize(
|
|
23067
23106
|
query,
|
|
23068
23107
|
vaultCtx,
|
|
23069
23108
|
embeddingOptions,
|
|
23070
23109
|
cache,
|
|
23071
|
-
|
|
23072
|
-
limit: requestLimit,
|
|
23073
|
-
minSimilarity,
|
|
23074
|
-
useFusion: false,
|
|
23075
|
-
...tuningForward,
|
|
23076
|
-
...folderId !== void 0 && { folderId },
|
|
23077
|
-
...searchOptions?.scopes && { scopes: searchOptions.scopes }
|
|
23078
|
-
}
|
|
23110
|
+
legacyOptions
|
|
23079
23111
|
);
|
|
23080
23112
|
if (legacy.length === 0) {
|
|
23081
23113
|
return embeddingsUnavailable ? EMBEDDINGS_DEGRADED_EMPTY_NO_LEXICAL : "No relevant memories found in the vault.";
|
|
@@ -23094,7 +23126,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
23094
23126
|
let recallDegraded = [];
|
|
23095
23127
|
const result = await recall(
|
|
23096
23128
|
query,
|
|
23097
|
-
{ vaultCtx, embeddingOptions, vaultCache: cache },
|
|
23129
|
+
"retain" in vaultCtx ? { factSource: vaultCtx.factSource, embeddingOptions } : { vaultCtx, embeddingOptions, vaultCache: cache },
|
|
23098
23130
|
{
|
|
23099
23131
|
onDiagnostics: (d) => {
|
|
23100
23132
|
recallDegraded = d.degraded;
|
|
@@ -23174,8 +23206,10 @@ function describeWriteOutcome(outcome2) {
|
|
|
23174
23206
|
}
|
|
23175
23207
|
}
|
|
23176
23208
|
function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
23209
|
+
const store = "retain" in vaultCtx ? vaultCtx : void 0;
|
|
23210
|
+
const ctx = "retain" in vaultCtx ? void 0 : vaultCtx;
|
|
23177
23211
|
const hasOnSave = !!options?.onSave;
|
|
23178
|
-
const folderNames = options?.folderMap ? Array.from(options.folderMap.keys()) : [];
|
|
23212
|
+
const folderNames = !store && options?.folderMap ? Array.from(options.folderMap.keys()) : [];
|
|
23179
23213
|
return {
|
|
23180
23214
|
type: "function",
|
|
23181
23215
|
function: {
|
|
@@ -23220,7 +23254,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
23220
23254
|
let previousContent;
|
|
23221
23255
|
const scope = options?.scope ?? "private";
|
|
23222
23256
|
if (isUpdate) {
|
|
23223
|
-
const existing = await getVaultMemoryOp(
|
|
23257
|
+
const existing = store ? await store.get(id) : await getVaultMemoryOp(ctx, id);
|
|
23224
23258
|
if (!existing) {
|
|
23225
23259
|
return `Error: Memory with ID "${id}" not found. Creating a new memory instead would require a separate call without an ID.`;
|
|
23226
23260
|
}
|
|
@@ -23241,9 +23275,18 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
23241
23275
|
return isUpdate ? `Memory update was cancelled by the user. The memory "${id}" was not modified.` : "Memory save was cancelled by the user. No memory was created.";
|
|
23242
23276
|
}
|
|
23243
23277
|
}
|
|
23244
|
-
if (isUpdate) {
|
|
23278
|
+
if (isUpdate && store) {
|
|
23279
|
+
const updated = await store.update(id, {
|
|
23280
|
+
content,
|
|
23281
|
+
...factType !== void 0 && { factType }
|
|
23282
|
+
});
|
|
23283
|
+
if (!updated) {
|
|
23284
|
+
return `Error: Failed to update memory "${id}".`;
|
|
23285
|
+
}
|
|
23286
|
+
return `Memory updated successfully (ID: ${updated.uniqueId}).`;
|
|
23287
|
+
} else if (isUpdate) {
|
|
23245
23288
|
const folderId = folderName ? options?.folderMap?.get(folderName) : void 0;
|
|
23246
|
-
const updated = await updateVaultMemoryOp(
|
|
23289
|
+
const updated = await updateVaultMemoryOp(ctx, id, {
|
|
23247
23290
|
content,
|
|
23248
23291
|
embedding: null,
|
|
23249
23292
|
folderId,
|
|
@@ -23258,7 +23301,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
23258
23301
|
content,
|
|
23259
23302
|
embeddingOptions,
|
|
23260
23303
|
cache,
|
|
23261
|
-
|
|
23304
|
+
ctx,
|
|
23262
23305
|
id,
|
|
23263
23306
|
updated.updatedAt
|
|
23264
23307
|
).catch(() => {
|
|
@@ -23278,18 +23321,22 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
|
|
|
23278
23321
|
await notifyWritten(options, input, outcome2);
|
|
23279
23322
|
return describeWriteOutcome(outcome2);
|
|
23280
23323
|
}
|
|
23281
|
-
const created = await
|
|
23324
|
+
const created = store ? await store.create({
|
|
23325
|
+
content,
|
|
23326
|
+
scope,
|
|
23327
|
+
...factType !== void 0 && { factType }
|
|
23328
|
+
}) : await createVaultMemoryOp(ctx, {
|
|
23282
23329
|
content,
|
|
23283
23330
|
scope,
|
|
23284
23331
|
folderId,
|
|
23285
23332
|
...factType !== void 0 && { factType }
|
|
23286
23333
|
});
|
|
23287
|
-
if (embeddingOptions && cache) {
|
|
23334
|
+
if (ctx && embeddingOptions && cache) {
|
|
23288
23335
|
eagerEmbedContent(
|
|
23289
23336
|
content,
|
|
23290
23337
|
embeddingOptions,
|
|
23291
23338
|
cache,
|
|
23292
|
-
|
|
23339
|
+
ctx,
|
|
23293
23340
|
created.uniqueId,
|
|
23294
23341
|
created.updatedAt
|
|
23295
23342
|
).catch(() => {
|
|
@@ -25588,6 +25635,8 @@ onClearAllEncryptionState(resetRecentToolSets);
|
|
|
25588
25635
|
// src/expo/useChatStorage.ts
|
|
25589
25636
|
var CONVERSATION_REDACTOR_LIMIT = 50;
|
|
25590
25637
|
var NO_CONVERSATION_KEY = "__no_conversation__";
|
|
25638
|
+
var NO_STORE_FOLDERS = "Folders are not supported with a memoryStore";
|
|
25639
|
+
var NO_STORE_MASK = "piiRedaction needs a memoryStore built with embeddingOptions.maskInput";
|
|
25591
25640
|
var conversationRedactors = /* @__PURE__ */ new Map();
|
|
25592
25641
|
var clientToolFilterCache = /* @__PURE__ */ new Map();
|
|
25593
25642
|
function getConversationRedactor(conversationId, nerDetector) {
|
|
@@ -25689,6 +25738,7 @@ function useChatStorage(options) {
|
|
|
25689
25738
|
signMessage,
|
|
25690
25739
|
embeddedWalletSigner,
|
|
25691
25740
|
getWalletAddress,
|
|
25741
|
+
memoryStore,
|
|
25692
25742
|
enableQueue = true,
|
|
25693
25743
|
autoFlushOnKeyAvailable = true,
|
|
25694
25744
|
extraToolSets,
|
|
@@ -25729,6 +25779,7 @@ function useChatStorage(options) {
|
|
|
25729
25779
|
[resolvedPiiRedaction]
|
|
25730
25780
|
);
|
|
25731
25781
|
const maskEmbeddingInput = isPiiRedactor(resolvedPiiRedaction) ? maskForEmbedding : void 0;
|
|
25782
|
+
const storeMaskMissing = memoryStore !== void 0 && maskEmbeddingInput !== void 0 && !memoryStore.masksEmbeddingInput;
|
|
25732
25783
|
const messagesCollection = (0, import_react5.useMemo)(() => database.get("history"), [database]);
|
|
25733
25784
|
const conversationsCollection = (0, import_react5.useMemo)(
|
|
25734
25785
|
() => database.get("conversations"),
|
|
@@ -25977,6 +26028,15 @@ function useChatStorage(options) {
|
|
|
25977
26028
|
}, [vaultEmbeddingCache]);
|
|
25978
26029
|
const retainVaultMemory = (0, import_react5.useCallback)(
|
|
25979
26030
|
async (input) => {
|
|
26031
|
+
if (memoryStore) {
|
|
26032
|
+
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
26033
|
+
if (input.folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
|
|
26034
|
+
return memoryStore.retain(input.content, {
|
|
26035
|
+
source: "manual",
|
|
26036
|
+
scope: input.scope,
|
|
26037
|
+
...input.factType !== void 0 && { factType: input.factType }
|
|
26038
|
+
});
|
|
26039
|
+
}
|
|
25980
26040
|
if (!getToken) {
|
|
25981
26041
|
throw new Error("getToken is required to retain a vault memory");
|
|
25982
26042
|
}
|
|
@@ -26000,37 +26060,56 @@ function useChatStorage(options) {
|
|
|
26000
26060
|
}
|
|
26001
26061
|
);
|
|
26002
26062
|
},
|
|
26003
|
-
[
|
|
26063
|
+
[
|
|
26064
|
+
vaultCtx,
|
|
26065
|
+
getToken,
|
|
26066
|
+
baseUrl,
|
|
26067
|
+
embeddingModel,
|
|
26068
|
+
maskEmbeddingInput,
|
|
26069
|
+
vaultEmbeddingCache,
|
|
26070
|
+
memoryStore,
|
|
26071
|
+
storeMaskMissing
|
|
26072
|
+
]
|
|
26004
26073
|
);
|
|
26005
26074
|
const createMemoryVaultTool2 = (0, import_react5.useCallback)(
|
|
26006
26075
|
(options2) => {
|
|
26076
|
+
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
26007
26077
|
return createMemoryVaultTool(
|
|
26008
|
-
vaultCtx,
|
|
26009
|
-
getToken ? { write: retainVaultMemory, ...options2 } : options2
|
|
26078
|
+
memoryStore ?? vaultCtx,
|
|
26079
|
+
getToken || memoryStore ? { write: retainVaultMemory, ...options2 } : options2
|
|
26010
26080
|
);
|
|
26011
26081
|
},
|
|
26012
|
-
[vaultCtx, getToken, retainVaultMemory]
|
|
26082
|
+
[vaultCtx, getToken, retainVaultMemory, memoryStore, storeMaskMissing]
|
|
26013
26083
|
);
|
|
26014
26084
|
const createRecallTool2 = (0, import_react5.useCallback)(
|
|
26015
26085
|
(toolOptions, callbacks) => {
|
|
26016
|
-
if (!getToken) {
|
|
26086
|
+
if (!getToken && !memoryStore) {
|
|
26017
26087
|
throw new Error("getToken is required for recall tool");
|
|
26018
26088
|
}
|
|
26019
26089
|
const resolvedToolOptions = toolOptions?.excludeConversationId !== void 0 || !currentConversationId ? toolOptions : { ...toolOptions, excludeConversationId: currentConversationId };
|
|
26090
|
+
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
26091
|
+
if (memoryStore && resolvedToolOptions?.folderId !== void 0)
|
|
26092
|
+
throw new Error(NO_STORE_FOLDERS);
|
|
26093
|
+
const embeddingOptions = {
|
|
26094
|
+
getToken,
|
|
26095
|
+
baseUrl,
|
|
26096
|
+
model: embeddingModel,
|
|
26097
|
+
maskInput: maskEmbeddingInput
|
|
26098
|
+
};
|
|
26020
26099
|
return createRecallTool(
|
|
26021
|
-
{
|
|
26100
|
+
memoryStore ? {
|
|
26101
|
+
factSource: memoryStore.factSource,
|
|
26102
|
+
...getToken && { storageCtx },
|
|
26103
|
+
embeddingOptions,
|
|
26104
|
+
chunkCache: chunkVectorCacheRef.current
|
|
26105
|
+
} : {
|
|
26022
26106
|
vaultCtx,
|
|
26023
26107
|
storageCtx,
|
|
26024
|
-
embeddingOptions
|
|
26025
|
-
getToken,
|
|
26026
|
-
baseUrl,
|
|
26027
|
-
model: embeddingModel,
|
|
26028
|
-
maskInput: maskEmbeddingInput
|
|
26029
|
-
},
|
|
26108
|
+
embeddingOptions,
|
|
26030
26109
|
vaultCache: vaultEmbeddingCache,
|
|
26031
26110
|
chunkCache: chunkVectorCacheRef.current
|
|
26032
26111
|
},
|
|
26033
|
-
resolvedToolOptions,
|
|
26112
|
+
memoryStore ? { ...resolvedToolOptions, memoryStore } : resolvedToolOptions,
|
|
26034
26113
|
callbacks
|
|
26035
26114
|
);
|
|
26036
26115
|
},
|
|
@@ -26042,12 +26121,14 @@ function useChatStorage(options) {
|
|
|
26042
26121
|
embeddingModel,
|
|
26043
26122
|
currentConversationId,
|
|
26044
26123
|
maskEmbeddingInput,
|
|
26045
|
-
vaultEmbeddingCache
|
|
26124
|
+
vaultEmbeddingCache,
|
|
26125
|
+
memoryStore,
|
|
26126
|
+
storeMaskMissing
|
|
26046
26127
|
]
|
|
26047
26128
|
);
|
|
26048
26129
|
const recallFn = (0, import_react5.useCallback)(
|
|
26049
26130
|
async (query, options2) => {
|
|
26050
|
-
if (!getToken) {
|
|
26131
|
+
if (!getToken && !memoryStore) {
|
|
26051
26132
|
return {
|
|
26052
26133
|
memories: [],
|
|
26053
26134
|
usedBudget: options2?.budget ?? "low",
|
|
@@ -26056,17 +26137,25 @@ function useChatStorage(options) {
|
|
|
26056
26137
|
};
|
|
26057
26138
|
}
|
|
26058
26139
|
const resolvedOptions = options2?.excludeConversationId !== void 0 || !currentConversationId ? options2 : { ...options2, excludeConversationId: currentConversationId };
|
|
26140
|
+
if (storeMaskMissing) throw new Error(NO_STORE_MASK);
|
|
26141
|
+
if (memoryStore && resolvedOptions?.folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
|
|
26142
|
+
const embeddingOptions = {
|
|
26143
|
+
getToken,
|
|
26144
|
+
baseUrl,
|
|
26145
|
+
model: embeddingModel,
|
|
26146
|
+
maskInput: maskEmbeddingInput
|
|
26147
|
+
};
|
|
26059
26148
|
return recall(
|
|
26060
26149
|
query,
|
|
26061
|
-
{
|
|
26150
|
+
memoryStore ? {
|
|
26151
|
+
factSource: memoryStore.factSource,
|
|
26152
|
+
...getToken && { storageCtx },
|
|
26153
|
+
embeddingOptions,
|
|
26154
|
+
chunkCache: chunkVectorCacheRef.current
|
|
26155
|
+
} : {
|
|
26062
26156
|
vaultCtx,
|
|
26063
26157
|
storageCtx,
|
|
26064
|
-
embeddingOptions
|
|
26065
|
-
getToken,
|
|
26066
|
-
baseUrl,
|
|
26067
|
-
model: embeddingModel,
|
|
26068
|
-
maskInput: maskEmbeddingInput
|
|
26069
|
-
},
|
|
26158
|
+
embeddingOptions,
|
|
26070
26159
|
vaultCache: vaultEmbeddingCache,
|
|
26071
26160
|
chunkCache: chunkVectorCacheRef.current
|
|
26072
26161
|
},
|
|
@@ -26081,20 +26170,27 @@ function useChatStorage(options) {
|
|
|
26081
26170
|
embeddingModel,
|
|
26082
26171
|
currentConversationId,
|
|
26083
26172
|
maskEmbeddingInput,
|
|
26084
|
-
vaultEmbeddingCache
|
|
26173
|
+
vaultEmbeddingCache,
|
|
26174
|
+
memoryStore,
|
|
26175
|
+
storeMaskMissing
|
|
26085
26176
|
]
|
|
26086
26177
|
);
|
|
26087
26178
|
const getVaultMemories = (0, import_react5.useCallback)(
|
|
26088
26179
|
(options2) => {
|
|
26089
|
-
return getAllVaultMemoriesOp(vaultCtx, options2);
|
|
26180
|
+
if (!memoryStore) return getAllVaultMemoriesOp(vaultCtx, options2);
|
|
26181
|
+
const { folderId, levels, kinds, ...listOptions } = options2 ?? {};
|
|
26182
|
+
if (folderId !== void 0) throw new Error(NO_STORE_FOLDERS);
|
|
26183
|
+
if (levels !== void 0 || kinds !== void 0)
|
|
26184
|
+
throw new Error("level and kind filters are not supported with a memoryStore");
|
|
26185
|
+
return memoryStore.list(listOptions);
|
|
26090
26186
|
},
|
|
26091
|
-
[vaultCtx]
|
|
26187
|
+
[vaultCtx, memoryStore]
|
|
26092
26188
|
);
|
|
26093
26189
|
const deleteVaultMemory = (0, import_react5.useCallback)(
|
|
26094
26190
|
(id) => {
|
|
26095
|
-
return deleteVaultMemoryOp(vaultCtx, id);
|
|
26191
|
+
return memoryStore ? memoryStore.delete(id) : deleteVaultMemoryOp(vaultCtx, id);
|
|
26096
26192
|
},
|
|
26097
|
-
[vaultCtx]
|
|
26193
|
+
[vaultCtx, memoryStore]
|
|
26098
26194
|
);
|
|
26099
26195
|
const {
|
|
26100
26196
|
isLoading,
|