@anuma/sdk 3.8.5 → 3.9.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.
@@ -4843,6 +4843,108 @@ async function getAllVaultMemoriesOp(ctx, options) {
4843
4843
  (raw) => vaultMemoryRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
4844
4844
  );
4845
4845
  }
4846
+ function vaultMemoryRawToRankable(raw) {
4847
+ return {
4848
+ uniqueId: raw.id,
4849
+ // @text coerces NULL→"" on the Model path; unsafeFetchRaw returns raw NULL, so guard.
4850
+ scope: raw.scope ?? "",
4851
+ folderId: raw.folder_id ?? null,
4852
+ embedding: raw.embedding ?? null,
4853
+ embeddingModel: raw.embedding_model ?? null,
4854
+ createdAt: new Date(raw.created_at),
4855
+ updatedAt: new Date(raw.updated_at)
4856
+ };
4857
+ }
4858
+ async function getVaultRankingProjectionsOp(ctx, options) {
4859
+ const conditions = [
4860
+ ...baseVaultConditions(ctx, options),
4861
+ ...options?.scopes?.length ? [import_watermelondb10.Q.where("scope", import_watermelondb10.Q.oneOf(options.scopes))] : [],
4862
+ ...options?.folderId !== void 0 ? [import_watermelondb10.Q.where("folder_id", options.folderId)] : [],
4863
+ import_watermelondb10.Q.sortBy(options?.since ? "updated_at" : "created_at", import_watermelondb10.Q.desc),
4864
+ ...options?.limit !== null && options?.limit !== void 0 && options.limit > 0 ? [import_watermelondb10.Q.take(options.limit)] : []
4865
+ ];
4866
+ const results = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
4867
+ return results.map(vaultMemoryRawToRankable);
4868
+ }
4869
+ function baseVaultSql(ctx) {
4870
+ const clauses = [
4871
+ '"is_deleted" = 0',
4872
+ '"archived_at" is null',
4873
+ `"trust_tier" is not 'quarantined'`,
4874
+ '"superseded_by" is null'
4875
+ ];
4876
+ const args = [];
4877
+ if (ctx.userId !== void 0) {
4878
+ clauses.push('"user_id" = ?');
4879
+ args.push(ctx.userId);
4880
+ }
4881
+ return { sql: clauses.join(" and "), args };
4882
+ }
4883
+ async function getVaultCandidateKeysOp(ctx, options) {
4884
+ const mapRaw = (raw) => ({
4885
+ uniqueId: raw.id,
4886
+ folderId: raw.folder_id ?? null,
4887
+ scope: raw.scope ?? "",
4888
+ embeddingModel: raw.embedding_model ?? null,
4889
+ updatedAt: new Date(raw.updated_at)
4890
+ });
4891
+ try {
4892
+ const base = baseVaultSql(ctx);
4893
+ const clauses = [base.sql];
4894
+ const args = [...base.args];
4895
+ if (options?.scopes?.length) {
4896
+ clauses.push(`"scope" in (${options.scopes.map(() => "?").join(",")})`);
4897
+ args.push(...options.scopes);
4898
+ }
4899
+ if (options?.folderId !== void 0) {
4900
+ clauses.push(options.folderId === null ? '"folder_id" is null' : '"folder_id" = ?');
4901
+ if (options.folderId !== null) args.push(options.folderId);
4902
+ }
4903
+ const sql = `select "id", "scope", "folder_id", "embedding_model", "updated_at" from "memory_vault" where ${clauses.join(" and ")}`;
4904
+ const rows = await ctx.vaultMemoryCollection.query(import_watermelondb10.Q.unsafeSqlQuery(sql, args)).unsafeFetchRaw();
4905
+ return rows.map(mapRaw);
4906
+ } catch (err) {
4907
+ getLogger().debug(
4908
+ "memoryVault: getVaultCandidateKeysOp projected SQL unavailable, using full-load fallback: " + (err instanceof Error ? err.message : String(err))
4909
+ );
4910
+ const conditions = [
4911
+ ...baseVaultConditions(ctx),
4912
+ ...options?.scopes?.length ? [import_watermelondb10.Q.where("scope", import_watermelondb10.Q.oneOf(options.scopes))] : [],
4913
+ ...options?.folderId !== void 0 ? [import_watermelondb10.Q.where("folder_id", options.folderId)] : []
4914
+ ];
4915
+ const rows = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
4916
+ return rows.map(mapRaw);
4917
+ }
4918
+ }
4919
+ async function getVaultEmbeddingsByIdsOp(ctx, ids) {
4920
+ if (ids.length === 0) return [];
4921
+ const mapRaw = (raw) => ({
4922
+ uniqueId: raw.id,
4923
+ embedding: raw.embedding ?? null,
4924
+ embeddingModel: raw.embedding_model ?? null
4925
+ });
4926
+ try {
4927
+ const base = baseVaultSql(ctx);
4928
+ const sql = `select "id", "embedding", "embedding_model" from "memory_vault" where ${base.sql} and "id" in (${ids.map(() => "?").join(",")})`;
4929
+ const rows = await ctx.vaultMemoryCollection.query(import_watermelondb10.Q.unsafeSqlQuery(sql, [...base.args, ...ids])).unsafeFetchRaw();
4930
+ return rows.map(mapRaw);
4931
+ } catch (err) {
4932
+ getLogger().debug(
4933
+ "memoryVault: getVaultEmbeddingsByIdsOp projected SQL unavailable, using full-load fallback: " + (err instanceof Error ? err.message : String(err))
4934
+ );
4935
+ const rows = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx), import_watermelondb10.Q.where("id", import_watermelondb10.Q.oneOf(ids))).unsafeFetchRaw();
4936
+ return rows.map(mapRaw);
4937
+ }
4938
+ }
4939
+ async function getVaultMemoriesByIdsOp(ctx, ids) {
4940
+ if (ids.length === 0) return [];
4941
+ const conditions = [...baseVaultConditions(ctx), import_watermelondb10.Q.where("id", import_watermelondb10.Q.oneOf(ids))];
4942
+ const results = await ctx.vaultMemoryCollection.query(...conditions).unsafeFetchRaw();
4943
+ return mapInBatches(
4944
+ results,
4945
+ (raw) => vaultMemoryRawToStored(raw, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner)
4946
+ );
4947
+ }
4846
4948
  async function getAllVaultMemoryContentsOp(ctx, options) {
4847
4949
  const results = await ctx.vaultMemoryCollection.query(...baseVaultConditions(ctx, options)).unsafeFetchRaw();
4848
4950
  return mapInBatches(results, async (raw) => {
@@ -5292,6 +5394,7 @@ var init_operations3 = __esm({
5292
5394
  "src/lib/db/memoryVault/operations.ts"() {
5293
5395
  "use strict";
5294
5396
  import_watermelondb10 = require("@nozbe/watermelondb");
5397
+ init_logger();
5295
5398
  init_operations2();
5296
5399
  init_encryption2();
5297
5400
  KNOWN_TRUST_TIERS = /* @__PURE__ */ new Set(["quarantined", "trusted"]);
@@ -6684,6 +6787,7 @@ async function recall(query, ctx, options = {}) {
6684
6787
  bm25AdmissionDivisor: options.bm25AdmissionDivisor
6685
6788
  },
6686
6789
  ...options.rrfK !== void 0 && { rrfK: options.rrfK },
6790
+ ...options.decryptLast !== void 0 && { decryptLast: options.decryptLast },
6687
6791
  ...decomposeAvailable && {
6688
6792
  decompose: "llm",
6689
6793
  decomposeOptions: options.decomposeOptions
@@ -7466,80 +7570,97 @@ async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, mem
7466
7570
  );
7467
7571
  }
7468
7572
  }
7469
- async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, cache, searchOptions) {
7470
- const limit = searchOptions?.limit ?? 5;
7471
- const minSimilarity = searchOptions?.minSimilarity ?? 0.1;
7472
- const scopes = searchOptions?.scopes;
7473
- if (!query || typeof query !== "string") {
7474
- return { results: [], vaultSize: 0, reranked: false, hadV2Head: false };
7475
- }
7476
- const folderId = searchOptions?.folderId;
7477
- const queryOpts = {};
7478
- if (scopes?.length) queryOpts.scopes = scopes;
7479
- if (folderId !== void 0) queryOpts.folderId = folderId;
7480
- if (searchOptions?.factTypes?.length) queryOpts.factTypes = searchOptions.factTypes;
7481
- if (searchOptions?.includeArchived) queryOpts.includeArchived = true;
7482
- const loaded = await getAllVaultMemoriesOp(
7573
+ function admitVaultProjections(queryEmbedding, vectored, k) {
7574
+ 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);
7575
+ }
7576
+ async function buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, queryOpts, opts) {
7577
+ const keys = await getVaultCandidateKeysOp(
7483
7578
  vaultCtx,
7484
7579
  Object.keys(queryOpts).length > 0 ? queryOpts : void 0
7485
7580
  );
7486
- const memories = loaded.filter((m) => !isEncrypted(m.content));
7487
- if (memories.length < loaded.length) {
7488
- getLogger().warn(
7489
- `memoryVault: ${loaded.length - memories.length}/${loaded.length} memories still encrypted (key unavailable?) \u2014 excluded from search`
7490
- );
7491
- }
7492
- if (memories.length === 0) {
7493
- return { results: [], vaultSize: loaded.length, reranked: false, hadV2Head: false };
7581
+ const vaultSize = keys.length;
7582
+ if (keys.length === 0) {
7583
+ return { memories: [], embeddedItems: [], queryEmbedding: [], vaultSize: 0 };
7494
7584
  }
7495
7585
  const queryEmbedding = await generateEmbedding(query, embeddingOptions);
7496
7586
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
7497
- const uncachedTexts = [];
7498
- const uncachedIndices = [];
7499
- let staleReembedCount = 0;
7500
- for (let i = 0; i < memories.length; i++) {
7501
- const content = memories[i].content;
7502
- const memoryId = memories[i].uniqueId;
7503
- const cached = cache.get(memoryId);
7504
- if (cached && cached.length === queryEmbedding.length) continue;
7505
- if (cached) cache.delete(memoryId);
7506
- const storedModel = memories[i].embeddingModel;
7507
- const modelCompatible = (storedModel ?? currentModel) === currentModel;
7508
- if (memories[i].embedding && modelCompatible) {
7587
+ const vectored = [];
7588
+ const missIds = [];
7589
+ const noVectorIds = [];
7590
+ const keyById = new Map(keys.map((k2) => [k2.uniqueId, k2]));
7591
+ for (const k2 of keys) {
7592
+ const cached = cache.get(k2.uniqueId);
7593
+ if (cached && cached.length === queryEmbedding.length) {
7594
+ vectored.push({ uniqueId: k2.uniqueId, embedding: cached, updatedAt: k2.updatedAt });
7595
+ continue;
7596
+ }
7597
+ const modelCompatible = (k2.embeddingModel ?? currentModel) === currentModel;
7598
+ if (modelCompatible) missIds.push(k2.uniqueId);
7599
+ else noVectorIds.push(k2.uniqueId);
7600
+ }
7601
+ if (missIds.length > 0) {
7602
+ const rows = await getVaultEmbeddingsByIdsOp(vaultCtx, missIds);
7603
+ const gotVector = /* @__PURE__ */ new Set();
7604
+ for (const r of rows) {
7605
+ if (!r.embedding) continue;
7509
7606
  try {
7510
- const parsed = JSON.parse(memories[i].embedding);
7607
+ const parsed = JSON.parse(r.embedding);
7511
7608
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
7512
- cache.set(memoryId, Float32Array.from(parsed));
7513
- continue;
7609
+ const vec = Float32Array.from(parsed);
7610
+ cache.set(r.uniqueId, vec);
7611
+ const k2 = keyById.get(r.uniqueId);
7612
+ vectored.push({ uniqueId: r.uniqueId, embedding: vec, updatedAt: k2.updatedAt });
7613
+ gotVector.add(r.uniqueId);
7514
7614
  }
7515
7615
  } catch {
7516
7616
  }
7517
7617
  }
7518
- if (memories[i].embedding && !modelCompatible) staleReembedCount++;
7519
- uncachedTexts.push(content);
7520
- uncachedIndices.push(i);
7618
+ for (const id of missIds) if (!gotVector.has(id)) noVectorIds.push(id);
7521
7619
  }
7522
- if (staleReembedCount > 0) {
7523
- getLogger().warn(
7524
- `memoryVault: re-embedding ${staleReembedCount} memories whose stored embedding model differs from the current model (${currentModel}) \u2014 embedding-model change detected`
7620
+ if (noVectorIds.length > 0) {
7621
+ const laneIds = noVectorIds.slice(0, opts.unembeddedCap);
7622
+ if (noVectorIds.length > laneIds.length) {
7623
+ getLogger().warn(
7624
+ `memoryVault: projected search un-embedded lane capped at ${laneIds.length}/${noVectorIds.length}`
7625
+ );
7626
+ }
7627
+ const laneRows = (await getVaultMemoriesByIdsOp(vaultCtx, laneIds)).filter(
7628
+ (m) => !isEncrypted(m.content)
7525
7629
  );
7526
- }
7527
- if (uncachedTexts.length > 0) {
7528
- const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
7529
- for (let j = 0; j < uncachedTexts.length; j++) {
7530
- cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
7531
- updateVaultMemoryEmbeddingOp(
7532
- vaultCtx,
7533
- memories[uncachedIndices[j]].uniqueId,
7534
- JSON.stringify(newEmbeddings[j]),
7535
- currentModel
7536
- ).catch(
7537
- // Silently swallow – SDK must not use console.*; embedding will be retried on next search
7538
- () => {
7539
- }
7630
+ if (laneRows.length > 0) {
7631
+ const laneVecs = await generateEmbeddings(
7632
+ laneRows.map((m) => m.content),
7633
+ embeddingOptions
7540
7634
  );
7635
+ laneRows.forEach((m, i) => {
7636
+ const vec = Float32Array.from(laneVecs[i]);
7637
+ cache.set(m.uniqueId, vec);
7638
+ vectored.push({ uniqueId: m.uniqueId, embedding: vec, updatedAt: m.updatedAt });
7639
+ updateVaultMemoryEmbeddingOp(
7640
+ vaultCtx,
7641
+ m.uniqueId,
7642
+ JSON.stringify(laneVecs[i]),
7643
+ currentModel
7644
+ ).catch(() => {
7645
+ });
7646
+ });
7647
+ }
7648
+ }
7649
+ const k = Math.max(opts.limit * opts.admitFactor, opts.admitFloor);
7650
+ const admittedIds = admitVaultProjections(queryEmbedding, vectored, k);
7651
+ const admissionSet = new Set(admittedIds);
7652
+ if (opts.forceIncludeIds) {
7653
+ for (const id of opts.forceIncludeIds) {
7654
+ if (keyById.has(id)) admissionSet.add(id);
7541
7655
  }
7542
7656
  }
7657
+ const admittedRows = await getVaultMemoriesByIdsOp(vaultCtx, [...admissionSet]);
7658
+ const memories = admittedRows.filter((m) => !isEncrypted(m.content));
7659
+ if (memories.length < admittedRows.length) {
7660
+ getLogger().warn(
7661
+ `memoryVault: ${admittedRows.length - memories.length}/${admittedRows.length} admitted memories still encrypted (key unavailable?) \u2014 excluded from projected search`
7662
+ );
7663
+ }
7543
7664
  const embeddedItems = memories.map((m) => ({
7544
7665
  id: m.uniqueId,
7545
7666
  content: m.content,
@@ -7554,6 +7675,125 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
7554
7675
  eventTimeKind: normalizeEventTimeKind(m.eventTimeKind),
7555
7676
  factType: m.factType
7556
7677
  }));
7678
+ return { memories, embeddedItems, queryEmbedding, vaultSize };
7679
+ }
7680
+ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, cache, searchOptions) {
7681
+ const limit = searchOptions?.limit ?? 5;
7682
+ const minSimilarity = searchOptions?.minSimilarity ?? 0.1;
7683
+ const scopes = searchOptions?.scopes;
7684
+ if (!query || typeof query !== "string") {
7685
+ return { results: [], vaultSize: 0, reranked: false, hadV2Head: false };
7686
+ }
7687
+ const folderId = searchOptions?.folderId;
7688
+ const queryOpts = {};
7689
+ if (scopes?.length) queryOpts.scopes = scopes;
7690
+ if (folderId !== void 0) queryOpts.folderId = folderId;
7691
+ if (searchOptions?.factTypes?.length) queryOpts.factTypes = searchOptions.factTypes;
7692
+ if (searchOptions?.includeArchived) queryOpts.includeArchived = true;
7693
+ const ADMIT_FACTOR = searchOptions?.admitFactor ?? 3;
7694
+ const ADMIT_FLOOR = searchOptions?.admitFloor ?? 30;
7695
+ const UNEMBEDDED_CAP = 200;
7696
+ let memories;
7697
+ let embeddedItems;
7698
+ let queryEmbedding;
7699
+ let vaultSize;
7700
+ if (searchOptions?.decryptLast) {
7701
+ const forceIncludeIds = [
7702
+ ...searchOptions.entityRanking ?? [],
7703
+ ...searchOptions.temporalRanking ?? []
7704
+ ];
7705
+ const corpus = await buildProjectedCorpus(query, vaultCtx, embeddingOptions, cache, queryOpts, {
7706
+ limit,
7707
+ admitFactor: ADMIT_FACTOR,
7708
+ admitFloor: ADMIT_FLOOR,
7709
+ unembeddedCap: UNEMBEDDED_CAP,
7710
+ ...forceIncludeIds.length > 0 && { forceIncludeIds }
7711
+ });
7712
+ if (corpus.vaultSize === 0) {
7713
+ return { results: [], vaultSize: 0, reranked: false, hadV2Head: false };
7714
+ }
7715
+ ({ memories, embeddedItems, queryEmbedding, vaultSize } = corpus);
7716
+ if (memories.length === 0) {
7717
+ return { results: [], vaultSize, reranked: false, hadV2Head: false };
7718
+ }
7719
+ } else {
7720
+ const loaded = await getAllVaultMemoriesOp(
7721
+ vaultCtx,
7722
+ Object.keys(queryOpts).length > 0 ? queryOpts : void 0
7723
+ );
7724
+ vaultSize = loaded.length;
7725
+ memories = loaded.filter((m) => !isEncrypted(m.content));
7726
+ if (memories.length < loaded.length) {
7727
+ getLogger().warn(
7728
+ `memoryVault: ${loaded.length - memories.length}/${loaded.length} memories still encrypted (key unavailable?) \u2014 excluded from search`
7729
+ );
7730
+ }
7731
+ if (memories.length === 0) {
7732
+ return { results: [], vaultSize: loaded.length, reranked: false, hadV2Head: false };
7733
+ }
7734
+ queryEmbedding = await generateEmbedding(query, embeddingOptions);
7735
+ const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
7736
+ const uncachedTexts = [];
7737
+ const uncachedIndices = [];
7738
+ let staleReembedCount = 0;
7739
+ for (let i = 0; i < memories.length; i++) {
7740
+ const content = memories[i].content;
7741
+ const memoryId = memories[i].uniqueId;
7742
+ const cached = cache.get(memoryId);
7743
+ if (cached && cached.length === queryEmbedding.length) continue;
7744
+ if (cached) cache.delete(memoryId);
7745
+ const storedModel = memories[i].embeddingModel;
7746
+ const modelCompatible = (storedModel ?? currentModel) === currentModel;
7747
+ if (memories[i].embedding && modelCompatible) {
7748
+ try {
7749
+ const parsed = JSON.parse(memories[i].embedding);
7750
+ if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
7751
+ cache.set(memoryId, Float32Array.from(parsed));
7752
+ continue;
7753
+ }
7754
+ } catch {
7755
+ }
7756
+ }
7757
+ if (memories[i].embedding && !modelCompatible) staleReembedCount++;
7758
+ uncachedTexts.push(content);
7759
+ uncachedIndices.push(i);
7760
+ }
7761
+ if (staleReembedCount > 0) {
7762
+ getLogger().warn(
7763
+ `memoryVault: re-embedding ${staleReembedCount} memories whose stored embedding model differs from the current model (${currentModel}) \u2014 embedding-model change detected`
7764
+ );
7765
+ }
7766
+ if (uncachedTexts.length > 0) {
7767
+ const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
7768
+ for (let j = 0; j < uncachedTexts.length; j++) {
7769
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
7770
+ updateVaultMemoryEmbeddingOp(
7771
+ vaultCtx,
7772
+ memories[uncachedIndices[j]].uniqueId,
7773
+ JSON.stringify(newEmbeddings[j]),
7774
+ currentModel
7775
+ ).catch(
7776
+ // Silently swallow – SDK must not use console.*; embedding will be retried on next search
7777
+ () => {
7778
+ }
7779
+ );
7780
+ }
7781
+ }
7782
+ embeddedItems = memories.map((m) => ({
7783
+ id: m.uniqueId,
7784
+ content: m.content,
7785
+ embedding: cache.get(m.uniqueId) ?? [],
7786
+ createdAt: m.createdAt,
7787
+ updatedAt: m.updatedAt,
7788
+ proofCount: m.proofCount,
7789
+ lastObservedAt: m.lastObservedAt,
7790
+ eventTimeStart: m.eventTimeStart,
7791
+ sourceChunkIds: m.sourceChunkIds,
7792
+ eventTimeEnd: m.eventTimeEnd,
7793
+ eventTimeKind: normalizeEventTimeKind(m.eventTimeKind),
7794
+ factType: m.factType
7795
+ }));
7796
+ }
7557
7797
  if (queryEmbedding.length > 0) {
7558
7798
  const mismatched = embeddedItems.filter(
7559
7799
  (it) => it.embedding.length > 0 && it.embedding.length !== queryEmbedding.length
@@ -7639,7 +7879,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
7639
7879
  });
7640
7880
  return stampTimestamps({
7641
7881
  results: composite,
7642
- vaultSize: loaded.length,
7882
+ vaultSize,
7643
7883
  reranked: rerankStats.applied,
7644
7884
  hadV2Head: v2HeadStats.hadResults
7645
7885
  });
@@ -7664,7 +7904,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
7664
7904
  });
7665
7905
  return stampTimestamps({
7666
7906
  results: results2,
7667
- vaultSize: loaded.length,
7907
+ vaultSize,
7668
7908
  reranked: rerankStats.applied,
7669
7909
  hadV2Head: v2HeadStats.hadResults
7670
7910
  });
@@ -7677,7 +7917,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
7677
7917
  ...searchOptions?.entityRanking && { entityRanking: searchOptions.entityRanking },
7678
7918
  ...searchOptions?.temporalRanking && { temporalRanking: searchOptions.temporalRanking }
7679
7919
  });
7680
- return stampTimestamps({ results: results2, vaultSize: loaded.length, hadV2Head: results2.length > 0 });
7920
+ return stampTimestamps({ results: results2, vaultSize, hadV2Head: results2.length > 0 });
7681
7921
  }
7682
7922
  const results = rankVaultMemories(query, queryEmbedding, embeddedItems, {
7683
7923
  limit,
@@ -7689,7 +7929,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
7689
7929
  supersessionWindow: searchOptions.supersessionWindow
7690
7930
  }
7691
7931
  });
7692
- return stampTimestamps({ results, vaultSize: loaded.length, hadV2Head: results.length > 0 });
7932
+ return stampTimestamps({ results, vaultSize, hadV2Head: results.length > 0 });
7693
7933
  }
7694
7934
  async function searchVaultMemories(query, vaultCtx, embeddingOptions, cache, searchOptions) {
7695
7935
  const { results } = await searchVaultMemoriesWithSize(
@@ -8275,8 +8515,12 @@ __export(index_exports, {
8275
8515
  getValidDriveToken: () => getValidDriveToken,
8276
8516
  getValidGithubToken: () => getValidGithubToken,
8277
8517
  getValidNotionToken: () => getValidNotionToken,
8518
+ getVaultCandidateKeysOp: () => getVaultCandidateKeysOp,
8519
+ getVaultEmbeddingsByIdsOp: () => getVaultEmbeddingsByIdsOp,
8278
8520
  getVaultFolderMemoryCountOp: () => getVaultFolderMemoryCountOp,
8521
+ getVaultMemoriesByIdsOp: () => getVaultMemoriesByIdsOp,
8279
8522
  getVaultMemoryOp: () => getVaultMemoryOp,
8523
+ getVaultRankingProjectionsOp: () => getVaultRankingProjectionsOp,
8280
8524
  getVideosOp: () => getVideosOp,
8281
8525
  handleCalendarCallback: () => handleCalendarCallback,
8282
8526
  handleDriveCallback: () => handleDriveCallback,
@@ -32850,8 +33094,12 @@ function renderAnumaJsx(jsx3) {
32850
33094
  getValidDriveToken,
32851
33095
  getValidGithubToken,
32852
33096
  getValidNotionToken,
33097
+ getVaultCandidateKeysOp,
33098
+ getVaultEmbeddingsByIdsOp,
32853
33099
  getVaultFolderMemoryCountOp,
33100
+ getVaultMemoriesByIdsOp,
32854
33101
  getVaultMemoryOp,
33102
+ getVaultRankingProjectionsOp,
32855
33103
  getVideosOp,
32856
33104
  handleCalendarCallback,
32857
33105
  handleDriveCallback,