@anuma/sdk 6.3.1 → 6.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/expo/{chunk-PBCULYOW.mjs → chunk-WYARTNEN.mjs} +49 -1
- package/dist/expo/index.cjs +239 -4
- package/dist/expo/index.d.mts +48 -0
- package/dist/expo/index.d.ts +48 -0
- package/dist/expo/index.mjs +191 -5
- package/dist/expo/{recall-UVM2366D.mjs → recall-7FOWWX5T.mjs} +1 -1
- package/dist/react/{chunk-TI3UVQPF.mjs → chunk-IO4ZCPK2.mjs} +49 -1
- package/dist/react/index.cjs +190 -30
- package/dist/react/index.d.mts +40 -0
- package/dist/react/index.d.ts +40 -0
- package/dist/react/index.mjs +142 -31
- package/dist/react/{recall-PCM7H5TA.mjs → recall-2J2755WC.mjs} +1 -1
- package/dist/server/{chunk-S5WEN7TE.mjs → chunk-EKYGWD5N.mjs} +49 -1
- package/dist/server/index.cjs +49 -0
- package/dist/server/index.mjs +1 -1
- package/dist/server/{recall-BQSCJBGI.mjs → recall-IVV6EILK.mjs} +1 -1
- package/package.json +1 -1
package/dist/react/index.mjs
CHANGED
|
@@ -168,7 +168,7 @@ import {
|
|
|
168
168
|
updateVaultMemoryOp,
|
|
169
169
|
useEncryption,
|
|
170
170
|
vaultMemoryToStored
|
|
171
|
-
} from "./chunk-
|
|
171
|
+
} from "./chunk-IO4ZCPK2.mjs";
|
|
172
172
|
import {
|
|
173
173
|
PiiRedactor,
|
|
174
174
|
createStreamingDeAnonymizer,
|
|
@@ -5350,6 +5350,7 @@ async function cleanupConversationSummary(database, conversationId) {
|
|
|
5350
5350
|
var HEADER = "[Tool Execution Results]\n\n";
|
|
5351
5351
|
var FOOTER = "\n\nBased on these results, continue with the task.";
|
|
5352
5352
|
var ENTRY_SEPARATOR = "\n\n";
|
|
5353
|
+
var TOOL_RESULT_FOOTER_LINE = FOOTER.trim();
|
|
5353
5354
|
var MAX_PERSISTED_TOOL_RESULT_CHARS = 1e5;
|
|
5354
5355
|
function buildToolResultContent(results) {
|
|
5355
5356
|
const entries = results.map((r) => `Tool "${r.name}" returned: ${JSON.stringify(r.result)}`);
|
|
@@ -5359,6 +5360,9 @@ function buildToolResultContent(results) {
|
|
|
5359
5360
|
);
|
|
5360
5361
|
return `${HEADER}${summary}${FOOTER}`;
|
|
5361
5362
|
}
|
|
5363
|
+
function capToolResultEntries(entries, budget) {
|
|
5364
|
+
return capEntries(entries, budget);
|
|
5365
|
+
}
|
|
5362
5366
|
function capEntries(entries, budget) {
|
|
5363
5367
|
const smallestFirst = entries.map((_, index) => index).sort((a, b) => entries[a].length - entries[b].length);
|
|
5364
5368
|
const capped = [...entries];
|
|
@@ -5383,6 +5387,112 @@ function truncationMarker(omitted) {
|
|
|
5383
5387
|
... (tool output truncated, ${omitted} characters omitted)`;
|
|
5384
5388
|
}
|
|
5385
5389
|
|
|
5390
|
+
// src/lib/chat/toolResults.ts
|
|
5391
|
+
var TOOL_RESULTS_PREFIX = "[Tool Execution Results]";
|
|
5392
|
+
var DISPLAY_CARD_PLACEHOLDER = "[displayed a card to the user with the tool result]";
|
|
5393
|
+
var TOOL_LINE = /^Tool "([^"]+)" returned: (.*)$/;
|
|
5394
|
+
var TOOL_RESULT_ORIGIN = "tool_result";
|
|
5395
|
+
function isToolResultsRow(row) {
|
|
5396
|
+
if (row.origin === TOOL_RESULT_ORIGIN) return true;
|
|
5397
|
+
if (typeof row.origin === "string") return false;
|
|
5398
|
+
if (row.role !== "user" || !row.content.startsWith(TOOL_RESULTS_PREFIX)) return false;
|
|
5399
|
+
return parseToolResultSegments(row.content).length > 0;
|
|
5400
|
+
}
|
|
5401
|
+
function parseToolResultSegments(content) {
|
|
5402
|
+
const segments = [];
|
|
5403
|
+
for (const raw of content.split("\n")) {
|
|
5404
|
+
const line = raw.trim();
|
|
5405
|
+
const match = TOOL_LINE.exec(line);
|
|
5406
|
+
if (match) {
|
|
5407
|
+
segments.push({ name: match[1], line });
|
|
5408
|
+
continue;
|
|
5409
|
+
}
|
|
5410
|
+
const current = segments[segments.length - 1];
|
|
5411
|
+
if (!current || line === "" || line === TOOL_RESULT_FOOTER_LINE) continue;
|
|
5412
|
+
if (line === TOOL_RESULTS_PREFIX) continue;
|
|
5413
|
+
current.line = `${current.line}
|
|
5414
|
+
${line}`;
|
|
5415
|
+
}
|
|
5416
|
+
return segments;
|
|
5417
|
+
}
|
|
5418
|
+
function prepareToolResultsForReplay(rows, options) {
|
|
5419
|
+
if (options.fold) {
|
|
5420
|
+
return foldToolResultsRows(rows, {
|
|
5421
|
+
exclude: options.exclude,
|
|
5422
|
+
placeholder: options.placeholder
|
|
5423
|
+
});
|
|
5424
|
+
}
|
|
5425
|
+
return rows.filter((row) => !isToolResultsRow(row));
|
|
5426
|
+
}
|
|
5427
|
+
function foldToolResultsRows(rows, options) {
|
|
5428
|
+
const exclude = new Set(options?.exclude ?? []);
|
|
5429
|
+
const out = [];
|
|
5430
|
+
const pending = [];
|
|
5431
|
+
const assistantIndexById = /* @__PURE__ */ new Map();
|
|
5432
|
+
for (const row of rows) {
|
|
5433
|
+
if (isToolResultsRow(row)) {
|
|
5434
|
+
pending.push({ row, insertionPoint: out.length });
|
|
5435
|
+
continue;
|
|
5436
|
+
}
|
|
5437
|
+
out.push(row);
|
|
5438
|
+
if (row.role === "assistant" && row.uniqueId) {
|
|
5439
|
+
assistantIndexById.set(row.uniqueId, out.length - 1);
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
const byTarget = /* @__PURE__ */ new Map();
|
|
5443
|
+
for (const { row, insertionPoint } of pending) {
|
|
5444
|
+
const target = resolveFoldTarget(out, row, insertionPoint, assistantIndexById);
|
|
5445
|
+
if (target === void 0) continue;
|
|
5446
|
+
const group = byTarget.get(target);
|
|
5447
|
+
if (group) group.push(row);
|
|
5448
|
+
else byTarget.set(target, [row]);
|
|
5449
|
+
}
|
|
5450
|
+
for (const [target, groupedRows] of byTarget) {
|
|
5451
|
+
const assistant = out[target];
|
|
5452
|
+
const kept = groupedRows.flatMap((row) => parseToolResultSegments(row.content)).filter((segment) => !exclude.has(segment.name));
|
|
5453
|
+
if (kept.length > 0) {
|
|
5454
|
+
out[target] = { ...assistant, content: appendToolResults(assistant.content, kept) };
|
|
5455
|
+
} else if (!assistant.content.trim() && options?.placeholder) {
|
|
5456
|
+
out[target] = { ...assistant, content: options.placeholder };
|
|
5457
|
+
}
|
|
5458
|
+
}
|
|
5459
|
+
return out;
|
|
5460
|
+
}
|
|
5461
|
+
function resolveFoldTarget(out, row, insertionPoint, assistantIndexById) {
|
|
5462
|
+
const linked = row.parentMessageId ? assistantIndexById.get(row.parentMessageId) : void 0;
|
|
5463
|
+
if (linked !== void 0) return linked;
|
|
5464
|
+
let previous;
|
|
5465
|
+
for (let i = insertionPoint - 1; i >= 0; i--) {
|
|
5466
|
+
if (out[i].role === "assistant") {
|
|
5467
|
+
previous = i;
|
|
5468
|
+
break;
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5471
|
+
let next;
|
|
5472
|
+
for (let i = insertionPoint; i < out.length; i++) {
|
|
5473
|
+
if (out[i].role === "assistant") {
|
|
5474
|
+
next = i;
|
|
5475
|
+
break;
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5478
|
+
if (previous === void 0) return next;
|
|
5479
|
+
if (next === void 0) return previous;
|
|
5480
|
+
return next - insertionPoint < insertionPoint - previous ? next : previous;
|
|
5481
|
+
}
|
|
5482
|
+
var MAX_FOLDED_APPENDIX_CHARS = 2e4;
|
|
5483
|
+
function appendToolResults(assistantContent, kept) {
|
|
5484
|
+
const framing = TOOL_RESULTS_PREFIX.length + 1 + (kept.length - 1);
|
|
5485
|
+
const capped = capToolResultEntries(
|
|
5486
|
+
kept.map((segment) => segment.line),
|
|
5487
|
+
MAX_FOLDED_APPENDIX_CHARS - framing
|
|
5488
|
+
);
|
|
5489
|
+
const appendix = `${TOOL_RESULTS_PREFIX}
|
|
5490
|
+
${capped.join("\n")}`;
|
|
5491
|
+
return assistantContent.trim() ? `${assistantContent}
|
|
5492
|
+
|
|
5493
|
+
${appendix}` : appendix;
|
|
5494
|
+
}
|
|
5495
|
+
|
|
5386
5496
|
// src/lib/db/chat/lazyDecrypt.ts
|
|
5387
5497
|
var LRU_CAPACITY = 256;
|
|
5388
5498
|
var titleCache = /* @__PURE__ */ new Map();
|
|
@@ -12612,11 +12722,17 @@ function useChatStorage(options) {
|
|
|
12612
12722
|
preProcessors,
|
|
12613
12723
|
piiRedaction,
|
|
12614
12724
|
onPiiRedacted,
|
|
12615
|
-
nerDetector
|
|
12725
|
+
nerDetector,
|
|
12726
|
+
toolResultsHistoryExclude,
|
|
12727
|
+
foldToolResultsInHistory
|
|
12616
12728
|
} = options;
|
|
12617
12729
|
const [currentConversationId, setCurrentConversationId] = useState4(
|
|
12618
12730
|
initialConversationId || null
|
|
12619
12731
|
);
|
|
12732
|
+
const toolResultsHistoryExcludeRef = useRef4(toolResultsHistoryExclude);
|
|
12733
|
+
toolResultsHistoryExcludeRef.current = toolResultsHistoryExclude;
|
|
12734
|
+
const foldToolResultsInHistoryRef = useRef4(foldToolResultsInHistory);
|
|
12735
|
+
foldToolResultsInHistoryRef.current = foldToolResultsInHistory;
|
|
12620
12736
|
const nerDetectorRef = useRef4(nerDetector);
|
|
12621
12737
|
nerDetectorRef.current = nerDetector;
|
|
12622
12738
|
const resolvedPiiRedaction = useMemo3(
|
|
@@ -13624,7 +13740,12 @@ function useChatStorage(options) {
|
|
|
13624
13740
|
}
|
|
13625
13741
|
if (includeHistory) {
|
|
13626
13742
|
const validMessages = storedMessages.filter((msg) => !msg.error);
|
|
13627
|
-
const
|
|
13743
|
+
const replayableMessages = prepareToolResultsForReplay(validMessages, {
|
|
13744
|
+
fold: foldToolResultsInHistoryRef.current === true,
|
|
13745
|
+
exclude: toolResultsHistoryExcludeRef.current,
|
|
13746
|
+
placeholder: DISPLAY_CARD_PLACEHOLDER
|
|
13747
|
+
});
|
|
13748
|
+
const limitedMessages = replayableMessages.slice(-maxHistoryMessages);
|
|
13628
13749
|
if (!fileContextForRequest) {
|
|
13629
13750
|
for (let i = limitedMessages.length - 1; i >= 0; i--) {
|
|
13630
13751
|
const msg = limitedMessages[i];
|
|
@@ -13634,6 +13755,7 @@ function useChatStorage(options) {
|
|
|
13634
13755
|
}
|
|
13635
13756
|
}
|
|
13636
13757
|
}
|
|
13758
|
+
const foldedHistory = limitedMessages;
|
|
13637
13759
|
let encryptionKey;
|
|
13638
13760
|
if (walletAddress && hasEncryptionKey(walletAddress) && isOPFSSupported()) {
|
|
13639
13761
|
try {
|
|
@@ -13650,7 +13772,7 @@ function useChatStorage(options) {
|
|
|
13650
13772
|
const { messagesToConvert, summarySystemMessage } = await maybeSummarizeHistory({
|
|
13651
13773
|
database,
|
|
13652
13774
|
conversationId: convId,
|
|
13653
|
-
messages:
|
|
13775
|
+
messages: foldedHistory,
|
|
13654
13776
|
summarizeHistory,
|
|
13655
13777
|
summaryTokenThreshold,
|
|
13656
13778
|
summaryMinWindowMessages,
|
|
@@ -14108,37 +14230,25 @@ function useChatStorage(options) {
|
|
|
14108
14230
|
}
|
|
14109
14231
|
}
|
|
14110
14232
|
const autoToolResults = result.autoExecutedToolResults;
|
|
14233
|
+
let storedToolResultsMessage;
|
|
14111
14234
|
if (autoToolResults && autoToolResults.length > 0) {
|
|
14112
|
-
const
|
|
14235
|
+
const toolResultsOpts = {
|
|
14236
|
+
conversationId: convId,
|
|
14237
|
+
role: "user",
|
|
14238
|
+
content: buildToolResultContent(autoToolResults),
|
|
14239
|
+
model: "",
|
|
14240
|
+
parentMessageId: storedAssistantMessage.uniqueId,
|
|
14241
|
+
origin: TOOL_RESULT_ORIGIN
|
|
14242
|
+
};
|
|
14113
14243
|
try {
|
|
14114
|
-
await writeOrQueue(
|
|
14244
|
+
const toolResultsWrite = await writeOrQueue(
|
|
14115
14245
|
"createMessage",
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
content: toolResultContent,
|
|
14120
|
-
model: "",
|
|
14121
|
-
parentMessageId: storedAssistantMessage.uniqueId,
|
|
14122
|
-
origin: "tool_result"
|
|
14123
|
-
},
|
|
14124
|
-
() => createMessageOp(storageCtx, {
|
|
14125
|
-
conversationId: convId,
|
|
14126
|
-
role: "user",
|
|
14127
|
-
content: toolResultContent,
|
|
14128
|
-
model: "",
|
|
14129
|
-
parentMessageId: storedAssistantMessage.uniqueId,
|
|
14130
|
-
origin: "tool_result"
|
|
14131
|
-
}),
|
|
14132
|
-
() => makeSyntheticStoredMessage({
|
|
14133
|
-
conversationId: convId,
|
|
14134
|
-
role: "user",
|
|
14135
|
-
content: toolResultContent,
|
|
14136
|
-
model: "",
|
|
14137
|
-
parentMessageId: storedAssistantMessage.uniqueId,
|
|
14138
|
-
origin: "tool_result"
|
|
14139
|
-
}),
|
|
14246
|
+
toolResultsOpts,
|
|
14247
|
+
() => createMessageOp(storageCtx, toolResultsOpts),
|
|
14248
|
+
() => makeSyntheticStoredMessage(toolResultsOpts),
|
|
14140
14249
|
assistantMsgQueueId ? [assistantMsgQueueId] : []
|
|
14141
14250
|
);
|
|
14251
|
+
storedToolResultsMessage = toolResultsWrite.result;
|
|
14142
14252
|
} catch {
|
|
14143
14253
|
}
|
|
14144
14254
|
}
|
|
@@ -14161,7 +14271,8 @@ function useChatStorage(options) {
|
|
|
14161
14271
|
error: null,
|
|
14162
14272
|
userMessage: storedUserMessage,
|
|
14163
14273
|
assistantMessage: storedAssistantMessage,
|
|
14164
|
-
autoExecutedToolResults:
|
|
14274
|
+
autoExecutedToolResults: autoToolResults,
|
|
14275
|
+
toolResultsMessage: storedToolResultsMessage
|
|
14165
14276
|
};
|
|
14166
14277
|
},
|
|
14167
14278
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- intentionally omitting stable refs and config values that don't change identity
|
|
@@ -18832,6 +18832,12 @@ async function embedMessage(ctx, messageId, options) {
|
|
|
18832
18832
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) {
|
|
18833
18833
|
return message;
|
|
18834
18834
|
}
|
|
18835
|
+
if (isEncrypted(message.content)) {
|
|
18836
|
+
getLogger().warn(
|
|
18837
|
+
`memoryEngine: message ${messageId} is still encrypted (key unavailable?) \u2014 not embedded`
|
|
18838
|
+
);
|
|
18839
|
+
return message;
|
|
18840
|
+
}
|
|
18835
18841
|
const embedding = await generateEmbedding(message.content, options);
|
|
18836
18842
|
const embeddingModel = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
18837
18843
|
return updateMessageEmbeddingOp(ctx, messageId, embedding, embeddingModel);
|
|
@@ -18839,11 +18845,17 @@ async function embedMessage(ctx, messageId, options) {
|
|
|
18839
18845
|
async function embedAllMessages(ctx, options, filter) {
|
|
18840
18846
|
const embeddingModel = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
18841
18847
|
let embeddedCount = 0;
|
|
18848
|
+
let stillEncrypted = 0;
|
|
18849
|
+
let considered = 0;
|
|
18850
|
+
let sealedRowsSeen = 0;
|
|
18851
|
+
let rowsSeen = 0;
|
|
18842
18852
|
const conversations = await getConversationsOp(ctx);
|
|
18843
18853
|
const targetConversations = filter?.conversationId ? conversations.filter((c) => c.conversationId === filter.conversationId) : conversations;
|
|
18844
18854
|
for (const conv of targetConversations) {
|
|
18845
18855
|
const messages = await getMessagesOp(ctx, conv.conversationId);
|
|
18846
18856
|
for (const message of messages) {
|
|
18857
|
+
rowsSeen++;
|
|
18858
|
+
if (isEncrypted(message.content)) sealedRowsSeen++;
|
|
18847
18859
|
if (message.vector && message.vector.length > 0) {
|
|
18848
18860
|
continue;
|
|
18849
18861
|
}
|
|
@@ -18856,6 +18868,11 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
18856
18868
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) {
|
|
18857
18869
|
continue;
|
|
18858
18870
|
}
|
|
18871
|
+
considered++;
|
|
18872
|
+
if (isEncrypted(message.content)) {
|
|
18873
|
+
stillEncrypted++;
|
|
18874
|
+
continue;
|
|
18875
|
+
}
|
|
18859
18876
|
const minLength = filter?.minContentLength ?? DEFAULT_MIN_CONTENT_LENGTH;
|
|
18860
18877
|
if (message.content.length < minLength) {
|
|
18861
18878
|
continue;
|
|
@@ -18870,6 +18887,13 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
18870
18887
|
}
|
|
18871
18888
|
}
|
|
18872
18889
|
}
|
|
18890
|
+
if (stillEncrypted > 0 || sealedRowsSeen > 0) {
|
|
18891
|
+
getLogger().error(
|
|
18892
|
+
"memoryEngine: messages still encrypted (key unavailable?) \u2014 excluded from embedding",
|
|
18893
|
+
void 0,
|
|
18894
|
+
{ stillEncrypted, considered, sealedRowsSeen, rowsSeen }
|
|
18895
|
+
);
|
|
18896
|
+
}
|
|
18873
18897
|
return embeddedCount;
|
|
18874
18898
|
}
|
|
18875
18899
|
async function chunkAndEmbedMessage(ctx, messageId, options) {
|
|
@@ -18884,6 +18908,12 @@ async function chunkAndEmbedMessage(ctx, messageId, options) {
|
|
|
18884
18908
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) {
|
|
18885
18909
|
return message;
|
|
18886
18910
|
}
|
|
18911
|
+
if (isEncrypted(message.content)) {
|
|
18912
|
+
getLogger().warn(
|
|
18913
|
+
`memoryEngine: message ${messageId} is still encrypted (key unavailable?) \u2014 not embedded`
|
|
18914
|
+
);
|
|
18915
|
+
return message;
|
|
18916
|
+
}
|
|
18887
18917
|
const embeddingModel = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
18888
18918
|
if (!shouldChunkMessage(message.content, chunkSize)) {
|
|
18889
18919
|
const embedding = await generateEmbedding(message.content, options);
|
|
@@ -18908,9 +18938,15 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
18908
18938
|
const targetConversations = filter?.conversationId ? conversations.filter((c) => c.conversationId === filter.conversationId) : conversations;
|
|
18909
18939
|
const shortMessages = [];
|
|
18910
18940
|
const longMessages = [];
|
|
18941
|
+
let stillEncrypted = 0;
|
|
18942
|
+
let considered = 0;
|
|
18943
|
+
let sealedRowsSeen = 0;
|
|
18944
|
+
let rowsSeen = 0;
|
|
18911
18945
|
for (const conv of targetConversations) {
|
|
18912
18946
|
const messages = await getMessagesOp(ctx, conv.conversationId);
|
|
18913
18947
|
for (const message of messages) {
|
|
18948
|
+
rowsSeen++;
|
|
18949
|
+
if (isEncrypted(message.content)) sealedRowsSeen++;
|
|
18914
18950
|
const isStale = message.embeddingModel !== void 0 && message.embeddingModel !== null && message.embeddingModel !== embeddingModel;
|
|
18915
18951
|
if (message.chunks && message.chunks.length > 0 && !isStale) continue;
|
|
18916
18952
|
const hasVector = message.vector && message.vector.length > 0;
|
|
@@ -18918,6 +18954,11 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
18918
18954
|
if (filter?.roles && !filter.roles.includes(message.role)) continue;
|
|
18919
18955
|
if (message.role === "system") continue;
|
|
18920
18956
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) continue;
|
|
18957
|
+
considered++;
|
|
18958
|
+
if (isEncrypted(message.content)) {
|
|
18959
|
+
stillEncrypted++;
|
|
18960
|
+
continue;
|
|
18961
|
+
}
|
|
18921
18962
|
if (message.content.length < minLength) continue;
|
|
18922
18963
|
if (shouldChunkMessage(message.content, chunkSize)) {
|
|
18923
18964
|
longMessages.push({
|
|
@@ -18929,6 +18970,13 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
18929
18970
|
}
|
|
18930
18971
|
}
|
|
18931
18972
|
}
|
|
18973
|
+
if (stillEncrypted > 0 || sealedRowsSeen > 0) {
|
|
18974
|
+
getLogger().error(
|
|
18975
|
+
"memoryEngine: messages still encrypted (key unavailable?) \u2014 excluded from embedding",
|
|
18976
|
+
void 0,
|
|
18977
|
+
{ stillEncrypted, considered, sealedRowsSeen, rowsSeen }
|
|
18978
|
+
);
|
|
18979
|
+
}
|
|
18932
18980
|
let embeddedCount = 0;
|
|
18933
18981
|
if (shortMessages.length > 0) {
|
|
18934
18982
|
try {
|
|
@@ -20709,7 +20757,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
20709
20757
|
subQueries = decomp.subQueries;
|
|
20710
20758
|
}
|
|
20711
20759
|
}
|
|
20712
|
-
const { recall: recall2 } = await import("./recall-
|
|
20760
|
+
const { recall: recall2 } = await import("./recall-IVV6EILK.mjs");
|
|
20713
20761
|
let recallDegraded = [];
|
|
20714
20762
|
const result = await recall2(
|
|
20715
20763
|
query,
|
package/dist/server/index.cjs
CHANGED
|
@@ -19753,6 +19753,12 @@ async function embedMessage(ctx, messageId, options) {
|
|
|
19753
19753
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) {
|
|
19754
19754
|
return message;
|
|
19755
19755
|
}
|
|
19756
|
+
if (isEncrypted(message.content)) {
|
|
19757
|
+
getLogger().warn(
|
|
19758
|
+
`memoryEngine: message ${messageId} is still encrypted (key unavailable?) \u2014 not embedded`
|
|
19759
|
+
);
|
|
19760
|
+
return message;
|
|
19761
|
+
}
|
|
19756
19762
|
const embedding = await generateEmbedding(message.content, options);
|
|
19757
19763
|
const embeddingModel = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
19758
19764
|
return updateMessageEmbeddingOp(ctx, messageId, embedding, embeddingModel);
|
|
@@ -19760,11 +19766,17 @@ async function embedMessage(ctx, messageId, options) {
|
|
|
19760
19766
|
async function embedAllMessages(ctx, options, filter) {
|
|
19761
19767
|
const embeddingModel = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
19762
19768
|
let embeddedCount = 0;
|
|
19769
|
+
let stillEncrypted = 0;
|
|
19770
|
+
let considered = 0;
|
|
19771
|
+
let sealedRowsSeen = 0;
|
|
19772
|
+
let rowsSeen = 0;
|
|
19763
19773
|
const conversations = await getConversationsOp(ctx);
|
|
19764
19774
|
const targetConversations = filter?.conversationId ? conversations.filter((c) => c.conversationId === filter.conversationId) : conversations;
|
|
19765
19775
|
for (const conv of targetConversations) {
|
|
19766
19776
|
const messages = await getMessagesOp(ctx, conv.conversationId);
|
|
19767
19777
|
for (const message of messages) {
|
|
19778
|
+
rowsSeen++;
|
|
19779
|
+
if (isEncrypted(message.content)) sealedRowsSeen++;
|
|
19768
19780
|
if (message.vector && message.vector.length > 0) {
|
|
19769
19781
|
continue;
|
|
19770
19782
|
}
|
|
@@ -19777,6 +19789,11 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
19777
19789
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) {
|
|
19778
19790
|
continue;
|
|
19779
19791
|
}
|
|
19792
|
+
considered++;
|
|
19793
|
+
if (isEncrypted(message.content)) {
|
|
19794
|
+
stillEncrypted++;
|
|
19795
|
+
continue;
|
|
19796
|
+
}
|
|
19780
19797
|
const minLength = filter?.minContentLength ?? DEFAULT_MIN_CONTENT_LENGTH;
|
|
19781
19798
|
if (message.content.length < minLength) {
|
|
19782
19799
|
continue;
|
|
@@ -19791,6 +19808,13 @@ async function embedAllMessages(ctx, options, filter) {
|
|
|
19791
19808
|
}
|
|
19792
19809
|
}
|
|
19793
19810
|
}
|
|
19811
|
+
if (stillEncrypted > 0 || sealedRowsSeen > 0) {
|
|
19812
|
+
getLogger().error(
|
|
19813
|
+
"memoryEngine: messages still encrypted (key unavailable?) \u2014 excluded from embedding",
|
|
19814
|
+
void 0,
|
|
19815
|
+
{ stillEncrypted, considered, sealedRowsSeen, rowsSeen }
|
|
19816
|
+
);
|
|
19817
|
+
}
|
|
19794
19818
|
return embeddedCount;
|
|
19795
19819
|
}
|
|
19796
19820
|
async function chunkAndEmbedMessage(ctx, messageId, options) {
|
|
@@ -19805,6 +19829,12 @@ async function chunkAndEmbedMessage(ctx, messageId, options) {
|
|
|
19805
19829
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) {
|
|
19806
19830
|
return message;
|
|
19807
19831
|
}
|
|
19832
|
+
if (isEncrypted(message.content)) {
|
|
19833
|
+
getLogger().warn(
|
|
19834
|
+
`memoryEngine: message ${messageId} is still encrypted (key unavailable?) \u2014 not embedded`
|
|
19835
|
+
);
|
|
19836
|
+
return message;
|
|
19837
|
+
}
|
|
19808
19838
|
const embeddingModel = options.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
19809
19839
|
if (!shouldChunkMessage(message.content, chunkSize)) {
|
|
19810
19840
|
const embedding = await generateEmbedding(message.content, options);
|
|
@@ -19829,9 +19859,15 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
19829
19859
|
const targetConversations = filter?.conversationId ? conversations.filter((c) => c.conversationId === filter.conversationId) : conversations;
|
|
19830
19860
|
const shortMessages = [];
|
|
19831
19861
|
const longMessages = [];
|
|
19862
|
+
let stillEncrypted = 0;
|
|
19863
|
+
let considered = 0;
|
|
19864
|
+
let sealedRowsSeen = 0;
|
|
19865
|
+
let rowsSeen = 0;
|
|
19832
19866
|
for (const conv of targetConversations) {
|
|
19833
19867
|
const messages = await getMessagesOp(ctx, conv.conversationId);
|
|
19834
19868
|
for (const message of messages) {
|
|
19869
|
+
rowsSeen++;
|
|
19870
|
+
if (isEncrypted(message.content)) sealedRowsSeen++;
|
|
19835
19871
|
const isStale = message.embeddingModel !== void 0 && message.embeddingModel !== null && message.embeddingModel !== embeddingModel;
|
|
19836
19872
|
if (message.chunks && message.chunks.length > 0 && !isStale) continue;
|
|
19837
19873
|
const hasVector = message.vector && message.vector.length > 0;
|
|
@@ -19839,6 +19875,11 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
19839
19875
|
if (filter?.roles && !filter.roles.includes(message.role)) continue;
|
|
19840
19876
|
if (message.role === "system") continue;
|
|
19841
19877
|
if (message.origin === NON_EMBEDDABLE_ORIGIN) continue;
|
|
19878
|
+
considered++;
|
|
19879
|
+
if (isEncrypted(message.content)) {
|
|
19880
|
+
stillEncrypted++;
|
|
19881
|
+
continue;
|
|
19882
|
+
}
|
|
19842
19883
|
if (message.content.length < minLength) continue;
|
|
19843
19884
|
if (shouldChunkMessage(message.content, chunkSize)) {
|
|
19844
19885
|
longMessages.push({
|
|
@@ -19850,6 +19891,13 @@ async function chunkAndEmbedAllMessages(ctx, options, filter) {
|
|
|
19850
19891
|
}
|
|
19851
19892
|
}
|
|
19852
19893
|
}
|
|
19894
|
+
if (stillEncrypted > 0 || sealedRowsSeen > 0) {
|
|
19895
|
+
getLogger().error(
|
|
19896
|
+
"memoryEngine: messages still encrypted (key unavailable?) \u2014 excluded from embedding",
|
|
19897
|
+
void 0,
|
|
19898
|
+
{ stillEncrypted, considered, sealedRowsSeen, rowsSeen }
|
|
19899
|
+
);
|
|
19900
|
+
}
|
|
19853
19901
|
let embeddedCount = 0;
|
|
19854
19902
|
if (shortMessages.length > 0) {
|
|
19855
19903
|
try {
|
|
@@ -19900,6 +19948,7 @@ var init_embeddings = __esm({
|
|
|
19900
19948
|
"src/lib/memoryEngine/embeddings.ts"() {
|
|
19901
19949
|
"use strict";
|
|
19902
19950
|
init_operations();
|
|
19951
|
+
init_encryption_utils();
|
|
19903
19952
|
init_logger();
|
|
19904
19953
|
init_chunking();
|
|
19905
19954
|
init_constants();
|
package/dist/server/index.mjs
CHANGED