@anuma/sdk 6.9.0 → 6.11.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-4M56MKBV.mjs → chunk-ZO7S3TBT.mjs} +79 -25
- package/dist/expo/index.cjs +98 -23
- package/dist/expo/index.d.mts +94 -1
- package/dist/expo/index.d.ts +94 -1
- package/dist/expo/index.mjs +31 -11
- package/dist/expo/{recall-WIB7RQQZ.mjs → recall-OALPGL3H.mjs} +1 -1
- package/dist/react/{chunk-EJ65X4GI.mjs → chunk-HNQ2ZEFF.mjs} +79 -25
- package/dist/react/index.cjs +98 -23
- package/dist/react/index.d.mts +94 -1
- package/dist/react/index.d.ts +94 -1
- package/dist/react/index.mjs +31 -11
- package/dist/react/{recall-FWILZSFH.mjs → recall-F5DBVCU2.mjs} +1 -1
- package/dist/server/{chunk-I56324FR.mjs → chunk-BKB6AT7Z.mjs} +79 -25
- package/dist/server/index.cjs +98 -23
- package/dist/server/index.d.mts +94 -1
- package/dist/server/index.d.ts +94 -1
- package/dist/server/index.mjs +31 -11
- package/dist/server/{recall-T7CNXTQ3.mjs → recall-HVIEAH7J.mjs} +1 -1
- package/package.json +1 -1
|
@@ -19307,9 +19307,9 @@ function recencyMultiplier(updatedAt, opts = {}) {
|
|
|
19307
19307
|
const updatedMs = updatedAt.getTime();
|
|
19308
19308
|
if (!Number.isFinite(updatedMs)) return noDate;
|
|
19309
19309
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
19310
|
-
const
|
|
19311
|
-
if (!Number.isFinite(
|
|
19312
|
-
const ageDays = Math.max(0, (
|
|
19310
|
+
const nowMs3 = now.getTime();
|
|
19311
|
+
if (!Number.isFinite(nowMs3)) return noDate;
|
|
19312
|
+
const ageDays = Math.max(0, (nowMs3 - updatedMs) / DAY_MS);
|
|
19313
19313
|
const perYearDecay = opts.perYearDecay ?? DEFAULT_PER_YEAR_DECAY;
|
|
19314
19314
|
const floor = opts.floor ?? DEFAULT_FLOOR;
|
|
19315
19315
|
const decay = perYearDecay * (ageDays / 365);
|
|
@@ -19655,6 +19655,7 @@ function createVaultEmbeddingCache(maxSize = DEFAULT_VAULT_CACHE_SIZE) {
|
|
|
19655
19655
|
}
|
|
19656
19656
|
|
|
19657
19657
|
// src/lib/memoryVault/searchTool.ts
|
|
19658
|
+
var nowMs = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
19658
19659
|
var warnedProgrammaticDecomposeIgnored = false;
|
|
19659
19660
|
function normalizeEventTimeKind(kind) {
|
|
19660
19661
|
return kind === "point" || kind === "range" || kind === "ongoing" ? kind : null;
|
|
@@ -19887,6 +19888,7 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
19887
19888
|
const rerankTopN = options.rerankTopN ?? 30;
|
|
19888
19889
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
19889
19890
|
const headSlice = v2Ranked.slice(0, rerankTopN);
|
|
19891
|
+
const ceStart = nowMs();
|
|
19890
19892
|
try {
|
|
19891
19893
|
const reranked = await rerankPairs(
|
|
19892
19894
|
query,
|
|
@@ -19914,6 +19916,8 @@ async function rankFusedVaultMemoriesAsync(query, queryEmbedding, items, options
|
|
|
19914
19916
|
getLogger().warn("[memory/search] cross-encoder rerank failed; using V2 ranking", err);
|
|
19915
19917
|
}
|
|
19916
19918
|
combined = v2Ranked;
|
|
19919
|
+
} finally {
|
|
19920
|
+
if (options.rerankStats) options.rerankStats.ms += nowMs() - ceStart;
|
|
19917
19921
|
}
|
|
19918
19922
|
} else {
|
|
19919
19923
|
combined = v2Ranked;
|
|
@@ -20080,6 +20084,7 @@ async function rankComposite(originalQuery, originalQueryEmbedding, subQueries,
|
|
|
20080
20084
|
const ceWeight = options.ceWeight ?? 0.1;
|
|
20081
20085
|
const headSlice = combined.slice(0, rerankTopN);
|
|
20082
20086
|
const tailSlice = combined.slice(rerankTopN);
|
|
20087
|
+
const ceStart = nowMs();
|
|
20083
20088
|
try {
|
|
20084
20089
|
const reranked = await rerankPairs(
|
|
20085
20090
|
originalQuery,
|
|
@@ -20107,6 +20112,8 @@ async function rankComposite(originalQuery, originalQueryEmbedding, subQueries,
|
|
|
20107
20112
|
err
|
|
20108
20113
|
);
|
|
20109
20114
|
}
|
|
20115
|
+
} finally {
|
|
20116
|
+
if (options.rerankStats) options.rerankStats.ms += nowMs() - ceStart;
|
|
20110
20117
|
}
|
|
20111
20118
|
}
|
|
20112
20119
|
if (options?.mmr) {
|
|
@@ -20233,11 +20240,13 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20233
20240
|
rowsDecrypted: 0
|
|
20234
20241
|
};
|
|
20235
20242
|
}
|
|
20243
|
+
const queryEmbedStart = nowMs();
|
|
20236
20244
|
const queryEmbedding = await embedQueryOrDegrade(
|
|
20237
20245
|
query,
|
|
20238
20246
|
embeddingOptions,
|
|
20239
20247
|
opts.onEmbeddingDegraded
|
|
20240
20248
|
);
|
|
20249
|
+
if (opts.embedStats) opts.embedStats.queryMs += nowMs() - queryEmbedStart;
|
|
20241
20250
|
const embeddingsDegraded = queryEmbedding.length === 0;
|
|
20242
20251
|
const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
20243
20252
|
const vectored = [];
|
|
@@ -20290,6 +20299,7 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20290
20299
|
const laneRows = laneFetched.filter((m) => !isEncrypted(m.content));
|
|
20291
20300
|
if (laneRows.length > 0) {
|
|
20292
20301
|
let laneVecs;
|
|
20302
|
+
if (opts.embedStats) opts.embedStats.rowsEmbedded += laneRows.length;
|
|
20293
20303
|
try {
|
|
20294
20304
|
laneVecs = await generateEmbeddings(
|
|
20295
20305
|
laneRows.map((m) => m.content),
|
|
@@ -20368,6 +20378,10 @@ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, qu
|
|
|
20368
20378
|
async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache, searchOptions) {
|
|
20369
20379
|
if (!query || typeof query !== "string") {
|
|
20370
20380
|
return {
|
|
20381
|
+
// Nothing was read and nothing was embedded — the short-circuit fires
|
|
20382
|
+
// before either.
|
|
20383
|
+
queryEmbedMs: 0,
|
|
20384
|
+
rowsEmbedded: 0,
|
|
20371
20385
|
memories: [],
|
|
20372
20386
|
embeddedItems: [],
|
|
20373
20387
|
queryEmbedding: [],
|
|
@@ -20400,6 +20414,7 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20400
20414
|
embeddingsUnavailable = true;
|
|
20401
20415
|
embeddingFailure = true;
|
|
20402
20416
|
};
|
|
20417
|
+
const embedStats = { queryMs: 0, rowsEmbedded: 0 };
|
|
20403
20418
|
if (searchOptions?.decryptLast) {
|
|
20404
20419
|
const forceIncludeIds = [
|
|
20405
20420
|
...searchOptions.entityRanking ?? [],
|
|
@@ -20411,7 +20426,8 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20411
20426
|
admitFloor: ADMIT_FLOOR,
|
|
20412
20427
|
unembeddedCap: UNEMBEDDED_CAP,
|
|
20413
20428
|
...forceIncludeIds.length > 0 && { forceIncludeIds },
|
|
20414
|
-
onEmbeddingDegraded
|
|
20429
|
+
onEmbeddingDegraded,
|
|
20430
|
+
embedStats
|
|
20415
20431
|
});
|
|
20416
20432
|
if (corpus.vaultSize === 0) {
|
|
20417
20433
|
return {
|
|
@@ -20422,7 +20438,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20422
20438
|
embeddingsUnavailable: false,
|
|
20423
20439
|
embeddingFailure: false,
|
|
20424
20440
|
decryptLast: true,
|
|
20425
|
-
rowsDecrypted: corpus.rowsDecrypted
|
|
20441
|
+
rowsDecrypted: corpus.rowsDecrypted,
|
|
20442
|
+
queryEmbedMs: embedStats.queryMs,
|
|
20443
|
+
rowsEmbedded: embedStats.rowsEmbedded
|
|
20426
20444
|
};
|
|
20427
20445
|
}
|
|
20428
20446
|
({ memories, embeddedItems, queryEmbedding, vaultSize } = corpus);
|
|
@@ -20439,7 +20457,9 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20439
20457
|
decryptLast: true,
|
|
20440
20458
|
// Rows WERE decrypt-attempted even though none came back readable — that
|
|
20441
20459
|
// is the whole point of reporting attempts rather than successes.
|
|
20442
|
-
rowsDecrypted: corpus.rowsDecrypted
|
|
20460
|
+
rowsDecrypted: corpus.rowsDecrypted,
|
|
20461
|
+
queryEmbedMs: embedStats.queryMs,
|
|
20462
|
+
rowsEmbedded: embedStats.rowsEmbedded
|
|
20443
20463
|
};
|
|
20444
20464
|
}
|
|
20445
20465
|
} else {
|
|
@@ -20464,10 +20484,14 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20464
20484
|
embeddingsUnavailable: false,
|
|
20465
20485
|
embeddingFailure: false,
|
|
20466
20486
|
decryptLast: false,
|
|
20467
|
-
rowsDecrypted: loaded.length
|
|
20487
|
+
rowsDecrypted: loaded.length,
|
|
20488
|
+
queryEmbedMs: embedStats.queryMs,
|
|
20489
|
+
rowsEmbedded: embedStats.rowsEmbedded
|
|
20468
20490
|
};
|
|
20469
20491
|
}
|
|
20492
|
+
const legacyEmbedStart = nowMs();
|
|
20470
20493
|
queryEmbedding = await embedQueryOrDegrade(query, embeddingOptions, onEmbeddingDegraded);
|
|
20494
|
+
embedStats.queryMs += nowMs() - legacyEmbedStart;
|
|
20471
20495
|
const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
|
|
20472
20496
|
const uncachedTexts = [];
|
|
20473
20497
|
const uncachedIndices = [];
|
|
@@ -20501,6 +20525,7 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20501
20525
|
}
|
|
20502
20526
|
if (uncachedTexts.length > 0) {
|
|
20503
20527
|
let newEmbeddings;
|
|
20528
|
+
embedStats.rowsEmbedded += uncachedTexts.length;
|
|
20504
20529
|
try {
|
|
20505
20530
|
newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
|
|
20506
20531
|
} catch (err) {
|
|
@@ -20544,6 +20569,8 @@ async function prepareVaultCandidates(query, vaultCtx, embeddingOptions, cache,
|
|
|
20544
20569
|
embeddingsUnavailable = true;
|
|
20545
20570
|
}
|
|
20546
20571
|
return {
|
|
20572
|
+
queryEmbedMs: embedStats.queryMs,
|
|
20573
|
+
rowsEmbedded: embedStats.rowsEmbedded,
|
|
20547
20574
|
memories,
|
|
20548
20575
|
embeddedItems,
|
|
20549
20576
|
queryEmbedding,
|
|
@@ -20594,11 +20621,15 @@ async function rankPreparedVaultCandidates(query, prepared, embeddingOptions, se
|
|
|
20594
20621
|
results: results2,
|
|
20595
20622
|
vaultSize: out.vaultSize,
|
|
20596
20623
|
reranked: out.reranked ?? false,
|
|
20624
|
+
// Read straight off the shared stats object rather than being passed in at
|
|
20625
|
+
// each call site: every return in this function funnels through here, so a
|
|
20626
|
+
// path added later reports the CE bill without having to remember to.
|
|
20627
|
+
rerankMs: rerankStats.ms,
|
|
20597
20628
|
hadV2Head: out.hadV2Head ?? false,
|
|
20598
20629
|
embeddingsUnavailable
|
|
20599
20630
|
};
|
|
20600
20631
|
};
|
|
20601
|
-
const rerankStats = { applied: false };
|
|
20632
|
+
const rerankStats = { applied: false, ms: 0 };
|
|
20602
20633
|
const useFusion = searchOptions?.useFusion ?? true;
|
|
20603
20634
|
const tuning = {
|
|
20604
20635
|
...searchOptions?.recencyAlpha !== void 0 && { recencyAlpha: searchOptions.recencyAlpha },
|
|
@@ -20717,13 +20748,16 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20717
20748
|
results: [],
|
|
20718
20749
|
vaultSize: 0,
|
|
20719
20750
|
reranked: false,
|
|
20751
|
+
rerankMs: 0,
|
|
20720
20752
|
hadV2Head: false,
|
|
20721
20753
|
embeddingsUnavailable: false,
|
|
20722
20754
|
rankedOnCosine: false,
|
|
20723
20755
|
// No storage read happened, so nothing was decrypted; report the path the
|
|
20724
20756
|
// caller asked for so this turn is still attributable.
|
|
20725
20757
|
decryptLast: !!searchOptions?.decryptLast,
|
|
20726
|
-
rowsDecrypted: 0
|
|
20758
|
+
rowsDecrypted: 0,
|
|
20759
|
+
queryEmbedMs: 0,
|
|
20760
|
+
rowsEmbedded: 0
|
|
20727
20761
|
};
|
|
20728
20762
|
}
|
|
20729
20763
|
if (searchOptions?.decompose === "llm" && normalizeSubQueries(searchOptions.subQueries).length < 2 && !warnedProgrammaticDecomposeIgnored) {
|
|
@@ -20744,11 +20778,14 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20744
20778
|
results: [],
|
|
20745
20779
|
vaultSize: 0,
|
|
20746
20780
|
reranked: false,
|
|
20781
|
+
rerankMs: 0,
|
|
20747
20782
|
hadV2Head: false,
|
|
20748
20783
|
embeddingsUnavailable: prepared.embeddingsUnavailable,
|
|
20749
20784
|
rankedOnCosine: false,
|
|
20750
20785
|
decryptLast: prepared.decryptLast,
|
|
20751
|
-
rowsDecrypted: prepared.rowsDecrypted
|
|
20786
|
+
rowsDecrypted: prepared.rowsDecrypted,
|
|
20787
|
+
queryEmbedMs: prepared.queryEmbedMs,
|
|
20788
|
+
rowsEmbedded: prepared.rowsEmbedded
|
|
20752
20789
|
};
|
|
20753
20790
|
}
|
|
20754
20791
|
if (prepared.memories.length === 0) {
|
|
@@ -20756,11 +20793,14 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20756
20793
|
results: [],
|
|
20757
20794
|
vaultSize: prepared.vaultSize,
|
|
20758
20795
|
reranked: false,
|
|
20796
|
+
rerankMs: 0,
|
|
20759
20797
|
hadV2Head: false,
|
|
20760
20798
|
embeddingsUnavailable: prepared.embeddingsUnavailable,
|
|
20761
20799
|
rankedOnCosine: false,
|
|
20762
20800
|
decryptLast: prepared.decryptLast,
|
|
20763
|
-
rowsDecrypted: prepared.rowsDecrypted
|
|
20801
|
+
rowsDecrypted: prepared.rowsDecrypted,
|
|
20802
|
+
queryEmbedMs: prepared.queryEmbedMs,
|
|
20803
|
+
rowsEmbedded: prepared.rowsEmbedded
|
|
20764
20804
|
};
|
|
20765
20805
|
}
|
|
20766
20806
|
const ranked = await rankPreparedVaultCandidates(
|
|
@@ -20773,7 +20813,9 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
|
|
|
20773
20813
|
...ranked,
|
|
20774
20814
|
rankedOnCosine: !ranked.embeddingsUnavailable,
|
|
20775
20815
|
decryptLast: prepared.decryptLast,
|
|
20776
|
-
rowsDecrypted: prepared.rowsDecrypted
|
|
20816
|
+
rowsDecrypted: prepared.rowsDecrypted,
|
|
20817
|
+
queryEmbedMs: prepared.queryEmbedMs,
|
|
20818
|
+
rowsEmbedded: prepared.rowsEmbedded
|
|
20777
20819
|
};
|
|
20778
20820
|
}
|
|
20779
20821
|
async function searchVaultMemories(query, vaultCtx, embeddingOptions, cache, searchOptions) {
|
|
@@ -20878,7 +20920,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
|
|
|
20878
20920
|
subQueries = decomp.subQueries;
|
|
20879
20921
|
}
|
|
20880
20922
|
}
|
|
20881
|
-
const { recall: recall2 } = await import("./recall-
|
|
20923
|
+
const { recall: recall2 } = await import("./recall-HVIEAH7J.mjs");
|
|
20882
20924
|
let recallDegraded = [];
|
|
20883
20925
|
const result = await recall2(
|
|
20884
20926
|
query,
|
|
@@ -21418,7 +21460,7 @@ function scoreEventTimeOverlap(memoryStart, memoryEnd, memoryKind, window2) {
|
|
|
21418
21460
|
var DEFAULT_LIMIT = 8;
|
|
21419
21461
|
var DEFAULT_BUDGET = "low";
|
|
21420
21462
|
var DEFAULT_FACT_MIN_SCORE = 0.1;
|
|
21421
|
-
var
|
|
21463
|
+
var nowMs2 = () => typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
|
|
21422
21464
|
var DEFAULT_CHUNK_MIN_SCORE = 0.5;
|
|
21423
21465
|
function flagsForBudget(budget) {
|
|
21424
21466
|
switch (budget) {
|
|
@@ -21451,7 +21493,7 @@ async function recall(query, ctx, options = {}) {
|
|
|
21451
21493
|
const flags = flagsForBudget(usedBudget);
|
|
21452
21494
|
const normalizedFacets = normalizeSubQueries(options.subQueries);
|
|
21453
21495
|
const subQueries = normalizedFacets.length >= 2 ? normalizedFacets : void 0;
|
|
21454
|
-
const t0 =
|
|
21496
|
+
const t0 = nowMs2();
|
|
21455
21497
|
let prepMs = 0;
|
|
21456
21498
|
let factLaneMs = 0;
|
|
21457
21499
|
let chunkLaneMs = 0;
|
|
@@ -21460,6 +21502,9 @@ async function recall(query, ctx, options = {}) {
|
|
|
21460
21502
|
const chunkResults = [];
|
|
21461
21503
|
let vaultSize;
|
|
21462
21504
|
let didRerank = false;
|
|
21505
|
+
let rerankMs = 0;
|
|
21506
|
+
let queryEmbedMs = 0;
|
|
21507
|
+
let vaultRowsEmbedded;
|
|
21463
21508
|
let hadV2Head = false;
|
|
21464
21509
|
let embeddingsUnavailable = false;
|
|
21465
21510
|
let chunkEmbedFailed = false;
|
|
@@ -21484,12 +21529,15 @@ async function recall(query, ctx, options = {}) {
|
|
|
21484
21529
|
...vaultSize !== void 0 && { vaultSize },
|
|
21485
21530
|
...decryptLastRan !== void 0 && { decryptLast: decryptLastRan },
|
|
21486
21531
|
...vaultRowsDecrypted !== void 0 && { vaultRowsDecrypted },
|
|
21532
|
+
...vaultRowsEmbedded !== void 0 && { vaultRowsEmbedded },
|
|
21487
21533
|
factCount: factResults.length,
|
|
21488
21534
|
chunkCount: chunkResults.length,
|
|
21489
21535
|
timings: {
|
|
21490
|
-
total:
|
|
21536
|
+
total: nowMs2() - t0,
|
|
21491
21537
|
prep: prepMs,
|
|
21492
21538
|
factLane: factLaneMs,
|
|
21539
|
+
rerank: rerankMs,
|
|
21540
|
+
queryEmbed: queryEmbedMs,
|
|
21493
21541
|
chunkLane: chunkLaneMs,
|
|
21494
21542
|
fuse: fuseMs
|
|
21495
21543
|
},
|
|
@@ -21507,7 +21555,7 @@ async function recall(query, ctx, options = {}) {
|
|
|
21507
21555
|
const needsChunkEmbedding = types.includes("chunk") && ctx.storageCtx;
|
|
21508
21556
|
const wantsTemporal = types.includes("fact") && ctx.vaultCtx;
|
|
21509
21557
|
const graphRefiner = flags.traverse && options.graphRefine && options.decomposeOptions ? createLlmNeighborRefiner(options.decomposeOptions) : void 0;
|
|
21510
|
-
const prepStart =
|
|
21558
|
+
const prepStart = nowMs2();
|
|
21511
21559
|
const [queryEmbedding, entityRanking, temporalRanking] = await Promise.all([
|
|
21512
21560
|
// The chunk lane is cosine-only — `searchChunksOp` needs a real vector, and
|
|
21513
21561
|
// there is no lexical fallback for it — so an embeddings outage must SKIP the
|
|
@@ -21545,14 +21593,17 @@ async function recall(query, ctx, options = {}) {
|
|
|
21545
21593
|
),
|
|
21546
21594
|
wantsTemporal ? safeLane("temporal", () => buildTemporalLaneRanking(query, ctx.vaultCtx, options.now)) : Promise.resolve([])
|
|
21547
21595
|
]);
|
|
21548
|
-
prepMs =
|
|
21596
|
+
prepMs = nowMs2() - prepStart;
|
|
21549
21597
|
if (types.includes("fact") && ctx.vaultCtx && ctx.vaultCache) {
|
|
21550
|
-
const factStart =
|
|
21598
|
+
const factStart = nowMs2();
|
|
21551
21599
|
const vaultMinScore = options.minScore ?? DEFAULT_FACT_MIN_SCORE;
|
|
21552
21600
|
const {
|
|
21553
21601
|
results,
|
|
21554
21602
|
vaultSize: size,
|
|
21555
21603
|
reranked,
|
|
21604
|
+
rerankMs: factRerankMs,
|
|
21605
|
+
queryEmbedMs: factQueryEmbedMs,
|
|
21606
|
+
rowsEmbedded: factRowsEmbedded,
|
|
21556
21607
|
hadV2Head: v2Head,
|
|
21557
21608
|
embeddingsUnavailable: factEmbeddingsUnavailable,
|
|
21558
21609
|
rankedOnCosine: factRankedOnCosine,
|
|
@@ -21611,16 +21662,19 @@ async function recall(query, ctx, options = {}) {
|
|
|
21611
21662
|
);
|
|
21612
21663
|
vaultSize = size;
|
|
21613
21664
|
didRerank = reranked;
|
|
21665
|
+
rerankMs = factRerankMs;
|
|
21666
|
+
queryEmbedMs = factQueryEmbedMs;
|
|
21667
|
+
vaultRowsEmbedded = factRowsEmbedded;
|
|
21614
21668
|
hadV2Head = v2Head;
|
|
21615
21669
|
if (factEmbeddingsUnavailable) embeddingsUnavailable = true;
|
|
21616
21670
|
factLaneRankedOnCosine = factRankedOnCosine;
|
|
21617
21671
|
decryptLastRan = factDecryptLast;
|
|
21618
21672
|
vaultRowsDecrypted = factRowsDecrypted;
|
|
21619
|
-
factLaneMs =
|
|
21673
|
+
factLaneMs = nowMs2() - factStart;
|
|
21620
21674
|
}
|
|
21621
21675
|
if (chunkEmbedFailed && !factLaneRankedOnCosine) embeddingsUnavailable = true;
|
|
21622
21676
|
if (types.includes("chunk") && ctx.storageCtx && queryEmbedding) {
|
|
21623
|
-
const chunkStart =
|
|
21677
|
+
const chunkStart = nowMs2();
|
|
21624
21678
|
const chunkMinScore = options.minScore ?? DEFAULT_CHUNK_MIN_SCORE;
|
|
21625
21679
|
const results = await searchChunksOp(ctx.storageCtx, queryEmbedding, {
|
|
21626
21680
|
limit: types.includes("fact") ? Math.max(limit * 2, 16) : limit,
|
|
@@ -21637,9 +21691,9 @@ async function recall(query, ctx, options = {}) {
|
|
|
21637
21691
|
(r) => r.chunkText.trim()
|
|
21638
21692
|
)
|
|
21639
21693
|
);
|
|
21640
|
-
chunkLaneMs =
|
|
21694
|
+
chunkLaneMs = nowMs2() - chunkStart;
|
|
21641
21695
|
}
|
|
21642
|
-
const fuseStart =
|
|
21696
|
+
const fuseStart = nowMs2();
|
|
21643
21697
|
if (types.length === 1 || factResults.length === 0 || chunkResults.length === 0) {
|
|
21644
21698
|
const memories2 = [
|
|
21645
21699
|
...factResults.map((r) => toFactMemory(r, options.now)),
|
|
@@ -21647,7 +21701,7 @@ async function recall(query, ctx, options = {}) {
|
|
|
21647
21701
|
];
|
|
21648
21702
|
memories2.sort((a, b) => b.score - a.score);
|
|
21649
21703
|
const candidateCount = factResults.length + chunkResults.length;
|
|
21650
|
-
fuseMs =
|
|
21704
|
+
fuseMs = nowMs2() - fuseStart;
|
|
21651
21705
|
emitDiagnostics(candidateCount);
|
|
21652
21706
|
return {
|
|
21653
21707
|
memories: memories2.slice(0, limit),
|
|
@@ -21702,7 +21756,7 @@ async function recall(query, ctx, options = {}) {
|
|
|
21702
21756
|
suppressed = next;
|
|
21703
21757
|
memories = selectWith(suppressed);
|
|
21704
21758
|
}
|
|
21705
|
-
fuseMs =
|
|
21759
|
+
fuseMs = nowMs2() - fuseStart;
|
|
21706
21760
|
emitDiagnostics(byId.size);
|
|
21707
21761
|
return {
|
|
21708
21762
|
memories,
|