@mastra/memory 1.36.0-alpha.2 → 1.36.0-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.
@@ -20804,6 +20804,25 @@ function getObserverMessageLabel(msg) {
20804
20804
  if (isSystemReminderMessage(msg)) return "system-reminder";
20805
20805
  return msg.role.charAt(0).toUpperCase() + msg.role.slice(1);
20806
20806
  }
20807
+ /**
20808
+ * Attachment URLs the agent already found undownloadable. Core records them on the user
20809
+ * message (`metadata.mastra.unavailableAttachments`) so they are not fetched again.
20810
+ */
20811
+ function getUnavailableAttachmentUrls(msg) {
20812
+ const mastra = msg.content?.metadata?.mastra;
20813
+ const urls = isRecord$2(mastra) ? mastra.unavailableAttachments : void 0;
20814
+ return new Set(Array.isArray(urls) ? urls.filter((url) => typeof url === "string") : []);
20815
+ }
20816
+ function getObserverAttachmentUrl(part) {
20817
+ const asset = part.type === "image" ? part.image : part.data ?? part.url;
20818
+ if (asset instanceof URL) return asset.toString();
20819
+ if (typeof asset !== "string") return void 0;
20820
+ try {
20821
+ return new URL(asset).toString();
20822
+ } catch {
20823
+ return;
20824
+ }
20825
+ }
20807
20826
  function formatObserverMessage(msg, counter, toolFormatting, options) {
20808
20827
  const maxLen = options?.maxPartLength;
20809
20828
  const maxToolResultTokens = options?.maxToolResultTokens ?? 5e3;
@@ -20812,6 +20831,7 @@ function formatObserverMessage(msg, counter, toolFormatting, options) {
20812
20831
  const role = getObserverMessageLabel(msg);
20813
20832
  const attachments = [];
20814
20833
  const messageCreatedAt = normalizeObserverCreatedAt(msg.createdAt);
20834
+ const unavailableUrls = getUnavailableAttachmentUrls(msg);
20815
20835
  let lines = [];
20816
20836
  const temporalGapText = isTemporalGapMarker(msg) ? getTemporalGapMarkerText(msg) : void 0;
20817
20837
  const pushLine = (title, body, createdAt) => {
@@ -20870,7 +20890,8 @@ function formatObserverMessage(msg, counter, toolFormatting, options) {
20870
20890
  }
20871
20891
  if (partType === "image" || partType === "file") {
20872
20892
  const attachment = part;
20873
- if (shouldIncludeObserverAttachment(attachment, attachmentFilter)) {
20893
+ const attachmentUrl = unavailableUrls.size > 0 ? getObserverAttachmentUrl(attachment) : void 0;
20894
+ if (!(attachmentUrl !== void 0 && unavailableUrls.has(attachmentUrl)) && shouldIncludeObserverAttachment(attachment, attachmentFilter)) {
20874
20895
  const inputAttachment = toObserverInputAttachmentPart(attachment);
20875
20896
  if (inputAttachment) attachments.push(inputAttachment);
20876
20897
  }
@@ -35276,4 +35297,4 @@ Notes:
35276
35297
  //#endregion
35277
35298
  export { formatMessagesForObserver as A, OBSERVATION_CONTEXT_PROMPT_THREAD as B, SUMMARIZE_THREAD_DEFAULTS as C, buildObserverPrompt as D, OBSERVER_SYSTEM_PROMPT as E, parseAnchorId as F, StaleKnowledgeSemanticIndexError as G, getObservationContextPrompt as H, stripEphemeralAnchorIds as I, SUBCONSCIOUS_ACTIVITY_STATE_ID as J, SubconsciousRemindExtractor as K, OBSERVATIONAL_MEMORY_DEFAULTS as L, optimizeObservationsForContext as M, parseObserverOutput as N, buildObserverSystemPrompt as O, injectAnchorIds as P, Extractor as Q, OBSERVATION_CONTEXT_INSTRUCTIONS as R, deepMergeWorkingMemory as S, TokenCounter as T, Subconscious as U, OBSERVATION_CONTINUATION_HINT as V, KnowledgeSemanticIndexCoordinator as W, publishSubconsciousActivity as X, buildSubconsciousActivitySnapshot as Y, renderSubconsciousActivity as Z, reconcileObservationGroupsFromReflection as _, extractWorkingMemoryContent as a, wrapInObservationGroup as b, getObservationsAsOf as c, WORKING_MEMORY_STATE_ID as d, WORKING_MEMORY_STATE_PROCESSOR_ID as f, parseObservationGroups as g, deriveObservationGroupProvenance as h, WorkingMemory as i, hasCurrentTaskSection as j, extractCurrentTask as k, ObservationalMemoryProcessor as l, combineObservationGroupRanges as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, WorkingMemoryStateProcessor as p, ModelByInputTokens as q, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, ObservationalMemory as u, renderObservationGroupsForReflection as v, summarizeConversation as w, WorkingMemoryExtractor as x, stripObservationGroups as y, OBSERVATION_CONTEXT_PROMPT as z };
35278
35299
 
35279
- //# sourceMappingURL=src-BxI-PDpC.js.map
35300
+ //# sourceMappingURL=src-BQOm4kZc.js.map