@anuma/sdk 6.0.0 → 6.1.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/{chunk-5QINPRGH.mjs → chunk-LMGWHYUM.mjs} +66 -17
- package/dist/expo/index.cjs +65 -16
- package/dist/expo/index.d.mts +21 -0
- package/dist/expo/index.d.ts +21 -0
- package/dist/expo/index.mjs +1 -1
- package/dist/expo/{recall-6CZ7MYHF.mjs → recall-JAV5PSNS.mjs} +1 -1
- package/dist/react/{chunk-2V5CMLGK.mjs → chunk-VE45E4KF.mjs} +66 -17
- package/dist/react/index.cjs +65 -16
- package/dist/react/index.d.mts +21 -0
- package/dist/react/index.d.ts +21 -0
- package/dist/react/index.mjs +1 -1
- package/dist/react/{recall-OKP4SCC4.mjs → recall-VZSBCGXW.mjs} +1 -1
- package/dist/server/{chunk-FKVYUOSD.mjs → chunk-EKKMINMD.mjs} +66 -17
- package/dist/server/index.cjs +65 -16
- package/dist/server/index.d.mts +21 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.mjs +1 -1
- package/dist/server/{recall-74L75BJ3.mjs → recall-PQ2RUQXJ.mjs} +1 -1
- package/package.json +3 -3
|
@@ -20011,6 +20011,7 @@ function admitVaultProjections(queryEmbedding, vectored, k) {
|
|
|
20011
20011
|
return vectored.map((it) => ({ it, score: cosineSimilarity(queryEmbedding, it.embedding) })).sort((a, b) => b.score - a.score || b.it.updatedAt.getTime() - a.it.updatedAt.getTime()).slice(0, k).map((s) => s.it.uniqueId);
|
|
20012
20012
|
}
|
|
20013
20013
|
async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, queryOpts, opts) {
|
|
20014
|
+
let rowsDecrypted = 0;
|
|
20014
20015
|
const keys = await getVaultCandidateKeysOp(
|
|
20015
20016
|
vaultCtx,
|
|
20016
20017
|
Object.keys(queryOpts).length > 0 ? queryOpts : void 0
|
|
@@ -20023,7 +20024,8 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20023
20024
|
embeddedItems: [],
|
|
20024
20025
|
queryEmbedding: [],
|
|
20025
20026
|
vaultSize: 0,
|
|
20026
|
-
laneEmbedFailed: false
|
|
20027
|
+
laneEmbedFailed: false,
|
|
20028
|
+
rowsDecrypted: 0
|
|
20027
20029
|
};
|
|
20028
20030
|
}
|
|
20029
20031
|
const queryEmbedding = await embedQueryOrDegrade(
|
|
@@ -20069,6 +20071,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20069
20071
|
for (const id of missIds) if (!gotVector.has(id)) noVectorIds.push(id);
|
|
20070
20072
|
}
|
|
20071
20073
|
let laneEmbedFailed = false;
|
|
20074
|
+
const laneById = /* @__PURE__ */ new Map();
|
|
20072
20075
|
if (noVectorIds.length > 0) {
|
|
20073
20076
|
const laneIds = noVectorIds.slice(0, opts.unembeddedCap);
|
|
20074
20077
|
if (noVectorIds.length > laneIds.length) {
|
|
@@ -20076,9 +20079,10 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20076
20079
|
`memoryVault: projected search un-embedded lane capped at ${laneIds.length}/${noVectorIds.length}`
|
|
20077
20080
|
);
|
|
20078
20081
|
}
|
|
20079
|
-
const
|
|
20080
|
-
|
|
20081
|
-
);
|
|
20082
|
+
const laneFetched = await getVaultMemoriesByIdsOp(vaultCtx, laneIds, hydrateOpts);
|
|
20083
|
+
rowsDecrypted += laneFetched.length;
|
|
20084
|
+
for (const row of laneFetched) laneById.set(row.uniqueId, row);
|
|
20085
|
+
const laneRows = laneFetched.filter((m) => !isEncrypted(m.content));
|
|
20082
20086
|
if (laneRows.length > 0) {
|
|
20083
20087
|
let laneVecs;
|
|
20084
20088
|
try {
|
|
@@ -20124,7 +20128,16 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20124
20128
|
if (keyById.has(id)) admissionSet.add(id);
|
|
20125
20129
|
}
|
|
20126
20130
|
}
|
|
20127
|
-
const
|
|
20131
|
+
const idsToFetch = [...admissionSet].filter((id) => !laneById.has(id));
|
|
20132
|
+
const fetched = idsToFetch.length > 0 ? await getVaultMemoriesByIdsOp(vaultCtx, idsToFetch, hydrateOpts) : [];
|
|
20133
|
+
rowsDecrypted += fetched.length;
|
|
20134
|
+
const admittedRows = [
|
|
20135
|
+
...fetched,
|
|
20136
|
+
...[...admissionSet].flatMap((id) => {
|
|
20137
|
+
const reused = laneById.get(id);
|
|
20138
|
+
return reused ? [reused] : [];
|
|
20139
|
+
})
|
|
20140
|
+
];
|
|
20128
20141
|
const memories = admittedRows.filter((m) => !isEncrypted(m.content));
|
|
20129
20142
|
if (memories.length < admittedRows.length) {
|
|
20130
20143
|
getLogger().warn(
|
|
@@ -20145,7 +20158,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20145
20158
|
eventTimeKind: normalizeEventTimeKind(m.eventTimeKind),
|
|
20146
20159
|
factType: m.factType
|
|
20147
20160
|
}));
|
|
20148
|
-
return { memories, embeddedItems, queryEmbedding, vaultSize, laneEmbedFailed };
|
|
20161
|
+
return { memories, embeddedItems, queryEmbedding, vaultSize, laneEmbedFailed, rowsDecrypted };
|
|
20149
20162
|
}
|
|
20150
20163
|
async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache, searchOptions) {
|
|
20151
20164
|
if (!query || typeof query !== "string") {
|
|
@@ -20155,7 +20168,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20155
20168
|
queryEmbedding: [],
|
|
20156
20169
|
vaultSize: 0,
|
|
20157
20170
|
embeddingsUnavailable: false,
|
|
20158
|
-
embeddingFailure: false
|
|
20171
|
+
embeddingFailure: false,
|
|
20172
|
+
decryptLast: !!searchOptions?.decryptLast,
|
|
20173
|
+
rowsDecrypted: 0
|
|
20159
20174
|
};
|
|
20160
20175
|
}
|
|
20161
20176
|
const limit = searchOptions?.limit ?? 5;
|
|
@@ -20173,6 +20188,7 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20173
20188
|
let embeddedItems;
|
|
20174
20189
|
let queryEmbedding;
|
|
20175
20190
|
let vaultSize;
|
|
20191
|
+
let rowsDecrypted;
|
|
20176
20192
|
let embeddingsUnavailable = false;
|
|
20177
20193
|
let embeddingFailure = false;
|
|
20178
20194
|
const onEmbeddingDegraded = () => {
|
|
@@ -20199,10 +20215,13 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20199
20215
|
queryEmbedding: [],
|
|
20200
20216
|
vaultSize: 0,
|
|
20201
20217
|
embeddingsUnavailable: false,
|
|
20202
|
-
embeddingFailure: false
|
|
20218
|
+
embeddingFailure: false,
|
|
20219
|
+
decryptLast: true,
|
|
20220
|
+
rowsDecrypted: corpus.rowsDecrypted
|
|
20203
20221
|
};
|
|
20204
20222
|
}
|
|
20205
20223
|
({ memories, embeddedItems, queryEmbedding, vaultSize } = corpus);
|
|
20224
|
+
rowsDecrypted = corpus.rowsDecrypted;
|
|
20206
20225
|
if (corpus.laneEmbedFailed) embeddingFailure = true;
|
|
20207
20226
|
if (memories.length === 0) {
|
|
20208
20227
|
return {
|
|
@@ -20211,7 +20230,11 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20211
20230
|
queryEmbedding: [],
|
|
20212
20231
|
vaultSize,
|
|
20213
20232
|
embeddingsUnavailable,
|
|
20214
|
-
embeddingFailure
|
|
20233
|
+
embeddingFailure,
|
|
20234
|
+
decryptLast: true,
|
|
20235
|
+
// Rows WERE decrypt-attempted even though none came back readable — that
|
|
20236
|
+
// is the whole point of reporting attempts rather than successes.
|
|
20237
|
+
rowsDecrypted: corpus.rowsDecrypted
|
|
20215
20238
|
};
|
|
20216
20239
|
}
|
|
20217
20240
|
} else {
|
|
@@ -20220,6 +20243,7 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20220
20243
|
Object.keys(queryOpts).length > 0 ? queryOpts : void 0
|
|
20221
20244
|
);
|
|
20222
20245
|
vaultSize = loaded.length;
|
|
20246
|
+
rowsDecrypted = loaded.length;
|
|
20223
20247
|
memories = loaded.filter((m) => !isEncrypted(m.content));
|
|
20224
20248
|
if (memories.length < loaded.length) {
|
|
20225
20249
|
getLogger().warn(
|
|
@@ -20233,7 +20257,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20233
20257
|
queryEmbedding: [],
|
|
20234
20258
|
vaultSize: loaded.length,
|
|
20235
20259
|
embeddingsUnavailable: false,
|
|
20236
|
-
embeddingFailure: false
|
|
20260
|
+
embeddingFailure: false,
|
|
20261
|
+
decryptLast: false,
|
|
20262
|
+
rowsDecrypted: loaded.length
|
|
20237
20263
|
};
|
|
20238
20264
|
}
|
|
20239
20265
|
queryEmbedding = await embedQueryOrDegrade(query, embeddingOptions, onEmbeddingDegraded);
|
|
@@ -20318,7 +20344,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20318
20344
|
queryEmbedding,
|
|
20319
20345
|
vaultSize,
|
|
20320
20346
|
embeddingsUnavailable,
|
|
20321
|
-
embeddingFailure
|
|
20347
|
+
embeddingFailure,
|
|
20348
|
+
decryptLast: !!searchOptions?.decryptLast,
|
|
20349
|
+
rowsDecrypted
|
|
20322
20350
|
};
|
|
20323
20351
|
}
|
|
20324
20352
|
async function rankPreparedVaultCandidates(query, prepared, embeddingOptions, searchOptions) {
|
|
@@ -20486,7 +20514,11 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20486
20514
|
reranked: false,
|
|
20487
20515
|
hadV2Head: false,
|
|
20488
20516
|
embeddingsUnavailable: false,
|
|
20489
|
-
rankedOnCosine: false
|
|
20517
|
+
rankedOnCosine: false,
|
|
20518
|
+
// No storage read happened, so nothing was decrypted; report the path the
|
|
20519
|
+
// caller asked for so this turn is still attributable.
|
|
20520
|
+
decryptLast: !!searchOptions?.decryptLast,
|
|
20521
|
+
rowsDecrypted: 0
|
|
20490
20522
|
};
|
|
20491
20523
|
}
|
|
20492
20524
|
if (searchOptions?.decompose === "llm" && normalizeSubQueries(searchOptions.subQueries).length < 2 && !warnedProgrammaticDecomposeIgnored) {
|
|
@@ -20509,7 +20541,9 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20509
20541
|
reranked: false,
|
|
20510
20542
|
hadV2Head: false,
|
|
20511
20543
|
embeddingsUnavailable: prepared.embeddingsUnavailable,
|
|
20512
|
-
rankedOnCosine: false
|
|
20544
|
+
rankedOnCosine: false,
|
|
20545
|
+
decryptLast: prepared.decryptLast,
|
|
20546
|
+
rowsDecrypted: prepared.rowsDecrypted
|
|
20513
20547
|
};
|
|
20514
20548
|
}
|
|
20515
20549
|
if (prepared.memories.length === 0) {
|
|
@@ -20519,7 +20553,9 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20519
20553
|
reranked: false,
|
|
20520
20554
|
hadV2Head: false,
|
|
20521
20555
|
embeddingsUnavailable: prepared.embeddingsUnavailable,
|
|
20522
|
-
rankedOnCosine: false
|
|
20556
|
+
rankedOnCosine: false,
|
|
20557
|
+
decryptLast: prepared.decryptLast,
|
|
20558
|
+
rowsDecrypted: prepared.rowsDecrypted
|
|
20523
20559
|
};
|
|
20524
20560
|
}
|
|
20525
20561
|
const ranked = await rankPreparedVaultCandidates(
|
|
@@ -20528,7 +20564,12 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20528
20564
|
embeddingOptions,
|
|
20529
20565
|
searchOptions
|
|
20530
20566
|
);
|
|
20531
|
-
return {
|
|
20567
|
+
return {
|
|
20568
|
+
...ranked,
|
|
20569
|
+
rankedOnCosine: !ranked.embeddingsUnavailable,
|
|
20570
|
+
decryptLast: prepared.decryptLast,
|
|
20571
|
+
rowsDecrypted: prepared.rowsDecrypted
|
|
20572
|
+
};
|
|
20532
20573
|
}
|
|
20533
20574
|
async function searchVaultMemories(query, vaultCtx, embeddingOptions, cache, searchOptions) {
|
|
20534
20575
|
const { results } = await searchVaultMemoriesWithSize(
|
|
@@ -20632,7 +20673,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
20632
20673
|
subQueries = decomp.subQueries;
|
|
20633
20674
|
}
|
|
20634
20675
|
}
|
|
20635
|
-
const { recall: recall2 } = await import("./recall-
|
|
20676
|
+
const { recall: recall2 } = await import("./recall-PQ2RUQXJ.mjs");
|
|
20636
20677
|
let recallDegraded = [];
|
|
20637
20678
|
const result = await recall2(
|
|
20638
20679
|
query,
|
|
@@ -21217,6 +21258,8 @@ async function recall(query, ctx, options = {}) {
|
|
|
21217
21258
|
let embeddingsUnavailable = false;
|
|
21218
21259
|
let chunkEmbedFailed = false;
|
|
21219
21260
|
let factLaneRankedOnCosine = false;
|
|
21261
|
+
let decryptLastRan;
|
|
21262
|
+
let vaultRowsDecrypted;
|
|
21220
21263
|
const emitDiagnostics = (candidateCount) => {
|
|
21221
21264
|
const cb = options.onDiagnostics;
|
|
21222
21265
|
if (!cb) return;
|
|
@@ -21233,6 +21276,8 @@ async function recall(query, ctx, options = {}) {
|
|
|
21233
21276
|
reranked: didRerank,
|
|
21234
21277
|
candidateCount,
|
|
21235
21278
|
...vaultSize !== void 0 && { vaultSize },
|
|
21279
|
+
...decryptLastRan !== void 0 && { decryptLast: decryptLastRan },
|
|
21280
|
+
...vaultRowsDecrypted !== void 0 && { vaultRowsDecrypted },
|
|
21236
21281
|
factCount: factResults.length,
|
|
21237
21282
|
chunkCount: chunkResults.length,
|
|
21238
21283
|
timings: {
|
|
@@ -21304,7 +21349,9 @@ async function recall(query, ctx, options = {}) {
|
|
|
21304
21349
|
reranked,
|
|
21305
21350
|
hadV2Head: v2Head,
|
|
21306
21351
|
embeddingsUnavailable: factEmbeddingsUnavailable,
|
|
21307
|
-
rankedOnCosine: factRankedOnCosine
|
|
21352
|
+
rankedOnCosine: factRankedOnCosine,
|
|
21353
|
+
decryptLast: factDecryptLast,
|
|
21354
|
+
rowsDecrypted: factRowsDecrypted
|
|
21308
21355
|
} = await searchVaultMemoriesWithSize(
|
|
21309
21356
|
query,
|
|
21310
21357
|
ctx.vaultCtx,
|
|
@@ -21361,6 +21408,8 @@ async function recall(query, ctx, options = {}) {
|
|
|
21361
21408
|
hadV2Head = v2Head;
|
|
21362
21409
|
if (factEmbeddingsUnavailable) embeddingsUnavailable = true;
|
|
21363
21410
|
factLaneRankedOnCosine = factRankedOnCosine;
|
|
21411
|
+
decryptLastRan = factDecryptLast;
|
|
21412
|
+
vaultRowsDecrypted = factRowsDecrypted;
|
|
21364
21413
|
factLaneMs = nowMs() - factStart;
|
|
21365
21414
|
}
|
|
21366
21415
|
if (chunkEmbedFailed && !factLaneRankedOnCosine) embeddingsUnavailable = true;
|
package/dist/server/index.cjs
CHANGED
|
@@ -21269,6 +21269,8 @@ async function recall(query, ctx, options = {}) {
|
|
|
21269
21269
|
let embeddingsUnavailable = false;
|
|
21270
21270
|
let chunkEmbedFailed = false;
|
|
21271
21271
|
let factLaneRankedOnCosine = false;
|
|
21272
|
+
let decryptLastRan;
|
|
21273
|
+
let vaultRowsDecrypted;
|
|
21272
21274
|
const emitDiagnostics = (candidateCount) => {
|
|
21273
21275
|
const cb = options.onDiagnostics;
|
|
21274
21276
|
if (!cb) return;
|
|
@@ -21285,6 +21287,8 @@ async function recall(query, ctx, options = {}) {
|
|
|
21285
21287
|
reranked: didRerank,
|
|
21286
21288
|
candidateCount,
|
|
21287
21289
|
...vaultSize !== void 0 && { vaultSize },
|
|
21290
|
+
...decryptLastRan !== void 0 && { decryptLast: decryptLastRan },
|
|
21291
|
+
...vaultRowsDecrypted !== void 0 && { vaultRowsDecrypted },
|
|
21288
21292
|
factCount: factResults.length,
|
|
21289
21293
|
chunkCount: chunkResults.length,
|
|
21290
21294
|
timings: {
|
|
@@ -21356,7 +21360,9 @@ async function recall(query, ctx, options = {}) {
|
|
|
21356
21360
|
reranked,
|
|
21357
21361
|
hadV2Head: v2Head,
|
|
21358
21362
|
embeddingsUnavailable: factEmbeddingsUnavailable,
|
|
21359
|
-
rankedOnCosine: factRankedOnCosine
|
|
21363
|
+
rankedOnCosine: factRankedOnCosine,
|
|
21364
|
+
decryptLast: factDecryptLast,
|
|
21365
|
+
rowsDecrypted: factRowsDecrypted
|
|
21360
21366
|
} = await searchVaultMemoriesWithSize(
|
|
21361
21367
|
query,
|
|
21362
21368
|
ctx.vaultCtx,
|
|
@@ -21413,6 +21419,8 @@ async function recall(query, ctx, options = {}) {
|
|
|
21413
21419
|
hadV2Head = v2Head;
|
|
21414
21420
|
if (factEmbeddingsUnavailable) embeddingsUnavailable = true;
|
|
21415
21421
|
factLaneRankedOnCosine = factRankedOnCosine;
|
|
21422
|
+
decryptLastRan = factDecryptLast;
|
|
21423
|
+
vaultRowsDecrypted = factRowsDecrypted;
|
|
21416
21424
|
factLaneMs = nowMs() - factStart;
|
|
21417
21425
|
}
|
|
21418
21426
|
if (chunkEmbedFailed && !factLaneRankedOnCosine) embeddingsUnavailable = true;
|
|
@@ -22201,6 +22209,7 @@ function admitVaultProjections(queryEmbedding, vectored, k) {
|
|
|
22201
22209
|
return vectored.map((it) => ({ it, score: cosineSimilarity(queryEmbedding, it.embedding) })).sort((a, b) => b.score - a.score || b.it.updatedAt.getTime() - a.it.updatedAt.getTime()).slice(0, k).map((s) => s.it.uniqueId);
|
|
22202
22210
|
}
|
|
22203
22211
|
async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, queryOpts, opts) {
|
|
22212
|
+
let rowsDecrypted = 0;
|
|
22204
22213
|
const keys = await getVaultCandidateKeysOp(
|
|
22205
22214
|
vaultCtx,
|
|
22206
22215
|
Object.keys(queryOpts).length > 0 ? queryOpts : void 0
|
|
@@ -22213,7 +22222,8 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
22213
22222
|
embeddedItems: [],
|
|
22214
22223
|
queryEmbedding: [],
|
|
22215
22224
|
vaultSize: 0,
|
|
22216
|
-
laneEmbedFailed: false
|
|
22225
|
+
laneEmbedFailed: false,
|
|
22226
|
+
rowsDecrypted: 0
|
|
22217
22227
|
};
|
|
22218
22228
|
}
|
|
22219
22229
|
const queryEmbedding = await embedQueryOrDegrade(
|
|
@@ -22259,6 +22269,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
22259
22269
|
for (const id of missIds) if (!gotVector.has(id)) noVectorIds.push(id);
|
|
22260
22270
|
}
|
|
22261
22271
|
let laneEmbedFailed = false;
|
|
22272
|
+
const laneById = /* @__PURE__ */ new Map();
|
|
22262
22273
|
if (noVectorIds.length > 0) {
|
|
22263
22274
|
const laneIds = noVectorIds.slice(0, opts.unembeddedCap);
|
|
22264
22275
|
if (noVectorIds.length > laneIds.length) {
|
|
@@ -22266,9 +22277,10 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
22266
22277
|
`memoryVault: projected search un-embedded lane capped at ${laneIds.length}/${noVectorIds.length}`
|
|
22267
22278
|
);
|
|
22268
22279
|
}
|
|
22269
|
-
const
|
|
22270
|
-
|
|
22271
|
-
);
|
|
22280
|
+
const laneFetched = await getVaultMemoriesByIdsOp(vaultCtx, laneIds, hydrateOpts);
|
|
22281
|
+
rowsDecrypted += laneFetched.length;
|
|
22282
|
+
for (const row of laneFetched) laneById.set(row.uniqueId, row);
|
|
22283
|
+
const laneRows = laneFetched.filter((m) => !isEncrypted(m.content));
|
|
22272
22284
|
if (laneRows.length > 0) {
|
|
22273
22285
|
let laneVecs;
|
|
22274
22286
|
try {
|
|
@@ -22314,7 +22326,16 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
22314
22326
|
if (keyById.has(id)) admissionSet.add(id);
|
|
22315
22327
|
}
|
|
22316
22328
|
}
|
|
22317
|
-
const
|
|
22329
|
+
const idsToFetch = [...admissionSet].filter((id) => !laneById.has(id));
|
|
22330
|
+
const fetched = idsToFetch.length > 0 ? await getVaultMemoriesByIdsOp(vaultCtx, idsToFetch, hydrateOpts) : [];
|
|
22331
|
+
rowsDecrypted += fetched.length;
|
|
22332
|
+
const admittedRows = [
|
|
22333
|
+
...fetched,
|
|
22334
|
+
...[...admissionSet].flatMap((id) => {
|
|
22335
|
+
const reused = laneById.get(id);
|
|
22336
|
+
return reused ? [reused] : [];
|
|
22337
|
+
})
|
|
22338
|
+
];
|
|
22318
22339
|
const memories = admittedRows.filter((m) => !isEncrypted(m.content));
|
|
22319
22340
|
if (memories.length < admittedRows.length) {
|
|
22320
22341
|
getLogger().warn(
|
|
@@ -22335,7 +22356,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
22335
22356
|
eventTimeKind: normalizeEventTimeKind(m.eventTimeKind),
|
|
22336
22357
|
factType: m.factType
|
|
22337
22358
|
}));
|
|
22338
|
-
return { memories, embeddedItems, queryEmbedding, vaultSize, laneEmbedFailed };
|
|
22359
|
+
return { memories, embeddedItems, queryEmbedding, vaultSize, laneEmbedFailed, rowsDecrypted };
|
|
22339
22360
|
}
|
|
22340
22361
|
async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache, searchOptions) {
|
|
22341
22362
|
if (!query || typeof query !== "string") {
|
|
@@ -22345,7 +22366,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
22345
22366
|
queryEmbedding: [],
|
|
22346
22367
|
vaultSize: 0,
|
|
22347
22368
|
embeddingsUnavailable: false,
|
|
22348
|
-
embeddingFailure: false
|
|
22369
|
+
embeddingFailure: false,
|
|
22370
|
+
decryptLast: !!searchOptions?.decryptLast,
|
|
22371
|
+
rowsDecrypted: 0
|
|
22349
22372
|
};
|
|
22350
22373
|
}
|
|
22351
22374
|
const limit = searchOptions?.limit ?? 5;
|
|
@@ -22363,6 +22386,7 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
22363
22386
|
let embeddedItems;
|
|
22364
22387
|
let queryEmbedding;
|
|
22365
22388
|
let vaultSize;
|
|
22389
|
+
let rowsDecrypted;
|
|
22366
22390
|
let embeddingsUnavailable = false;
|
|
22367
22391
|
let embeddingFailure = false;
|
|
22368
22392
|
const onEmbeddingDegraded = () => {
|
|
@@ -22389,10 +22413,13 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
22389
22413
|
queryEmbedding: [],
|
|
22390
22414
|
vaultSize: 0,
|
|
22391
22415
|
embeddingsUnavailable: false,
|
|
22392
|
-
embeddingFailure: false
|
|
22416
|
+
embeddingFailure: false,
|
|
22417
|
+
decryptLast: true,
|
|
22418
|
+
rowsDecrypted: corpus.rowsDecrypted
|
|
22393
22419
|
};
|
|
22394
22420
|
}
|
|
22395
22421
|
({ memories, embeddedItems, queryEmbedding, vaultSize } = corpus);
|
|
22422
|
+
rowsDecrypted = corpus.rowsDecrypted;
|
|
22396
22423
|
if (corpus.laneEmbedFailed) embeddingFailure = true;
|
|
22397
22424
|
if (memories.length === 0) {
|
|
22398
22425
|
return {
|
|
@@ -22401,7 +22428,11 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
22401
22428
|
queryEmbedding: [],
|
|
22402
22429
|
vaultSize,
|
|
22403
22430
|
embeddingsUnavailable,
|
|
22404
|
-
embeddingFailure
|
|
22431
|
+
embeddingFailure,
|
|
22432
|
+
decryptLast: true,
|
|
22433
|
+
// Rows WERE decrypt-attempted even though none came back readable — that
|
|
22434
|
+
// is the whole point of reporting attempts rather than successes.
|
|
22435
|
+
rowsDecrypted: corpus.rowsDecrypted
|
|
22405
22436
|
};
|
|
22406
22437
|
}
|
|
22407
22438
|
} else {
|
|
@@ -22410,6 +22441,7 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
22410
22441
|
Object.keys(queryOpts).length > 0 ? queryOpts : void 0
|
|
22411
22442
|
);
|
|
22412
22443
|
vaultSize = loaded.length;
|
|
22444
|
+
rowsDecrypted = loaded.length;
|
|
22413
22445
|
memories = loaded.filter((m) => !isEncrypted(m.content));
|
|
22414
22446
|
if (memories.length < loaded.length) {
|
|
22415
22447
|
getLogger().warn(
|
|
@@ -22423,7 +22455,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
22423
22455
|
queryEmbedding: [],
|
|
22424
22456
|
vaultSize: loaded.length,
|
|
22425
22457
|
embeddingsUnavailable: false,
|
|
22426
|
-
embeddingFailure: false
|
|
22458
|
+
embeddingFailure: false,
|
|
22459
|
+
decryptLast: false,
|
|
22460
|
+
rowsDecrypted: loaded.length
|
|
22427
22461
|
};
|
|
22428
22462
|
}
|
|
22429
22463
|
queryEmbedding = await embedQueryOrDegrade(query, embeddingOptions, onEmbeddingDegraded);
|
|
@@ -22508,7 +22542,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
22508
22542
|
queryEmbedding,
|
|
22509
22543
|
vaultSize,
|
|
22510
22544
|
embeddingsUnavailable,
|
|
22511
|
-
embeddingFailure
|
|
22545
|
+
embeddingFailure,
|
|
22546
|
+
decryptLast: !!searchOptions?.decryptLast,
|
|
22547
|
+
rowsDecrypted
|
|
22512
22548
|
};
|
|
22513
22549
|
}
|
|
22514
22550
|
async function rankPreparedVaultCandidates(query, prepared, embeddingOptions, searchOptions) {
|
|
@@ -22676,7 +22712,11 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
22676
22712
|
reranked: false,
|
|
22677
22713
|
hadV2Head: false,
|
|
22678
22714
|
embeddingsUnavailable: false,
|
|
22679
|
-
rankedOnCosine: false
|
|
22715
|
+
rankedOnCosine: false,
|
|
22716
|
+
// No storage read happened, so nothing was decrypted; report the path the
|
|
22717
|
+
// caller asked for so this turn is still attributable.
|
|
22718
|
+
decryptLast: !!searchOptions?.decryptLast,
|
|
22719
|
+
rowsDecrypted: 0
|
|
22680
22720
|
};
|
|
22681
22721
|
}
|
|
22682
22722
|
if (searchOptions?.decompose === "llm" && normalizeSubQueries(searchOptions.subQueries).length < 2 && !warnedProgrammaticDecomposeIgnored) {
|
|
@@ -22699,7 +22739,9 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
22699
22739
|
reranked: false,
|
|
22700
22740
|
hadV2Head: false,
|
|
22701
22741
|
embeddingsUnavailable: prepared.embeddingsUnavailable,
|
|
22702
|
-
rankedOnCosine: false
|
|
22742
|
+
rankedOnCosine: false,
|
|
22743
|
+
decryptLast: prepared.decryptLast,
|
|
22744
|
+
rowsDecrypted: prepared.rowsDecrypted
|
|
22703
22745
|
};
|
|
22704
22746
|
}
|
|
22705
22747
|
if (prepared.memories.length === 0) {
|
|
@@ -22709,7 +22751,9 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
22709
22751
|
reranked: false,
|
|
22710
22752
|
hadV2Head: false,
|
|
22711
22753
|
embeddingsUnavailable: prepared.embeddingsUnavailable,
|
|
22712
|
-
rankedOnCosine: false
|
|
22754
|
+
rankedOnCosine: false,
|
|
22755
|
+
decryptLast: prepared.decryptLast,
|
|
22756
|
+
rowsDecrypted: prepared.rowsDecrypted
|
|
22713
22757
|
};
|
|
22714
22758
|
}
|
|
22715
22759
|
const ranked = await rankPreparedVaultCandidates(
|
|
@@ -22718,7 +22762,12 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
22718
22762
|
embeddingOptions,
|
|
22719
22763
|
searchOptions
|
|
22720
22764
|
);
|
|
22721
|
-
return {
|
|
22765
|
+
return {
|
|
22766
|
+
...ranked,
|
|
22767
|
+
rankedOnCosine: !ranked.embeddingsUnavailable,
|
|
22768
|
+
decryptLast: prepared.decryptLast,
|
|
22769
|
+
rowsDecrypted: prepared.rowsDecrypted
|
|
22770
|
+
};
|
|
22722
22771
|
}
|
|
22723
22772
|
async function searchVaultMemories(query, vaultCtx, embeddingOptions, cache, searchOptions) {
|
|
22724
22773
|
const { results } = await searchVaultMemoriesWithSize(
|
package/dist/server/index.d.mts
CHANGED
|
@@ -5446,6 +5446,27 @@ interface RecallDiagnostics {
|
|
|
5446
5446
|
candidateCount: number;
|
|
5447
5447
|
/** Total vault size when the fact lane ran (absent if it didn't). */
|
|
5448
5448
|
vaultSize?: number;
|
|
5449
|
+
/**
|
|
5450
|
+
* Which vault read path the fact lane actually executed: `true` for the
|
|
5451
|
+
* projected key scan that decrypts only the admission window, `false` for the
|
|
5452
|
+
* legacy whole-vault load. Absent when the fact lane didn't run.
|
|
5453
|
+
*
|
|
5454
|
+
* Reported because "the option was passed" and "the branch ran" are different
|
|
5455
|
+
* facts, and #845 needed the second one: the projected path was enabled in
|
|
5456
|
+
* production and the p50 did not move, with no way to tell a flag that never
|
|
5457
|
+
* reached the bundle from a projection that isn't cheaper at that vault size.
|
|
5458
|
+
*/
|
|
5459
|
+
decryptLast?: boolean;
|
|
5460
|
+
/**
|
|
5461
|
+
* Rows the fact lane paid to decrypt. Absent when it didn't run.
|
|
5462
|
+
*
|
|
5463
|
+
* Read against {@link RecallDiagnostics.vaultSize} — that ratio is the whole
|
|
5464
|
+
* point. `decryptLast` true with `vaultRowsDecrypted` ≈ `vaultSize` means the
|
|
5465
|
+
* admission window is admitting the entire vault and the projection is buying
|
|
5466
|
+
* nothing. Far below `vaultSize` with latency unchanged means the decrypt was
|
|
5467
|
+
* never the cost.
|
|
5468
|
+
*/
|
|
5469
|
+
vaultRowsDecrypted?: number;
|
|
5449
5470
|
/** Facts the fact lane returned (post-dedupe, pre-fusion). */
|
|
5450
5471
|
factCount: number;
|
|
5451
5472
|
/** Chunks the chunk lane returned (post-dedupe, pre-fusion). */
|
package/dist/server/index.d.ts
CHANGED
|
@@ -5446,6 +5446,27 @@ interface RecallDiagnostics {
|
|
|
5446
5446
|
candidateCount: number;
|
|
5447
5447
|
/** Total vault size when the fact lane ran (absent if it didn't). */
|
|
5448
5448
|
vaultSize?: number;
|
|
5449
|
+
/**
|
|
5450
|
+
* Which vault read path the fact lane actually executed: `true` for the
|
|
5451
|
+
* projected key scan that decrypts only the admission window, `false` for the
|
|
5452
|
+
* legacy whole-vault load. Absent when the fact lane didn't run.
|
|
5453
|
+
*
|
|
5454
|
+
* Reported because "the option was passed" and "the branch ran" are different
|
|
5455
|
+
* facts, and #845 needed the second one: the projected path was enabled in
|
|
5456
|
+
* production and the p50 did not move, with no way to tell a flag that never
|
|
5457
|
+
* reached the bundle from a projection that isn't cheaper at that vault size.
|
|
5458
|
+
*/
|
|
5459
|
+
decryptLast?: boolean;
|
|
5460
|
+
/**
|
|
5461
|
+
* Rows the fact lane paid to decrypt. Absent when it didn't run.
|
|
5462
|
+
*
|
|
5463
|
+
* Read against {@link RecallDiagnostics.vaultSize} — that ratio is the whole
|
|
5464
|
+
* point. `decryptLast` true with `vaultRowsDecrypted` ≈ `vaultSize` means the
|
|
5465
|
+
* admission window is admitting the entire vault and the projection is buying
|
|
5466
|
+
* nothing. Far below `vaultSize` with latency unchanged means the decrypt was
|
|
5467
|
+
* never the cost.
|
|
5468
|
+
*/
|
|
5469
|
+
vaultRowsDecrypted?: number;
|
|
5449
5470
|
/** Facts the fact lane returned (post-dedupe, pre-fusion). */
|
|
5450
5471
|
factCount: number;
|
|
5451
5472
|
/** Chunks the chunk lane returned (post-dedupe, pre-fusion). */
|
package/dist/server/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anuma/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -275,8 +275,8 @@
|
|
|
275
275
|
"js-yaml@>=4 <4.2.0": ">=4.2.0 <5.0.0",
|
|
276
276
|
"js-yaml@>=3 <3.15.0": ">=3.15.0 <4.0.0",
|
|
277
277
|
"markdown-it@<14.2.0": ">=14.2.0",
|
|
278
|
-
"brace-expansion@1": ">=1.1.
|
|
279
|
-
"brace-expansion@2": ">=2.1.
|
|
278
|
+
"brace-expansion@1": ">=1.1.18 <2.0.0",
|
|
279
|
+
"brace-expansion@2": ">=2.1.4 <3.0.0"
|
|
280
280
|
},
|
|
281
281
|
"patchedDependencies": {
|
|
282
282
|
"tesseract.js@6.0.1": "patches/tesseract.js@6.0.1.patch",
|