@anuma/sdk 1.4.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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-UAL346D2.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 },
@@ -5,8 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ var __esm = (fn, res, err) => function __init() {
9
+ if (err) throw err[0];
10
+ try {
11
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
+ } catch (e) {
13
+ throw err = [e], e;
14
+ }
10
15
  };
11
16
  var __export = (target, all) => {
12
17
  for (var name in all)
@@ -6110,29 +6115,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6110
6115
  const uncachedKeys = [];
6111
6116
  const uncachedIds = [];
6112
6117
  for (const m of memories) {
6113
- const key = m.content;
6114
- if (isEncrypted(key)) continue;
6115
- if (!cache.has(key)) {
6118
+ const content = m.content;
6119
+ if (isEncrypted(content)) continue;
6120
+ if (!cache.has(m.uniqueId)) {
6116
6121
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
6117
6122
  if (m.embedding && modelCompatible) {
6118
6123
  try {
6119
6124
  const parsed = JSON.parse(m.embedding);
6120
6125
  if (Array.isArray(parsed)) {
6121
- cache.set(key, parsed);
6126
+ cache.set(m.uniqueId, Float32Array.from(parsed));
6122
6127
  continue;
6123
6128
  }
6124
6129
  } catch {
6125
6130
  }
6126
6131
  }
6127
6132
  uncachedTexts.push(m.content);
6128
- uncachedKeys.push(key);
6133
+ uncachedKeys.push(m.uniqueId);
6129
6134
  uncachedIds.push(m.uniqueId);
6130
6135
  }
6131
6136
  }
6132
6137
  if (uncachedTexts.length > 0) {
6133
6138
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6134
6139
  for (let i = 0; i < uncachedKeys.length; i++) {
6135
- cache.set(uncachedKeys[i], embeddings[i]);
6140
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
6136
6141
  updateVaultMemoryEmbeddingOp(
6137
6142
  vaultCtx,
6138
6143
  uncachedIds[i],
@@ -6146,7 +6151,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6146
6151
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
6147
6152
  if (isEncrypted(content)) return;
6148
6153
  const embedding = await generateEmbedding(content, embeddingOptions);
6149
- cache.set(content, embedding);
6154
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
6150
6155
  if (vaultCtx && memoryId) {
6151
6156
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
6152
6157
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -6187,16 +6192,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6187
6192
  let staleReembedCount = 0;
6188
6193
  for (let i = 0; i < memories.length; i++) {
6189
6194
  const content = memories[i].content;
6190
- const cached = cache.get(content);
6195
+ const memoryId = memories[i].uniqueId;
6196
+ const cached = cache.get(memoryId);
6191
6197
  if (cached && cached.length === queryEmbedding.length) continue;
6192
- if (cached) cache.delete(content);
6198
+ if (cached) cache.delete(memoryId);
6193
6199
  const storedModel = memories[i].embeddingModel;
6194
6200
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
6195
6201
  if (memories[i].embedding && modelCompatible) {
6196
6202
  try {
6197
6203
  const parsed = JSON.parse(memories[i].embedding);
6198
6204
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
6199
- cache.set(content, parsed);
6205
+ cache.set(memoryId, Float32Array.from(parsed));
6200
6206
  continue;
6201
6207
  }
6202
6208
  } catch {
@@ -6214,7 +6220,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6214
6220
  if (uncachedTexts.length > 0) {
6215
6221
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6216
6222
  for (let j = 0; j < uncachedTexts.length; j++) {
6217
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
6223
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
6218
6224
  updateVaultMemoryEmbeddingOp(
6219
6225
  vaultCtx,
6220
6226
  memories[uncachedIndices[j]].uniqueId,
@@ -6230,7 +6236,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6230
6236
  const embeddedItems = memories.map((m) => ({
6231
6237
  id: m.uniqueId,
6232
6238
  content: m.content,
6233
- embedding: cache.get(m.content) ?? [],
6239
+ embedding: cache.get(m.uniqueId) ?? [],
6234
6240
  createdAt: m.createdAt,
6235
6241
  updatedAt: m.updatedAt,
6236
6242
  proofCount: m.proofCount,
@@ -12635,7 +12641,6 @@ async function retain(content, ctx, options = {}) {
12635
12641
  }
12636
12642
  }
12637
12643
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
12638
- ctx.vaultCache.set(trimmed, embedding);
12639
12644
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
12640
12645
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
12641
12646
  content: trimmed,
@@ -12656,6 +12661,7 @@ async function retain(content, ctx, options = {}) {
12656
12661
  }
12657
12662
  }
12658
12663
  });
12664
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
12659
12665
  return {
12660
12666
  action: "create",
12661
12667
  memoryId: created.uniqueId,
@@ -12732,7 +12738,6 @@ async function tryConsolidate(trimmed, ctx, options) {
12732
12738
  options.sourceChunkIds ?? []
12733
12739
  );
12734
12740
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
12735
- ctx.vaultCache.set(decision.content, newEmbedding);
12736
12741
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
12737
12742
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
12738
12743
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -12752,6 +12757,7 @@ async function tryConsolidate(trimmed, ctx, options) {
12752
12757
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
12753
12758
  return null;
12754
12759
  }
12760
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
12755
12761
  return {
12756
12762
  action: "update",
12757
12763
  memoryId: decision.targetId,
@@ -13821,9 +13827,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
13821
13827
  return `Error: Failed to update memory "${id}".`;
13822
13828
  }
13823
13829
  if (embeddingOptions && cache) {
13824
- if (previousContent) {
13825
- cache.delete(previousContent);
13826
- }
13830
+ cache.delete(id);
13827
13831
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
13828
13832
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
13829
13833
  () => {
@@ -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-RMZ4QAQV.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-RMZ4QAQV.mjs";
3
+ } from "./chunk-N4FEY34G.mjs";
4
4
  import "./chunk-DFVCS3QQ.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
package/dist/index.cjs CHANGED
@@ -3,8 +3,13 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __esm = (fn, res) => function __init() {
7
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ var __esm = (fn, res, err) => function __init() {
7
+ if (err) throw err[0];
8
+ try {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ } catch (e) {
11
+ throw err = [e], e;
12
+ }
8
13
  };
9
14
  var __export = (target, all) => {
10
15
  for (var name in all)
@@ -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-L3QROVGM.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 },
@@ -5,8 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ var __esm = (fn, res, err) => function __init() {
9
+ if (err) throw err[0];
10
+ try {
11
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
+ } catch (e) {
13
+ throw err = [e], e;
14
+ }
10
15
  };
11
16
  var __export = (target, all) => {
12
17
  for (var name in all)
@@ -6441,29 +6446,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6441
6446
  const uncachedKeys = [];
6442
6447
  const uncachedIds = [];
6443
6448
  for (const m of memories) {
6444
- const key = m.content;
6445
- if (isEncrypted(key)) continue;
6446
- if (!cache.has(key)) {
6449
+ const content = m.content;
6450
+ if (isEncrypted(content)) continue;
6451
+ if (!cache.has(m.uniqueId)) {
6447
6452
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
6448
6453
  if (m.embedding && modelCompatible) {
6449
6454
  try {
6450
6455
  const parsed = JSON.parse(m.embedding);
6451
6456
  if (Array.isArray(parsed)) {
6452
- cache.set(key, parsed);
6457
+ cache.set(m.uniqueId, Float32Array.from(parsed));
6453
6458
  continue;
6454
6459
  }
6455
6460
  } catch {
6456
6461
  }
6457
6462
  }
6458
6463
  uncachedTexts.push(m.content);
6459
- uncachedKeys.push(key);
6464
+ uncachedKeys.push(m.uniqueId);
6460
6465
  uncachedIds.push(m.uniqueId);
6461
6466
  }
6462
6467
  }
6463
6468
  if (uncachedTexts.length > 0) {
6464
6469
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6465
6470
  for (let i = 0; i < uncachedKeys.length; i++) {
6466
- cache.set(uncachedKeys[i], embeddings[i]);
6471
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
6467
6472
  updateVaultMemoryEmbeddingOp(
6468
6473
  vaultCtx,
6469
6474
  uncachedIds[i],
@@ -6477,7 +6482,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
6477
6482
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
6478
6483
  if (isEncrypted(content)) return;
6479
6484
  const embedding = await generateEmbedding(content, embeddingOptions);
6480
- cache.set(content, embedding);
6485
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
6481
6486
  if (vaultCtx && memoryId) {
6482
6487
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
6483
6488
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -6518,16 +6523,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6518
6523
  let staleReembedCount = 0;
6519
6524
  for (let i = 0; i < memories.length; i++) {
6520
6525
  const content = memories[i].content;
6521
- const cached = cache.get(content);
6526
+ const memoryId = memories[i].uniqueId;
6527
+ const cached = cache.get(memoryId);
6522
6528
  if (cached && cached.length === queryEmbedding.length) continue;
6523
- if (cached) cache.delete(content);
6529
+ if (cached) cache.delete(memoryId);
6524
6530
  const storedModel = memories[i].embeddingModel;
6525
6531
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
6526
6532
  if (memories[i].embedding && modelCompatible) {
6527
6533
  try {
6528
6534
  const parsed = JSON.parse(memories[i].embedding);
6529
6535
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
6530
- cache.set(content, parsed);
6536
+ cache.set(memoryId, Float32Array.from(parsed));
6531
6537
  continue;
6532
6538
  }
6533
6539
  } catch {
@@ -6545,7 +6551,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6545
6551
  if (uncachedTexts.length > 0) {
6546
6552
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
6547
6553
  for (let j = 0; j < uncachedTexts.length; j++) {
6548
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
6554
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
6549
6555
  updateVaultMemoryEmbeddingOp(
6550
6556
  vaultCtx,
6551
6557
  memories[uncachedIndices[j]].uniqueId,
@@ -6561,7 +6567,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
6561
6567
  const embeddedItems = memories.map((m) => ({
6562
6568
  id: m.uniqueId,
6563
6569
  content: m.content,
6564
- embedding: cache.get(m.content) ?? [],
6570
+ embedding: cache.get(m.uniqueId) ?? [],
6565
6571
  createdAt: m.createdAt,
6566
6572
  updatedAt: m.updatedAt,
6567
6573
  proofCount: m.proofCount,
@@ -13984,7 +13990,6 @@ async function retain(content, ctx, options = {}) {
13984
13990
  }
13985
13991
  }
13986
13992
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
13987
- ctx.vaultCache.set(trimmed, embedding);
13988
13993
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
13989
13994
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
13990
13995
  content: trimmed,
@@ -14005,6 +14010,7 @@ async function retain(content, ctx, options = {}) {
14005
14010
  }
14006
14011
  }
14007
14012
  });
14013
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
14008
14014
  return {
14009
14015
  action: "create",
14010
14016
  memoryId: created.uniqueId,
@@ -14081,7 +14087,6 @@ async function tryConsolidate(trimmed, ctx, options) {
14081
14087
  options.sourceChunkIds ?? []
14082
14088
  );
14083
14089
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
14084
- ctx.vaultCache.set(decision.content, newEmbedding);
14085
14090
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
14086
14091
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
14087
14092
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -14101,6 +14106,7 @@ async function tryConsolidate(trimmed, ctx, options) {
14101
14106
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
14102
14107
  return null;
14103
14108
  }
14109
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
14104
14110
  return {
14105
14111
  action: "update",
14106
14112
  memoryId: decision.targetId,
@@ -15170,9 +15176,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
15170
15176
  return `Error: Failed to update memory "${id}".`;
15171
15177
  }
15172
15178
  if (embeddingOptions && cache) {
15173
- if (previousContent) {
15174
- cache.delete(previousContent);
15175
- }
15179
+ cache.delete(id);
15176
15180
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
15177
15181
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
15178
15182
  () => {
@@ -17795,7 +17799,7 @@ function useChatStorage(options) {
17795
17799
  const result = await updateVaultMemoryOp(vaultCtx, id, { content, scope, embedding: null });
17796
17800
  if (result && getToken) {
17797
17801
  if (existing) {
17798
- vaultEmbeddingCacheRef.current.delete(existing.content);
17802
+ vaultEmbeddingCacheRef.current.delete(id);
17799
17803
  }
17800
17804
  eagerEmbedContent(
17801
17805
  content,
@@ -17816,7 +17820,7 @@ function useChatStorage(options) {
17816
17820
  const existing = await getVaultMemoryOp(vaultCtx, id);
17817
17821
  const result = await deleteVaultMemoryOp(vaultCtx, id);
17818
17822
  if (result && existing) {
17819
- vaultEmbeddingCacheRef.current.delete(existing.content);
17823
+ vaultEmbeddingCacheRef.current.delete(id);
17820
17824
  }
17821
17825
  return result;
17822
17826
  },
@@ -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
  */
@@ -121,7 +121,7 @@ import {
121
121
  updateVaultMemoryEmbeddingOp,
122
122
  updateVaultMemoryOp,
123
123
  useEncryption
124
- } from "./chunk-4FNDAPTF.mjs";
124
+ } from "./chunk-63IW5BS5.mjs";
125
125
  import {
126
126
  PiiRedactor,
127
127
  createStreamingDeAnonymizer,
@@ -6733,7 +6733,6 @@ async function retain(content, ctx, options = {}) {
6733
6733
  }
6734
6734
  }
6735
6735
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
6736
- ctx.vaultCache.set(trimmed, embedding);
6737
6736
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
6738
6737
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
6739
6738
  content: trimmed,
@@ -6754,6 +6753,7 @@ async function retain(content, ctx, options = {}) {
6754
6753
  }
6755
6754
  }
6756
6755
  });
6756
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
6757
6757
  return {
6758
6758
  action: "create",
6759
6759
  memoryId: created.uniqueId,
@@ -6830,7 +6830,6 @@ async function tryConsolidate(trimmed, ctx, options) {
6830
6830
  options.sourceChunkIds ?? []
6831
6831
  );
6832
6832
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
6833
- ctx.vaultCache.set(decision.content, newEmbedding);
6834
6833
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
6835
6834
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
6836
6835
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -6850,6 +6849,7 @@ async function tryConsolidate(trimmed, ctx, options) {
6850
6849
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
6851
6850
  return null;
6852
6851
  }
6852
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
6853
6853
  return {
6854
6854
  action: "update",
6855
6855
  memoryId: decision.targetId,
@@ -7894,9 +7894,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
7894
7894
  return `Error: Failed to update memory "${id}".`;
7895
7895
  }
7896
7896
  if (embeddingOptions && cache) {
7897
- if (previousContent) {
7898
- cache.delete(previousContent);
7899
- }
7897
+ cache.delete(id);
7900
7898
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
7901
7899
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
7902
7900
  () => {
@@ -10499,7 +10497,7 @@ function useChatStorage(options) {
10499
10497
  const result = await updateVaultMemoryOp(vaultCtx, id, { content, scope, embedding: null });
10500
10498
  if (result && getToken) {
10501
10499
  if (existing) {
10502
- vaultEmbeddingCacheRef.current.delete(existing.content);
10500
+ vaultEmbeddingCacheRef.current.delete(id);
10503
10501
  }
10504
10502
  eagerEmbedContent(
10505
10503
  content,
@@ -10520,7 +10518,7 @@ function useChatStorage(options) {
10520
10518
  const existing = await getVaultMemoryOp(vaultCtx, id);
10521
10519
  const result = await deleteVaultMemoryOp(vaultCtx, id);
10522
10520
  if (result && existing) {
10523
- vaultEmbeddingCacheRef.current.delete(existing.content);
10521
+ vaultEmbeddingCacheRef.current.delete(id);
10524
10522
  }
10525
10523
  return result;
10526
10524
  },
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-4FNDAPTF.mjs";
3
+ } from "./chunk-63IW5BS5.mjs";
4
4
  import "./chunk-DFVCS3QQ.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
@@ -5,7 +5,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
8
+ try {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ } catch (e) {
11
+ throw mod = 0, e;
12
+ }
9
13
  };
10
14
  var __copyProps = (to, from, except, desc) => {
11
15
  if (from && typeof from === "object" || typeof from === "function") {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  callPortalJsonCompletion,
3
3
  getLogger
4
- } from "./chunk-RCCKRTBI.mjs";
4
+ } from "./chunk-AHJT66EO.mjs";
5
5
  import {
6
6
  BASE_URL,
7
7
  __commonJS,
8
8
  __toESM,
9
9
  createClientConfig
10
- } from "./chunk-FMGZTVXQ.mjs";
10
+ } from "./chunk-3RPGXXPZ.mjs";
11
11
 
12
12
  // node_modules/.pnpm/@babel+runtime@7.26.0/node_modules/@babel/runtime/helpers/interopRequireDefault.js
13
13
  var require_interopRequireDefault = __commonJS({
@@ -18531,29 +18531,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
18531
18531
  const uncachedKeys = [];
18532
18532
  const uncachedIds = [];
18533
18533
  for (const m of memories) {
18534
- const key = m.content;
18535
- if (isEncrypted(key)) continue;
18536
- if (!cache.has(key)) {
18534
+ const content = m.content;
18535
+ if (isEncrypted(content)) continue;
18536
+ if (!cache.has(m.uniqueId)) {
18537
18537
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
18538
18538
  if (m.embedding && modelCompatible) {
18539
18539
  try {
18540
18540
  const parsed = JSON.parse(m.embedding);
18541
18541
  if (Array.isArray(parsed)) {
18542
- cache.set(key, parsed);
18542
+ cache.set(m.uniqueId, Float32Array.from(parsed));
18543
18543
  continue;
18544
18544
  }
18545
18545
  } catch {
18546
18546
  }
18547
18547
  }
18548
18548
  uncachedTexts.push(m.content);
18549
- uncachedKeys.push(key);
18549
+ uncachedKeys.push(m.uniqueId);
18550
18550
  uncachedIds.push(m.uniqueId);
18551
18551
  }
18552
18552
  }
18553
18553
  if (uncachedTexts.length > 0) {
18554
18554
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
18555
18555
  for (let i = 0; i < uncachedKeys.length; i++) {
18556
- cache.set(uncachedKeys[i], embeddings[i]);
18556
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
18557
18557
  updateVaultMemoryEmbeddingOp(
18558
18558
  vaultCtx,
18559
18559
  uncachedIds[i],
@@ -18567,7 +18567,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
18567
18567
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
18568
18568
  if (isEncrypted(content)) return;
18569
18569
  const embedding = await generateEmbedding(content, embeddingOptions);
18570
- cache.set(content, embedding);
18570
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
18571
18571
  if (vaultCtx && memoryId) {
18572
18572
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
18573
18573
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -18608,16 +18608,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
18608
18608
  let staleReembedCount = 0;
18609
18609
  for (let i = 0; i < memories.length; i++) {
18610
18610
  const content = memories[i].content;
18611
- const cached = cache.get(content);
18611
+ const memoryId = memories[i].uniqueId;
18612
+ const cached = cache.get(memoryId);
18612
18613
  if (cached && cached.length === queryEmbedding.length) continue;
18613
- if (cached) cache.delete(content);
18614
+ if (cached) cache.delete(memoryId);
18614
18615
  const storedModel = memories[i].embeddingModel;
18615
18616
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
18616
18617
  if (memories[i].embedding && modelCompatible) {
18617
18618
  try {
18618
18619
  const parsed = JSON.parse(memories[i].embedding);
18619
18620
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
18620
- cache.set(content, parsed);
18621
+ cache.set(memoryId, Float32Array.from(parsed));
18621
18622
  continue;
18622
18623
  }
18623
18624
  } catch {
@@ -18635,7 +18636,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
18635
18636
  if (uncachedTexts.length > 0) {
18636
18637
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
18637
18638
  for (let j = 0; j < uncachedTexts.length; j++) {
18638
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
18639
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
18639
18640
  updateVaultMemoryEmbeddingOp(
18640
18641
  vaultCtx,
18641
18642
  memories[uncachedIndices[j]].uniqueId,
@@ -18651,7 +18652,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
18651
18652
  const embeddedItems = memories.map((m) => ({
18652
18653
  id: m.uniqueId,
18653
18654
  content: m.content,
18654
- embedding: cache.get(m.content) ?? [],
18655
+ embedding: cache.get(m.uniqueId) ?? [],
18655
18656
  createdAt: m.createdAt,
18656
18657
  updatedAt: m.updatedAt,
18657
18658
  proofCount: m.proofCount,
@@ -18847,7 +18848,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
18847
18848
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
18848
18849
  );
18849
18850
  }
18850
- const { recall: recall2 } = await import("./recall-UHJN6H5V.mjs");
18851
+ const { recall: recall2 } = await import("./recall-RMBNCEG6.mjs");
18851
18852
  const result = await recall2(
18852
18853
  query,
18853
18854
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BASE_URL
3
- } from "./chunk-FMGZTVXQ.mjs";
3
+ } from "./chunk-3RPGXXPZ.mjs";
4
4
 
5
5
  // src/lib/logger.ts
6
6
  var consoleLogger = {
@@ -3,7 +3,7 @@ import {
3
3
  MCP_R2_DOMAIN,
4
4
  createClientConfig,
5
5
  resolveBaseUrl
6
- } from "./chunk-FMGZTVXQ.mjs";
6
+ } from "./chunk-3RPGXXPZ.mjs";
7
7
  export {
8
8
  BASE_URL,
9
9
  MCP_R2_DOMAIN,
@@ -4,8 +4,8 @@ import {
4
4
  import {
5
5
  callPortalJsonCompletion,
6
6
  getLogger
7
- } from "./chunk-RCCKRTBI.mjs";
8
- import "./chunk-FMGZTVXQ.mjs";
7
+ } from "./chunk-AHJT66EO.mjs";
8
+ import "./chunk-3RPGXXPZ.mjs";
9
9
 
10
10
  // src/lib/memory/consolidate.ts
11
11
  var DEFAULT_MODEL = "inclusionai/ling-2.6-flash";
@@ -5,11 +5,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __esm = (fn, res) => function __init() {
9
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ var __esm = (fn, res, err) => function __init() {
9
+ if (err) throw err[0];
10
+ try {
11
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
12
+ } catch (e) {
13
+ throw err = [e], e;
14
+ }
10
15
  };
11
16
  var __commonJS = (cb, mod) => function __require() {
12
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ try {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ } catch (e) {
20
+ throw mod = 0, e;
21
+ }
13
22
  };
14
23
  var __export = (target, all) => {
15
24
  for (var name in all)
@@ -20246,29 +20255,29 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
20246
20255
  const uncachedKeys = [];
20247
20256
  const uncachedIds = [];
20248
20257
  for (const m of memories) {
20249
- const key = m.content;
20250
- if (isEncrypted(key)) continue;
20251
- if (!cache.has(key)) {
20258
+ const content = m.content;
20259
+ if (isEncrypted(content)) continue;
20260
+ if (!cache.has(m.uniqueId)) {
20252
20261
  const modelCompatible = (m.embeddingModel ?? currentModel) === currentModel;
20253
20262
  if (m.embedding && modelCompatible) {
20254
20263
  try {
20255
20264
  const parsed = JSON.parse(m.embedding);
20256
20265
  if (Array.isArray(parsed)) {
20257
- cache.set(key, parsed);
20266
+ cache.set(m.uniqueId, Float32Array.from(parsed));
20258
20267
  continue;
20259
20268
  }
20260
20269
  } catch {
20261
20270
  }
20262
20271
  }
20263
20272
  uncachedTexts.push(m.content);
20264
- uncachedKeys.push(key);
20273
+ uncachedKeys.push(m.uniqueId);
20265
20274
  uncachedIds.push(m.uniqueId);
20266
20275
  }
20267
20276
  }
20268
20277
  if (uncachedTexts.length > 0) {
20269
20278
  const embeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
20270
20279
  for (let i = 0; i < uncachedKeys.length; i++) {
20271
- cache.set(uncachedKeys[i], embeddings[i]);
20280
+ cache.set(uncachedKeys[i], Float32Array.from(embeddings[i]));
20272
20281
  updateVaultMemoryEmbeddingOp(
20273
20282
  vaultCtx,
20274
20283
  uncachedIds[i],
@@ -20282,7 +20291,7 @@ async function preEmbedVaultMemories(vaultCtx, embeddingOptions, cache, options)
20282
20291
  async function eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, memoryId) {
20283
20292
  if (isEncrypted(content)) return;
20284
20293
  const embedding = await generateEmbedding(content, embeddingOptions);
20285
- cache.set(content, embedding);
20294
+ if (memoryId) cache.set(memoryId, Float32Array.from(embedding));
20286
20295
  if (vaultCtx && memoryId) {
20287
20296
  const currentModel = embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
20288
20297
  updateVaultMemoryEmbeddingOp(vaultCtx, memoryId, JSON.stringify(embedding), currentModel).catch(
@@ -20323,16 +20332,17 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
20323
20332
  let staleReembedCount = 0;
20324
20333
  for (let i = 0; i < memories.length; i++) {
20325
20334
  const content = memories[i].content;
20326
- const cached = cache.get(content);
20335
+ const memoryId = memories[i].uniqueId;
20336
+ const cached = cache.get(memoryId);
20327
20337
  if (cached && cached.length === queryEmbedding.length) continue;
20328
- if (cached) cache.delete(content);
20338
+ if (cached) cache.delete(memoryId);
20329
20339
  const storedModel = memories[i].embeddingModel;
20330
20340
  const modelCompatible = (storedModel ?? currentModel) === currentModel;
20331
20341
  if (memories[i].embedding && modelCompatible) {
20332
20342
  try {
20333
20343
  const parsed = JSON.parse(memories[i].embedding);
20334
20344
  if (Array.isArray(parsed) && parsed.length === queryEmbedding.length) {
20335
- cache.set(content, parsed);
20345
+ cache.set(memoryId, Float32Array.from(parsed));
20336
20346
  continue;
20337
20347
  }
20338
20348
  } catch {
@@ -20350,7 +20360,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
20350
20360
  if (uncachedTexts.length > 0) {
20351
20361
  const newEmbeddings = await generateEmbeddings(uncachedTexts, embeddingOptions);
20352
20362
  for (let j = 0; j < uncachedTexts.length; j++) {
20353
- cache.set(memories[uncachedIndices[j]].content, newEmbeddings[j]);
20363
+ cache.set(memories[uncachedIndices[j]].uniqueId, Float32Array.from(newEmbeddings[j]));
20354
20364
  updateVaultMemoryEmbeddingOp(
20355
20365
  vaultCtx,
20356
20366
  memories[uncachedIndices[j]].uniqueId,
@@ -20366,7 +20376,7 @@ async function searchVaultMemoriesWithSize(query, vaultCtx, embeddingOptions, ca
20366
20376
  const embeddedItems = memories.map((m) => ({
20367
20377
  id: m.uniqueId,
20368
20378
  content: m.content,
20369
- embedding: cache.get(m.content) ?? [],
20379
+ embedding: cache.get(m.uniqueId) ?? [],
20370
20380
  createdAt: m.createdAt,
20371
20381
  updatedAt: m.updatedAt,
20372
20382
  proofCount: m.proofCount,
@@ -25527,9 +25537,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
25527
25537
  return `Error: Failed to update memory "${id}".`;
25528
25538
  }
25529
25539
  if (embeddingOptions && cache) {
25530
- if (previousContent) {
25531
- cache.delete(previousContent);
25532
- }
25540
+ cache.delete(id);
25533
25541
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
25534
25542
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
25535
25543
  () => {
@@ -25640,7 +25648,6 @@ async function retain(content, ctx, options = {}) {
25640
25648
  }
25641
25649
  }
25642
25650
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
25643
- ctx.vaultCache.set(trimmed, embedding);
25644
25651
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
25645
25652
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
25646
25653
  content: trimmed,
@@ -25661,6 +25668,7 @@ async function retain(content, ctx, options = {}) {
25661
25668
  }
25662
25669
  }
25663
25670
  });
25671
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
25664
25672
  return {
25665
25673
  action: "create",
25666
25674
  memoryId: created.uniqueId,
@@ -25737,7 +25745,6 @@ async function tryConsolidate(trimmed, ctx, options) {
25737
25745
  options.sourceChunkIds ?? []
25738
25746
  );
25739
25747
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
25740
- ctx.vaultCache.set(decision.content, newEmbedding);
25741
25748
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
25742
25749
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
25743
25750
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -25757,6 +25764,7 @@ async function tryConsolidate(trimmed, ctx, options) {
25757
25764
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
25758
25765
  return null;
25759
25766
  }
25767
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
25760
25768
  return {
25761
25769
  action: "update",
25762
25770
  memoryId: decision.targetId,
@@ -5311,7 +5311,9 @@ interface RecencyOptions {
5311
5311
 
5312
5312
  declare const DEFAULT_VAULT_CACHE_SIZE = 5000;
5313
5313
  /**
5314
- * Create a VaultEmbeddingCache backed by an LRU with a default cap of 1000 entries.
5314
+ * Create a VaultEmbeddingCache backed by an LRU with a default cap of
5315
+ * DEFAULT_VAULT_CACHE_SIZE entries. Values are Float32Array — the model's
5316
+ * native precision — not float64 number[], halving resident RAM losslessly.
5315
5317
  */
5316
5318
  declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCache;
5317
5319
 
@@ -5326,7 +5328,7 @@ declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCach
5326
5328
  * Embedding cache keyed by content string. Stores pre-computed embeddings
5327
5329
  * so that search only needs to embed the query, not the vault entries.
5328
5330
  */
5329
- type VaultEmbeddingCache = Map<string, number[]>;
5331
+ type VaultEmbeddingCache = Map<string, Float32Array>;
5330
5332
  /**
5331
5333
  * Options for the vault search tool.
5332
5334
  */
@@ -5311,7 +5311,9 @@ interface RecencyOptions {
5311
5311
 
5312
5312
  declare const DEFAULT_VAULT_CACHE_SIZE = 5000;
5313
5313
  /**
5314
- * Create a VaultEmbeddingCache backed by an LRU with a default cap of 1000 entries.
5314
+ * Create a VaultEmbeddingCache backed by an LRU with a default cap of
5315
+ * DEFAULT_VAULT_CACHE_SIZE entries. Values are Float32Array — the model's
5316
+ * native precision — not float64 number[], halving resident RAM losslessly.
5315
5317
  */
5316
5318
  declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCache;
5317
5319
 
@@ -5326,7 +5328,7 @@ declare function createVaultEmbeddingCache(maxSize?: number): VaultEmbeddingCach
5326
5328
  * Embedding cache keyed by content string. Stores pre-computed embeddings
5327
5329
  * so that search only needs to embed the query, not the vault entries.
5328
5330
  */
5329
- type VaultEmbeddingCache = Map<string, number[]>;
5331
+ type VaultEmbeddingCache = Map<string, Float32Array>;
5330
5332
  /**
5331
5333
  * Options for the vault search tool.
5332
5334
  */
@@ -95,7 +95,7 @@ import {
95
95
  updateVaultMemoryEmbeddingOp,
96
96
  updateVaultMemoryOp,
97
97
  upsertMessageOp
98
- } from "./chunk-SJLYHCMG.mjs";
98
+ } from "./chunk-45GOZ3AB.mjs";
99
99
  import {
100
100
  createStreamingDeAnonymizer,
101
101
  resolvePiiRedactor
@@ -106,13 +106,13 @@ import {
106
106
  getLogger,
107
107
  resolvePortalAuthHeaders,
108
108
  supportsResponseFormat
109
- } from "./chunk-RCCKRTBI.mjs";
109
+ } from "./chunk-AHJT66EO.mjs";
110
110
  import {
111
111
  BASE_URL,
112
112
  __commonJS,
113
113
  __decorateClass,
114
114
  __toESM
115
- } from "./chunk-FMGZTVXQ.mjs";
115
+ } from "./chunk-3RPGXXPZ.mjs";
116
116
 
117
117
  // node_modules/.pnpm/@nozbe+watermelondb@0.28.0/node_modules/@nozbe/watermelondb/utils/fp/sortBy/index.js
118
118
  var require_sortBy = __commonJS({
@@ -4595,9 +4595,7 @@ function createMemoryVaultTool(vaultCtx, options, embeddingOptions, cache) {
4595
4595
  return `Error: Failed to update memory "${id}".`;
4596
4596
  }
4597
4597
  if (embeddingOptions && cache) {
4598
- if (previousContent) {
4599
- cache.delete(previousContent);
4600
- }
4598
+ cache.delete(id);
4601
4599
  eagerEmbedContent(content, embeddingOptions, cache, vaultCtx, id).catch(
4602
4600
  // Silently swallow – SDK must not use console.*; embedding will be retried on next search
4603
4601
  () => {
@@ -4699,7 +4697,6 @@ async function retain(content, ctx, options = {}) {
4699
4697
  }
4700
4698
  }
4701
4699
  const embedding = await generateEmbedding(trimmed, ctx.embeddingOptions);
4702
- ctx.vaultCache.set(trimmed, embedding);
4703
4700
  const embeddingModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
4704
4701
  const created = await createVaultMemoryOp(ctx.vaultCtx, {
4705
4702
  content: trimmed,
@@ -4720,6 +4717,7 @@ async function retain(content, ctx, options = {}) {
4720
4717
  }
4721
4718
  }
4722
4719
  });
4720
+ ctx.vaultCache.set(created.uniqueId, Float32Array.from(embedding));
4723
4721
  return {
4724
4722
  action: "create",
4725
4723
  memoryId: created.uniqueId,
@@ -4759,7 +4757,7 @@ async function tryConsolidate(trimmed, ctx, options) {
4759
4757
  content: m.content,
4760
4758
  similarity: m.similarity
4761
4759
  }));
4762
- const { consolidateMemory: doConsolidate } = await import("./consolidate-A2ZIX5WF.mjs");
4760
+ const { consolidateMemory: doConsolidate } = await import("./consolidate-TDT4HRHG.mjs");
4763
4761
  const decision = await doConsolidate(trimmed, candidates, consolidateOptions);
4764
4762
  if (decision.action === "create") return null;
4765
4763
  if (decision.action === "noop" && decision.targetId) {
@@ -4796,7 +4794,6 @@ async function tryConsolidate(trimmed, ctx, options) {
4796
4794
  options.sourceChunkIds ?? []
4797
4795
  );
4798
4796
  const newEmbedding = await generateEmbedding(decision.content, ctx.embeddingOptions);
4799
- ctx.vaultCache.set(decision.content, newEmbedding);
4800
4797
  const consolidatedModel = ctx.embeddingOptions.model ?? DEFAULT_API_EMBEDDING_MODEL;
4801
4798
  const eventTimeUpdate = pickEventTimeUpdate(existing, options.eventTime);
4802
4799
  const updated = await updateVaultMemoryOp(ctx.vaultCtx, decision.targetId, {
@@ -4816,6 +4813,7 @@ async function tryConsolidate(trimmed, ctx, options) {
4816
4813
  await assertMergeTargetGoneOrThrow(ctx, decision.targetId);
4817
4814
  return null;
4818
4815
  }
4816
+ ctx.vaultCache.set(decision.targetId, Float32Array.from(newEmbedding));
4819
4817
  return {
4820
4818
  action: "update",
4821
4819
  memoryId: decision.targetId,
@@ -5768,7 +5766,7 @@ async function getServerTools(options) {
5768
5766
  return cached.tools;
5769
5767
  }
5770
5768
  try {
5771
- const { BASE_URL: BASE_URL2 } = await import("./clientConfig-GMADOBPK.mjs");
5769
+ const { BASE_URL: BASE_URL2 } = await import("./clientConfig-VIMT6Q32.mjs");
5772
5770
  const effectiveBaseUrl = baseUrl ?? BASE_URL2;
5773
5771
  if (apiKey) {
5774
5772
  const response = await fetch(`${effectiveBaseUrl}/api/v1/tools`, {
@@ -0,0 +1,8 @@
1
+ import {
2
+ recall
3
+ } from "./chunk-45GOZ3AB.mjs";
4
+ import "./chunk-AHJT66EO.mjs";
5
+ import "./chunk-3RPGXXPZ.mjs";
6
+ export {
7
+ recall
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "1.4.1",
3
+ "version": "2.0.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -200,6 +200,7 @@
200
200
  "typescript": "^5.9.3",
201
201
  "typescript-eslint": "^8.56.0",
202
202
  "unist-util-visit": "^5.0.0",
203
+ "vite": ">=7.3.5 <8.0.0",
203
204
  "vitest": "^4.1.8"
204
205
  },
205
206
  "peerDependencies": {
@@ -235,22 +236,30 @@
235
236
  "overrides": {
236
237
  "react": ">=19.0.1 <19.1.0 || >=19.1.2 <19.2.0 || >=19.2.1",
237
238
  "react-dom": ">=19.0.1 <19.1.0 || >=19.1.2 <19.2.0 || >=19.2.1",
238
- "tar": ">=7.5.11",
239
+ "tar": ">=7.5.16",
239
240
  "picomatch": ">=2.3.2 <3.0.0 || >=4.0.4",
240
241
  "@xmldom/xmldom": ">=0.8.13 <0.9.0",
241
242
  "protobufjs": ">=7.6.1 <8.0.0",
242
243
  "tmp": ">=0.2.7",
243
244
  "ws@6": ">=6.2.4 <7.0.0",
244
245
  "ws@7": ">=7.5.11 <8.0.0",
246
+ "ws@8": ">=8.21.0 <9.0.0",
245
247
  "shell-quote": ">=1.8.4",
246
248
  "axios": ">=1.16.0 <2.0.0",
247
249
  "hono": ">=4.12.21 <5.0.0",
248
250
  "js-cookie": ">=3.0.7 <4.0.0",
249
251
  "postcss": ">=8.5.10 <9.0.0",
250
- "dompurify": ">=3.4.0 <4.0.0",
252
+ "dompurify": ">=3.4.11 <4.0.0",
251
253
  "lodash": ">=4.18.0 <5.0.0",
252
254
  "minimatch@10": ">=10.2.3 <11.0.0",
253
- "uuid@<11.1.1": ">=11.1.1 <12.0.0"
255
+ "uuid@<11.1.1": ">=11.1.1 <12.0.0",
256
+ "form-data@>=4 <4.0.6": ">=4.0.6",
257
+ "undici@>=7 <7.28.0": ">=7.28.0 <8.0.0",
258
+ "vite@>=7 <7.3.5": ">=7.3.5",
259
+ "esbuild@>=0.27.3 <0.28.1": ">=0.28.1",
260
+ "js-yaml@>=4 <4.2.0": ">=4.2.0 <5.0.0",
261
+ "js-yaml@>=3 <3.15.0": ">=3.15.0 <4.0.0",
262
+ "markdown-it@<14.2.0": ">=14.2.0"
254
263
  },
255
264
  "patchedDependencies": {
256
265
  "tesseract.js@6.0.1": "patches/tesseract.js@6.0.1.patch",
@@ -1,8 +0,0 @@
1
- import {
2
- recall
3
- } from "./chunk-SJLYHCMG.mjs";
4
- import "./chunk-RCCKRTBI.mjs";
5
- import "./chunk-FMGZTVXQ.mjs";
6
- export {
7
- recall
8
- };