@mastra/memory 1.26.1-alpha.3 → 1.26.1-alpha.6

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/docs/SKILL.md +3 -1
  3. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  4. package/dist/docs/references/docs-agents-agent-approval.md +14 -0
  5. package/dist/docs/references/docs-capabilities-subagents.md +4 -1
  6. package/dist/docs/references/docs-long-running-agents-goals.md +1 -1
  7. package/dist/docs/references/docs-memory-message-history.md +2 -2
  8. package/dist/docs/references/docs-memory-multi-user-threads.md +1 -1
  9. package/dist/docs/references/docs-memory-observational-memory.md +1 -1
  10. package/dist/docs/references/docs-memory-semantic-recall.md +2 -1
  11. package/dist/docs/references/docs-memory-working-memory.md +1 -0
  12. package/dist/docs/references/docs-storage-overview.md +1 -0
  13. package/dist/docs/references/reference-file-based-agents-memory.md +2 -0
  14. package/dist/docs/references/reference-storage-oracledb.md +239 -0
  15. package/dist/docs/references/reference-vectors-oracledb.md +347 -0
  16. package/dist/index.cjs +1 -1
  17. package/dist/index.d.ts +2 -2
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/processors/index.cjs +1 -1
  21. package/dist/processors/index.js +1 -1
  22. package/dist/processors/observational-memory/measure-image-buffer.d.ts +23 -0
  23. package/dist/processors/observational-memory/measure-image-buffer.d.ts.map +1 -0
  24. package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
  25. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  26. package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
  27. package/dist/processors/observational-memory/tool-result-helpers.d.ts +8 -0
  28. package/dist/processors/observational-memory/tool-result-helpers.d.ts.map +1 -1
  29. package/dist/{src-CTQrRb5X.cjs → src-B2WSEEmS.cjs} +72 -33
  30. package/dist/src-B2WSEEmS.cjs.map +1 -0
  31. package/dist/{src-MScpLVRh.js → src-B_n15_Xg.js} +71 -32
  32. package/dist/src-B_n15_Xg.js.map +1 -0
  33. package/package.json +6 -7
  34. package/dist/src-CTQrRb5X.cjs.map +0 -1
  35. package/dist/src-MScpLVRh.js.map +0 -1
@@ -51,8 +51,8 @@ let tokenx = require("tokenx");
51
51
  let crypto$1 = require("crypto");
52
52
  let _mastra_core_storage = require("@mastra/core/storage");
53
53
  let async_hooks = require("async_hooks");
54
- let image_size = require("image-size");
55
- image_size = __toESM$1(image_size, 1);
54
+ let probe_image_size_sync_js = require("probe-image-size/sync.js");
55
+ probe_image_size_sync_js = __toESM$1(probe_image_size_sync_js, 1);
56
56
  let _mastra_core_tools = require("@mastra/core/tools");
57
57
  let _mastra_core_schema = require("@mastra/core/schema");
58
58
  let _mastra_core_error = require("@mastra/core/error");
@@ -15635,6 +15635,16 @@ function sanitizeToolResultValue(value, seen = /* @__PURE__ */ new WeakMap()) {
15635
15635
  }
15636
15636
  return sanitizedObject;
15637
15637
  }
15638
+ /**
15639
+ * Serializes a tool result without truncating it.
15640
+ *
15641
+ * Token accounting must see the full result: the truncation applied by
15642
+ * {@link formatToolResultForObserver} exists to bound what the Observer LLM reads,
15643
+ * not to describe what the agent's provider context actually holds.
15644
+ */
15645
+ function serializeToolResultForTokenCounting(value) {
15646
+ return stringifyToolResult(value);
15647
+ }
15638
15648
  function stringifyToolResult(value) {
15639
15649
  if (typeof value === "string") return value;
15640
15650
  const sanitized = sanitizeToolResultValue(value);
@@ -17356,6 +17366,42 @@ var ObserverRunner = class {
17356
17366
  }
17357
17367
  };
17358
17368
  //#endregion
17369
+ //#region src/processors/observational-memory/measure-image-buffer.ts
17370
+ /**
17371
+ * Synchronous image dimension lookup for in-memory image buffers.
17372
+ *
17373
+ * Uses `probe-image-size`'s sync parsers rather than `image-size`, which has unfixed
17374
+ * denial-of-service advisories (GHSA-w3rx-r6r6-pgpr / CVE-2025-71330 and
17375
+ * GHSA-5p2g-fcmc-qvqq) affecting every published version, on an archived repository
17376
+ * with no fixed release coming. A malformed 32-byte ICNS buffer was enough to hang the
17377
+ * parse loop and exhaust the heap, and image bytes reaching agent memory are untrusted.
17378
+ *
17379
+ * `probe-image-size` covers the formats models actually accept (PNG, JPEG, WebP, GIF,
17380
+ * AVIF, BMP, ICO, PSD, SVG, TIFF). Anything else returns `undefined`, which callers
17381
+ * already handle as "dimensions unknown".
17382
+ */
17383
+ const probeBuffer = probe_image_size_sync_js.default;
17384
+ /**
17385
+ * Read the pixel dimensions of an image buffer.
17386
+ *
17387
+ * @returns The dimensions, or `undefined` if the buffer isn't a recognized image.
17388
+ */
17389
+ function measureImageBuffer(buffer) {
17390
+ let probed;
17391
+ try {
17392
+ probed = probeBuffer(buffer);
17393
+ } catch {
17394
+ return;
17395
+ }
17396
+ if (!probed) return;
17397
+ const { width, height } = probed;
17398
+ if (typeof width !== "number" || !Number.isFinite(width) || typeof height !== "number" || !Number.isFinite(height)) return;
17399
+ return {
17400
+ width,
17401
+ height
17402
+ };
17403
+ }
17404
+ //#endregion
17359
17405
  //#region src/processors/observational-memory/token-counter.ts
17360
17406
  const IMAGE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
17361
17407
  "png",
@@ -17662,26 +17708,23 @@ function resolveImageDimensions(part) {
17662
17708
  width,
17663
17709
  height
17664
17710
  };
17665
- try {
17666
- const measured = (0, image_size.default)(buffer);
17667
- const measuredWidth = getFiniteNumber(measured.width);
17668
- const measuredHeight = getFiniteNumber(measured.height);
17669
- if (!measuredWidth || !measuredHeight) return {
17670
- width,
17671
- height
17672
- };
17673
- const resolved = {
17674
- width: width ?? measuredWidth,
17675
- height: height ?? measuredHeight
17676
- };
17677
- persistImageDimensions(part, resolved);
17678
- return resolved;
17679
- } catch {
17680
- return {
17681
- width,
17682
- height
17683
- };
17684
- }
17711
+ const measured = measureImageBuffer(buffer);
17712
+ if (!measured) return {
17713
+ width,
17714
+ height
17715
+ };
17716
+ const measuredWidth = getFiniteNumber(measured.width);
17717
+ const measuredHeight = getFiniteNumber(measured.height);
17718
+ if (!measuredWidth || !measuredHeight) return {
17719
+ width,
17720
+ height
17721
+ };
17722
+ const resolved = {
17723
+ width: width ?? measuredWidth,
17724
+ height: height ?? measuredHeight
17725
+ };
17726
+ persistImageDimensions(part, resolved);
17727
+ return resolved;
17685
17728
  }
17686
17729
  function getBase64Size(base64) {
17687
17730
  const sanitized = base64.replace(/\s+/g, "");
@@ -18240,7 +18283,7 @@ var TokenCounter = class TokenCounter {
18240
18283
  let tokens = 0;
18241
18284
  const cacheParts = [];
18242
18285
  const countJsonContentPart = (contentPart) => {
18243
- const formatted = formatToolResultForObserver(contentPart);
18286
+ const formatted = serializeToolResultForTokenCounting(contentPart);
18244
18287
  tokens += this.countString(formatted);
18245
18288
  cacheParts.push({
18246
18289
  type: "json",
@@ -18603,7 +18646,7 @@ var TokenCounter = class TokenCounter {
18603
18646
  const contentTokens = this.countMultimodalToolResultContent(part, resultForCounting);
18604
18647
  if (contentTokens !== void 0) tokens += contentTokens;
18605
18648
  else {
18606
- const formattedResult = formatToolResultForObserver(resultForCounting);
18649
+ const formattedResult = serializeToolResultForTokenCounting(resultForCounting);
18607
18650
  tokens += this.readOrPersistPartEstimate(part, usingStoredModelOutput ? "tool-result-model-output-json" : "tool-result-json", formattedResult);
18608
18651
  }
18609
18652
  if (typeof resultForCounting !== "string") overheadDelta -= 12;
@@ -21392,7 +21435,7 @@ var SyncObservationStrategy = class extends ObservationStrategy {
21392
21435
  });
21393
21436
  await this.storage.updateThread({
21394
21437
  id: threadId,
21395
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
21438
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
21396
21439
  metadata: newMetadata
21397
21440
  });
21398
21441
  if (shouldUpdateThreadTitle) threadUpdateMarker = createThreadUpdateMarker({
@@ -21584,7 +21627,7 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
21584
21627
  });
21585
21628
  await this.storage.updateThread({
21586
21629
  id: threadId,
21587
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
21630
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
21588
21631
  metadata: newMetadata
21589
21632
  });
21590
21633
  if (shouldUpdateThreadTitle) {
@@ -21929,7 +21972,7 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
21929
21972
  });
21930
21973
  await this.storage.updateThread({
21931
21974
  id: update.threadId,
21932
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
21975
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
21933
21976
  metadata: newMetadata
21934
21977
  });
21935
21978
  if (shouldUpdateThreadTitle) threadUpdateMarkers.push(createThreadUpdateMarker({
@@ -22872,7 +22915,6 @@ async function persistThreadExtractedValues(storage, extractors, threadId, value
22872
22915
  });
22873
22916
  await storage.updateThread({
22874
22917
  id: threadId,
22875
- title: thread.title ?? "",
22876
22918
  metadata: newMetadata
22877
22919
  });
22878
22920
  }
@@ -25844,7 +25886,7 @@ ${formattedMessages}
25844
25886
  const shouldUpdateThreadTitle = !!newTitle && newTitle.length >= 3 && newTitle !== oldTitle;
25845
25887
  await this.storage.updateThread({
25846
25888
  id: threadId,
25847
- title: shouldUpdateThreadTitle ? newTitle : thread.title ?? "",
25889
+ ...shouldUpdateThreadTitle ? { title: newTitle } : {},
25848
25890
  metadata: newMetadata
25849
25891
  });
25850
25892
  }
@@ -26062,7 +26104,6 @@ ${formattedMessages}
26062
26104
  });
26063
26105
  await this.storage.updateThread({
26064
26106
  id: threadId,
26065
- title: thread.title ?? "",
26066
26107
  metadata: newMetadata
26067
26108
  });
26068
26109
  }
@@ -27208,7 +27249,6 @@ var Memory = class extends _mastra_core_memory.MastraMemory {
27208
27249
  if (!thread) throw new Error(`Thread ${threadId} not found`);
27209
27250
  await memoryStore.updateThread({
27210
27251
  id: threadId,
27211
- title: thread.title || "",
27212
27252
  metadata: {
27213
27253
  ...thread.metadata,
27214
27254
  workingMemory
@@ -27297,7 +27337,6 @@ ${workingMemory}`;
27297
27337
  if (!thread) throw new Error(`Thread ${threadId} not found`);
27298
27338
  await memoryStore.updateThread({
27299
27339
  id: threadId,
27300
- title: thread.title || "",
27301
27340
  metadata: {
27302
27341
  ...thread.metadata,
27303
27342
  workingMemory
@@ -28867,4 +28906,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
28867
28906
  }
28868
28907
  });
28869
28908
 
28870
- //# sourceMappingURL=src-CTQrRb5X.cjs.map
28909
+ //# sourceMappingURL=src-B2WSEEmS.cjs.map