@mastra/memory 1.29.0-alpha.0 → 1.29.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18914,11 +18914,11 @@ function formatObserverAttachmentPlaceholder(part, counter) {
18914
18914
  const label = resolveObserverAttachmentLabel(part);
18915
18915
  return label ? `[${attachmentType} #${attachmentId}: ${label}]` : `[${attachmentType} #${attachmentId}]`;
18916
18916
  }
18917
- function isRecord$3(value) {
18917
+ function isRecord$4(value) {
18918
18918
  return !!value && typeof value === "object";
18919
18919
  }
18920
18920
  function mapToolResultBlockToAttachment(block) {
18921
- if (!isRecord$3(block) || typeof block.type !== "string") return;
18921
+ if (!isRecord$4(block) || typeof block.type !== "string") return;
18922
18922
  const mediaType = typeof block.mediaType === "string" ? block.mediaType : void 0;
18923
18923
  const filename = typeof block.filename === "string" ? block.filename : void 0;
18924
18924
  switch (block.type) {
@@ -18979,7 +18979,7 @@ function mapToolResultBlockToAttachment(block) {
18979
18979
  }
18980
18980
  }
18981
18981
  function extractToolResultAttachments(result, counter, attachmentFilter) {
18982
- if (!isRecord$3(result) || result.type !== "content" || !Array.isArray(result.value)) return {
18982
+ if (!isRecord$4(result) || result.type !== "content" || !Array.isArray(result.value)) return {
18983
18983
  resultWithoutAttachments: result,
18984
18984
  attachments: []
18985
18985
  };
@@ -18993,7 +18993,7 @@ function extractToolResultAttachments(result, counter, attachmentFilter) {
18993
18993
  if (shouldIncludeObserverAttachment(attachment, attachmentFilter)) attachments.push(toObserverInputAttachmentPart(attachment));
18994
18994
  const placeholder = formatObserverAttachmentPlaceholder(attachment, counter);
18995
18995
  return {
18996
- type: isRecord$3(block) ? block.type : void 0,
18996
+ type: isRecord$4(block) ? block.type : void 0,
18997
18997
  placeholder
18998
18998
  };
18999
18999
  });
@@ -19614,17 +19614,17 @@ const TRANSIENT_MESSAGE_SUBSTRINGS = [
19614
19614
  "connection reset",
19615
19615
  "connection closed"
19616
19616
  ];
19617
- function isRecord$2(value) {
19617
+ function isRecord$3(value) {
19618
19618
  return typeof value === "object" && value !== null;
19619
19619
  }
19620
19620
  function isAbortError(error) {
19621
- if (!isRecord$2(error)) return false;
19621
+ if (!isRecord$3(error)) return false;
19622
19622
  if (error.name === "AbortError") return true;
19623
19623
  if (typeof error.code === "string" && error.code === "ABORT_ERR") return true;
19624
19624
  return false;
19625
19625
  }
19626
19626
  function hasTransientMessage(value) {
19627
- if (!isRecord$2(value)) return false;
19627
+ if (!isRecord$3(value)) return false;
19628
19628
  const message = typeof value.message === "string" ? value.message.toLowerCase() : "";
19629
19629
  if (message && TRANSIENT_MESSAGE_SUBSTRINGS.some((sub) => message.includes(sub))) return true;
19630
19630
  if (typeof value.code === "string" && value.code.toUpperCase().startsWith("UND_ERR_")) return true;
@@ -19635,13 +19635,13 @@ function isRetryableHttpStatus(status) {
19635
19635
  return status >= 500 && status <= 599;
19636
19636
  }
19637
19637
  function hasRetryableHttpStatus(value) {
19638
- if (!isRecord$2(value)) return false;
19638
+ if (!isRecord$3(value)) return false;
19639
19639
  if (typeof value.statusCode === "number" && isRetryableHttpStatus(value.statusCode)) return true;
19640
19640
  if (typeof value.code === "number" && isRetryableHttpStatus(value.code)) return true;
19641
19641
  return false;
19642
19642
  }
19643
19643
  function hasIsRetryableFlag(value) {
19644
- if (!isRecord$2(value)) return false;
19644
+ if (!isRecord$3(value)) return false;
19645
19645
  return value.isRetryable === true;
19646
19646
  }
19647
19647
  /**
@@ -19659,14 +19659,14 @@ function isTransientLLMError(error) {
19659
19659
  if (isAbortError(error)) return false;
19660
19660
  const visited = /* @__PURE__ */ new WeakSet();
19661
19661
  function visit(candidate) {
19662
- if (isRecord$2(candidate)) {
19662
+ if (isRecord$3(candidate)) {
19663
19663
  if (visited.has(candidate)) return false;
19664
19664
  visited.add(candidate);
19665
19665
  }
19666
19666
  if (hasTransientMessage(candidate)) return true;
19667
19667
  if (hasRetryableHttpStatus(candidate)) return true;
19668
19668
  if (hasIsRetryableFlag(candidate)) return true;
19669
- if (isRecord$2(candidate)) {
19669
+ if (isRecord$3(candidate)) {
19670
19670
  if (visit(candidate.cause)) return true;
19671
19671
  if (visit(candidate.error)) return true;
19672
19672
  }
@@ -23431,6 +23431,45 @@ function didProviderChange(actorModel, lastModel) {
23431
23431
  return false;
23432
23432
  }
23433
23433
  //#endregion
23434
+ //#region src/processors/observational-memory/error.ts
23435
+ function isRecord$2(value) {
23436
+ return typeof value === "object" && value !== null;
23437
+ }
23438
+ /** Keep provider diagnostics in streamed/persisted markers, not whole API request/response objects. */
23439
+ function formatOmError(error) {
23440
+ const details = /* @__PURE__ */ new Set();
23441
+ const visited = /* @__PURE__ */ new Set();
23442
+ const add = (value) => {
23443
+ if (typeof value === "string" && value.trim()) details.add(value.trim().slice(0, 2e3));
23444
+ };
23445
+ function collectErrorDetails(value, depth) {
23446
+ if (depth > 5) return;
23447
+ if (!isRecord$2(value)) {
23448
+ if (value !== void 0) add(String(value));
23449
+ return;
23450
+ }
23451
+ if (visited.has(value)) return;
23452
+ visited.add(value);
23453
+ add(value.message);
23454
+ if (typeof value.statusCode === "number") add(`HTTP ${value.statusCode}`);
23455
+ if (typeof value.responseBody === "string") try {
23456
+ const body = JSON.parse(value.responseBody);
23457
+ if (isRecord$2(body)) {
23458
+ add(body.message);
23459
+ if (isRecord$2(body.error)) add(body.error.message);
23460
+ else add(body.error);
23461
+ }
23462
+ } catch {}
23463
+ if (value.cause !== void 0) collectErrorDetails(value.cause, depth + 1);
23464
+ if (value.error !== void 0) collectErrorDetails(value.error, depth + 1);
23465
+ }
23466
+ try {
23467
+ collectErrorDetails(error, 0);
23468
+ } catch {}
23469
+ const message = [...details].join(": ") || "Unknown error";
23470
+ return message.length > 2e3 ? `${message.slice(0, 1997)}...` : message;
23471
+ }
23472
+ //#endregion
23434
23473
  //#region src/processors/observational-memory/markers.ts
23435
23474
  /**
23436
23475
  * Create a start marker for when observation begins.
@@ -23489,7 +23528,7 @@ function createObservationFailedMarker(params) {
23489
23528
  failedAt,
23490
23529
  durationMs,
23491
23530
  tokensAttempted: params.tokensAttempted,
23492
- error: params.error,
23531
+ error: formatOmError(params.error),
23493
23532
  recordId: params.recordId,
23494
23533
  threadId: params.threadId
23495
23534
  }
@@ -23550,7 +23589,7 @@ function createBufferingFailedMarker(params) {
23550
23589
  failedAt,
23551
23590
  durationMs,
23552
23591
  tokensAttempted: params.tokensAttempted,
23553
- error: params.error,
23592
+ error: formatOmError(params.error),
23554
23593
  recordId: params.recordId,
23555
23594
  threadId: params.threadId
23556
23595
  }
@@ -24173,7 +24212,7 @@ var ObservationStrategy = class ObservationStrategy {
24173
24212
  cycleId,
24174
24213
  operationType: "observation",
24175
24214
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
24176
- error: error instanceof Error ? error.message : String(error),
24215
+ error: formatOmError(error),
24177
24216
  recordId: record.id,
24178
24217
  threadId
24179
24218
  }
@@ -24574,7 +24613,7 @@ var SyncObservationStrategy = class extends ObservationStrategy {
24574
24613
  operationType: "observation",
24575
24614
  startedAt: this.startedAt,
24576
24615
  tokensAttempted: this.tokensToObserve,
24577
- error: error instanceof Error ? error.message : String(error),
24616
+ error,
24578
24617
  recordId: this.opts.record.id,
24579
24618
  threadId: this.opts.threadId
24580
24619
  });
@@ -24775,7 +24814,7 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
24775
24814
  operationType: "observation",
24776
24815
  startedAt: this.startedAt,
24777
24816
  tokensAttempted,
24778
- error: error instanceof Error ? error.message : String(error),
24817
+ error,
24779
24818
  recordId: record.id,
24780
24819
  threadId
24781
24820
  });
@@ -25143,7 +25182,7 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
25143
25182
  operationType: "observation",
25144
25183
  startedAt: this.startedAt,
25145
25184
  tokensAttempted,
25146
- error: error instanceof Error ? error.message : String(error),
25185
+ error,
25147
25186
  recordId: this.opts.record.id,
25148
25187
  threadId
25149
25188
  });
@@ -26409,7 +26448,7 @@ var ReflectorRunner = class {
26409
26448
  operationType: "reflection",
26410
26449
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
26411
26450
  tokensAttempted: observationTokens,
26412
- error: reflectionError.message,
26451
+ error,
26413
26452
  recordId: record.id,
26414
26453
  threadId: record.threadId ?? ""
26415
26454
  });
@@ -26828,7 +26867,7 @@ var ReflectorRunner = class {
26828
26867
  operationType: "reflection",
26829
26868
  startedAt: streamContext.startedAt,
26830
26869
  tokensAttempted: observationTokens,
26831
- error: error instanceof Error ? error.message : String(error),
26870
+ error,
26832
26871
  recordId: record.id,
26833
26872
  threadId
26834
26873
  });
@@ -32385,4 +32424,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
32385
32424
  }
32386
32425
  });
32387
32426
 
32388
- //# sourceMappingURL=src-CG7RR0Ep.cjs.map
32427
+ //# sourceMappingURL=src-DjCR8GJe.cjs.map