@anuma/sdk 1.4.0 → 2.0.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.
@@ -4373,29 +4373,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
4373
4373
  const uncachedKeys = [];
4374
4374
  const uncachedIds = [];
4375
4375
  for (const m of memories) {
4376
- const key = m.content;
4377
- if (isEncrypted(key)) continue;
4378
- if (!cache.has(key)) {
4376
+ const content = m.content;
4377
+ if (isEncrypted(content)) continue;
4378
+ if (!cache.has(m.uniqueId)) {
4379
4379
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
4380
4380
  if (m.embedding && modelCompatible) {
4381
4381
  try {
4382
4382
  const parsed = JSON.parse(m.embedding);
4383
4383
  if (Array.isArray(parsed)) {
4384
- cache.set(key, parsed);
4384
+ cache.set(m.uniqueId, Float32Array.from(parsed));
4385
4385
  continue;
4386
4386
  }
4387
4387
  } catch {
4388
4388
  }
4389
4389
  }
4390
4390
  uncachedTexts.push(m.content);
4391
- uncachedKeys.push(key);
4391
+ uncachedKeys.push(m.uniqueId);
4392
4392
  uncachedIds.push(m.uniqueId);
4393
4393
  }
4394
4394
  }
4395
4395
  if (uncachedTexts.length > 0) {
4396
4396
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
4397
4397
  for (let i = 0; i < uncachedKeys.length; i++) {
4398
- cache.set(uncachedKeys[i], embeddings[i]);
4398
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
4399
4399
  updateVaultMemoryEmbeddingOp(
4400
4400
  vaultCtx,
4401
4401
  uncachedIds[i],
@@ -4409,7 +4409,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
4409
4409
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
4410
4410
  if (isEncrypted(content)) return;
4411
4411
  const embedding = await generateEmbedding(content, embeddingOptions);
4412
- cache.set(content, embedding);
4412
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
4413
4413
  if (vaultCtx && memoryId) {
4414
4414
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
4415
4415
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -4450,16 +4450,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
4450
4450
  let staleReembedCount = 0;
4451
4451
  for (let i = 0; i < memories.length; i++) {
4452
4452
  const content = memories[i].content;
4453
- const cached = cache.get(content);
4453
+ const memoryId = memories[i].uniqueId;
4454
+ const cached = cache.get(memoryId);
4454
4455
  if (cached && cached.length === queryEmbedding.length) continue;
4455
- if (cached) cache.delete(content);
4456
+ if (cached) cache.delete(memoryId);
4456
4457
  const storedModel = memories[i].embeddingModel;
4457
4458
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
4458
4459
  if (memories[i].embedding && modelCompatible) {
4459
4460
  try {
4460
4461
  const parsed = JSON.parse(memories[i].embedding);
4461
4462
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
4462
- cache.set(content, parsed);
4463
+ cache.set(memoryId, Float32Array.from(parsed));
4463
4464
  continue;
4464
4465
  }
4465
4466
  } catch {
@@ -4477,7 +4478,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
4477
4478
  if (uncachedTexts.length > 0) {
4478
4479
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
4479
4480
  for (let j = 0; j < uncachedTexts.length; j++) {
4480
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
4481
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
4481
4482
  updateVaultMemoryEmbeddingOp(
4482
4483
  vaultCtx,
4483
4484
  memories[uncachedIndices[j]].uniqueId,
@@ -4493,7 +4494,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
4493
4494
  const embeddedItems = memories.map((m) => ({
4494
4495
  id: m.uniqueId,
4495
4496
  content: m.content,
4496
- embedding: cache.get(m.content) ?? [],
4497
+ embedding: cache.get(m.uniqueId) ?? [],
4497
4498
  createdAt: m.createdAt,
4498
4499
  updatedAt: m.updatedAt,
4499
4500
  proofCount: m.proofCount,
@@ -4689,7 +4690,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
4689
4690
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
4690
4691
  );
4691
4692
  }
4692
- const { recall: recall2 } = await import("./recall-YKNVP2DF.mjs");
4693
+ const { recall: recall2 } = await import("./recall-DHOR5WWW.mjs");
4693
4694
  const result = await recall2(
4694
4695
  query,
4695
4696
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -6110,29 +6110,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6110
6110
  const uncachedKeys = [];
6111
6111
  const uncachedIds = [];
6112
6112
  for (const m of memories) {
6113
- const key = m.content;
6114
- if (isEncrypted(key)) continue;
6115
- if (!cache.has(key)) {
6113
+ const content = m.content;
6114
+ if (isEncrypted(content)) continue;
6115
+ if (!cache.has(m.uniqueId)) {
6116
6116
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
6117
6117
  if (m.embedding && modelCompatible) {
6118
6118
  try {
6119
6119
  const parsed = JSON.parse(m.embedding);
6120
6120
  if (Array.isArray(parsed)) {
6121
- cache.set(key, parsed);
6121
+ cache.set(m.uniqueId, Float32Array.from(parsed));
6122
6122
  continue;
6123
6123
  }
6124
6124
  } catch {
6125
6125
  }
6126
6126
  }
6127
6127
  uncachedTexts.push(m.content);
6128
- uncachedKeys.push(key);
6128
+ uncachedKeys.push(m.uniqueId);
6129
6129
  uncachedIds.push(m.uniqueId);
6130
6130
  }
6131
6131
  }
6132
6132
  if (uncachedTexts.length > 0) {
6133
6133
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6134
6134
  for (let i = 0; i < uncachedKeys.length; i++) {
6135
- cache.set(uncachedKeys[i], embeddings[i]);
6135
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
6136
6136
  updateVaultMemoryEmbeddingOp(
6137
6137
  vaultCtx,
6138
6138
  uncachedIds[i],
@@ -6146,7 +6146,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6146
6146
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
6147
6147
  if (isEncrypted(content)) return;
6148
6148
  const embedding = await generateEmbedding(content, embeddingOptions);
6149
- cache.set(content, embedding);
6149
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
6150
6150
  if (vaultCtx && memoryId) {
6151
6151
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
6152
6152
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -6187,16 +6187,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6187
6187
  let staleReembedCount = 0;
6188
6188
  for (let i = 0; i < memories.length; i++) {
6189
6189
  const content = memories[i].content;
6190
- const cached = cache.get(content);
6190
+ const memoryId = memories[i].uniqueId;
6191
+ const cached = cache.get(memoryId);
6191
6192
  if (cached && cached.length === queryEmbedding.length) continue;
6192
- if (cached) cache.delete(content);
6193
+ if (cached) cache.delete(memoryId);
6193
6194
  const storedModel = memories[i].embeddingModel;
6194
6195
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
6195
6196
  if (memories[i].embedding && modelCompatible) {
6196
6197
  try {
6197
6198
  const parsed = JSON.parse(memories[i].embedding);
6198
6199
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
6199
- cache.set(content, parsed);
6200
+ cache.set(memoryId, Float32Array.from(parsed));
6200
6201
  continue;
6201
6202
  }
6202
6203
  } catch {
@@ -6214,7 +6215,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6214
6215
  if (uncachedTexts.length > 0) {
6215
6216
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6216
6217
  for (let j = 0; j < uncachedTexts.length; j++) {
6217
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
6218
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
6218
6219
  updateVaultMemoryEmbeddingOp(
6219
6220
  vaultCtx,
6220
6221
  memories[uncachedIndices[j]].uniqueId,
@@ -6230,7 +6231,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6230
6231
  const embeddedItems = memories.map((m) => ({
6231
6232
  id: m.uniqueId,
6232
6233
  content: m.content,
6233
- embedding: cache.get(m.content) ?? [],
6234
+ embedding: cache.get(m.uniqueId) ?? [],
6234
6235
  createdAt: m.createdAt,
6235
6236
  updatedAt: m.updatedAt,
6236
6237
  proofCount: m.proofCount,
@@ -12635,7 +12636,6 @@ async function retain(content, ctx, options = {}) {
12635
12636
  }
12636
12637
  }
12637
12638
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
12638
- ctx.vaultCache.set(trimmed, embedding);
12639
12639
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
12640
12640
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
12641
12641
  content: trimmed,
@@ -12656,6 +12656,7 @@ async function retain(content, ctx, options = {}) {
12656
12656
  }
12657
12657
  }
12658
12658
  });
12659
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
12659
12660
  return {
12660
12661
  action: "create",
12661
12662
  memoryId: created.uniqueId,
@@ -12732,7 +12733,6 @@ async function tryConsolidate(trimmed, ctx, options) {
12732
12733
  options.sourceChunkIds ?? []
12733
12734
  );
12734
12735
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
12735
- ctx.vaultCache.set(decision.content, newEmbedding);
12736
12736
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
12737
12737
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
12738
12738
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -12752,6 +12752,7 @@ async function tryConsolidate(trimmed, ctx, options) {
12752
12752
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
12753
12753
  return null;
12754
12754
  }
12755
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
12755
12756
  return {
12756
12757
  action: "update",
12757
12758
  memoryId: decision.targetId,
@@ -13821,9 +13822,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
13821
13822
  return `Error: Failed to update memory "${id}".`;
13822
13823
  }
13823
13824
  if (embeddingOptions && cache) {
13824
- if (previousContent) {
13825
- cache.delete(previousContent);
13826
- }
13825
+ cache.delete(id);
13827
13826
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
13828
13827
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
13829
13828
  () => {
@@ -4726,7 +4726,9 @@ interface RecencyOptions {
4726
4726
 
4727
4727
  declare const DEFAULT_VAULT_CACHE_SIZE = 5000;
4728
4728
  /**
4729
- * Create a VaultEmbeddingCache backed by an LRU with a default cap of 1000 entries.
4729
+ * Create a VaultEmbeddingCache backed by an LRU with a default cap of
4730
+ * DEFAULT_VAULT_CACHE_SIZE entries. Values are Float32Array — the model's
4731
+ * native precision — not float64 number[], halving resident RAM losslessly.
4730
4732
  */
4731
4733
  declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCache;
4732
4734
 
@@ -4741,7 +4743,7 @@ declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCach
4741
4743
  * Embedding cache keyed by content string. Stores pre-computed embeddings
4742
4744
  * so that search only needs to embed the query, not the vault entries.
4743
4745
  */
4744
- type VaultEmbeddingCache = Map<string, number[]>;
4746
+ type VaultEmbeddingCache = Map<string, Float32Array>;
4745
4747
  /**
4746
4748
  * Options for the vault search tool.
4747
4749
  */
@@ -4726,7 +4726,9 @@ interface RecencyOptions {
4726
4726
 
4727
4727
  declare const DEFAULT_VAULT_CACHE_SIZE = 5000;
4728
4728
  /**
4729
- * Create a VaultEmbeddingCache backed by an LRU with a default cap of 1000 entries.
4729
+ * Create a VaultEmbeddingCache backed by an LRU with a default cap of
4730
+ * DEFAULT_VAULT_CACHE_SIZE entries. Values are Float32Array — the model's
4731
+ * native precision — not float64 number[], halving resident RAM losslessly.
4730
4732
  */
4731
4733
  declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCache;
4732
4734
 
@@ -4741,7 +4743,7 @@ declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCach
4741
4743
  * Embedding cache keyed by content string. Stores pre-computed embeddings
4742
4744
  * so that search only needs to embed the query, not the vault entries.
4743
4745
  */
4744
- type VaultEmbeddingCache = Map<string, number[]>;
4746
+ type VaultEmbeddingCache = Map<string, Float32Array>;
4745
4747
  /**
4746
4748
  * Options for the vault search tool.
4747
4749
  */
@@ -79,7 +79,7 @@ import {
79
79
  updateVaultMemoryOp,
80
80
  upsertMessageOp,
81
81
  useEncryption
82
- } from "./chunk-QKF7PRL5.mjs";
82
+ } from "./chunk-N4FEY34G.mjs";
83
83
  import {
84
84
  PII_PATTERNS,
85
85
  PiiRedactor,
@@ -5911,7 +5911,6 @@ async function retain(content, ctx, options = {}) {
5911
5911
  }
5912
5912
  }
5913
5913
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
5914
- ctx.vaultCache.set(trimmed, embedding);
5915
5914
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
5916
5915
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
5917
5916
  content: trimmed,
@@ -5932,6 +5931,7 @@ async function retain(content, ctx, options = {}) {
5932
5931
  }
5933
5932
  }
5934
5933
  });
5934
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
5935
5935
  return {
5936
5936
  action: "create",
5937
5937
  memoryId: created.uniqueId,
@@ -6008,7 +6008,6 @@ async function tryConsolidate(trimmed, ctx, options) {
6008
6008
  options.sourceChunkIds ?? []
6009
6009
  );
6010
6010
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
6011
- ctx.vaultCache.set(decision.content, newEmbedding);
6012
6011
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
6013
6012
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
6014
6013
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -6028,6 +6027,7 @@ async function tryConsolidate(trimmed, ctx, options) {
6028
6027
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
6029
6028
  return null;
6030
6029
  }
6030
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
6031
6031
  return {
6032
6032
  action: "update",
6033
6033
  memoryId: decision.targetId,
@@ -7072,9 +7072,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
7072
7072
  return `Error: Failed to update memory "${id}".`;
7073
7073
  }
7074
7074
  if (embeddingOptions && cache) {
7075
- if (previousContent) {
7076
- cache.delete(previousContent);
7077
- }
7075
+ cache.delete(id);
7078
7076
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
7079
7077
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
7080
7078
  () => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-QKF7PRL5.mjs";
3
+ } from "./chunk-N4FEY34G.mjs";
4
4
  import "./chunk-DFVCS3QQ.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
package/dist/index.d.mts CHANGED
@@ -1253,6 +1253,7 @@ type HandlersConfigResponse = {
1253
1253
  * Apps is the list of active apps
1254
1254
  */
1255
1255
  apps?: Array<HandlersAppConfig>;
1256
+ mobile_app?: HandlersMobileAppVersions;
1256
1257
  /**
1257
1258
  * PhoneCallsEnabled indicates whether Bland phone calling is available
1258
1259
  */
@@ -1640,6 +1641,28 @@ type HandlersListUsersResponse = {
1640
1641
  pagination: HandlersPaginationResponse;
1641
1642
  users: Array<HandlersDeveloperUserResponse>;
1642
1643
  };
1644
+ /**
1645
+ * MobileApp is the mobile app version info; absent when not configured
1646
+ */
1647
+ type HandlersMobileAppVersions = {
1648
+ android?: HandlersMobilePlatformVersions;
1649
+ ios?: HandlersMobilePlatformVersions;
1650
+ };
1651
+ /**
1652
+ * Android versions for the Play Store build
1653
+ */
1654
+ type HandlersMobilePlatformVersions = {
1655
+ /**
1656
+ * LatestVersion is the newest version live in the platform's store;
1657
+ * older clients show a dismissible update nudge
1658
+ */
1659
+ latest_version?: string;
1660
+ /**
1661
+ * MinSupportedVersion is the oldest version still supported; older
1662
+ * clients are blocked behind an update-required wall
1663
+ */
1664
+ min_supported_version?: string;
1665
+ };
1643
1666
  type HandlersModelToolUsageItem = {
1644
1667
  call_count: number;
1645
1668
  cost_usd: number;
package/dist/index.d.ts CHANGED
@@ -1253,6 +1253,7 @@ type HandlersConfigResponse = {
1253
1253
  * Apps is the list of active apps
1254
1254
  */
1255
1255
  apps?: Array<HandlersAppConfig>;
1256
+ mobile_app?: HandlersMobileAppVersions;
1256
1257
  /**
1257
1258
  * PhoneCallsEnabled indicates whether Bland phone calling is available
1258
1259
  */
@@ -1640,6 +1641,28 @@ type HandlersListUsersResponse = {
1640
1641
  pagination: HandlersPaginationResponse;
1641
1642
  users: Array<HandlersDeveloperUserResponse>;
1642
1643
  };
1644
+ /**
1645
+ * MobileApp is the mobile app version info; absent when not configured
1646
+ */
1647
+ type HandlersMobileAppVersions = {
1648
+ android?: HandlersMobilePlatformVersions;
1649
+ ios?: HandlersMobilePlatformVersions;
1650
+ };
1651
+ /**
1652
+ * Android versions for the Play Store build
1653
+ */
1654
+ type HandlersMobilePlatformVersions = {
1655
+ /**
1656
+ * LatestVersion is the newest version live in the platform's store;
1657
+ * older clients show a dismissible update nudge
1658
+ */
1659
+ latest_version?: string;
1660
+ /**
1661
+ * MinSupportedVersion is the oldest version still supported; older
1662
+ * clients are blocked behind an update-required wall
1663
+ */
1664
+ min_supported_version?: string;
1665
+ };
1643
1666
  type HandlersModelToolUsageItem = {
1644
1667
  call_count: number;
1645
1668
  cost_usd: number;
@@ -4704,29 +4704,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
4704
4704
  const uncachedKeys = [];
4705
4705
  const uncachedIds = [];
4706
4706
  for (const m of memories) {
4707
- const key = m.content;
4708
- if (isEncrypted(key)) continue;
4709
- if (!cache.has(key)) {
4707
+ const content = m.content;
4708
+ if (isEncrypted(content)) continue;
4709
+ if (!cache.has(m.uniqueId)) {
4710
4710
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
4711
4711
  if (m.embedding && modelCompatible) {
4712
4712
  try {
4713
4713
  const parsed = JSON.parse(m.embedding);
4714
4714
  if (Array.isArray(parsed)) {
4715
- cache.set(key, parsed);
4715
+ cache.set(m.uniqueId, Float32Array.from(parsed));
4716
4716
  continue;
4717
4717
  }
4718
4718
  } catch {
4719
4719
  }
4720
4720
  }
4721
4721
  uncachedTexts.push(m.content);
4722
- uncachedKeys.push(key);
4722
+ uncachedKeys.push(m.uniqueId);
4723
4723
  uncachedIds.push(m.uniqueId);
4724
4724
  }
4725
4725
  }
4726
4726
  if (uncachedTexts.length > 0) {
4727
4727
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
4728
4728
  for (let i = 0; i < uncachedKeys.length; i++) {
4729
- cache.set(uncachedKeys[i], embeddings[i]);
4729
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
4730
4730
  updateVaultMemoryEmbeddingOp(
4731
4731
  vaultCtx,
4732
4732
  uncachedIds[i],
@@ -4740,7 +4740,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
4740
4740
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
4741
4741
  if (isEncrypted(content)) return;
4742
4742
  const embedding = await generateEmbedding(content, embeddingOptions);
4743
- cache.set(content, embedding);
4743
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
4744
4744
  if (vaultCtx && memoryId) {
4745
4745
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
4746
4746
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -4781,16 +4781,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
4781
4781
  let staleReembedCount = 0;
4782
4782
  for (let i = 0; i < memories.length; i++) {
4783
4783
  const content = memories[i].content;
4784
- const cached = cache.get(content);
4784
+ const memoryId = memories[i].uniqueId;
4785
+ const cached = cache.get(memoryId);
4785
4786
  if (cached && cached.length === queryEmbedding.length) continue;
4786
- if (cached) cache.delete(content);
4787
+ if (cached) cache.delete(memoryId);
4787
4788
  const storedModel = memories[i].embeddingModel;
4788
4789
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
4789
4790
  if (memories[i].embedding && modelCompatible) {
4790
4791
  try {
4791
4792
  const parsed = JSON.parse(memories[i].embedding);
4792
4793
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
4793
- cache.set(content, parsed);
4794
+ cache.set(memoryId, Float32Array.from(parsed));
4794
4795
  continue;
4795
4796
  }
4796
4797
  } catch {
@@ -4808,7 +4809,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
4808
4809
  if (uncachedTexts.length > 0) {
4809
4810
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
4810
4811
  for (let j = 0; j < uncachedTexts.length; j++) {
4811
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
4812
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
4812
4813
  updateVaultMemoryEmbeddingOp(
4813
4814
  vaultCtx,
4814
4815
  memories[uncachedIndices[j]].uniqueId,
@@ -4824,7 +4825,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
4824
4825
  const embeddedItems = memories.map((m) => ({
4825
4826
  id: m.uniqueId,
4826
4827
  content: m.content,
4827
- embedding: cache.get(m.content) ?? [],
4828
+ embedding: cache.get(m.uniqueId) ?? [],
4828
4829
  createdAt: m.createdAt,
4829
4830
  updatedAt: m.updatedAt,
4830
4831
  proofCount: m.proofCount,
@@ -5020,7 +5021,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
5020
5021
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
5021
5022
  );
5022
5023
  }
5023
- const { recall: recall2 } = await import("./recall-UWH5HU6V.mjs");
5024
+ const { recall: recall2 } = await import("./recall-PUXEQHAP.mjs");
5024
5025
  const result = await recall2(
5025
5026
  query,
5026
5027
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -6441,29 +6441,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6441
6441
  const uncachedKeys = [];
6442
6442
  const uncachedIds = [];
6443
6443
  for (const m of memories) {
6444
- const key = m.content;
6445
- if (isEncrypted(key)) continue;
6446
- if (!cache.has(key)) {
6444
+ const content = m.content;
6445
+ if (isEncrypted(content)) continue;
6446
+ if (!cache.has(m.uniqueId)) {
6447
6447
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
6448
6448
  if (m.embedding && modelCompatible) {
6449
6449
  try {
6450
6450
  const parsed = JSON.parse(m.embedding);
6451
6451
  if (Array.isArray(parsed)) {
6452
- cache.set(key, parsed);
6452
+ cache.set(m.uniqueId, Float32Array.from(parsed));
6453
6453
  continue;
6454
6454
  }
6455
6455
  } catch {
6456
6456
  }
6457
6457
  }
6458
6458
  uncachedTexts.push(m.content);
6459
- uncachedKeys.push(key);
6459
+ uncachedKeys.push(m.uniqueId);
6460
6460
  uncachedIds.push(m.uniqueId);
6461
6461
  }
6462
6462
  }
6463
6463
  if (uncachedTexts.length > 0) {
6464
6464
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6465
6465
  for (let i = 0; i < uncachedKeys.length; i++) {
6466
- cache.set(uncachedKeys[i], embeddings[i]);
6466
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
6467
6467
  updateVaultMemoryEmbeddingOp(
6468
6468
  vaultCtx,
6469
6469
  uncachedIds[i],
@@ -6477,7 +6477,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6477
6477
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
6478
6478
  if (isEncrypted(content)) return;
6479
6479
  const embedding = await generateEmbedding(content, embeddingOptions);
6480
- cache.set(content, embedding);
6480
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
6481
6481
  if (vaultCtx && memoryId) {
6482
6482
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
6483
6483
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -6518,16 +6518,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6518
6518
  let staleReembedCount = 0;
6519
6519
  for (let i = 0; i < memories.length; i++) {
6520
6520
  const content = memories[i].content;
6521
- const cached = cache.get(content);
6521
+ const memoryId = memories[i].uniqueId;
6522
+ const cached = cache.get(memoryId);
6522
6523
  if (cached && cached.length === queryEmbedding.length) continue;
6523
- if (cached) cache.delete(content);
6524
+ if (cached) cache.delete(memoryId);
6524
6525
  const storedModel = memories[i].embeddingModel;
6525
6526
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
6526
6527
  if (memories[i].embedding && modelCompatible) {
6527
6528
  try {
6528
6529
  const parsed = JSON.parse(memories[i].embedding);
6529
6530
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
6530
- cache.set(content, parsed);
6531
+ cache.set(memoryId, Float32Array.from(parsed));
6531
6532
  continue;
6532
6533
  }
6533
6534
  } catch {
@@ -6545,7 +6546,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6545
6546
  if (uncachedTexts.length > 0) {
6546
6547
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6547
6548
  for (let j = 0; j < uncachedTexts.length; j++) {
6548
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
6549
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
6549
6550
  updateVaultMemoryEmbeddingOp(
6550
6551
  vaultCtx,
6551
6552
  memories[uncachedIndices[j]].uniqueId,
@@ -6561,7 +6562,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6561
6562
  const embeddedItems = memories.map((m) => ({
6562
6563
  id: m.uniqueId,
6563
6564
  content: m.content,
6564
- embedding: cache.get(m.content) ?? [],
6565
+ embedding: cache.get(m.uniqueId) ?? [],
6565
6566
  createdAt: m.createdAt,
6566
6567
  updatedAt: m.updatedAt,
6567
6568
  proofCount: m.proofCount,
@@ -13984,7 +13985,6 @@ async function retain(content, ctx, options = {}) {
13984
13985
  }
13985
13986
  }
13986
13987
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
13987
- ctx.vaultCache.set(trimmed, embedding);
13988
13988
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
13989
13989
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
13990
13990
  content: trimmed,
@@ -14005,6 +14005,7 @@ async function retain(content, ctx, options = {}) {
14005
14005
  }
14006
14006
  }
14007
14007
  });
14008
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
14008
14009
  return {
14009
14010
  action: "create",
14010
14011
  memoryId: created.uniqueId,
@@ -14081,7 +14082,6 @@ async function tryConsolidate(trimmed, ctx, options) {
14081
14082
  options.sourceChunkIds ?? []
14082
14083
  );
14083
14084
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
14084
- ctx.vaultCache.set(decision.content, newEmbedding);
14085
14085
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
14086
14086
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
14087
14087
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -14101,6 +14101,7 @@ async function tryConsolidate(trimmed, ctx, options) {
14101
14101
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
14102
14102
  return null;
14103
14103
  }
14104
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
14104
14105
  return {
14105
14106
  action: "update",
14106
14107
  memoryId: decision.targetId,
@@ -15170,9 +15171,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
15170
15171
  return `Error: Failed to update memory "${id}".`;
15171
15172
  }
15172
15173
  if (embeddingOptions && cache) {
15173
- if (previousContent) {
15174
- cache.delete(previousContent);
15175
- }
15174
+ cache.delete(id);
15176
15175
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
15177
15176
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
15178
15177
  () => {
@@ -17795,7 +17794,7 @@ function useChatStorage(options) {
17795
17794
  const result = await updateVaultMemoryOp(vaultCtx, id, { content, scope, embedding: null });
17796
17795
  if (result && getToken) {
17797
17796
  if (existing) {
17798
- vaultEmbeddingCacheRef.current.delete(existing.content);
17797
+ vaultEmbeddingCacheRef.current.delete(id);
17799
17798
  }
17800
17799
  eagerEmbedContent(
17801
17800
  content,
@@ -17816,7 +17815,7 @@ function useChatStorage(options) {
17816
17815
  const existing = await getVaultMemoryOp(vaultCtx, id);
17817
17816
  const result = await deleteVaultMemoryOp(vaultCtx, id);
17818
17817
  if (result && existing) {
17819
- vaultEmbeddingCacheRef.current.delete(existing.content);
17818
+ vaultEmbeddingCacheRef.current.delete(id);
17820
17819
  }
17821
17820
  return result;
17822
17821
  },
@@ -5857,7 +5857,9 @@ interface RecencyOptions {
5857
5857
 
5858
5858
  declare const DEFAULT_VAULT_CACHE_SIZE = 5000;
5859
5859
  /**
5860
- * Create a VaultEmbeddingCache backed by an LRU with a default cap of 1000 entries.
5860
+ * Create a VaultEmbeddingCache backed by an LRU with a default cap of
5861
+ * DEFAULT_VAULT_CACHE_SIZE entries. Values are Float32Array — the model's
5862
+ * native precision — not float64 number[], halving resident RAM losslessly.
5861
5863
  */
5862
5864
  declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCache;
5863
5865
 
@@ -5872,7 +5874,7 @@ declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCach
5872
5874
  * Embedding cache keyed by content string. Stores pre-computed embeddings
5873
5875
  * so that search only needs to embed the query, not the vault entries.
5874
5876
  */
5875
- type VaultEmbeddingCache = Map<string, number[]>;
5877
+ type VaultEmbeddingCache = Map<string, Float32Array>;
5876
5878
  /**
5877
5879
  * Options for the vault search tool.
5878
5880
  */
@@ -5857,7 +5857,9 @@ interface RecencyOptions {
5857
5857
 
5858
5858
  declare const DEFAULT_VAULT_CACHE_SIZE = 5000;
5859
5859
  /**
5860
- * Create a VaultEmbeddingCache backed by an LRU with a default cap of 1000 entries.
5860
+ * Create a VaultEmbeddingCache backed by an LRU with a default cap of
5861
+ * DEFAULT_VAULT_CACHE_SIZE entries. Values are Float32Array — the model's
5862
+ * native precision — not float64 number[], halving resident RAM losslessly.
5861
5863
  */
5862
5864
  declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCache;
5863
5865
 
@@ -5872,7 +5874,7 @@ declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCach
5872
5874
  * Embedding cache keyed by content string. Stores pre-computed embeddings
5873
5875
  * so that search only needs to embed the query, not the vault entries.
5874
5876
  */
5875
- type VaultEmbeddingCache = Map<string, number[]>;
5877
+ type VaultEmbeddingCache = Map<string, Float32Array>;
5876
5878
  /**
5877
5879
  * Options for the vault search tool.
5878
5880
  */