@mastra/memory 1.28.3-alpha.1 → 1.28.3-alpha.3

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.
@@ -29,6 +29,8 @@ var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(
29
29
  enumerable: true
30
30
  }) : target, mod));
31
31
  //#endregion
32
+ let crypto$1 = require("crypto");
33
+ crypto$1 = __toESM$1(crypto$1, 1);
32
34
  let zod_v3 = require("zod/v3");
33
35
  let zod = require("zod");
34
36
  let zod_v4 = require("zod/v4");
@@ -46,8 +48,6 @@ xxhash_wasm = __toESM$1(xxhash_wasm, 1);
46
48
  let _mastra_core_storage = require("@mastra/core/storage");
47
49
  let fs = require("fs");
48
50
  let path = require("path");
49
- let crypto$1 = require("crypto");
50
- crypto$1 = __toESM$1(crypto$1, 1);
51
51
  let _mastra_core_tools = require("@mastra/core/tools");
52
52
  let _mastra_core_request_context = require("@mastra/core/request-context");
53
53
  let _mastra_core_llm = require("@mastra/core/llm");
@@ -17009,7 +17009,8 @@ var SubconsciousRemindExtractor = class extends Extractor {
17009
17009
  let store;
17010
17010
  try {
17011
17011
  scope = resolveScope(context);
17012
- const resourceId = resolveKnowledgeResourceId(context.requestContext, context.resourceId);
17012
+ const resourceId = context.resourceId;
17013
+ if (!resourceId) throw new Error("Subconscious remind requires a resourceId.");
17013
17014
  store = await context.memory.storage.getStore("knowledge");
17014
17015
  if (!store) throw new Error("Subconscious remind requires a configured knowledge storage domain.");
17015
17016
  const sources = await dropFreshOwnRecords(store, await findReminderSources(store, scope, context.rawObservations), context.threadId);
@@ -17603,6 +17604,7 @@ const OBSERVATIONAL_MEMORY_DEFAULTS = {
17603
17604
  },
17604
17605
  providerOptions: { google: { thinkingConfig: { thinkingBudget: 215 } } },
17605
17606
  maxTokensPerBatch: 1e4,
17607
+ observeAttachments: ["image/*", "application/pdf"],
17606
17608
  bufferTokens: .2,
17607
17609
  bufferActivation: .8
17608
17610
  },
@@ -24211,13 +24213,16 @@ var ObservationStrategy = class ObservationStrategy {
24211
24213
  if (!resourceId || !this.deps.onIndexObservations) return;
24212
24214
  const groups = parseObservationGroups(observations);
24213
24215
  if (groups.length === 0) return;
24214
- await Promise.all(groups.map((group) => this.deps.onIndexObservations({
24216
+ await Promise.all(groups.map((group) => withRetry(() => this.deps.onIndexObservations({
24215
24217
  text: group.content,
24216
24218
  groupId: group.id,
24217
24219
  range: group.range,
24218
24220
  threadId,
24219
24221
  resourceId,
24220
24222
  observedAt
24223
+ }), {
24224
+ label: "index-observations",
24225
+ abortSignal: this.opts.abortSignal
24221
24226
  })));
24222
24227
  }
24223
24228
  /**
@@ -27384,7 +27389,7 @@ var ObservationalMemory = class ObservationalMemory {
27384
27389
  previousObserverTokens: config.observation?.previousObserverTokens ?? 2e3,
27385
27390
  instruction: config.observation?.instruction,
27386
27391
  threadTitle: config.observation?.threadTitle ?? false,
27387
- observeAttachments: config.observation?.observeAttachments ?? true,
27392
+ observeAttachments: config.observation?.observeAttachments ?? [...OBSERVATIONAL_MEMORY_DEFAULTS.observation.observeAttachments],
27388
27393
  extractors: composeObservationExtractors({
27389
27394
  threadTitle: config.observation?.threadTitle ?? false,
27390
27395
  extract: config.observation?.extract,
@@ -31233,8 +31238,21 @@ Notes:
31233
31238
  const embedResult = await this.embedMessageContent(text);
31234
31239
  if (embedResult.embeddings.length === 0 || embedResult.dimension === void 0) return;
31235
31240
  const { indexName } = await this.createObservationEmbeddingIndex(embedResult.dimension);
31241
+ const ids = embedResult.chunks.map((_, chunkIndex) => {
31242
+ const hash = (0, crypto$1.createHash)("sha256").update(JSON.stringify([
31243
+ resourceId,
31244
+ threadId,
31245
+ groupId,
31246
+ chunkIndex
31247
+ ])).digest();
31248
+ hash[6] = hash[6] & 15 | 128;
31249
+ hash[8] = hash[8] & 63 | 128;
31250
+ const hex = hash.toString("hex", 0, 16);
31251
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
31252
+ });
31236
31253
  await this.vector.upsert({
31237
31254
  indexName,
31255
+ ids,
31238
31256
  vectors: embedResult.embeddings,
31239
31257
  metadata: embedResult.chunks.map((chunk) => ({
31240
31258
  group_id: groupId,
@@ -32258,4 +32276,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
32258
32276
  }
32259
32277
  });
32260
32278
 
32261
- //# sourceMappingURL=src-CIhnLM0F.cjs.map
32279
+ //# sourceMappingURL=src-D4Wm6M4v.cjs.map