@mastra/memory 1.39.1-alpha.2 → 1.39.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.
@@ -1 +1 @@
1
- {"version":3,"file":"processor.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,yBAAyB,EAAwB,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EACV,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAUtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAoBlE,2EAA2E;AAC3E,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC;QAC9F,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;QAClC,QAAQ,EAAE,eAAe,EAAE,CAAC;QAC5B,eAAe,EAAE,OAAO,CAAC;QACzB,QAAQ,EAAE,yBAAyB,GAAG,IAAI,CAAC;QAC3C,mBAAmB,EAAE,eAAe,GAAG,SAAS,CAAC;QACjD,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;KACzC,CAAC,CAAC;IACH,8GAA8G;IAC9G,eAAe,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,OAA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ACnC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,SAAS,CAAC,EAAE,MAAM;IAKd,iBAAiB,CAAC,cAAc,CAAC,EAAE,GAAG;;;;;;;;mBAIymrB,CAAC;;;;;;;;;;mBAA4N,CAAC;;;;;;CADp3rB"}
@@ -54,14 +54,15 @@ export declare class OmIncompleteResponseError extends Error {
54
54
  constructor(label: string, finishReason: string);
55
55
  }
56
56
  /**
57
- * A model reply that finished but contains no text, or only whitespace.
57
+ * A model reply that finished but carries nothing usable: no text, only whitespace,
58
+ * or text with no recognised Observer sections (e.g. a refusal).
58
59
  * Retryable, so an empty reply is retried like a transport error.
59
60
  *
60
61
  * @internal
61
62
  */
62
63
  export declare class OmEmptyResponseError extends Error {
63
64
  readonly isRetryable = true;
64
- constructor(label: string);
65
+ constructor(label: string, what?: string);
65
66
  }
66
67
  /**
67
68
  * OM calls are single-step (`maxSteps: 1`). A step that ends with `other` or
@@ -1 +1 @@
1
- {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/retry.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY;IACvB,yEAAyE;;IAEzE,6CAA6C;;IAE7C,iEAAiE;;IAEjE,qCAAqC;;IAErC,2EAA2E;;IAE3E;;;;;;OAMG;;CAEJ,CAAC;AAqBF;;;;;GAKG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,WAAW,QAAQ;gBAEhB,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM;CAIjD;AAED;;;;;;GAMG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAKhD,QAAQ,CAAC,YAAY,EAAE,MAAM;IAJ/B,QAAQ,CAAC,WAAW,QAAQ;gBAG1B,KAAK,EAAE,MAAM,EACJ,YAAY,EAAE,MAAM;CAKhC;AAED;;;;;GAKG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,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/B,EAAE,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACtE,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,CAAC,CAAC,CAkCZ"}
@@ -4,7 +4,7 @@ import * as z4 from "zod/v4";
4
4
  import { any, array, boolean, custom, discriminatedUnion, enum as enum$1, instanceof as instanceof$1, json, lazy, literal, looseObject, never, null as null$1, number, object, record, safeParseAsync, string, union, unknown, z as z$1 } from "zod/v4";
5
5
  import { toJSONSchema } from "zod/v4/core";
6
6
  import { Agent, MessageList } from "@mastra/core/agent";
7
- import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
7
+ import { ErrorCategory, ErrorDomain, MastraError, classifyProviderError } from "@mastra/core/error";
8
8
  import { coreFeatures } from "@mastra/core/features";
9
9
  import { MastraMemory, getMemoryTokenBoundary, getThreadOMMetadata, isAfterMemoryTokenBoundary, isThreadTitlePinned, loadMessageHistory, normalizeMessageHistoryConfig, parseMemoryRequestContext, setThreadOMMetadata } from "@mastra/core/memory";
10
10
  import { EntityType, SpanType, createObservabilityContext, getOrCreateSpan } from "@mastra/core/observability";
@@ -27105,15 +27105,16 @@ var OmIncompleteResponseError = class extends Error {
27105
27105
  }
27106
27106
  };
27107
27107
  /**
27108
- * A model reply that finished but contains no text, or only whitespace.
27108
+ * A model reply that finished but carries nothing usable: no text, only whitespace,
27109
+ * or text with no recognised Observer sections (e.g. a refusal).
27109
27110
  * Retryable, so an empty reply is retried like a transport error.
27110
27111
  *
27111
27112
  * @internal
27112
27113
  */
27113
27114
  var OmEmptyResponseError = class extends Error {
27114
27115
  isRetryable = true;
27115
- constructor(label) {
27116
- super(`${label} returned empty output`);
27116
+ constructor(label, what = "empty output") {
27117
+ super(`${label} returned ${what}`);
27117
27118
  this.name = "OmEmptyResponseError";
27118
27119
  }
27119
27120
  };
@@ -27656,7 +27657,7 @@ function formatGapBetweenDates(prevDate, currDate) {
27656
27657
  else if (diffDays < 14) return `[1 week later]`;
27657
27658
  else if (diffDays < 30) return `[${Math.floor(diffDays / 7)} weeks later]`;
27658
27659
  else if (diffDays < 60) return `[1 month later]`;
27659
- else return `[${Math.floor(diffDays / 30)} months later]`;
27660
+ return `[${Math.floor(diffDays / 30)} months later]`;
27660
27661
  }
27661
27662
  const MONTH_INDEX = {
27662
27663
  jan: 0,
@@ -29644,13 +29645,15 @@ function parseMemorySectionXml(content) {
29644
29645
  suggestedResponse: "",
29645
29646
  threadTitle: ""
29646
29647
  };
29647
- const observationsMatches = [...content.matchAll(/^[ \t]*<observations>([\s\S]*?)^[ \t]*<\/observations>/gim)];
29648
- if (observationsMatches.length > 0) result.observations = observationsMatches.map((m) => m[1]?.trim() ?? "").filter(Boolean).join("\n");
29648
+ const observationsMatches = [...content.matchAll(/^[ \t]*<observations>(?:([^\r\n]*?)<\/observations>[ \t]*$|([\s\S]*?)^[ \t]*<\/observations>)/gim)];
29649
+ if (observationsMatches.length > 0) result.observations = observationsMatches.map((m) => (m[1] ?? m[2])?.trim() ?? "").filter(Boolean).join("\n");
29649
29650
  else result.observations = extractListItemsOnly(content);
29650
- const currentTaskMatch = content.match(/^[ \t]*<current-task>([\s\S]*?)^[ \t]*<\/current-task>/im);
29651
- if (currentTaskMatch?.[1]) result.currentTask = currentTaskMatch[1].trim();
29652
- const suggestedResponseMatch = content.match(/^[ \t]*<suggested-response>([\s\S]*?)^[ \t]*<\/suggested-response>/im);
29653
- if (suggestedResponseMatch?.[1]) result.suggestedResponse = suggestedResponseMatch[1].trim();
29651
+ const currentTaskMatch = content.match(/^[ \t]*<current-task>(?:([^\r\n]*?)<\/current-task>[ \t]*$|([\s\S]*?)^[ \t]*<\/current-task>)/im);
29652
+ const currentTask = currentTaskMatch?.[1] ?? currentTaskMatch?.[2];
29653
+ if (currentTask) result.currentTask = currentTask.trim();
29654
+ const suggestedResponseMatch = content.match(/^[ \t]*<suggested-response>(?:([^\r\n]*?)<\/suggested-response>[ \t]*$|([\s\S]*?)^[ \t]*<\/suggested-response>)/im);
29655
+ const suggestedResponse = suggestedResponseMatch?.[1] ?? suggestedResponseMatch?.[2];
29656
+ if (suggestedResponse) result.suggestedResponse = suggestedResponse.trim();
29654
29657
  const threadTitleMatch = content.match(/^[ \t]*<thread-title>([\s\S]*?)<\/thread-title>/im);
29655
29658
  if (threadTitleMatch?.[1]) result.threadTitle = threadTitleMatch[1].trim();
29656
29659
  return result;
@@ -30223,7 +30226,7 @@ var ObserverRunner = class {
30223
30226
  callback: (childObservabilityContext) => this.withAbortCheck(async () => {
30224
30227
  try {
30225
30228
  attemptMemory = temporaryMemory?.newThread();
30226
- return assertNonEmptyObserverOutput(assertCompleteModelResponse(await (await agent.stream(observerMessages, {
30229
+ return assertRecognizedObserverOutput(assertNonEmptyObserverOutput(assertCompleteModelResponse(await (await agent.stream(observerMessages, {
30227
30230
  maxSteps: 1,
30228
30231
  modelSettings: { ...this.observationConfig.modelSettings },
30229
30232
  providerOptions: this.observationConfig.providerOptions,
@@ -30232,7 +30235,7 @@ var ObserverRunner = class {
30232
30235
  onChunk: onActivity,
30233
30236
  ...internalRequestContext ? { requestContext: internalRequestContext } : {},
30234
30237
  ...childObservabilityContext
30235
- })).getFullOutput(), "OM observer"), "OM observer");
30238
+ })).getFullOutput(), "OM observer"), "OM observer"), "OM observer", (text) => hasSingleThreadObserverContent(text, activeExtractors));
30236
30239
  } catch (error) {
30237
30240
  this.mastra?.getLogger?.().error("OM observer provider call failed", {
30238
30241
  diagnostic: formatOmError(error),
@@ -30335,7 +30338,7 @@ var ObserverRunner = class {
30335
30338
  for (const threadId of allThreadOrder) {
30336
30339
  const threadResult = output.results.get(threadId);
30337
30340
  if (!threadResult) {
30338
- output.results.set(threadId, { observations: "" });
30341
+ if (!messagesByThread.has(threadId)) output.results.set(threadId, { observations: "" });
30339
30342
  continue;
30340
30343
  }
30341
30344
  threadResult.observations = await applyTextTransform(this.hooks, "afterObservation", threadResult.observations, contextFor(threadId));
@@ -30437,7 +30440,7 @@ var ObserverRunner = class {
30437
30440
  },
30438
30441
  callback: (childObservabilityContext) => this.withAbortCheck(async () => {
30439
30442
  try {
30440
- return assertNonEmptyObserverOutput(assertCompleteModelResponse(await (await agent.stream(observerMessages, {
30443
+ return assertRecognizedObserverOutput(assertNonEmptyObserverOutput(assertCompleteModelResponse(await (await agent.stream(observerMessages, {
30441
30444
  maxSteps: 1,
30442
30445
  modelSettings: { ...this.observationConfig.modelSettings },
30443
30446
  providerOptions: this.observationConfig.providerOptions,
@@ -30445,7 +30448,7 @@ var ObserverRunner = class {
30445
30448
  onChunk: onActivity,
30446
30449
  ...internalRequestContext ? { requestContext: internalRequestContext } : {},
30447
30450
  ...childObservabilityContext
30448
- })).getFullOutput(), "OM multi-thread observer"), "OM multi-thread observer");
30451
+ })).getFullOutput(), "OM multi-thread observer"), "OM multi-thread observer"), "OM multi-thread observer", (text) => hasMultiThreadObserverContent(text, activeExtractors, threadOrder));
30449
30452
  } catch (error) {
30450
30453
  this.mastra?.getLogger?.().error("OM multi-thread observer provider call failed", {
30451
30454
  diagnostic: formatOmError(error),
@@ -30522,8 +30525,7 @@ var ObserverRunner = class {
30522
30525
  extractors: activeExtractors
30523
30526
  });
30524
30527
  }
30525
- for (const threadId of threadOrder) if (!results.has(threadId)) results.set(threadId, { observations: "" });
30526
- for (const msgs of messagesByThread.values()) for (const msg of msgs) this.observedMessageIds.add(msg.id);
30528
+ for (const threadId of results.keys()) for (const msg of messagesByThread.get(threadId) ?? []) this.observedMessageIds.add(msg.id);
30527
30529
  const usage = result.totalUsage ?? result.usage;
30528
30530
  return {
30529
30531
  results,
@@ -30546,6 +30548,29 @@ function assertNonEmptyObserverOutput(output, label) {
30546
30548
  if (!output.text?.trim()) throw new OmEmptyResponseError(label);
30547
30549
  return output;
30548
30550
  }
30551
+ /**
30552
+ * A reply with text but nothing the parser recognises (e.g. a refusal like
30553
+ * "I can't help with that") parses to zero observations. Committing it would drop
30554
+ * the observed messages the same way an empty reply does, so it gets the same retry.
30555
+ * Degenerate replies pass through; the degenerate retry handles them.
30556
+ */
30557
+ function assertRecognizedObserverOutput(output, label, isRecognized) {
30558
+ if (!isRecognized(output.text)) throw new OmEmptyResponseError(label, "no observations");
30559
+ return output;
30560
+ }
30561
+ function hasSingleThreadObserverContent(text, extractors) {
30562
+ if (/^[ \t]*<observations>/im.test(text)) return true;
30563
+ const parsed = parseObserverOutput(text, extractors);
30564
+ return Boolean(parsed.degenerate || parsed.observations || parsed.currentTask || parsed.suggestedContinuation || parsed.threadTitle || Object.keys(parsed.extractedValues ?? {}).length || parsed.extractionFailures?.length);
30565
+ }
30566
+ /**
30567
+ * Multi-thread replies carry every recognised section inside `<thread>` blocks, so a reply
30568
+ * with no block for any requested thread has nothing to record.
30569
+ */
30570
+ function hasMultiThreadObserverContent(text, extractors, threadOrder) {
30571
+ const parsed = parseMultiThreadObserverOutput(text, extractors);
30572
+ return Boolean(parsed.degenerate || threadOrder.some((threadId) => parsed.threads.has(threadId)));
30573
+ }
30549
30574
  // src/processors/observational-memory/measure-image-buffer.ts
30550
30575
  /**
30551
30576
  * Synchronous image dimension lookup for in-memory image buffers.
@@ -42080,54 +42105,6 @@ ${formattedMessages}
42080
42105
  });
42081
42106
  }
42082
42107
  };
42083
- // src/processors/observational-memory/context-overflow.ts
42084
- /**
42085
- * Detects provider errors that reject a request for exceeding the model's context window.
42086
- *
42087
- * Providers report this with different codes and wording, so this matches the known shapes
42088
- * (OpenAI and OpenAI-compatible APIs, Anthropic, Google, Bedrock, xAI, Mistral, local servers)
42089
- * against the error's message, code, response body and causes.
42090
- */
42091
- const CONTEXT_OVERFLOW_PATTERNS = [
42092
- /context[_ ]length[_ ]exceeded/i,
42093
- /maximum context length/i,
42094
- /maximum prompt length/i,
42095
- /prompt is too long/i,
42096
- /input is too long/i,
42097
- /exceed\w*\b[^.]{0,40}\bcontext (?:window|length|limit|size)/i,
42098
- /input token count[^.]{0,40}exceeds the maximum/i,
42099
- /reduce the length of the (?:messages|prompt|input)/i
42100
- ];
42101
- const MAX_CAUSE_DEPTH = 4;
42102
- function collectErrorText(error, depth = 0) {
42103
- if (depth > MAX_CAUSE_DEPTH || error == null) return [];
42104
- if (typeof error === "string") return [error];
42105
- if (typeof error !== "object") return [];
42106
- const record = error;
42107
- const texts = [];
42108
- for (const key of [
42109
- "message",
42110
- "code",
42111
- "type",
42112
- "responseBody"
42113
- ]) {
42114
- const value = record[key];
42115
- if (typeof value === "string") texts.push(value);
42116
- }
42117
- if (record.data && typeof record.data === "object") texts.push(...collectErrorText(record.data.error ?? record.data, depth + 1));
42118
- if (record.error && typeof record.error === "object") texts.push(...collectErrorText(record.error, depth + 1));
42119
- texts.push(...collectErrorText(record.cause, depth + 1));
42120
- return texts;
42121
- }
42122
- function isRateLimited(error, depth = 0) {
42123
- if (depth > MAX_CAUSE_DEPTH || error == null || typeof error !== "object") return false;
42124
- const record = error;
42125
- return record.statusCode === 429 || isRateLimited(record.cause, depth + 1);
42126
- }
42127
- function isContextOverflowError(error) {
42128
- if (isRateLimited(error)) return false;
42129
- return collectErrorText(error).some((text) => CONTEXT_OVERFLOW_PATTERNS.some((pattern) => pattern.test(text)));
42130
- }
42131
42108
  // src/processors/observational-memory/temporal-markers.ts
42132
42109
  const TEMPORAL_GAP_REMINDER_TYPE = "temporal-gap";
42133
42110
  function getTemporalGapReminderText(gapText, timestamp) {
@@ -42529,7 +42506,7 @@ var ObservationalMemoryProcessor = class {
42529
42506
  if (!this.engine.getObservationConfig().observeOnContextOverflow) return;
42530
42507
  if (state[GATEWAY_STATE_KEY]) return;
42531
42508
  if (state[CONTEXT_OVERFLOW_STEP_KEY] === stepNumber) return;
42532
- if (!isContextOverflowError(error)) return;
42509
+ if (classifyProviderError(error) !== "context_overflow") return;
42533
42510
  const context = this.engine.getThreadContext(requestContext, messageList);
42534
42511
  if (!context) return;
42535
42512
  if (parseMemoryRequestContext(requestContext)?.memoryConfig?.readOnly) return;
@@ -44686,7 +44663,7 @@ Notes:
44686
44663
  messageIds = input.map((item) => {
44687
44664
  if (typeof item === "string") return item;
44688
44665
  else if (item && typeof item === "object" && "id" in item) return item.id;
44689
- else throw new Error("Invalid input: array items must be strings or objects with an id property");
44666
+ throw new Error("Invalid input: array items must be strings or objects with an id property");
44690
44667
  });
44691
44668
  if (messageIds.filter((id) => !id || typeof id !== "string").length > 0) throw new Error("All message IDs must be non-empty strings");
44692
44669
  const span = this.createMemorySpan("delete", observabilityContext, void 0, { messageCount: messageIds.length });
@@ -45341,4 +45318,4 @@ Notes:
45341
45318
  };
45342
45319
  export { renderSubconsciousActivity as $, buildObserverSystemPrompt as A, OBSERVATION_CONTEXT_INSTRUCTIONS as B, WorkingMemoryExtractor as C, TokenCounter as D, summarizeConversation as E, parseObserverOutput as F, Subconscious as G, OBSERVATION_CONTEXT_PROMPT_THREAD as H, injectAnchorIds as I, SubconsciousRemindExtractor as J, KnowledgeSemanticIndexCoordinator as K, parseAnchorId as L, formatMessagesForObserver as M, hasCurrentTaskSection as N, OBSERVER_SYSTEM_PROMPT as O, optimizeObservationsForContext as P, publishSubconsciousActivity as Q, stripEphemeralAnchorIds as R, wrapInObservationGroup as S, SUMMARIZE_THREAD_DEFAULTS as T, OBSERVATION_CONTINUATION_HINT as U, OBSERVATION_CONTEXT_PROMPT as V, getObservationContextPrompt as W, SUBCONSCIOUS_ACTIVITY_STATE_ID as X, ModelByInputTokens as Y, buildSubconsciousActivitySnapshot as Z, deriveObservationGroupProvenance as _, extractWorkingMemoryContent as a, renderObservationGroupsForReflection as b, getObservationsAsOf as c, AUTO_MODEL_BY_PROVIDER as d, Extractor as et, resolveAutoModelId as f, combineObservationGroupRanges as g, WorkingMemoryStateProcessor as h, WorkingMemory as i, extractCurrentTask as j, buildObserverPrompt as k, ObservationalMemoryProcessor as l, WORKING_MEMORY_STATE_PROCESSOR_ID as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, WORKING_MEMORY_STATE_ID as p, StaleKnowledgeSemanticIndexError as q, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, ObservationalMemory as u, parseObservationGroups as v, deepMergeWorkingMemory as w, stripObservationGroups as x, reconcileObservationGroupsFromReflection as y, OBSERVATIONAL_MEMORY_DEFAULTS as z };
45343
45320
 
45344
- //# sourceMappingURL=src-stSVckwY.js.map
45321
+ //# sourceMappingURL=src-CLQXrKvR.js.map