@mastra/server 1.75.0-alpha.5 → 1.75.0-alpha.8

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 (122) hide show
  1. package/dist/{agents-kOz1lr_e.js → agents-BuKPiseS.js} +4 -2
  2. package/dist/agents-BuKPiseS.js.map +1 -0
  3. package/dist/{agents-DwJE1tsB.cjs → agents-COAEoXsc.cjs} +4 -2
  4. package/dist/agents-COAEoXsc.cjs.map +1 -0
  5. package/dist/{api-schema-manifest-BKsEMyEs.cjs → api-schema-manifest-D_esmkjG.cjs} +2 -2
  6. package/dist/{api-schema-manifest-BKsEMyEs.cjs.map → api-schema-manifest-D_esmkjG.cjs.map} +1 -1
  7. package/dist/{api-schema-manifest-KsETdHDS.js → api-schema-manifest-I5zotQbd.js} +2 -2
  8. package/dist/{api-schema-manifest-KsETdHDS.js.map → api-schema-manifest-I5zotQbd.js.map} +1 -1
  9. package/dist/{dist-DWXEVDmb.js → dist-DMtuYRLk.js} +176 -87
  10. package/dist/dist-DMtuYRLk.js.map +1 -0
  11. package/dist/{dist-DRLe8Sd-.cjs → dist-DpUNsgQx.cjs} +176 -87
  12. package/dist/dist-DpUNsgQx.cjs.map +1 -0
  13. package/dist/docs/SKILL.md +1 -1
  14. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  15. package/dist/{editor-builder-BLi1jvZd.js → editor-builder-CdLGv1Ka.js} +2 -2
  16. package/dist/{editor-builder-BLi1jvZd.js.map → editor-builder-CdLGv1Ka.js.map} +1 -1
  17. package/dist/{editor-builder-Dm6jviKJ.cjs → editor-builder-DJl5x_Kj.cjs} +2 -2
  18. package/dist/{editor-builder-Dm6jviKJ.cjs.map → editor-builder-DJl5x_Kj.cjs.map} +1 -1
  19. package/dist/{editor-builder-DrDs-t9i.cjs → editor-builder-DRlsFCN0.cjs} +2 -2
  20. package/dist/{editor-builder-DrDs-t9i.cjs.map → editor-builder-DRlsFCN0.cjs.map} +1 -1
  21. package/dist/{editor-builder-DJMAKDR5.js → editor-builder-DU3y5Ant.js} +2 -2
  22. package/dist/{editor-builder-DJMAKDR5.js.map → editor-builder-DU3y5Ant.js.map} +1 -1
  23. package/dist/{mcp-CzeJPT9B.js → mcp-BK6cmwww.js} +4 -2
  24. package/dist/{mcp-CzeJPT9B.js.map → mcp-BK6cmwww.js.map} +1 -1
  25. package/dist/{mcp-PvdJ7pkd.cjs → mcp-Jus386Vq.cjs} +4 -2
  26. package/dist/mcp-Jus386Vq.cjs.map +1 -0
  27. package/dist/{observability-new-endpoints-Kphyk3do.cjs → observability-new-endpoints-DBmaTpap.cjs} +2 -2
  28. package/dist/{observability-new-endpoints-Kphyk3do.cjs.map → observability-new-endpoints-DBmaTpap.cjs.map} +1 -1
  29. package/dist/{observability-new-endpoints-DQuhr8aL.js → observability-new-endpoints-wd_fs1mo.js} +2 -2
  30. package/dist/{observability-new-endpoints-DQuhr8aL.js.map → observability-new-endpoints-wd_fs1mo.js.map} +1 -1
  31. package/dist/{probe-image-size-CDCRrXNo.cjs → probe-image-size-DBGjhUtJ.cjs} +111 -161
  32. package/dist/probe-image-size-DBGjhUtJ.cjs.map +1 -0
  33. package/dist/{probe-image-size-Tf8sNZhU.js → probe-image-size-Dmoxv93t.js} +111 -161
  34. package/dist/probe-image-size-Dmoxv93t.js.map +1 -0
  35. package/dist/{routes-B_ehFjzs.js → routes-CdEBhq8U.js} +4 -4
  36. package/dist/{routes-B_ehFjzs.js.map → routes-CdEBhq8U.js.map} +1 -1
  37. package/dist/{routes-Op7uJGai.cjs → routes-CjpyDJjY.cjs} +4 -4
  38. package/dist/{routes-Op7uJGai.cjs.map → routes-CjpyDJjY.cjs.map} +1 -1
  39. package/dist/server/handlers/agent-builder.cjs +2 -2
  40. package/dist/server/handlers/agent-builder.js +2 -2
  41. package/dist/server/handlers/agent-controller.cjs +12 -9
  42. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  43. package/dist/server/handlers/agent-controller.d.ts +8 -6
  44. package/dist/server/handlers/agent-controller.d.ts.map +1 -1
  45. package/dist/server/handlers/agent-controller.js +12 -9
  46. package/dist/server/handlers/agent-controller.js.map +1 -1
  47. package/dist/server/handlers/agents.cjs +1 -1
  48. package/dist/server/handlers/agents.d.ts +448 -0
  49. package/dist/server/handlers/agents.d.ts.map +1 -1
  50. package/dist/server/handlers/agents.js +1 -1
  51. package/dist/server/handlers/editor-builder.cjs +1 -1
  52. package/dist/server/handlers/editor-builder.js +1 -1
  53. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  54. package/dist/server/handlers/favorites-enrichment.js +1 -1
  55. package/dist/server/handlers/mcp.cjs +1 -1
  56. package/dist/server/handlers/mcp.d.ts +4 -0
  57. package/dist/server/handlers/mcp.d.ts.map +1 -1
  58. package/dist/server/handlers/mcp.js +1 -1
  59. package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
  60. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  61. package/dist/server/handlers/observability.cjs +1 -1
  62. package/dist/server/handlers/observability.js +1 -1
  63. package/dist/server/handlers/plans.cjs +1 -1
  64. package/dist/server/handlers/plans.js +1 -1
  65. package/dist/server/handlers/stored-agent-favorites.cjs +1 -1
  66. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  67. package/dist/server/handlers/stored-agents.cjs +1 -1
  68. package/dist/server/handlers/stored-agents.js +1 -1
  69. package/dist/server/handlers/stored-skill-favorites.cjs +1 -1
  70. package/dist/server/handlers/stored-skill-favorites.js +1 -1
  71. package/dist/server/handlers/stored-skills.cjs +1 -1
  72. package/dist/server/handlers/stored-skills.js +1 -1
  73. package/dist/server/handlers/system.cjs +5 -2
  74. package/dist/server/handlers/system.cjs.map +1 -1
  75. package/dist/server/handlers/system.d.ts +2 -0
  76. package/dist/server/handlers/system.d.ts.map +1 -1
  77. package/dist/server/handlers/system.js +5 -2
  78. package/dist/server/handlers/system.js.map +1 -1
  79. package/dist/server/handlers/tools.cjs +1 -1
  80. package/dist/server/handlers/tools.js +1 -1
  81. package/dist/server/handlers/workflow-builder.cjs +1 -1
  82. package/dist/server/handlers/workflow-builder.js +1 -1
  83. package/dist/server/handlers/workflows.cjs +1 -1
  84. package/dist/server/handlers/workflows.js +1 -1
  85. package/dist/server/schemas/agents.d.ts +4 -0
  86. package/dist/server/schemas/agents.d.ts.map +1 -1
  87. package/dist/server/schemas/index.cjs +4 -4
  88. package/dist/server/schemas/index.js +4 -4
  89. package/dist/server/schemas/mcp.d.ts +4 -0
  90. package/dist/server/schemas/mcp.d.ts.map +1 -1
  91. package/dist/server/schemas/system.d.ts +1 -0
  92. package/dist/server/schemas/system.d.ts.map +1 -1
  93. package/dist/server/server-adapter/index.cjs +1 -1
  94. package/dist/server/server-adapter/index.js +1 -1
  95. package/dist/server/server-adapter/routes/mcp.d.ts +4 -0
  96. package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -1
  97. package/dist/server/server-adapter/routes/system.d.ts +2 -0
  98. package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
  99. package/dist/{sync-BG15Yae1.js → sync-Ai_ZDz7U.js} +176 -132
  100. package/dist/sync-Ai_ZDz7U.js.map +1 -0
  101. package/dist/{sync-C4LbbSKR.cjs → sync-BrO5MtSe.cjs} +181 -131
  102. package/dist/sync-BrO5MtSe.cjs.map +1 -0
  103. package/dist/{system-Be5n6H_z.cjs → system-CycnKGR3.cjs} +3 -1
  104. package/dist/system-CycnKGR3.cjs.map +1 -0
  105. package/dist/{system-BtGAJr9R.js → system-Di2kpGTC.js} +3 -1
  106. package/dist/system-Di2kpGTC.js.map +1 -0
  107. package/dist/{workflow-builder-BSjQJCVD.cjs → workflow-builder-DYfgyaeB.cjs} +3 -3
  108. package/dist/{workflow-builder-BSjQJCVD.cjs.map → workflow-builder-DYfgyaeB.cjs.map} +1 -1
  109. package/dist/{workflow-builder-DJ48IzXQ.js → workflow-builder-DxQMzsT9.js} +3 -3
  110. package/dist/{workflow-builder-DJ48IzXQ.js.map → workflow-builder-DxQMzsT9.js.map} +1 -1
  111. package/package.json +6 -6
  112. package/dist/agents-DwJE1tsB.cjs.map +0 -1
  113. package/dist/agents-kOz1lr_e.js.map +0 -1
  114. package/dist/dist-DRLe8Sd-.cjs.map +0 -1
  115. package/dist/dist-DWXEVDmb.js.map +0 -1
  116. package/dist/mcp-PvdJ7pkd.cjs.map +0 -1
  117. package/dist/probe-image-size-CDCRrXNo.cjs.map +0 -1
  118. package/dist/probe-image-size-Tf8sNZhU.js.map +0 -1
  119. package/dist/sync-BG15Yae1.js.map +0 -1
  120. package/dist/sync-C4LbbSKR.cjs.map +0 -1
  121. package/dist/system-Be5n6H_z.cjs.map +0 -1
  122. package/dist/system-BtGAJr9R.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { o as __toESM$1, t as __commonJSMin$1 } from "./rolldown-runtime-maW3aOIk.js";
2
2
  import { n as standardSchemaToJSONSchema, r as toStandardSchema$1, t as isStandardSchemaWithJSON$1 } from "./schema-e0VHpMt0-CvPvLS06.js";
3
3
  import "./schema-Xxr5X5Je.js";
4
- import { t as require_sync } from "./sync-BG15Yae1.js";
4
+ import { t as require_sync } from "./sync-Ai_ZDz7U.js";
5
5
  import { openai } from "./dist-Bz4l8I_x.js";
6
6
  import { createRequire } from "module";
7
7
  import * as z4 from "zod/v4";
@@ -4637,7 +4637,7 @@ function splitLines(text) {
4637
4637
  return result;
4638
4638
  }
4639
4639
  //#endregion
4640
- //#region ../memory/dist/src-BQOm4kZc.js
4640
+ //#region ../memory/dist/src-yhShj4JX.js
4641
4641
  var __defProp$3 = Object.defineProperty;
4642
4642
  var __exportAll = (all, no_symbols) => {
4643
4643
  let target = {};
@@ -23310,8 +23310,38 @@ const TRANSIENT_MESSAGE_SUBSTRINGS = [
23310
23310
  "request timed out",
23311
23311
  "request timeout",
23312
23312
  "connection reset",
23313
- "connection closed"
23313
+ "connection closed",
23314
+ "finished with finishreason \"other\""
23314
23315
  ];
23316
+ const INCOMPLETE_FINISH_REASONS = /* @__PURE__ */ new Set(["other", "unknown"]);
23317
+ /**
23318
+ * A model reply that ended before the model finished. Carries the AI SDK's
23319
+ * `isRetryable` flag, which `isTransientLLMError` and core's error processors
23320
+ * already recognize.
23321
+ *
23322
+ * @internal
23323
+ */
23324
+ var OmIncompleteResponseError = class extends Error {
23325
+ finishReason;
23326
+ isRetryable = true;
23327
+ constructor(label, finishReason) {
23328
+ super(`${label} response ended early (finishReason: ${finishReason})`);
23329
+ this.finishReason = finishReason;
23330
+ this.name = "OmIncompleteResponseError";
23331
+ }
23332
+ };
23333
+ /**
23334
+ * OM calls are single-step (`maxSteps: 1`). A step that ends with `other` or
23335
+ * `unknown` means the stream closed before the model finished, so its text is
23336
+ * partial. Throw a retryable error so `withRetry` re-runs the whole call
23337
+ * instead of saving it.
23338
+ *
23339
+ * @internal
23340
+ */
23341
+ function assertCompleteModelResponse(output, label) {
23342
+ if (output.finishReason && INCOMPLETE_FINISH_REASONS.has(output.finishReason)) throw new OmIncompleteResponseError(label, output.finishReason);
23343
+ return output;
23344
+ }
23315
23345
  function isRecord$5(value) {
23316
23346
  return typeof value === "object" && value !== null;
23317
23347
  }
@@ -24530,8 +24560,9 @@ function stringifyToolResult(value) {
24530
24560
  }
24531
24561
  function resolveToolResultValue(part, invocationResult) {
24532
24562
  const mastraMetadata = part?.providerMetadata?.mastra;
24533
- if (mastraMetadata && typeof mastraMetadata === "object" && "modelOutput" in mastraMetadata) return {
24534
- value: mastraMetadata.modelOutput,
24563
+ const modelOutput = mastraMetadata && typeof mastraMetadata === "object" ? mastraMetadata.modelOutput : void 0;
24564
+ if (modelOutput != null) return {
24565
+ value: modelOutput,
24535
24566
  usingStoredModelOutput: true
24536
24567
  };
24537
24568
  return {
@@ -25572,7 +25603,7 @@ function buildMultiThreadObserverContextPrompt(existingObservations, threadOrder
25572
25603
  */
25573
25604
  function parseMultiThreadObserverOutput(output, extractors = []) {
25574
25605
  const threads = /* @__PURE__ */ new Map();
25575
- if (detectDegenerateRepetition(output)) return {
25606
+ if (detectDegenerateRepetition(sanitizeObservationLines(output))) return {
25576
25607
  threads,
25577
25608
  rawOutput: output,
25578
25609
  degenerate: true
@@ -25678,7 +25709,7 @@ function getStringExtractedValue$1(values, slug) {
25678
25709
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
25679
25710
  }
25680
25711
  function parseObserverOutput(output, extractors = []) {
25681
- if (detectDegenerateRepetition(output)) return {
25712
+ if (detectDegenerateRepetition(sanitizeObservationLines(output))) return {
25682
25713
  observations: "",
25683
25714
  rawOutput: output,
25684
25715
  degenerate: true
@@ -25741,6 +25772,34 @@ const MAX_OBSERVATION_LINE_CHARS = 1e4;
25741
25772
  */
25742
25773
  const MIN_DUPLICATE_LINE_CHARS = 24;
25743
25774
  /**
25775
+ * Collapse a run of back-to-back identical lines to a single line when that
25776
+ * run is the line's only occurrence and is no bigger than one maximum-length
25777
+ * observation line. A faithful summary of a repetitive tool loop (e.g. 30×
25778
+ * "pnpm --filter … build → ok") produces exactly that shape at any line
25779
+ * length. Loops are left intact: a model stuck on one line runs far past the
25780
+ * size bound, and a line that keeps recurring between other lines has more
25781
+ * than one run.
25782
+ */
25783
+ function collapseBoundedLineRuns(lines) {
25784
+ const runs = [];
25785
+ for (const line of lines) {
25786
+ const last = runs[runs.length - 1];
25787
+ if (last && last.line === line) last.count++;
25788
+ else runs.push({
25789
+ line,
25790
+ count: 1
25791
+ });
25792
+ }
25793
+ const runsPerLine = /* @__PURE__ */ new Map();
25794
+ for (const run of runs) runsPerLine.set(run.line, (runsPerLine.get(run.line) ?? 0) + 1);
25795
+ const result = [];
25796
+ for (const run of runs) {
25797
+ const collapse = runsPerLine.get(run.line) === 1 && run.count * (run.line.length + 1) <= MAX_OBSERVATION_LINE_CHARS;
25798
+ for (let j = 0; j < (collapse ? 1 : run.count); j++) result.push(run.line);
25799
+ }
25800
+ return result;
25801
+ }
25802
+ /**
25744
25803
  * Truncate individual observation lines that exceed the maximum length.
25745
25804
  */
25746
25805
  function sanitizeObservationLines(observations) {
@@ -25753,31 +25812,28 @@ function sanitizeObservationLines(observations) {
25753
25812
  }
25754
25813
  return changed ? lines.join("\n") : observations;
25755
25814
  }
25756
- /**
25757
- * Detect degenerate repetition in observer/reflector output.
25758
- * Returns true if the text contains suspicious levels of repeated content,
25759
- * which indicates an LLM repeat-penalty bug (e.g., Gemini Flash looping).
25760
- *
25761
- * Strategy: sample sequential chunks of the text and check if a high
25762
- * proportion are near-identical to previous chunks.
25763
- */
25764
- function detectDegenerateRepetition(text) {
25765
- if (!text || text.length < 2e3) return false;
25815
+ function analyzeDegenerateRepetition(text) {
25816
+ const lines = collapseBoundedLineRuns(text.split("\n"));
25817
+ const windowText = lines.filter((line) => line.trim().length >= MIN_DUPLICATE_LINE_CHARS && line.length <= MAX_OBSERVATION_LINE_CHARS).join("\n");
25766
25818
  const windowSize = 200;
25767
- const step = Math.max(1, Math.floor(text.length / 50));
25819
+ const step = Math.max(1, Math.floor(windowText.length / 50));
25768
25820
  const seen = /* @__PURE__ */ new Map();
25769
25821
  let duplicateWindows = 0;
25770
25822
  let totalWindows = 0;
25771
- for (let i = 0; i + windowSize <= text.length; i += step) {
25772
- const window = text.slice(i, i + windowSize);
25823
+ let topWindow = "";
25824
+ let topWindowCount = 0;
25825
+ for (let i = 0; i + windowSize <= windowText.length; i += step) {
25826
+ const window = windowText.slice(i, i + windowSize);
25773
25827
  totalWindows++;
25774
25828
  const count = (seen.get(window) ?? 0) + 1;
25775
25829
  seen.set(window, count);
25776
25830
  if (count > 1) duplicateWindows++;
25831
+ if (count > topWindowCount) {
25832
+ topWindowCount = count;
25833
+ topWindow = window;
25834
+ }
25777
25835
  }
25778
- if (totalWindows > 5 && duplicateWindows / totalWindows > .4) return true;
25779
- const lines = text.split("\n");
25780
- for (const line of lines) if (line.length > 5e4) return true;
25836
+ const windowFired = windowText.length >= 2e3 && totalWindows > 5 && duplicateWindows / totalWindows > .4;
25781
25837
  const seenLines = /* @__PURE__ */ new Map();
25782
25838
  let duplicateLines = 0;
25783
25839
  let totalCountedLines = 0;
@@ -25789,8 +25845,50 @@ function detectDegenerateRepetition(text) {
25789
25845
  seenLines.set(trimmed, count);
25790
25846
  if (count > 1) duplicateLines++;
25791
25847
  }
25792
- if (totalCountedLines >= 20 && duplicateLines / totalCountedLines > .5) return true;
25793
- return false;
25848
+ const lineFired = totalCountedLines >= 20 && duplicateLines / totalCountedLines > .5;
25849
+ let shortLineFired = false;
25850
+ let shortLineCounts = /* @__PURE__ */ new Map();
25851
+ const runExceedsBudget = () => {
25852
+ let repeatedShortChars = 0;
25853
+ for (const { count, chars } of shortLineCounts.values()) if (count > 1) repeatedShortChars += chars;
25854
+ return repeatedShortChars - 1 > MAX_OBSERVATION_LINE_CHARS;
25855
+ };
25856
+ for (const line of lines) {
25857
+ const trimmed = line.trim();
25858
+ if (!trimmed) continue;
25859
+ if (trimmed.length >= MIN_DUPLICATE_LINE_CHARS) {
25860
+ if (runExceedsBudget()) shortLineFired = true;
25861
+ shortLineCounts = /* @__PURE__ */ new Map();
25862
+ continue;
25863
+ }
25864
+ if (/^<\/?[A-Za-z][\w-]*(?:\s[^<>]*)?>$/.test(trimmed) || trimmed.startsWith("Date:")) continue;
25865
+ const entry = shortLineCounts.get(trimmed) ?? {
25866
+ count: 0,
25867
+ chars: 0
25868
+ };
25869
+ entry.count++;
25870
+ entry.chars += line.length + 1;
25871
+ shortLineCounts.set(trimmed, entry);
25872
+ }
25873
+ if (runExceedsBudget()) shortLineFired = true;
25874
+ const eligible = text.length >= 2e3;
25875
+ return {
25876
+ windowText,
25877
+ totalWindows,
25878
+ duplicateWindows,
25879
+ topWindow,
25880
+ topWindowCount,
25881
+ totalCountedLines,
25882
+ duplicateLines,
25883
+ windowFired: eligible && windowFired,
25884
+ lineFired: eligible && lineFired,
25885
+ shortLineFired: eligible && shortLineFired
25886
+ };
25887
+ }
25888
+ function detectDegenerateRepetition(text) {
25889
+ if (!text || text.length < 2e3) return false;
25890
+ const analysis = analyzeDegenerateRepetition(text);
25891
+ return analysis.windowFired || analysis.lineFired || analysis.shortLineFired;
25794
25892
  }
25795
25893
  /**
25796
25894
  * Build a single-line diagnostic description of output flagged by
@@ -25799,55 +25897,35 @@ function detectDegenerateRepetition(text) {
25799
25897
  * without it there is no way to tell a real repetition loop apart from a
25800
25898
  * detector false-positive on legitimately repetitive content.
25801
25899
  *
25802
- * Reuses the detector's sampling parameters (200-char windows, ~50 samples)
25803
- * so the reported duplicate ratio and most-repeated window match what
25804
- * triggered the detection. Snippets are JSON-escaped so the result stays on
25805
- * one line.
25900
+ * Runs the detector's analysis on the same sanitized text the detector judges
25901
+ * (giant lines truncated), so `strategy=` names what triggered the rejection.
25902
+ * For a short-line loop the window and line ratios read n/a or low, because
25903
+ * short lines are excluded from both. `length` and `longestLine` describe the
25904
+ * raw output. Snippets are JSON-escaped so the result stays on one line.
25806
25905
  */
25807
25906
  function describeDegenerateOutput(text, snippetChars = 400) {
25808
- const windowSize = 200;
25809
- const step = Math.max(1, Math.floor(text.length / 50));
25810
- const seen = /* @__PURE__ */ new Map();
25811
- let duplicateWindows = 0;
25812
- let totalWindows = 0;
25813
- for (let i = 0; i + windowSize <= text.length; i += step) {
25814
- const window = text.slice(i, i + windowSize);
25815
- totalWindows++;
25816
- const count = (seen.get(window) ?? 0) + 1;
25817
- seen.set(window, count);
25818
- if (count > 1) duplicateWindows++;
25819
- }
25820
- let topWindow = "";
25821
- let topCount = 0;
25822
- for (const [window, count] of seen) if (count > topCount) {
25823
- topCount = count;
25824
- topWindow = window;
25825
- }
25907
+ const a = analyzeDegenerateRepetition(sanitizeObservationLines(text));
25826
25908
  let longestLine = 0;
25827
- const seenLines = /* @__PURE__ */ new Map();
25828
- let duplicateLines = 0;
25829
- let totalCountedLines = 0;
25830
- for (const line of text.split("\n")) {
25831
- if (line.length > longestLine) longestLine = line.length;
25832
- const trimmed = line.trim();
25833
- if (trimmed.length < MIN_DUPLICATE_LINE_CHARS) continue;
25834
- totalCountedLines++;
25835
- const count = (seenLines.get(trimmed) ?? 0) + 1;
25836
- seenLines.set(trimmed, count);
25837
- if (count > 1) duplicateLines++;
25838
- }
25839
- const duplicateRatio = totalWindows > 0 ? (duplicateWindows / totalWindows).toFixed(2) : "n/a";
25840
- const duplicateLineRatio = totalCountedLines > 0 ? (duplicateLines / totalCountedLines).toFixed(2) : "n/a";
25909
+ for (const line of text.split("\n")) if (line.length > longestLine) longestLine = line.length;
25910
+ const fired = [
25911
+ a.windowFired && "window",
25912
+ a.lineFired && "duplicateLines",
25913
+ a.shortLineFired && "shortLineLoop"
25914
+ ].filter(Boolean).join("+") || "none";
25915
+ const duplicateRatio = a.totalWindows > 0 ? (a.duplicateWindows / a.totalWindows).toFixed(2) : "n/a";
25916
+ const duplicateLineRatio = a.totalCountedLines > 0 ? (a.duplicateLines / a.totalCountedLines).toFixed(2) : "n/a";
25841
25917
  const parts = [
25918
+ `strategy=${fired}`,
25842
25919
  `length=${text.length}`,
25843
- `sampledWindows=${totalWindows}`,
25920
+ `windowTextLength=${a.windowText.length}`,
25921
+ `sampledWindows=${a.totalWindows}`,
25844
25922
  `duplicateRatio=${duplicateRatio}`,
25845
25923
  `duplicateLineRatio=${duplicateLineRatio}`,
25846
- `countedLines=${totalCountedLines}`,
25924
+ `countedLines=${a.totalCountedLines}`,
25847
25925
  `longestLine=${longestLine}`,
25848
- `topWindowCount=${topCount}`
25926
+ `topWindowCount=${a.topWindowCount}`
25849
25927
  ];
25850
- if (topCount > 1) parts.push(`topWindow=${JSON.stringify(topWindow)}`);
25928
+ if (a.topWindowCount > 1) parts.push(`topWindow=${JSON.stringify(a.topWindow)}`);
25851
25929
  parts.push(`head=${JSON.stringify(text.slice(0, snippetChars))}`);
25852
25930
  if (text.length > snippetChars * 2) parts.push(`tail=${JSON.stringify(text.slice(-snippetChars))}`);
25853
25931
  return parts.join(" ");
@@ -25900,20 +25978,20 @@ function optimizeObservationsForContext(observations) {
25900
25978
  return optimized.trim();
25901
25979
  }
25902
25980
  function createTemporaryOmMemoryContext(prefix) {
25903
- const options = {
25904
- thread: `${prefix}-${globalThis.crypto.randomUUID()}`,
25905
- resource: prefix,
25906
- options: {
25907
- lastMessages: 10,
25908
- generateTitle: false
25909
- }
25981
+ const memoryOptions = {
25982
+ lastMessages: 10,
25983
+ generateTitle: false
25910
25984
  };
25911
25985
  return {
25912
25986
  memory: new Memory({
25913
25987
  storage: new InMemoryStore(),
25914
- options: options.options
25988
+ options: memoryOptions
25915
25989
  }),
25916
- options
25990
+ newThread: () => ({
25991
+ thread: `${prefix}-${globalThis.crypto.randomUUID()}`,
25992
+ resource: prefix,
25993
+ options: memoryOptions
25994
+ })
25917
25995
  };
25918
25996
  }
25919
25997
  const PHASE_CONFIG = {
@@ -26052,6 +26130,7 @@ var ObserverRunner = class {
26052
26130
  id: isMultiThread ? "multi-thread-observer" : "observational-memory-observer",
26053
26131
  name: isMultiThread ? "multi-thread-observer" : "Observer",
26054
26132
  maxRetries: 0,
26133
+ errorProcessorDefaults: false,
26055
26134
  instructions: buildObserverSystemPrompt(isMultiThread, this.observationConfig.instruction, this.observationConfig.threadTitle, extractors),
26056
26135
  model: agentModel,
26057
26136
  ...memory ? { memory } : {},
@@ -26140,6 +26219,7 @@ var ObserverRunner = class {
26140
26219
  const temporaryMemory = activeExtractors.filter((extractor) => extractor.mode === "structured").length > 0 ? await createTemporaryOmMemoryContext("structured-observer") : void 0;
26141
26220
  const agent = temporaryMemory ? this.createAgent(resolvedModel.model, false, temporaryMemory.memory, activeExtractors) : this.createAgent(resolvedModel.model, false, void 0, activeExtractors);
26142
26221
  const internalRequestContext = withOmInternalThreadId(options?.requestContext, agent.id);
26222
+ let attemptMemory;
26143
26223
  const attachmentFilter = this.resolveAttachmentFilter(resolvedModel.model, options?.requestContext);
26144
26224
  const observerMessages = [buildObserverRequestMessage(existingObservations, messagesToObserve, {
26145
26225
  ...options,
@@ -26167,14 +26247,16 @@ var ObserverRunner = class {
26167
26247
  },
26168
26248
  callback: (childObservabilityContext) => this.withAbortCheck(async () => {
26169
26249
  try {
26170
- return await (await agent.stream(observerMessages, {
26250
+ attemptMemory = temporaryMemory?.newThread();
26251
+ return assertCompleteModelResponse(await (await agent.stream(observerMessages, {
26252
+ maxSteps: 1,
26171
26253
  modelSettings: { ...this.observationConfig.modelSettings },
26172
26254
  providerOptions: this.observationConfig.providerOptions,
26173
- ...temporaryMemory ? { memory: temporaryMemory.options } : {},
26255
+ ...attemptMemory ? { memory: attemptMemory } : {},
26174
26256
  ...abortSignal ? { abortSignal } : {},
26175
26257
  ...internalRequestContext ? { requestContext: internalRequestContext } : {},
26176
26258
  ...childObservabilityContext
26177
- })).getFullOutput();
26259
+ })).getFullOutput(), "OM observer");
26178
26260
  } catch (error) {
26179
26261
  this.mastra?.getLogger?.().error("OM observer provider call failed", {
26180
26262
  diagnostic: formatOmError(error),
@@ -26213,7 +26295,7 @@ var ObserverRunner = class {
26213
26295
  agent,
26214
26296
  source: "observer",
26215
26297
  extractors: activeExtractors,
26216
- memory: temporaryMemory?.options,
26298
+ memory: attemptMemory,
26217
26299
  priorExtractedValues: options?.priorExtractedValues,
26218
26300
  requestContext: internalRequestContext,
26219
26301
  observabilityContext: options?.observabilityContext,
@@ -26373,13 +26455,14 @@ var ObserverRunner = class {
26373
26455
  },
26374
26456
  callback: (childObservabilityContext) => this.withAbortCheck(async () => {
26375
26457
  try {
26376
- return await (await agent.stream(observerMessages, {
26458
+ return assertCompleteModelResponse(await (await agent.stream(observerMessages, {
26459
+ maxSteps: 1,
26377
26460
  modelSettings: { ...this.observationConfig.modelSettings },
26378
26461
  providerOptions: this.observationConfig.providerOptions,
26379
26462
  ...abortSignal ? { abortSignal } : {},
26380
26463
  ...internalRequestContext ? { requestContext: internalRequestContext } : {},
26381
26464
  ...childObservabilityContext
26382
- })).getFullOutput();
26465
+ })).getFullOutput(), "OM multi-thread observer");
26383
26466
  } catch (error) {
26384
26467
  this.mastra?.getLogger?.().error("OM multi-thread observer provider call failed", {
26385
26468
  diagnostic: formatOmError(error),
@@ -26780,7 +26863,7 @@ async function resolveImageDimensionsAsync(part) {
26780
26863
  const url = resolveHttpAssetUrl(getObjectValue(part, "image") ?? getObjectValue(part, "data"));
26781
26864
  if (!url) return existing;
26782
26865
  try {
26783
- const probeImageSize = (await import("./probe-image-size-Tf8sNZhU.js").then((m) => /* @__PURE__ */ __toESM$1(m.default, 1))).default;
26866
+ const probeImageSize = (await import("./probe-image-size-Dmoxv93t.js").then((m) => /* @__PURE__ */ __toESM$1(m.default, 1))).default;
26784
26867
  const probed = await probeImageSize(url, {
26785
26868
  open_timeout: REMOTE_IMAGE_PROBE_TIMEOUT_MS,
26786
26869
  response_timeout: REMOTE_IMAGE_PROBE_TIMEOUT_MS,
@@ -30860,6 +30943,7 @@ function createObservationFailedMarker(params) {
30860
30943
  tokensAttempted: params.tokensAttempted,
30861
30944
  error: formatOmError(params.error),
30862
30945
  ...getOmFailureMetadata(params.error, params.failurePolicy ?? "abort"),
30946
+ ...params.retrying ? { retrying: true } : {},
30863
30947
  recordId: params.recordId,
30864
30948
  threadId: params.threadId
30865
30949
  }
@@ -33132,7 +33216,7 @@ function getStringExtractedValue(values, slug) {
33132
33216
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
33133
33217
  }
33134
33218
  function parseReflectorOutput(output, sourceObservations, extractors = []) {
33135
- if (detectDegenerateRepetition(output)) return {
33219
+ if (detectDegenerateRepetition(sanitizeObservationLines(output))) return {
33136
33220
  observations: "",
33137
33221
  degenerate: true
33138
33222
  };
@@ -33323,6 +33407,7 @@ var ReflectorRunner = class {
33323
33407
  instructions: buildReflectorSystemPrompt(this.reflectionConfig.instruction, extractors),
33324
33408
  model: agentModel,
33325
33409
  maxRetries: 0,
33410
+ errorProcessorDefaults: false,
33326
33411
  ...memory ? { memory } : {},
33327
33412
  ...this.mastra ? { mastra: this.mastra } : {}
33328
33413
  });
@@ -33363,6 +33448,7 @@ var ReflectorRunner = class {
33363
33448
  const temporaryMemory = activeExtractors.filter((extractor) => extractor.mode === "structured").length > 0 ? await createTemporaryOmMemoryContext("structured-reflector") : void 0;
33364
33449
  const agent = temporaryMemory ? this.createAgent(resolvedModel.model, temporaryMemory.memory, activeExtractors) : this.createAgent(resolvedModel.model, void 0, activeExtractors);
33365
33450
  const internalRequestContext = withOmInternalThreadId(requestContext, agent.id);
33451
+ let attemptMemory;
33366
33452
  const targetThreshold = observationTokensThreshold ?? getMaxThreshold(this.reflectionConfig.observationTokens);
33367
33453
  let totalUsage = {
33368
33454
  inputTokens: 0,
@@ -33405,10 +33491,12 @@ var ReflectorRunner = class {
33405
33491
  callback: (childObservabilityContext) => withAbortCheck(async () => {
33406
33492
  chunkCount = 0;
33407
33493
  try {
33408
- return await (await agent.stream(prompt, {
33494
+ attemptMemory = temporaryMemory?.newThread();
33495
+ return assertCompleteModelResponse(await (await agent.stream(prompt, {
33496
+ maxSteps: 1,
33409
33497
  modelSettings: { ...this.reflectionConfig.modelSettings },
33410
33498
  providerOptions: this.reflectionConfig.providerOptions,
33411
- ...temporaryMemory ? { memory: temporaryMemory.options } : {},
33499
+ ...attemptMemory ? { memory: attemptMemory } : {},
33412
33500
  ...abortSignal ? { abortSignal } : {},
33413
33501
  ...internalRequestContext ? { requestContext: internalRequestContext } : {},
33414
33502
  ...childObservabilityContext,
@@ -33430,7 +33518,7 @@ var ReflectorRunner = class {
33430
33518
  omError(`[OM:callReflector] onError after ${chunkCount} chunks`, error);
33431
33519
  }
33432
33520
  } : {}
33433
- })).getFullOutput();
33521
+ })).getFullOutput(), "OM reflector");
33434
33522
  } catch (error) {
33435
33523
  if (abortSignal?.aborted || !isOmModelExecutionFailure(error)) throw error;
33436
33524
  throw new OmModelExecutionError("reflector-model", error);
@@ -33471,6 +33559,7 @@ var ReflectorRunner = class {
33471
33559
  startedAt: streamContext.startedAt,
33472
33560
  tokensAttempted: originalTokens,
33473
33561
  error: `Did not compress below threshold (${originalTokens} → ${reflectedTokens}, target: ${targetThreshold}), retrying at level ${currentLevel + 1}`,
33562
+ retrying: true,
33474
33563
  recordId: streamContext.recordId,
33475
33564
  threadId: streamContext.threadId
33476
33565
  });
@@ -33504,7 +33593,7 @@ var ReflectorRunner = class {
33504
33593
  agent,
33505
33594
  source: "reflector",
33506
33595
  extractors: activeExtractors,
33507
- memory: temporaryMemory?.options,
33596
+ memory: attemptMemory,
33508
33597
  priorExtractedValues,
33509
33598
  requestContext: internalRequestContext,
33510
33599
  observabilityContext,
@@ -50484,4 +50573,4 @@ const agentBuilderWorkflows = {
50484
50573
  //#endregion
50485
50574
  export { agentBuilderWorkflows };
50486
50575
 
50487
- //# sourceMappingURL=dist-DWXEVDmb.js.map
50576
+ //# sourceMappingURL=dist-DMtuYRLk.js.map