@anuma/sdk 3.1.0 → 3.1.2

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.
@@ -1474,6 +1474,18 @@ async function upsertMessageOp(ctx, opts) {
1474
1474
  const updated = await _updateMessageOp(ctx, opts.uniqueId, updateOpts);
1475
1475
  return updated ?? messageToStored(existing, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1476
1476
  }
1477
+ async function getMessageOp(ctx, uniqueId) {
1478
+ let message;
1479
+ try {
1480
+ message = await ctx.messagesCollection.find(uniqueId);
1481
+ } catch (error) {
1482
+ if (error instanceof Error && /not found/i.test(error.message)) {
1483
+ return null;
1484
+ }
1485
+ throw error;
1486
+ }
1487
+ return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1488
+ }
1477
1489
  async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
1478
1490
  let message;
1479
1491
  try {
@@ -2500,27 +2512,25 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
2500
2512
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
2501
2513
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
2502
2514
  await ctx.database.write(async () => {
2503
- const prepared = [];
2515
+ const records = [];
2504
2516
  for (const id of chunkIds) {
2505
- let record;
2506
2517
  try {
2507
- record = await ctx.vaultMemoryCollection.find(id);
2518
+ records.push(await ctx.vaultMemoryCollection.find(id));
2508
2519
  } catch {
2509
- continue;
2510
2520
  }
2511
- if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.topicsUserManaged) {
2512
- continue;
2513
- }
2514
- const originalUpdatedAt = record.updatedAt.getTime();
2515
- prepared.push(
2516
- record.prepareUpdate((r) => {
2517
- r._setRaw("topics_extracted_at", extractedAt);
2518
- r._setRaw("topics_extracted_version", version);
2519
- r._setRaw("updated_at", originalUpdatedAt);
2520
- })
2521
- );
2522
- stamped.push(id);
2523
2521
  }
2522
+ const eligible = records.filter(
2523
+ (record) => !record.isDeleted && isOwnedByCtxUser(ctx, record) && !record.topicsUserManaged
2524
+ );
2525
+ const prepared = eligible.map((record) => {
2526
+ const originalUpdatedAt = record.updatedAt.getTime();
2527
+ return record.prepareUpdate((r) => {
2528
+ r._setRaw("topics_extracted_at", extractedAt);
2529
+ r._setRaw("topics_extracted_version", version);
2530
+ r._setRaw("updated_at", originalUpdatedAt);
2531
+ });
2532
+ });
2533
+ for (const record of eligible) stamped.push(record.id);
2524
2534
  if (prepared.length > 0) await ctx.database.batch(...prepared);
2525
2535
  });
2526
2536
  }
@@ -2906,13 +2916,7 @@ async function generateEmbeddings(texts, options) {
2906
2916
  // src/lib/memoryEngine/embeddings.ts
2907
2917
  var DEFAULT_MIN_CONTENT_LENGTH = 10;
2908
2918
  async function embedMessage(ctx, messageId, options) {
2909
- let message;
2910
- const conversations = await getConversationsOp(ctx);
2911
- for (const conv of conversations) {
2912
- const messages = await getMessagesOp(ctx, conv.conversationId);
2913
- message = messages.find((m) => m.uniqueId === messageId);
2914
- if (message) break;
2915
- }
2919
+ const message = await getMessageOp(ctx, messageId);
2916
2920
  if (!message) {
2917
2921
  return null;
2918
2922
  }
@@ -2958,13 +2962,7 @@ async function embedAllMessages(ctx, options, filter) {
2958
2962
  }
2959
2963
  async function chunkAndEmbedMessage(ctx, messageId, options) {
2960
2964
  const { chunkSize = DEFAULT_CHUNK_SIZE } = options;
2961
- let message;
2962
- const conversations = await getConversationsOp(ctx);
2963
- for (const conv of conversations) {
2964
- const messages = await getMessagesOp(ctx, conv.conversationId);
2965
- message = messages.find((m) => m.uniqueId === messageId);
2966
- if (message) break;
2967
- }
2965
+ const message = await getMessageOp(ctx, messageId);
2968
2966
  if (!message) {
2969
2967
  return null;
2970
2968
  }
@@ -4324,7 +4322,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
4324
4322
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
4325
4323
  );
4326
4324
  }
4327
- const { recall: recall2 } = await import("./recall-LICO3TJ7.mjs");
4325
+ const { recall: recall2 } = await import("./recall-WPKWZM5N.mjs");
4328
4326
  const result = await recall2(
4329
4327
  query,
4330
4328
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -1585,6 +1585,18 @@ async function upsertMessageOp(ctx, opts) {
1585
1585
  const updated = await _updateMessageOp(ctx, opts.uniqueId, updateOpts);
1586
1586
  return updated ?? messageToStored(existing, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1587
1587
  }
1588
+ async function getMessageOp(ctx, uniqueId) {
1589
+ let message;
1590
+ try {
1591
+ message = await ctx.messagesCollection.find(uniqueId);
1592
+ } catch (error) {
1593
+ if (error instanceof Error && /not found/i.test(error.message)) {
1594
+ return null;
1595
+ }
1596
+ throw error;
1597
+ }
1598
+ return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1599
+ }
1588
1600
  async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
1589
1601
  let message;
1590
1602
  try {
@@ -2274,13 +2286,7 @@ var init_generate = __esm({
2274
2286
 
2275
2287
  // src/lib/memoryEngine/embeddings.ts
2276
2288
  async function embedMessage(ctx, messageId, options) {
2277
- let message;
2278
- const conversations = await getConversationsOp(ctx);
2279
- for (const conv of conversations) {
2280
- const messages = await getMessagesOp(ctx, conv.conversationId);
2281
- message = messages.find((m) => m.uniqueId === messageId);
2282
- if (message) break;
2283
- }
2289
+ const message = await getMessageOp(ctx, messageId);
2284
2290
  if (!message) {
2285
2291
  return null;
2286
2292
  }
@@ -2326,13 +2332,7 @@ async function embedAllMessages(ctx, options, filter) {
2326
2332
  }
2327
2333
  async function chunkAndEmbedMessage(ctx, messageId, options) {
2328
2334
  const { chunkSize = DEFAULT_CHUNK_SIZE } = options;
2329
- let message;
2330
- const conversations = await getConversationsOp(ctx);
2331
- for (const conv of conversations) {
2332
- const messages = await getMessagesOp(ctx, conv.conversationId);
2333
- message = messages.find((m) => m.uniqueId === messageId);
2334
- if (message) break;
2335
- }
2335
+ const message = await getMessageOp(ctx, messageId);
2336
2336
  if (!message) {
2337
2337
  return null;
2338
2338
  }
@@ -3849,27 +3849,25 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
3849
3849
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
3850
3850
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
3851
3851
  await ctx.database.write(async () => {
3852
- const prepared = [];
3852
+ const records = [];
3853
3853
  for (const id of chunkIds) {
3854
- let record;
3855
3854
  try {
3856
- record = await ctx.vaultMemoryCollection.find(id);
3855
+ records.push(await ctx.vaultMemoryCollection.find(id));
3857
3856
  } catch {
3858
- continue;
3859
- }
3860
- if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.topicsUserManaged) {
3861
- continue;
3862
3857
  }
3863
- const originalUpdatedAt = record.updatedAt.getTime();
3864
- prepared.push(
3865
- record.prepareUpdate((r) => {
3866
- r._setRaw("topics_extracted_at", extractedAt);
3867
- r._setRaw("topics_extracted_version", version);
3868
- r._setRaw("updated_at", originalUpdatedAt);
3869
- })
3870
- );
3871
- stamped.push(id);
3872
3858
  }
3859
+ const eligible = records.filter(
3860
+ (record) => !record.isDeleted && isOwnedByCtxUser(ctx, record) && !record.topicsUserManaged
3861
+ );
3862
+ const prepared = eligible.map((record) => {
3863
+ const originalUpdatedAt = record.updatedAt.getTime();
3864
+ return record.prepareUpdate((r) => {
3865
+ r._setRaw("topics_extracted_at", extractedAt);
3866
+ r._setRaw("topics_extracted_version", version);
3867
+ r._setRaw("updated_at", originalUpdatedAt);
3868
+ });
3869
+ });
3870
+ for (const record of eligible) stamped.push(record.id);
3873
3871
  if (prepared.length > 0) await ctx.database.batch(...prepared);
3874
3872
  });
3875
3873
  }
@@ -14003,7 +14001,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
14003
14001
  return formatRecallResult(result.memories);
14004
14002
  } catch (error) {
14005
14003
  const message = error instanceof Error ? error.message : "Unknown error";
14006
- return `Error searching memory: ${message}`;
14004
+ const wrapped = new Error(`recall_memory: search failed \u2014 ${message}`);
14005
+ wrapped.cause = error;
14006
+ throw wrapped;
14007
14007
  }
14008
14008
  }
14009
14009
  };
@@ -18562,6 +18562,7 @@ async function updateVaultFolderOp(ctx, id, opts) {
18562
18562
  if (record.isDeleted) return null;
18563
18563
  const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
18564
18564
  const updated = await ctx.database.write(async () => {
18565
+ const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb22.Q.where("folder_id", id), import_watermelondb22.Q.where("is_deleted", false)).fetch() : [];
18565
18566
  const updates = [];
18566
18567
  updates.push(
18567
18568
  record.prepareUpdate((r) => {
@@ -18569,15 +18570,12 @@ async function updateVaultFolderOp(ctx, id, opts) {
18569
18570
  if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
18570
18571
  })
18571
18572
  );
18572
- if (scopeChanged) {
18573
- const memories = await ctx.vaultMemoryCollection.query(import_watermelondb22.Q.where("folder_id", id), import_watermelondb22.Q.where("is_deleted", false)).fetch();
18574
- for (const memory of memories) {
18575
- updates.push(
18576
- memory.prepareUpdate((r) => {
18577
- r._setRaw("scope", opts.scope);
18578
- })
18579
- );
18580
- }
18573
+ for (const memory of memories) {
18574
+ updates.push(
18575
+ memory.prepareUpdate((r) => {
18576
+ r._setRaw("scope", opts.scope);
18577
+ })
18578
+ );
18581
18579
  }
18582
18580
  await ctx.database.batch(...updates);
18583
18581
  return ctx.vaultFolderCollection.find(id);
@@ -87,7 +87,7 @@ import {
87
87
  upsertMessageOp,
88
88
  useEncryption,
89
89
  vaultMemoryToStored
90
- } from "./chunk-22CSPJLL.mjs";
90
+ } from "./chunk-JVL5PLZS.mjs";
91
91
  import {
92
92
  PII_PATTERNS,
93
93
  PiiRedactor,
@@ -7633,7 +7633,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
7633
7633
  return formatRecallResult(result.memories);
7634
7634
  } catch (error) {
7635
7635
  const message = error instanceof Error ? error.message : "Unknown error";
7636
- return `Error searching memory: ${message}`;
7636
+ const wrapped = new Error(`recall_memory: search failed \u2014 ${message}`);
7637
+ wrapped.cause = error;
7638
+ throw wrapped;
7637
7639
  }
7638
7640
  }
7639
7641
  };
@@ -12154,6 +12156,7 @@ async function updateVaultFolderOp(ctx, id, opts) {
12154
12156
  if (record.isDeleted) return null;
12155
12157
  const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
12156
12158
  const updated = await ctx.database.write(async () => {
12159
+ const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(Q5.where("folder_id", id), Q5.where("is_deleted", false)).fetch() : [];
12157
12160
  const updates = [];
12158
12161
  updates.push(
12159
12162
  record.prepareUpdate((r) => {
@@ -12161,15 +12164,12 @@ async function updateVaultFolderOp(ctx, id, opts) {
12161
12164
  if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
12162
12165
  })
12163
12166
  );
12164
- if (scopeChanged) {
12165
- const memories = await ctx.vaultMemoryCollection.query(Q5.where("folder_id", id), Q5.where("is_deleted", false)).fetch();
12166
- for (const memory of memories) {
12167
- updates.push(
12168
- memory.prepareUpdate((r) => {
12169
- r._setRaw("scope", opts.scope);
12170
- })
12171
- );
12172
- }
12167
+ for (const memory of memories) {
12168
+ updates.push(
12169
+ memory.prepareUpdate((r) => {
12170
+ r._setRaw("scope", opts.scope);
12171
+ })
12172
+ );
12173
12173
  }
12174
12174
  await ctx.database.batch(...updates);
12175
12175
  return ctx.vaultFolderCollection.find(id);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-22CSPJLL.mjs";
3
+ } from "./chunk-JVL5PLZS.mjs";
4
4
  import "./chunk-DFVCS3QQ.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
@@ -1523,6 +1523,18 @@ async function createMessageOp(ctx, opts) {
1523
1523
  });
1524
1524
  return messageToStored(created, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1525
1525
  }
1526
+ async function getMessageOp(ctx, uniqueId) {
1527
+ let message;
1528
+ try {
1529
+ message = await ctx.messagesCollection.find(uniqueId);
1530
+ } catch (error) {
1531
+ if (error instanceof Error && /not found/i.test(error.message)) {
1532
+ return null;
1533
+ }
1534
+ throw error;
1535
+ }
1536
+ return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1537
+ }
1526
1538
  async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
1527
1539
  let message;
1528
1540
  try {
@@ -2707,27 +2719,25 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
2707
2719
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
2708
2720
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
2709
2721
  await ctx.database.write(async () => {
2710
- const prepared = [];
2722
+ const records = [];
2711
2723
  for (const id of chunkIds) {
2712
- let record;
2713
2724
  try {
2714
- record = await ctx.vaultMemoryCollection.find(id);
2725
+ records.push(await ctx.vaultMemoryCollection.find(id));
2715
2726
  } catch {
2716
- continue;
2717
2727
  }
2718
- if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.topicsUserManaged) {
2719
- continue;
2720
- }
2721
- const originalUpdatedAt = record.updatedAt.getTime();
2722
- prepared.push(
2723
- record.prepareUpdate((r) => {
2724
- r._setRaw("topics_extracted_at", extractedAt);
2725
- r._setRaw("topics_extracted_version", version);
2726
- r._setRaw("updated_at", originalUpdatedAt);
2727
- })
2728
- );
2729
- stamped.push(id);
2730
2728
  }
2729
+ const eligible = records.filter(
2730
+ (record) => !record.isDeleted && isOwnedByCtxUser(ctx, record) && !record.topicsUserManaged
2731
+ );
2732
+ const prepared = eligible.map((record) => {
2733
+ const originalUpdatedAt = record.updatedAt.getTime();
2734
+ return record.prepareUpdate((r) => {
2735
+ r._setRaw("topics_extracted_at", extractedAt);
2736
+ r._setRaw("topics_extracted_version", version);
2737
+ r._setRaw("updated_at", originalUpdatedAt);
2738
+ });
2739
+ });
2740
+ for (const record of eligible) stamped.push(record.id);
2731
2741
  if (prepared.length > 0) await ctx.database.batch(...prepared);
2732
2742
  });
2733
2743
  }
@@ -3113,13 +3123,7 @@ async function generateEmbeddings(texts, options) {
3113
3123
  // src/lib/memoryEngine/embeddings.ts
3114
3124
  var DEFAULT_MIN_CONTENT_LENGTH = 10;
3115
3125
  async function embedMessage(ctx, messageId, options) {
3116
- let message;
3117
- const conversations = await getConversationsOp(ctx);
3118
- for (const conv of conversations) {
3119
- const messages = await getMessagesOp(ctx, conv.conversationId);
3120
- message = messages.find((m) => m.uniqueId === messageId);
3121
- if (message) break;
3122
- }
3126
+ const message = await getMessageOp(ctx, messageId);
3123
3127
  if (!message) {
3124
3128
  return null;
3125
3129
  }
@@ -3165,13 +3169,7 @@ async function embedAllMessages(ctx, options, filter) {
3165
3169
  }
3166
3170
  async function chunkAndEmbedMessage(ctx, messageId, options) {
3167
3171
  const { chunkSize = DEFAULT_CHUNK_SIZE } = options;
3168
- let message;
3169
- const conversations = await getConversationsOp(ctx);
3170
- for (const conv of conversations) {
3171
- const messages = await getMessagesOp(ctx, conv.conversationId);
3172
- message = messages.find((m) => m.uniqueId === messageId);
3173
- if (message) break;
3174
- }
3172
+ const message = await getMessageOp(ctx, messageId);
3175
3173
  if (!message) {
3176
3174
  return null;
3177
3175
  }
@@ -4531,7 +4529,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
4531
4529
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
4532
4530
  );
4533
4531
  }
4534
- const { recall: recall2 } = await import("./recall-FPACUZGD.mjs");
4532
+ const { recall: recall2 } = await import("./recall-NG2P5ZQ7.mjs");
4535
4533
  const result = await recall2(
4536
4534
  query,
4537
4535
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -1666,6 +1666,18 @@ async function createMessageOp(ctx, opts) {
1666
1666
  });
1667
1667
  return messageToStored(created, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1668
1668
  }
1669
+ async function getMessageOp(ctx, uniqueId) {
1670
+ let message;
1671
+ try {
1672
+ message = await ctx.messagesCollection.find(uniqueId);
1673
+ } catch (error) {
1674
+ if (error instanceof Error && /not found/i.test(error.message)) {
1675
+ return null;
1676
+ }
1677
+ throw error;
1678
+ }
1679
+ return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
1680
+ }
1669
1681
  async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
1670
1682
  let message;
1671
1683
  try {
@@ -2402,13 +2414,7 @@ var init_generate = __esm({
2402
2414
 
2403
2415
  // src/lib/memoryEngine/embeddings.ts
2404
2416
  async function embedMessage(ctx, messageId, options) {
2405
- let message;
2406
- const conversations = await getConversationsOp(ctx);
2407
- for (const conv of conversations) {
2408
- const messages = await getMessagesOp(ctx, conv.conversationId);
2409
- message = messages.find((m) => m.uniqueId === messageId);
2410
- if (message) break;
2411
- }
2417
+ const message = await getMessageOp(ctx, messageId);
2412
2418
  if (!message) {
2413
2419
  return null;
2414
2420
  }
@@ -2454,13 +2460,7 @@ async function embedAllMessages(ctx, options, filter) {
2454
2460
  }
2455
2461
  async function chunkAndEmbedMessage(ctx, messageId, options) {
2456
2462
  const { chunkSize = DEFAULT_CHUNK_SIZE } = options;
2457
- let message;
2458
- const conversations = await getConversationsOp(ctx);
2459
- for (const conv of conversations) {
2460
- const messages = await getMessagesOp(ctx, conv.conversationId);
2461
- message = messages.find((m) => m.uniqueId === messageId);
2462
- if (message) break;
2463
- }
2463
+ const message = await getMessageOp(ctx, messageId);
2464
2464
  if (!message) {
2465
2465
  return null;
2466
2466
  }
@@ -4056,27 +4056,25 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
4056
4056
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
4057
4057
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
4058
4058
  await ctx.database.write(async () => {
4059
- const prepared = [];
4059
+ const records = [];
4060
4060
  for (const id of chunkIds) {
4061
- let record;
4062
4061
  try {
4063
- record = await ctx.vaultMemoryCollection.find(id);
4062
+ records.push(await ctx.vaultMemoryCollection.find(id));
4064
4063
  } catch {
4065
- continue;
4066
4064
  }
4067
- if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.topicsUserManaged) {
4068
- continue;
4069
- }
4070
- const originalUpdatedAt = record.updatedAt.getTime();
4071
- prepared.push(
4072
- record.prepareUpdate((r) => {
4073
- r._setRaw("topics_extracted_at", extractedAt);
4074
- r._setRaw("topics_extracted_version", version);
4075
- r._setRaw("updated_at", originalUpdatedAt);
4076
- })
4077
- );
4078
- stamped.push(id);
4079
4065
  }
4066
+ const eligible = records.filter(
4067
+ (record) => !record.isDeleted && isOwnedByCtxUser(ctx, record) && !record.topicsUserManaged
4068
+ );
4069
+ const prepared = eligible.map((record) => {
4070
+ const originalUpdatedAt = record.updatedAt.getTime();
4071
+ return record.prepareUpdate((r) => {
4072
+ r._setRaw("topics_extracted_at", extractedAt);
4073
+ r._setRaw("topics_extracted_version", version);
4074
+ r._setRaw("updated_at", originalUpdatedAt);
4075
+ });
4076
+ });
4077
+ for (const record of eligible) stamped.push(record.id);
4080
4078
  if (prepared.length > 0) await ctx.database.batch(...prepared);
4081
4079
  });
4082
4080
  }
@@ -14526,7 +14524,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
14526
14524
  return formatRecallResult(result.memories);
14527
14525
  } catch (error) {
14528
14526
  const message = error instanceof Error ? error.message : "Unknown error";
14529
- return `Error searching memory: ${message}`;
14527
+ const wrapped = new Error(`recall_memory: search failed \u2014 ${message}`);
14528
+ wrapped.cause = error;
14529
+ throw wrapped;
14530
14530
  }
14531
14531
  }
14532
14532
  };
@@ -21098,6 +21098,7 @@ async function updateVaultFolderOp(ctx, id, opts) {
21098
21098
  if (record.isDeleted) return null;
21099
21099
  const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
21100
21100
  const updated = await ctx.database.write(async () => {
21101
+ const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb27.Q.where("folder_id", id), import_watermelondb27.Q.where("is_deleted", false)).fetch() : [];
21101
21102
  const updates = [];
21102
21103
  updates.push(
21103
21104
  record.prepareUpdate((r) => {
@@ -21105,15 +21106,12 @@ async function updateVaultFolderOp(ctx, id, opts) {
21105
21106
  if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
21106
21107
  })
21107
21108
  );
21108
- if (scopeChanged) {
21109
- const memories = await ctx.vaultMemoryCollection.query(import_watermelondb27.Q.where("folder_id", id), import_watermelondb27.Q.where("is_deleted", false)).fetch();
21110
- for (const memory of memories) {
21111
- updates.push(
21112
- memory.prepareUpdate((r) => {
21113
- r._setRaw("scope", opts.scope);
21114
- })
21115
- );
21116
- }
21109
+ for (const memory of memories) {
21110
+ updates.push(
21111
+ memory.prepareUpdate((r) => {
21112
+ r._setRaw("scope", opts.scope);
21113
+ })
21114
+ );
21117
21115
  }
21118
21116
  await ctx.database.batch(...updates);
21119
21117
  return ctx.vaultFolderCollection.find(id);
@@ -112,7 +112,7 @@ import {
112
112
  updateVaultMemoryOp,
113
113
  useEncryption,
114
114
  vaultMemoryToStored
115
- } from "./chunk-FD5MB73N.mjs";
115
+ } from "./chunk-3KGACSSP.mjs";
116
116
  import {
117
117
  PiiRedactor,
118
118
  createStreamingDeAnonymizer,
@@ -7734,7 +7734,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
7734
7734
  return formatRecallResult(result.memories);
7735
7735
  } catch (error) {
7736
7736
  const message = error instanceof Error ? error.message : "Unknown error";
7737
- return `Error searching memory: ${message}`;
7737
+ const wrapped = new Error(`recall_memory: search failed \u2014 ${message}`);
7738
+ wrapped.cause = error;
7739
+ throw wrapped;
7738
7740
  }
7739
7741
  }
7740
7742
  };
@@ -14257,6 +14259,7 @@ async function updateVaultFolderOp(ctx, id, opts) {
14257
14259
  if (record.isDeleted) return null;
14258
14260
  const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
14259
14261
  const updated = await ctx.database.write(async () => {
14262
+ const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(Q9.where("folder_id", id), Q9.where("is_deleted", false)).fetch() : [];
14260
14263
  const updates = [];
14261
14264
  updates.push(
14262
14265
  record.prepareUpdate((r) => {
@@ -14264,15 +14267,12 @@ async function updateVaultFolderOp(ctx, id, opts) {
14264
14267
  if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
14265
14268
  })
14266
14269
  );
14267
- if (scopeChanged) {
14268
- const memories = await ctx.vaultMemoryCollection.query(Q9.where("folder_id", id), Q9.where("is_deleted", false)).fetch();
14269
- for (const memory of memories) {
14270
- updates.push(
14271
- memory.prepareUpdate((r) => {
14272
- r._setRaw("scope", opts.scope);
14273
- })
14274
- );
14275
- }
14270
+ for (const memory of memories) {
14271
+ updates.push(
14272
+ memory.prepareUpdate((r) => {
14273
+ r._setRaw("scope", opts.scope);
14274
+ })
14275
+ );
14276
14276
  }
14277
14277
  await ctx.database.batch(...updates);
14278
14278
  return ctx.vaultFolderCollection.find(id);
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-FD5MB73N.mjs";
3
+ } from "./chunk-3KGACSSP.mjs";
4
4
  import "./chunk-DFVCS3QQ.mjs";
5
5
  import "./chunk-GYKJOWEO.mjs";
6
6
  export {
@@ -15600,6 +15600,18 @@ async function upsertMessageOp(ctx, opts) {
15600
15600
  const updated = await _updateMessageOp(ctx, opts.uniqueId, updateOpts);
15601
15601
  return updated ?? messageToStored(existing, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
15602
15602
  }
15603
+ async function getMessageOp(ctx, uniqueId) {
15604
+ let message;
15605
+ try {
15606
+ message = await ctx.messagesCollection.find(uniqueId);
15607
+ } catch (error) {
15608
+ if (error instanceof Error && /not found/i.test(error.message)) {
15609
+ return null;
15610
+ }
15611
+ throw error;
15612
+ }
15613
+ return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
15614
+ }
15603
15615
  async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
15604
15616
  let message;
15605
15617
  try {
@@ -16702,27 +16714,25 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
16702
16714
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
16703
16715
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
16704
16716
  await ctx.database.write(async () => {
16705
- const prepared = [];
16717
+ const records = [];
16706
16718
  for (const id of chunkIds) {
16707
- let record;
16708
16719
  try {
16709
- record = await ctx.vaultMemoryCollection.find(id);
16720
+ records.push(await ctx.vaultMemoryCollection.find(id));
16710
16721
  } catch {
16711
- continue;
16712
16722
  }
16713
- if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.topicsUserManaged) {
16714
- continue;
16715
- }
16716
- const originalUpdatedAt = record.updatedAt.getTime();
16717
- prepared.push(
16718
- record.prepareUpdate((r) => {
16719
- r._setRaw("topics_extracted_at", extractedAt);
16720
- r._setRaw("topics_extracted_version", version);
16721
- r._setRaw("updated_at", originalUpdatedAt);
16722
- })
16723
- );
16724
- stamped.push(id);
16725
16723
  }
16724
+ const eligible = records.filter(
16725
+ (record) => !record.isDeleted && isOwnedByCtxUser(ctx, record) && !record.topicsUserManaged
16726
+ );
16727
+ const prepared = eligible.map((record) => {
16728
+ const originalUpdatedAt = record.updatedAt.getTime();
16729
+ return record.prepareUpdate((r) => {
16730
+ r._setRaw("topics_extracted_at", extractedAt);
16731
+ r._setRaw("topics_extracted_version", version);
16732
+ r._setRaw("updated_at", originalUpdatedAt);
16733
+ });
16734
+ });
16735
+ for (const record of eligible) stamped.push(record.id);
16726
16736
  if (prepared.length > 0) await ctx.database.batch(...prepared);
16727
16737
  });
16728
16738
  }
@@ -17108,13 +17118,7 @@ async function generateEmbeddings(texts, options) {
17108
17118
  // src/lib/memoryEngine/embeddings.ts
17109
17119
  var DEFAULT_MIN_CONTENT_LENGTH = 10;
17110
17120
  async function embedMessage(ctx, messageId, options) {
17111
- let message;
17112
- const conversations = await getConversationsOp(ctx);
17113
- for (const conv of conversations) {
17114
- const messages = await getMessagesOp(ctx, conv.conversationId);
17115
- message = messages.find((m) => m.uniqueId === messageId);
17116
- if (message) break;
17117
- }
17121
+ const message = await getMessageOp(ctx, messageId);
17118
17122
  if (!message) {
17119
17123
  return null;
17120
17124
  }
@@ -17160,13 +17164,7 @@ async function embedAllMessages(ctx, options, filter) {
17160
17164
  }
17161
17165
  async function chunkAndEmbedMessage(ctx, messageId, options) {
17162
17166
  const { chunkSize = DEFAULT_CHUNK_SIZE } = options;
17163
- let message;
17164
- const conversations = await getConversationsOp(ctx);
17165
- for (const conv of conversations) {
17166
- const messages = await getMessagesOp(ctx, conv.conversationId);
17167
- message = messages.find((m) => m.uniqueId === messageId);
17168
- if (message) break;
17169
- }
17167
+ const message = await getMessageOp(ctx, messageId);
17170
17168
  if (!message) {
17171
17169
  return null;
17172
17170
  }
@@ -18526,7 +18524,7 @@ function createMemoryVaultSearchTool(vaultCtx, embeddingOptions, cache, searchOp
18526
18524
  legacy.map((r) => ({ id: r.uniqueId, content: r.content, score: r.similarity }))
18527
18525
  );
18528
18526
  }
18529
- const { recall: recall2 } = await import("./recall-WT5HY2IA.mjs");
18527
+ const { recall: recall2 } = await import("./recall-2K7IOKY3.mjs");
18530
18528
  const result = await recall2(
18531
18529
  query,
18532
18530
  { vaultCtx, embeddingOptions, vaultCache: cache },
@@ -19204,6 +19202,7 @@ export {
19204
19202
  clearMessagesOp,
19205
19203
  createMessageOp,
19206
19204
  upsertMessageOp,
19205
+ getMessageOp,
19207
19206
  updateMessageEmbeddingOp,
19208
19207
  updateMessageChunksOp,
19209
19208
  updateMessageErrorOp,
@@ -16346,6 +16346,18 @@ async function upsertMessageOp(ctx, opts) {
16346
16346
  const updated = await _updateMessageOp(ctx, opts.uniqueId, updateOpts);
16347
16347
  return updated ?? messageToStored(existing, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
16348
16348
  }
16349
+ async function getMessageOp(ctx, uniqueId) {
16350
+ let message;
16351
+ try {
16352
+ message = await ctx.messagesCollection.find(uniqueId);
16353
+ } catch (error) {
16354
+ if (error instanceof Error && /not found/i.test(error.message)) {
16355
+ return null;
16356
+ }
16357
+ throw error;
16358
+ }
16359
+ return messageToStored(message, ctx.walletAddress, ctx.signMessage, ctx.embeddedWalletSigner);
16360
+ }
16349
16361
  async function updateMessageEmbeddingOp(ctx, uniqueId, vector, embeddingModel) {
16350
16362
  let message;
16351
16363
  try {
@@ -17509,27 +17521,25 @@ async function stampTopicsExtractedAtOp(ctx, memoryIds, extractedAt, version = T
17509
17521
  for (let i = 0; i < uniqueIds.length; i += CHUNK) {
17510
17522
  const chunkIds = uniqueIds.slice(i, i + CHUNK);
17511
17523
  await ctx.database.write(async () => {
17512
- const prepared = [];
17524
+ const records = [];
17513
17525
  for (const id of chunkIds) {
17514
- let record;
17515
17526
  try {
17516
- record = await ctx.vaultMemoryCollection.find(id);
17527
+ records.push(await ctx.vaultMemoryCollection.find(id));
17517
17528
  } catch {
17518
- continue;
17519
- }
17520
- if (record.isDeleted || !isOwnedByCtxUser(ctx, record) || record.topicsUserManaged) {
17521
- continue;
17522
17529
  }
17523
- const originalUpdatedAt = record.updatedAt.getTime();
17524
- prepared.push(
17525
- record.prepareUpdate((r) => {
17526
- r._setRaw("topics_extracted_at", extractedAt);
17527
- r._setRaw("topics_extracted_version", version);
17528
- r._setRaw("updated_at", originalUpdatedAt);
17529
- })
17530
- );
17531
- stamped.push(id);
17532
17530
  }
17531
+ const eligible = records.filter(
17532
+ (record) => !record.isDeleted && isOwnedByCtxUser(ctx, record) && !record.topicsUserManaged
17533
+ );
17534
+ const prepared = eligible.map((record) => {
17535
+ const originalUpdatedAt = record.updatedAt.getTime();
17536
+ return record.prepareUpdate((r) => {
17537
+ r._setRaw("topics_extracted_at", extractedAt);
17538
+ r._setRaw("topics_extracted_version", version);
17539
+ r._setRaw("updated_at", originalUpdatedAt);
17540
+ });
17541
+ });
17542
+ for (const record of eligible) stamped.push(record.id);
17533
17543
  if (prepared.length > 0) await ctx.database.batch(...prepared);
17534
17544
  });
17535
17545
  }
@@ -17944,13 +17954,7 @@ var init_generate = __esm({
17944
17954
 
17945
17955
  // src/lib/memoryEngine/embeddings.ts
17946
17956
  async function embedMessage(ctx, messageId, options) {
17947
- let message;
17948
- const conversations = await getConversationsOp(ctx);
17949
- for (const conv of conversations) {
17950
- const messages = await getMessagesOp(ctx, conv.conversationId);
17951
- message = messages.find((m) => m.uniqueId === messageId);
17952
- if (message) break;
17953
- }
17957
+ const message = await getMessageOp(ctx, messageId);
17954
17958
  if (!message) {
17955
17959
  return null;
17956
17960
  }
@@ -17996,13 +18000,7 @@ async function embedAllMessages(ctx, options, filter) {
17996
18000
  }
17997
18001
  async function chunkAndEmbedMessage(ctx, messageId, options) {
17998
18002
  const { chunkSize = DEFAULT_CHUNK_SIZE } = options;
17999
- let message;
18000
- const conversations = await getConversationsOp(ctx);
18001
- for (const conv of conversations) {
18002
- const messages = await getMessagesOp(ctx, conv.conversationId);
18003
- message = messages.find((m) => m.uniqueId === messageId);
18004
- if (message) break;
18005
- }
18003
+ const message = await getMessageOp(ctx, messageId);
18006
18004
  if (!message) {
18007
18005
  return null;
18008
18006
  }
@@ -21269,6 +21267,7 @@ __export(index_exports, {
21269
21267
  getMediaOp: () => getMediaOp,
21270
21268
  getMediaTypeFromMime: () => getMediaTypeFromMime,
21271
21269
  getMemoriesNeedingTopicExtractionOp: () => getMemoriesNeedingTopicExtractionOp,
21270
+ getMessageOp: () => getMessageOp,
21272
21271
  getMessagesOp: () => getMessagesOp,
21273
21272
  getModelPreferenceOp: () => getModelPreferenceOp,
21274
21273
  getProjectConversationCountOp: () => getProjectConversationCountOp,
@@ -23947,6 +23946,7 @@ async function updateVaultFolderOp(ctx, id, opts) {
23947
23946
  if (record.isDeleted) return null;
23948
23947
  const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
23949
23948
  const updated = await ctx.database.write(async () => {
23949
+ const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb18.Q.where("folder_id", id), import_watermelondb18.Q.where("is_deleted", false)).fetch() : [];
23950
23950
  const updates = [];
23951
23951
  updates.push(
23952
23952
  record.prepareUpdate((r) => {
@@ -23954,15 +23954,12 @@ async function updateVaultFolderOp(ctx, id, opts) {
23954
23954
  if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
23955
23955
  })
23956
23956
  );
23957
- if (scopeChanged) {
23958
- const memories = await ctx.vaultMemoryCollection.query(import_watermelondb18.Q.where("folder_id", id), import_watermelondb18.Q.where("is_deleted", false)).fetch();
23959
- for (const memory of memories) {
23960
- updates.push(
23961
- memory.prepareUpdate((r) => {
23962
- r._setRaw("scope", opts.scope);
23963
- })
23964
- );
23965
- }
23957
+ for (const memory of memories) {
23958
+ updates.push(
23959
+ memory.prepareUpdate((r) => {
23960
+ r._setRaw("scope", opts.scope);
23961
+ })
23962
+ );
23966
23963
  }
23967
23964
  await ctx.database.batch(...updates);
23968
23965
  return ctx.vaultFolderCollection.find(id);
@@ -26244,7 +26241,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
26244
26241
  return formatRecallResult(result.memories);
26245
26242
  } catch (error) {
26246
26243
  const message = error instanceof Error ? error.message : "Unknown error";
26247
- return `Error searching memory: ${message}`;
26244
+ const wrapped = new Error(`recall_memory: search failed \u2014 ${message}`);
26245
+ wrapped.cause = error;
26246
+ throw wrapped;
26248
26247
  }
26249
26248
  }
26250
26249
  };
@@ -32470,6 +32469,7 @@ function buildSystemPrompt(ctx, options) {
32470
32469
  getMediaOp,
32471
32470
  getMediaTypeFromMime,
32472
32471
  getMemoriesNeedingTopicExtractionOp,
32472
+ getMessageOp,
32473
32473
  getMessagesOp,
32474
32474
  getModelPreferenceOp,
32475
32475
  getProjectConversationCountOp,
@@ -3968,6 +3968,13 @@ declare function createMessageOp(ctx: StorageOperationsContext, opts: CreateMess
3968
3968
  declare function upsertMessageOp(ctx: StorageOperationsContext, opts: CreateMessageOptions & {
3969
3969
  uniqueId: string;
3970
3970
  }): Promise<StoredMessage>;
3971
+ /**
3972
+ * Fetch a single message by its uniqueId (the WatermelonDB record id),
3973
+ * decrypted to a StoredMessage. Returns null if not found. O(1) indexed
3974
+ * lookup — prefer this over scanning `getMessagesOp` across every conversation
3975
+ * when you already hold a message id.
3976
+ */
3977
+ declare function getMessageOp(ctx: StorageOperationsContext, uniqueId: string): Promise<StoredMessage | null>;
3971
3978
  declare function updateMessageEmbeddingOp(ctx: StorageOperationsContext, uniqueId: string, vector: number[], embeddingModel: string): Promise<StoredMessage | null>;
3972
3979
  declare function updateMessageChunksOp(ctx: StorageOperationsContext, uniqueId: string, chunks: MessageChunk[], embeddingModel: string): Promise<StoredMessage | null>;
3973
3980
  declare function updateMessageErrorOp(ctx: StorageOperationsContext, uniqueId: string, error: string): Promise<StoredMessage | null>;
@@ -7937,4 +7944,4 @@ declare function sanitizeQuotes(s: string): string;
7937
7944
  declare function renderTemplate(value: string | null | undefined, template: string): string | null;
7938
7945
  declare function buildSystemPrompt(ctx: PromptContext, options?: BuildPromptOptions): BuildPromptResult;
7939
7946
 
7940
- export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summaryToSystemMessage, supersedeVaultMemoryOp, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };
7947
+ export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summaryToSystemMessage, supersedeVaultMemoryOp, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };
@@ -3968,6 +3968,13 @@ declare function createMessageOp(ctx: StorageOperationsContext, opts: CreateMess
3968
3968
  declare function upsertMessageOp(ctx: StorageOperationsContext, opts: CreateMessageOptions & {
3969
3969
  uniqueId: string;
3970
3970
  }): Promise<StoredMessage>;
3971
+ /**
3972
+ * Fetch a single message by its uniqueId (the WatermelonDB record id),
3973
+ * decrypted to a StoredMessage. Returns null if not found. O(1) indexed
3974
+ * lookup — prefer this over scanning `getMessagesOp` across every conversation
3975
+ * when you already hold a message id.
3976
+ */
3977
+ declare function getMessageOp(ctx: StorageOperationsContext, uniqueId: string): Promise<StoredMessage | null>;
3971
3978
  declare function updateMessageEmbeddingOp(ctx: StorageOperationsContext, uniqueId: string, vector: number[], embeddingModel: string): Promise<StoredMessage | null>;
3972
3979
  declare function updateMessageChunksOp(ctx: StorageOperationsContext, uniqueId: string, chunks: MessageChunk[], embeddingModel: string): Promise<StoredMessage | null>;
3973
3980
  declare function updateMessageErrorOp(ctx: StorageOperationsContext, uniqueId: string, error: string): Promise<StoredMessage | null>;
@@ -7937,4 +7944,4 @@ declare function sanitizeQuotes(s: string): string;
7937
7944
  declare function renderTemplate(value: string | null | undefined, template: string): string | null;
7938
7945
  declare function buildSystemPrompt(ctx: PromptContext, options?: BuildPromptOptions): BuildPromptResult;
7939
7946
 
7940
- export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summaryToSystemMessage, supersedeVaultMemoryOp, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };
7947
+ export { type AnalyzeStyleOptions, type AnalyzeStyleResult, type ApiResponse, type ApiType, type AutoExecutedToolResult, type AutoExtractMessage, type AutoExtractor, type Budget, type BuildPromptOptions, type BuildPromptResult, type CachedChunkVectors, type CachedServerTools, type ChatCompletionUsage, type ChatRole, type ChunkSearchResult, type ChunkVectorCache, type ChunkingOptions, type ConnectorGuidance, type ConnectorGuidanceInput, type ConsolidationFallbackReason, Conversation, ConversationSummary, type CreateAutoExtractorOptions, type CreateConversationOptions, type CreateMediaOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, type CreateProjectOptions, type CreateUserPreferenceOptions, type CreateVaultFolderOptions, type CreateVaultMemoryOptions, type CryptoPriceClassification, type CryptoPricePreProcessorOptions, DEFAULT_ANALYSIS_PROMPT, DEFAULT_ANALYZE_AFTER_MESSAGES, DEFAULT_CACHE_EXPIRATION_MS, DEFAULT_CHUNK_CACHE_SIZE, DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, DEFAULT_DOCUMENT_PATTERN, DEFAULT_EXCLUDED_SERVER_TOOLS, DEFAULT_MAX_INPUT_MESSAGES, DEFAULT_MAX_PROFILE_LENGTH, DEFAULT_MIN_CHUNK_SIZE, DEFAULT_MIN_MESSAGES, DEFAULT_PERSONALITY_SETTINGS, DEFAULT_PROMPT_TEMPLATES, DEFAULT_REFRESH_EVERY_MESSAGES, DEFAULT_SERVER_TOOLS_MATCH_OPTIONS, DEFAULT_SUMMARY_MIN_WINDOW_MESSAGES, DEFAULT_SUMMARY_MODEL, DEFAULT_SUMMARY_TOKEN_THRESHOLD, DEFAULT_VAULT_CACHE_SIZE, DatabaseManager, type DatabaseManagerLogger, type DatabaseManagerOptions, type EmbeddedWalletSignerFn, ExcelProcessor, type ExtractFactsOptions, type ExtractOutcome, type ExtractedCandidate, type ExtractedEntity, type ExtractionCursorStore, type FactType, type FileMetadata, type FileProcessor, type FileTypeQuery, type FileWithData, type FlushResult, type GetConversationsPageOptions, INFERENCE_ID_HEADER, type LazyStoredConversation, type LlmTokenUsage, MAX_MESSAGES_PER_SUMMARIZATION, Media, type MediaDimensions, type MediaFilterOptions, type MediaMetadata, type MediaOperationsContext, type MediaRole, type MediaType, type MemoriesNeedingTopicExtraction, type EmbeddingOptions as MemoryEngineEmbeddingOptions, type MemoryEngineResult, type MemoryEngineSearchOptions, type MemoryExtractedEvent, type MemoryKind, type MemoryVaultSearchOptions, type MemoryVaultToolOptions, Message, type MessageChunk, type MessageFeedback, type ModelCallEndEvent, type ModelCallStartEvent, ModelPreference, type OperationExecutor, type ParsedServerToolsResponse, PdfProcessor, type PersonalitySettings, type PersonalitySliders, type PersonalityStyle, type PgClientLike, type PgPoolLike, type PlatformStorage, type PortalLlmAuth, PostgreSQLAdapter, type PostgreSQLAdapterOptions, type PreprocessingOptions, type PreprocessingResult, type ProcessedFileResult, ProcessorRegistry, type ProfileUpdate, Project, type ProjectOperationsContext, type PromptContext, type PromptPreProcessor, type PromptPreProcessorContext, type PromptSection, type PromptTemplates, type QueueEncryptionContext, QueueManager, type QueueStatus, type QueuedOperation, type QueuedOperationType, RECALL_MAX_LIMIT, RECALL_TOOL_NAME, type RankedMemory, type RecallContext, type RecallDegradation, type RecallDiagnostics, type RecallOptions, type RecallResult, type RecallToolCallbacks, type RecallToolOptions, type RecencyOptions, type ReflectOptions, type ReflectResult, RerankerUnavailableError, type ResumeStreamOptions, type ResumeStreamResult, type RetainAction, type RetainContext, type RetainOptions, type RetainResult, type RetainSource, type RunEndEvent, type RunErrorEvent, type RunHooks, type RunStartEvent, type RunToolLoopOptions, type RunToolLoopResult, SDK_SCHEMA_VERSION, SERVER_TOOL_DEPENDENCY_SETS, SLIDER_CONFIG, STREAM_RESUMABLE_HEADER, type ScoreBreakdown, type SearchSource, type SelectServerToolsForPromptOptions, type ServerTool, type ServerToolCallEvent, type ServerToolsFilterFunction, type ServerToolsOptions, type ServerToolsResponse, type SettingsStorageOperationsContext, type SignMessageFn, type StepFinishEvent, type StockPriceClassification, type StockPricePreProcessorOptions, type StorageOperationsContext, type StoredConversation, type StoredConversationSummary, type StoredFileWithContext, type StoredMedia, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, type StoredProject, type StoredUserPreference, type StoredVaultFolder, type StoredVaultMemory, StreamExpiredError, type StreamMetaEvent, type StreamResumeHandle, type StreamSmoothingConfig, type StreamingTransport, type StreamingTransportOptions, type StreamingTransportResult, type StyleAnalysisSchedule, TOOL_CATALOG, TOPICS_EXTRACTION_VERSION, TOPIC_EXTRACTION_BATCH_SIZE, type TextChunk, TextProcessor, type ToolConfig, type ToolExecutor, type ToolMatchOptions, type ToolMatchResult, type ToolSet, type ToolUseEndEvent, type ToolUseStartEvent, type TopicExtractOptions, type TopicExtractionInput, type TopicExtractionRunResult, type TurnCompleteEvent, type TurnSkippedEvent, type UpdateMediaOptions, type UpdateModelPreferenceOptions, type UpdateProjectOptions, type UpdateUserPreferenceOptions, type UpdateVaultFolderOptions, type UpdateVaultMemoryOptions, UserPreference, type UserPreferencesStorageOperationsContext, type VaultEmbeddingCache, VaultFolder, type VaultFolderOperationsContext, VaultMemory, type VaultMemoryOperationsContext, type VaultSaveOperation, type VaultSearchResult, WalletPoller, type WeatherClassification, type WeatherPreProcessorOptions, type WebSearchClassification, type WebSearchPreProcessorOptions, WordProcessor, ZipProcessor, type ZipProcessorOptions, activatedToolSetNames, analyzeStyle, buildConnectorGuidance, buildDeniedToolsRider, buildSystemPrompt, chunkAndEmbedAllMessages, chunkAndEmbedMessage, chunkText, classifyCryptoPrice, classifyCryptoPriceBatch, classifyStockPrice, classifyStockPriceBatch, classifyWeather, classifyWeatherBatch, classifyWebSearch, classifyWebSearchBatch, cleanupConversationSummary, clearAllEncryptionKeys, clearAllEncryptionState, clearAllKeyPairs, clearEncryptionKey, clearKeyPair, clearLazyTitleCache, clearMessagesOp, clearServerToolsCache, composeHooks, createAutoExtractor, createChunkVectorCache, createConversationOp, createCryptoPricePreProcessor, createMediaBatchOp, createMediaOp, createMemoryEngineTool, createMemoryVaultSearchTool, createMemoryVaultTool, createMessageOp, createPlatformCursorStore, createProjectOp, createRecallTool, createServerToolsFilter, createStockPricePreProcessor, createSummaryContext, createVaultEmbeddingCache, createVaultFolderOp, createVaultMemoriesBatchOp, createVaultMemoryOp, createWeatherPreProcessor, createWebSearchPreProcessor, decryptConversationTitle, decryptData, decryptDataBatch, decryptDataBytes, decryptDataBytesFromBytes, decryptDataWithKey, defaultServerToolsFilter, deleteAllVaultMemoriesForUserOp, deleteConversationOp, deleteConversationSummaryOp, deleteMediaByConversationOp, deleteMediaByMessageOp, deleteMediaOp, deleteModelPreferenceOp, deleteProjectOp, deleteUserPreferenceOp, deleteVaultFolderOp, deleteVaultMemoryOp, eagerEmbedContent, embedAllMessages, embedMessage, encryptData, encryptDataBatch, encryptDataBytes, encryptDataWithKey, ensureDefaultFoldersOp, estimateMessagesTokens, estimateTokens, exportPublicKey, extractAndLinkEntitiesForMemoriesOp, extractAndRetain, extractEntitiesForMemories, extractFacts, findMatchingTools, generateConversationId, generateEmbedding, generateEmbeddings, generateMediaId, generateProjectId, getAIGeneratedMediaOp, getAllFilesOp, getAllVaultFoldersOp, getAllVaultMemoriesOp, getAllVaultMemoryContentsOp, getAudioOp, getCachedServerTools, getConversationOp, getConversationSummaryOp, getConversationsByProjectLazyOp, getConversationsByProjectOp, getConversationsLazyOp, getConversationsOp, getConversationsPageOp, getDocumentsOp, getEncryptionKey, getImagesOp, getMediaByConversationOp, getMediaByIdOp, getMediaByIdsOp, getMediaByMessageOp, getMediaByModelOp, getMediaByRoleOp, getMediaBySourceUrlOp, getMediaByTypeOp, getMediaCountOp, getMediaCountsByTypeOp, getMediaOp, getMediaTypeFromMime, getMemoriesNeedingTopicExtractionOp, getMessageOp, getMessagesOp, getModelPreferenceOp, getProjectConversationCountOp, getProjectConversationsOp, getProjectOp, getProjectsOp, getRecentMediaOp, getServerTools, getSupportedFileTypes, getToolsChecksum, getUnfiledVaultMemoriesOp, getUserPreferenceOp, getUserUploadedMediaOp, getVaultFolderMemoryCountOp, getVaultMemoryOp, getVideosOp, hardDeleteMediaOp, hasEncryptionKey, hasKeyPair, isRerankerAvailable, isSupportedFile, isSupportedMediaType, makeSyntheticStoredConversation, makeSyntheticStoredMessage, maybeSummarizeHistory, mediaToStored, migrateFromModelPreferencesOp, moveMemoriesToFolderOp, onKeyAvailable, preEmbedVaultMemories, preprocessFiles, progressiveSummarize, projectToStored, queueManager, recall, reflect, relinkMisclassifiedVideosOp, renderTemplate, requestEncryptionKey, requestKeyPair, resumeStream, retain, runToolLoop, sanitizeQuotes, schemaToCreateSQL, sdkMigrations, sdkModelClasses, sdkSchema, searchChunksOp, searchMediaOp, searchMessagesOp, searchVaultMemories, selectServerToolsForPrompt, serverPlatformStorage, setModelPreferenceOp, setUserPreferenceOp, shouldAnalyzeStyle, shouldChunkMessage, shouldRefreshTools, splitMessagesAtThreshold, stampTopicsExtractedAtOp, streamCancelPath, streamReplayPath, summaryToSystemMessage, supersedeVaultMemoryOp, toolSetSystemPrompts, updateConversationProjectOp, updateConversationTitleOp, updateMediaMessageIdBatchOp, updateMediaOp, updateMessageChunksOp, updateMessageEmbeddingOp, updateMessageErrorOp, updateMessageFeedbackOp, updateModelsOp, updatePersonalityOp, updateProfileOp, updateProjectNameOp, updateProjectOp, updateVaultFolderContextOp, updateVaultFolderOp, updateVaultMemoryEmbeddingOp, updateVaultMemoryOp, upsertConversationSummaryOp, upsertMessageOp };
@@ -60,6 +60,7 @@ import {
60
60
  getConversationsPageOp,
61
61
  getEncryptionKey,
62
62
  getMemoriesNeedingTopicExtractionOp,
63
+ getMessageOp,
63
64
  getMessagesOp,
64
65
  getUnfiledVaultMemoriesOp,
65
66
  getVaultMemoryOp,
@@ -107,7 +108,7 @@ import {
107
108
  updateVaultMemoryOp,
108
109
  upsertMessageOp,
109
110
  vaultMemoryToStored
110
- } from "./chunk-RKUNGNBF.mjs";
111
+ } from "./chunk-A4V7FRZ6.mjs";
111
112
  import {
112
113
  createStreamingDeAnonymizer,
113
114
  resolvePiiRedactor
@@ -3347,6 +3348,7 @@ async function updateVaultFolderOp(ctx, id, opts) {
3347
3348
  if (record.isDeleted) return null;
3348
3349
  const scopeChanged = opts.scope !== void 0 && opts.scope !== record.scope;
3349
3350
  const updated = await ctx.database.write(async () => {
3351
+ const memories = scopeChanged ? await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch() : [];
3350
3352
  const updates = [];
3351
3353
  updates.push(
3352
3354
  record.prepareUpdate((r) => {
@@ -3354,15 +3356,12 @@ async function updateVaultFolderOp(ctx, id, opts) {
3354
3356
  if (opts.scope !== void 0) r._setRaw("scope", opts.scope);
3355
3357
  })
3356
3358
  );
3357
- if (scopeChanged) {
3358
- const memories = await ctx.vaultMemoryCollection.query(import_watermelondb15.Q.where("folder_id", id), import_watermelondb15.Q.where("is_deleted", false)).fetch();
3359
- for (const memory of memories) {
3360
- updates.push(
3361
- memory.prepareUpdate((r) => {
3362
- r._setRaw("scope", opts.scope);
3363
- })
3364
- );
3365
- }
3359
+ for (const memory of memories) {
3360
+ updates.push(
3361
+ memory.prepareUpdate((r) => {
3362
+ r._setRaw("scope", opts.scope);
3363
+ })
3364
+ );
3366
3365
  }
3367
3366
  await ctx.database.batch(...updates);
3368
3367
  return ctx.vaultFolderCollection.find(id);
@@ -5608,7 +5607,9 @@ function createRecallTool(ctx, toolOptions, callbacks) {
5608
5607
  return formatRecallResult(result.memories);
5609
5608
  } catch (error) {
5610
5609
  const message = error instanceof Error ? error.message : "Unknown error";
5611
- return `Error searching memory: ${message}`;
5610
+ const wrapped = new Error(`recall_memory: search failed \u2014 ${message}`);
5611
+ wrapped.cause = error;
5612
+ throw wrapped;
5612
5613
  }
5613
5614
  }
5614
5615
  };
@@ -11779,6 +11780,7 @@ export {
11779
11780
  getMediaOp,
11780
11781
  getMediaTypeFromMime,
11781
11782
  getMemoriesNeedingTopicExtractionOp,
11783
+ getMessageOp,
11782
11784
  getMessagesOp,
11783
11785
  getModelPreferenceOp,
11784
11786
  getProjectConversationCountOp,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  recall
3
- } from "./chunk-RKUNGNBF.mjs";
3
+ } from "./chunk-A4V7FRZ6.mjs";
4
4
  import "./chunk-AHJT66EO.mjs";
5
5
  import "./chunk-3RPGXXPZ.mjs";
6
6
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anuma/sdk",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",