@mastra/server 1.67.0-alpha.4 → 1.67.0-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 (208) hide show
  1. package/dist/a2a-DQ8GeDz4.cjs.map +1 -1
  2. package/dist/a2a-DUBjstWk.js.map +1 -1
  3. package/dist/{agent-builder-DUM8fGTt.js → agent-builder-k5ALpndR.js} +2 -2
  4. package/dist/{agent-builder-DUM8fGTt.js.map → agent-builder-k5ALpndR.js.map} +1 -1
  5. package/dist/{agent-builder-B2GCn_tS.cjs → agent-builder-k72O4OB9.cjs} +2 -2
  6. package/dist/{agent-builder-B2GCn_tS.cjs.map → agent-builder-k72O4OB9.cjs.map} +1 -1
  7. package/dist/{agent-versions-MYjO6Wl1.cjs → agent-versions-D99q4Gos.cjs} +3 -3
  8. package/dist/{agent-versions-MYjO6Wl1.cjs.map → agent-versions-D99q4Gos.cjs.map} +1 -1
  9. package/dist/{agent-versions-mFXaw5ma.js → agent-versions-NGajm4l5.js} +3 -3
  10. package/dist/{agent-versions-mFXaw5ma.js.map → agent-versions-NGajm4l5.js.map} +1 -1
  11. package/dist/{agents-C3k-sZBO.cjs → agents-CZE_MSQE.cjs} +2 -2
  12. package/dist/{agents-C3k-sZBO.cjs.map → agents-CZE_MSQE.cjs.map} +1 -1
  13. package/dist/{agents-AMeMJBI1.js → agents-ssoMemNs.js} +2 -2
  14. package/dist/{agents-AMeMJBI1.js.map → agents-ssoMemNs.js.map} +1 -1
  15. package/dist/{api-schema-manifest-B8uyCfJp.js → api-schema-manifest-CeREx1dB.js} +2 -2
  16. package/dist/{api-schema-manifest-B8uyCfJp.js.map → api-schema-manifest-CeREx1dB.js.map} +1 -1
  17. package/dist/{api-schema-manifest-nIt4xi1r.cjs → api-schema-manifest-DzWP4nLu.cjs} +2 -2
  18. package/dist/{api-schema-manifest-nIt4xi1r.cjs.map → api-schema-manifest-DzWP4nLu.cjs.map} +1 -1
  19. package/dist/{background-tasks-BarPeyNJ.cjs → background-tasks-CFJ0vNgp.cjs} +4 -3
  20. package/dist/background-tasks-CFJ0vNgp.cjs.map +1 -0
  21. package/dist/{background-tasks-B4yoNDY_.js → background-tasks-kXPoCvgG.js} +4 -3
  22. package/dist/background-tasks-kXPoCvgG.js.map +1 -0
  23. package/dist/{common-DQn8jX5T.cjs → common-BPjna_b6.cjs} +7 -1
  24. package/dist/common-BPjna_b6.cjs.map +1 -0
  25. package/dist/{common-5ZZuR6wj.js → common-C7NBaaQu.js} +2 -2
  26. package/dist/common-C7NBaaQu.js.map +1 -0
  27. package/dist/{conversations-o3AEJjRo.cjs → conversations-DstENx2x.cjs} +2 -2
  28. package/dist/{conversations-o3AEJjRo.cjs.map → conversations-DstENx2x.cjs.map} +1 -1
  29. package/dist/{conversations-Bs-k9f9N.js → conversations-b3vJRHF3.js} +2 -2
  30. package/dist/{conversations-Bs-k9f9N.js.map → conversations-b3vJRHF3.js.map} +1 -1
  31. package/dist/{datasets-Dhk4CUat.js → datasets-CCC2huR0.js} +4 -9
  32. package/dist/datasets-CCC2huR0.js.map +1 -0
  33. package/dist/{datasets-BqCRJLYH.cjs → datasets-zlaJQ9D0.cjs} +4 -9
  34. package/dist/datasets-zlaJQ9D0.cjs.map +1 -0
  35. package/dist/{dist-CBDJtAr5.cjs → dist-BKxbtiJd.cjs} +100 -34
  36. package/dist/{dist-CBDJtAr5.cjs.map → dist-BKxbtiJd.cjs.map} +1 -1
  37. package/dist/{dist-8iDh9UbP.js → dist-DOpm-tIl.js} +100 -34
  38. package/dist/{dist-8iDh9UbP.js.map → dist-DOpm-tIl.js.map} +1 -1
  39. package/dist/docs/SKILL.md +1 -1
  40. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  41. package/dist/{editor-builder-WLxTW05v.cjs → editor-builder-BHf-g7q9.cjs} +2 -2
  42. package/dist/{editor-builder-WLxTW05v.cjs.map → editor-builder-BHf-g7q9.cjs.map} +1 -1
  43. package/dist/{editor-builder-QRcP8-SQ.js → editor-builder-BI5yHrbT.js} +2 -2
  44. package/dist/{editor-builder-QRcP8-SQ.js.map → editor-builder-BI5yHrbT.js.map} +1 -1
  45. package/dist/{editor-builder-DFh_-7Id.cjs → editor-builder-CKAeON9r.cjs} +2 -2
  46. package/dist/{editor-builder-DFh_-7Id.cjs.map → editor-builder-CKAeON9r.cjs.map} +1 -1
  47. package/dist/{editor-builder-BmEpZsqX.js → editor-builder-D6P_hq7c.js} +2 -2
  48. package/dist/{editor-builder-BmEpZsqX.js.map → editor-builder-D6P_hq7c.js.map} +1 -1
  49. package/dist/{logs-Cz5NiwGP.js → logs-Cbz2Nxm2.js} +2 -2
  50. package/dist/{logs-Cz5NiwGP.js.map → logs-Cbz2Nxm2.js.map} +1 -1
  51. package/dist/{logs-BDuGFqxu.cjs → logs-LBot9fsG.cjs} +2 -2
  52. package/dist/{logs-BDuGFqxu.cjs.map → logs-LBot9fsG.cjs.map} +1 -1
  53. package/dist/{mcp-Buvksst5.cjs → mcp-BPmrXX9r.cjs} +2 -2
  54. package/dist/{mcp-Buvksst5.cjs.map → mcp-BPmrXX9r.cjs.map} +1 -1
  55. package/dist/{mcp-oOFVSK8L.js → mcp-B_OMG3Ol.js} +2 -2
  56. package/dist/{mcp-oOFVSK8L.js.map → mcp-B_OMG3Ol.js.map} +1 -1
  57. package/dist/{mcp-client-versions-CG7po4hq.cjs → mcp-client-versions-DoGlpOEW.cjs} +2 -2
  58. package/dist/{mcp-client-versions-CG7po4hq.cjs.map → mcp-client-versions-DoGlpOEW.cjs.map} +1 -1
  59. package/dist/{mcp-client-versions-Co8d39A6.js → mcp-client-versions-Dpk4z-zx.js} +2 -2
  60. package/dist/{mcp-client-versions-Co8d39A6.js.map → mcp-client-versions-Dpk4z-zx.js.map} +1 -1
  61. package/dist/{memory-Cp3Yo-OX.js → memory-BvKPIpyH.js} +2 -2
  62. package/dist/{memory-Cp3Yo-OX.js.map → memory-BvKPIpyH.js.map} +1 -1
  63. package/dist/{memory-CE6rUGmo.cjs → memory-CDYtqQnE.cjs} +2 -2
  64. package/dist/{memory-CE6rUGmo.cjs.map → memory-CDYtqQnE.cjs.map} +1 -1
  65. package/dist/{prompt-block-versions-Cgt_Grk2.cjs → prompt-block-versions-ChvK-DMW.cjs} +2 -2
  66. package/dist/{prompt-block-versions-Cgt_Grk2.cjs.map → prompt-block-versions-ChvK-DMW.cjs.map} +1 -1
  67. package/dist/{prompt-block-versions-CBjHhMVK.js → prompt-block-versions-DU0xf_a5.js} +2 -2
  68. package/dist/{prompt-block-versions-CBjHhMVK.js.map → prompt-block-versions-DU0xf_a5.js.map} +1 -1
  69. package/dist/{routes-BSAA4PVg.js → routes-BJZtqLVx.js} +4 -4
  70. package/dist/{routes-BSAA4PVg.js.map → routes-BJZtqLVx.js.map} +1 -1
  71. package/dist/{routes-D5r7qWgZ.cjs → routes-PJ3eKHbs.cjs} +4 -4
  72. package/dist/{routes-D5r7qWgZ.cjs.map → routes-PJ3eKHbs.cjs.map} +1 -1
  73. package/dist/{scorer-versions-mL--H4LL.cjs → scorer-versions-B6U7batJ.cjs} +3 -3
  74. package/dist/{scorer-versions-mL--H4LL.cjs.map → scorer-versions-B6U7batJ.cjs.map} +1 -1
  75. package/dist/{scorer-versions-D0_KP67E.js → scorer-versions-Dh2iaz4Y.js} +3 -3
  76. package/dist/{scorer-versions-D0_KP67E.js.map → scorer-versions-Dh2iaz4Y.js.map} +1 -1
  77. package/dist/{scores-C_Au9jSw.cjs → scores-5aHyxHos.cjs} +5 -13
  78. package/dist/scores-5aHyxHos.cjs.map +1 -0
  79. package/dist/{scores-B1IdMcDj.js → scores-BjcbsulG.js} +5 -13
  80. package/dist/scores-BjcbsulG.js.map +1 -0
  81. package/dist/server/handlers/agent-builder.cjs +5 -5
  82. package/dist/server/handlers/agent-builder.js +5 -5
  83. package/dist/server/handlers/agent-controller.cjs +1 -1
  84. package/dist/server/handlers/agent-controller.js +1 -1
  85. package/dist/server/handlers/agent-versions.cjs +2 -2
  86. package/dist/server/handlers/agent-versions.js +2 -2
  87. package/dist/server/handlers/agents.cjs +2 -2
  88. package/dist/server/handlers/agents.js +2 -2
  89. package/dist/server/handlers/background-tasks.cjs +1 -1
  90. package/dist/server/handlers/background-tasks.js +1 -1
  91. package/dist/server/handlers/conversations.cjs +1 -1
  92. package/dist/server/handlers/conversations.js +1 -1
  93. package/dist/server/handlers/datasets.cjs +2 -2
  94. package/dist/server/handlers/datasets.d.ts +165 -50
  95. package/dist/server/handlers/datasets.d.ts.map +1 -1
  96. package/dist/server/handlers/datasets.js +2 -2
  97. package/dist/server/handlers/editor-builder.cjs +1 -1
  98. package/dist/server/handlers/editor-builder.js +1 -1
  99. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  100. package/dist/server/handlers/favorites-enrichment.js +1 -1
  101. package/dist/server/handlers/logs.cjs +2 -2
  102. package/dist/server/handlers/logs.js +2 -2
  103. package/dist/server/handlers/mcp-client-versions.cjs +1 -1
  104. package/dist/server/handlers/mcp-client-versions.js +1 -1
  105. package/dist/server/handlers/mcp.cjs +1 -1
  106. package/dist/server/handlers/mcp.js +1 -1
  107. package/dist/server/handlers/memory.cjs +1 -1
  108. package/dist/server/handlers/memory.js +1 -1
  109. package/dist/server/handlers/plans.cjs +1 -1
  110. package/dist/server/handlers/plans.js +1 -1
  111. package/dist/server/handlers/prompt-block-versions.cjs +1 -1
  112. package/dist/server/handlers/prompt-block-versions.js +1 -1
  113. package/dist/server/handlers/scorer-versions.cjs +1 -1
  114. package/dist/server/handlers/scorer-versions.js +1 -1
  115. package/dist/server/handlers/scores.cjs +2 -2
  116. package/dist/server/handlers/scores.d.ts +43 -21
  117. package/dist/server/handlers/scores.d.ts.map +1 -1
  118. package/dist/server/handlers/scores.js +2 -2
  119. package/dist/server/handlers/stored-agent-favorites.cjs +2 -2
  120. package/dist/server/handlers/stored-agent-favorites.js +2 -2
  121. package/dist/server/handlers/stored-agents.cjs +3 -3
  122. package/dist/server/handlers/stored-agents.js +3 -3
  123. package/dist/server/handlers/stored-mcp-clients.cjs +2 -2
  124. package/dist/server/handlers/stored-mcp-clients.js +2 -2
  125. package/dist/server/handlers/stored-prompt-blocks.cjs +2 -2
  126. package/dist/server/handlers/stored-prompt-blocks.js +2 -2
  127. package/dist/server/handlers/stored-scorers.cjs +2 -2
  128. package/dist/server/handlers/stored-scorers.js +2 -2
  129. package/dist/server/handlers/stored-skill-favorites.cjs +2 -2
  130. package/dist/server/handlers/stored-skill-favorites.js +2 -2
  131. package/dist/server/handlers/stored-skills.cjs +2 -2
  132. package/dist/server/handlers/stored-skills.js +2 -2
  133. package/dist/server/handlers/stored-workspaces.cjs +1 -1
  134. package/dist/server/handlers/stored-workspaces.js +1 -1
  135. package/dist/server/handlers/system.cjs +1 -1
  136. package/dist/server/handlers/system.js +1 -1
  137. package/dist/server/handlers/tools.cjs +2 -2
  138. package/dist/server/handlers/tools.js +2 -2
  139. package/dist/server/handlers/vector.cjs +1 -1
  140. package/dist/server/handlers/vector.js +1 -1
  141. package/dist/server/handlers/workflow-builder.cjs +1 -1
  142. package/dist/server/handlers/workflow-builder.js +1 -1
  143. package/dist/server/handlers/workflows.cjs +3 -3
  144. package/dist/server/handlers/workflows.js +3 -3
  145. package/dist/server/schemas/background-tasks.d.ts.map +1 -1
  146. package/dist/server/schemas/common.d.ts +11 -0
  147. package/dist/server/schemas/common.d.ts.map +1 -1
  148. package/dist/server/schemas/datasets.d.ts +36 -0
  149. package/dist/server/schemas/datasets.d.ts.map +1 -1
  150. package/dist/server/schemas/index.cjs +24 -23
  151. package/dist/server/schemas/index.js +24 -24
  152. package/dist/server/schemas/scores.d.ts +11 -0
  153. package/dist/server/schemas/scores.d.ts.map +1 -1
  154. package/dist/server/server-adapter/index.cjs +1 -1
  155. package/dist/server/server-adapter/index.js +1 -1
  156. package/dist/server/server-adapter/routes/datasets.d.ts +165 -50
  157. package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
  158. package/dist/server/server-adapter/routes/scorers.d.ts +43 -21
  159. package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -1
  160. package/dist/{stored-agents-DMW5wrF7.js → stored-agents-AC0najKd.js} +3 -3
  161. package/dist/{stored-agents-DMW5wrF7.js.map → stored-agents-AC0najKd.js.map} +1 -1
  162. package/dist/{stored-agents-D6JEb3zN.cjs → stored-agents-BJMM5f9A.cjs} +3 -3
  163. package/dist/{stored-agents-D6JEb3zN.cjs.map → stored-agents-BJMM5f9A.cjs.map} +1 -1
  164. package/dist/{stored-mcp-clients-CoCfZRhw.js → stored-mcp-clients-BEcB720j.js} +2 -2
  165. package/dist/{stored-mcp-clients-CoCfZRhw.js.map → stored-mcp-clients-BEcB720j.js.map} +1 -1
  166. package/dist/{stored-mcp-clients-CJJPe_09.cjs → stored-mcp-clients-Bh7nQkqD.cjs} +2 -2
  167. package/dist/{stored-mcp-clients-CJJPe_09.cjs.map → stored-mcp-clients-Bh7nQkqD.cjs.map} +1 -1
  168. package/dist/{stored-prompt-blocks-DcmkZaCm.js → stored-prompt-blocks-CRGk4tz5.js} +2 -2
  169. package/dist/{stored-prompt-blocks-DcmkZaCm.js.map → stored-prompt-blocks-CRGk4tz5.js.map} +1 -1
  170. package/dist/{stored-prompt-blocks-XI4frgZv.cjs → stored-prompt-blocks-CyL4SKVR.cjs} +2 -2
  171. package/dist/{stored-prompt-blocks-XI4frgZv.cjs.map → stored-prompt-blocks-CyL4SKVR.cjs.map} +1 -1
  172. package/dist/{stored-scorers-BA4suzgn.js → stored-scorers-B8QVQCCs.js} +3 -3
  173. package/dist/{stored-scorers-BA4suzgn.js.map → stored-scorers-B8QVQCCs.js.map} +1 -1
  174. package/dist/{stored-scorers-D8IwVM0S.cjs → stored-scorers-CWxW1_mY.cjs} +3 -3
  175. package/dist/{stored-scorers-D8IwVM0S.cjs.map → stored-scorers-CWxW1_mY.cjs.map} +1 -1
  176. package/dist/{stored-skills-BqNK0ssS.cjs → stored-skills-CkA2oWJJ.cjs} +2 -2
  177. package/dist/{stored-skills-BqNK0ssS.cjs.map → stored-skills-CkA2oWJJ.cjs.map} +1 -1
  178. package/dist/{stored-skills-JTWbMybs.js → stored-skills-DlNmwsTl.js} +2 -2
  179. package/dist/{stored-skills-JTWbMybs.js.map → stored-skills-DlNmwsTl.js.map} +1 -1
  180. package/dist/{stored-workspaces-6PYE4Y3m.js → stored-workspaces-B0p0wPGV.js} +2 -2
  181. package/dist/{stored-workspaces-6PYE4Y3m.js.map → stored-workspaces-B0p0wPGV.js.map} +1 -1
  182. package/dist/{stored-workspaces-Dl8B20LD.cjs → stored-workspaces-epewrppK.cjs} +2 -2
  183. package/dist/{stored-workspaces-Dl8B20LD.cjs.map → stored-workspaces-epewrppK.cjs.map} +1 -1
  184. package/dist/{vectors-D6uZn2f1.cjs → vectors-DlW_SU5m.cjs} +2 -2
  185. package/dist/{vectors-D6uZn2f1.cjs.map → vectors-DlW_SU5m.cjs.map} +1 -1
  186. package/dist/{vectors-Ck7Qu6yz.js → vectors-DqRRlfF0.js} +2 -2
  187. package/dist/{vectors-Ck7Qu6yz.js.map → vectors-DqRRlfF0.js.map} +1 -1
  188. package/dist/{version-common-AtNRQ5xH.cjs → version-common-CxQdBbPm.cjs} +2 -2
  189. package/dist/{version-common-AtNRQ5xH.cjs.map → version-common-CxQdBbPm.cjs.map} +1 -1
  190. package/dist/{version-common-CudZ_WuW.js → version-common-cEBltPQN.js} +2 -2
  191. package/dist/{version-common-CudZ_WuW.js.map → version-common-cEBltPQN.js.map} +1 -1
  192. package/dist/{workflow-builder-_rQWs1B6.cjs → workflow-builder-D5dPsrog.cjs} +3 -3
  193. package/dist/{workflow-builder-_rQWs1B6.cjs.map → workflow-builder-D5dPsrog.cjs.map} +1 -1
  194. package/dist/{workflow-builder-C9DVk9Tw.js → workflow-builder-Eape8SyU.js} +3 -3
  195. package/dist/{workflow-builder-C9DVk9Tw.js.map → workflow-builder-Eape8SyU.js.map} +1 -1
  196. package/dist/{workflows-BNnfyZhn.cjs → workflows-CvYeyvIc.cjs} +2 -2
  197. package/dist/{workflows-BNnfyZhn.cjs.map → workflows-CvYeyvIc.cjs.map} +1 -1
  198. package/dist/{workflows-CUgR3bTL.js → workflows-Z8FHqT4y.js} +2 -2
  199. package/dist/{workflows-CUgR3bTL.js.map → workflows-Z8FHqT4y.js.map} +1 -1
  200. package/package.json +6 -6
  201. package/dist/background-tasks-B4yoNDY_.js.map +0 -1
  202. package/dist/background-tasks-BarPeyNJ.cjs.map +0 -1
  203. package/dist/common-5ZZuR6wj.js.map +0 -1
  204. package/dist/common-DQn8jX5T.cjs.map +0 -1
  205. package/dist/datasets-BqCRJLYH.cjs.map +0 -1
  206. package/dist/datasets-Dhk4CUat.js.map +0 -1
  207. package/dist/scores-B1IdMcDj.js.map +0 -1
  208. package/dist/scores-C_Au9jSw.cjs.map +0 -1
@@ -4693,7 +4693,7 @@ function splitLines(text) {
4693
4693
  return result;
4694
4694
  }
4695
4695
  //#endregion
4696
- //#region ../memory/dist/src-t3Mhge0m.js
4696
+ //#region ../memory/dist/src-Dt8oPiQN.js
4697
4697
  var __defProp$3 = Object.defineProperty;
4698
4698
  var __exportAll = (all, no_symbols) => {
4699
4699
  let target = {};
@@ -29781,9 +29781,58 @@ async function loadMemoryContextMessages({ memory, messageList, threadId, resour
29781
29781
  resourceId,
29782
29782
  runState
29783
29783
  });
29784
- for (const msg of ctx.messages) if (msg.role !== "system") messageList.add(msg, "memory");
29784
+ const existingIds = new Set(messageList.get.all.db().map((message) => message.id));
29785
+ for (const msg of ctx.messages) if (msg.role !== "system" && !existingIds.has(msg.id)) messageList.add(msg, "memory");
29785
29786
  return ctx;
29786
29787
  }
29788
+ function hasPendingToolCall(message) {
29789
+ return message.content.parts?.some((part) => part.type === "tool-invocation" && part.toolInvocation.state === "call") ?? false;
29790
+ }
29791
+ /**
29792
+ * Selects the unobserved messages that are safe to buffer while a tool call
29793
+ * may still be in flight.
29794
+ *
29795
+ * Only the chronologically last candidate can hold a live pending call: a
29796
+ * `tool-invocation` still in state `call` (client- or provider-executed) on the
29797
+ * newest message means the request ended waiting for its result. Any earlier
29798
+ * `call` is an orphan — the conversation already continued past it, and core's
29799
+ * output converter drops or placeholder-pairs it before the prompt reaches a
29800
+ * provider — so it is buffered like any other message.
29801
+ *
29802
+ * When the last candidate is pending, the prefix before it is buffered, but only
29803
+ * when the cut is clean. The cut is unsafe — and the whole attempt is deferred —
29804
+ * when:
29805
+ *
29806
+ * - Cursor collision: buffering advances the persisted cursor to
29807
+ * `max(buffered.createdAt) + 1ms`, and later candidate selection requires
29808
+ * `createdAt > cursor`. If the retained message sits at the same or +1ms
29809
+ * timestamp, the cursor would permanently hide it even after its result
29810
+ * arrives.
29811
+ * - Split tool exchange: a `toolCallId` appears on both sides of the cut, so
29812
+ * the observer would see half of a tool exchange.
29813
+ * - Ambiguous tail: several candidates share the newest timestamp and one of
29814
+ * them holds a pending call. `createdAt` alone cannot say which is really
29815
+ * last, so the pending call is treated as the tail and the attempt deferred.
29816
+ *
29817
+ * The result is always in chronological order. When the tail has no pending
29818
+ * call, every message is returned. An empty result means "defer this buffering
29819
+ * attempt" — callers must skip buffering entirely. Raw message persistence is
29820
+ * unaffected and happens elsewhere; the retained message becomes eligible again
29821
+ * once its tool call completes.
29822
+ */
29823
+ function selectSafeBufferPrefix(messages) {
29824
+ const chronological = [...messages].sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
29825
+ const last = chronological[chronological.length - 1];
29826
+ if (!last) return chronological;
29827
+ const newestTime = new Date(last.createdAt).getTime();
29828
+ const newestGroup = chronological.filter((message) => new Date(message.createdAt).getTime() === newestTime);
29829
+ if (!newestGroup.some(hasPendingToolCall)) return chronological;
29830
+ if (newestGroup.length > 1) return [];
29831
+ const prefix = chronological.slice(0, -1);
29832
+ const retainedTime = new Date(last.createdAt).getTime();
29833
+ const retainedToolIds = new Set((last.content.parts ?? []).flatMap((part) => part.type === "tool-invocation" ? [part.toolInvocation.toolCallId] : []));
29834
+ return prefix.some((message) => new Date(message.createdAt).getTime() + 1 >= retainedTime || message.content.parts?.some((part) => part.type === "tool-invocation" && retainedToolIds.has(part.toolInvocation.toolCallId))) ? [] : prefix;
29835
+ }
29787
29836
  /**
29788
29837
  * Represents a single step in the agentic loop within an observation turn.
29789
29838
  *
@@ -29905,37 +29954,41 @@ var ObservationStep = class {
29905
29954
  record: this.turn.record,
29906
29955
  messages: getObservableMessages(messageList)
29907
29956
  });
29908
- if (statusSnapshot.shouldBuffer && !hasIncompleteToolCalls) {
29957
+ if (statusSnapshot.shouldBuffer) {
29909
29958
  const allMessages = getObservableMessages(messageList);
29910
29959
  const unobservedMessages = om.getUnobservedMessages(allMessages, statusSnapshot.record);
29911
29960
  const candidates = om.getUnobservedMessages(unobservedMessages, statusSnapshot.record, { excludeBuffered: true });
29912
- if (candidates.length > 0) {
29913
- om.sealMessagesForBuffering(candidates);
29961
+ const safeCandidates = selectSafeBufferPrefix(candidates);
29962
+ const deferred = candidates.length > 0 && safeCandidates.length === 0;
29963
+ if (safeCandidates.length > 0) {
29964
+ om.sealMessagesForBuffering(safeCandidates);
29914
29965
  try {
29915
29966
  await this.turn.hooks?.onBufferChunkSealed?.();
29916
29967
  } catch (error) {
29917
29968
  omDebug(`[OM:buffer] onBufferChunkSealed hook failed: ${error instanceof Error ? error.message : String(error)}`);
29918
29969
  }
29919
- if (this.turn.memory) await this.turn.memory.persistMessages(candidates);
29920
- messageList.removeByIds(candidates.map((msg) => msg.id));
29921
- for (const msg of candidates) messageList.add(msg, "memory");
29970
+ if (this.turn.memory) await this.turn.memory.persistMessages(safeCandidates);
29971
+ messageList.removeByIds(safeCandidates.map((msg) => msg.id));
29972
+ for (const msg of safeCandidates) messageList.add(msg, "memory");
29973
+ }
29974
+ if (!deferred) {
29975
+ om.trackBackgroundWork(om.buffer({
29976
+ threadId,
29977
+ resourceId,
29978
+ messages: safeCandidates,
29979
+ pendingTokens: statusSnapshot.pendingTokens,
29980
+ record: statusSnapshot.record,
29981
+ writer: this.turn.writer,
29982
+ agent: this.turn.agent,
29983
+ sendSignal: this.turn.sendSignal,
29984
+ sendStateSignal: this.turn.sendStateSignal,
29985
+ requestContext: this.turn.requestContext,
29986
+ observabilityContext: this.turn.observabilityContext
29987
+ }).catch((err) => {
29988
+ omDebug(`[OM:buffer] fire-and-forget buffer failed: ${err?.message}`);
29989
+ }));
29990
+ buffered = true;
29922
29991
  }
29923
- om.trackBackgroundWork(om.buffer({
29924
- threadId,
29925
- resourceId,
29926
- messages: unobservedMessages,
29927
- pendingTokens: statusSnapshot.pendingTokens,
29928
- record: statusSnapshot.record,
29929
- writer: this.turn.writer,
29930
- agent: this.turn.agent,
29931
- sendSignal: this.turn.sendSignal,
29932
- sendStateSignal: this.turn.sendStateSignal,
29933
- requestContext: this.turn.requestContext,
29934
- observabilityContext: this.turn.observabilityContext
29935
- }).catch((err) => {
29936
- omDebug(`[OM:buffer] fire-and-forget buffer failed: ${err?.message}`);
29937
- }));
29938
- buffered = true;
29939
29992
  }
29940
29993
  const willObserveNow = statusSnapshot.shouldObserve && !hasIncompleteToolCalls;
29941
29994
  /** In-flight message ids the step-0 cleanup must never remove from live context. */
@@ -30308,11 +30361,11 @@ var ObservationTurn = class {
30308
30361
  if (asyncObservationEnabled && bufferOnIdle) {
30309
30362
  const allMessages = getObservableMessages(this.messageList);
30310
30363
  const record = this._record;
30311
- const unobservedMessages = this.om.getUnobservedMessages(allMessages, record);
30312
- if (unobservedMessages.length > 0) this.om.trackBackgroundWork(this.om.buffer({
30364
+ const idleMessages = selectSafeBufferPrefix(this.om.getUnobservedMessages(allMessages, record));
30365
+ if (idleMessages.length > 0) this.om.trackBackgroundWork(this.om.buffer({
30313
30366
  threadId: this.threadId,
30314
30367
  resourceId: this.resourceId,
30315
- messages: unobservedMessages,
30368
+ messages: idleMessages,
30316
30369
  record,
30317
30370
  writer: this.writer,
30318
30371
  agent: this.agent,
@@ -32032,15 +32085,18 @@ var ObservationalMemory = class ObservationalMemory {
32032
32085
  this.hookExecution = config.hookExecution ?? "non-blocking";
32033
32086
  this.mastra = config.mastra;
32034
32087
  this.memory = config.memory;
32088
+ const topLevelModel = config.model;
32089
+ const observationConfigModel = config.observation?.model;
32090
+ const reflectionConfigModel = config.reflection?.model;
32035
32091
  const resolveModel = (model, defaultModel) => model === "default" ? defaultModel : model;
32036
- const observationModel = resolveModel(config.model, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? resolveModel(config.observation?.model, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? resolveModel(config.reflection?.model, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.model;
32037
- const reflectionModel = resolveModel(config.model, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? resolveModel(config.reflection?.model, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? resolveModel(config.observation?.model, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model;
32092
+ const observationModel = resolveModel(topLevelModel, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? resolveModel(observationConfigModel, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? resolveModel(reflectionConfigModel, OBSERVATIONAL_MEMORY_DEFAULTS.observation.model) ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.model;
32093
+ const reflectionModel = resolveModel(topLevelModel, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? resolveModel(reflectionConfigModel, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? resolveModel(observationConfigModel, OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model) ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.model;
32038
32094
  const messageTokens = config.observation?.messageTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.messageTokens;
32039
32095
  const observationTokens = config.reflection?.observationTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.observationTokens;
32040
32096
  const isSharedBudget = config.shareTokenBudget ?? false;
32041
32097
  const isDefaultModelSelection = (model) => model === void 0 || model === "default" || model instanceof ModelByInputTokens;
32042
- const observationSelectedModel = config.model ?? config.observation?.model ?? config.reflection?.model;
32043
- const reflectionSelectedModel = config.model ?? config.reflection?.model ?? config.observation?.model;
32098
+ const observationSelectedModel = topLevelModel ?? observationConfigModel ?? reflectionConfigModel;
32099
+ const reflectionSelectedModel = topLevelModel ?? reflectionConfigModel ?? observationConfigModel;
32044
32100
  const observationDefaultMaxOutputTokens = config.observation?.modelSettings?.maxOutputTokens ?? (isDefaultModelSelection(observationSelectedModel) ? OBSERVATIONAL_MEMORY_DEFAULTS.observation.modelSettings.maxOutputTokens : void 0);
32045
32101
  const reflectionDefaultMaxOutputTokens = config.reflection?.modelSettings?.maxOutputTokens ?? (isDefaultModelSelection(reflectionSelectedModel) ? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.modelSettings.maxOutputTokens : void 0);
32046
32102
  const totalBudget = messageTokens + observationTokens;
@@ -34735,6 +34791,16 @@ function normalizeObservationalMemoryConfig(config) {
34735
34791
  if (typeof config === "object" && config.enabled === false) return void 0;
34736
34792
  return config;
34737
34793
  }
34794
+ /**
34795
+ * Observer model selection (`observation.model`, else top-level `model`), read into the widened
34796
+ * model type first: combining values of the public type makes TS subtype-reduce the model-id
34797
+ * literal union, which fails with TS2590 once the provider registry is large enough.
34798
+ */
34799
+ function selectObserverModel(omConfig) {
34800
+ const observationModel = omConfig.observation?.model;
34801
+ const topLevelModel = omConfig.model;
34802
+ return observationModel ?? topLevelModel;
34803
+ }
34738
34804
  function hasWorkingMemoryExtractor(extractors) {
34739
34805
  return !!extractors?.some((extractor) => extractor.slug === "working-memory");
34740
34806
  }
@@ -34852,7 +34918,7 @@ var Memory = class Memory extends MastraMemory {
34852
34918
  const extract = observation.extract ?? [];
34853
34919
  const existingSlugs = new Set(extract.map((extractor) => extractor.slug));
34854
34920
  let curatorMemory;
34855
- const subconsciousExtractors = omConfig.experimental_subconscious.createObservationExtractors(observation.model ?? omConfig.model, () => curatorMemory ??= new Memory({
34921
+ const subconsciousExtractors = omConfig.experimental_subconscious.createObservationExtractors(selectObserverModel(omConfig), () => curatorMemory ??= new Memory({
34856
34922
  storage: this.storage,
34857
34923
  options: { observationalMemory: false }
34858
34924
  })).filter((extractor) => !existingSlugs.has(extractor.slug));
@@ -36158,7 +36224,7 @@ Notes:
36158
36224
  if (remind && "builtIn" in remind) tools.ask_memory = createAskMemoryTool({
36159
36225
  memory: this,
36160
36226
  config: remind,
36161
- omModel: omConfig.observation?.model ?? omConfig.model,
36227
+ omModel: selectObserverModel(omConfig),
36162
36228
  getParentAgent: (agentId) => this._mastraInstance?.getAgentById(agentId)
36163
36229
  });
36164
36230
  }
@@ -47217,4 +47283,4 @@ const agentBuilderWorkflows = {
47217
47283
  //#endregion
47218
47284
  export { agentBuilderWorkflows };
47219
47285
 
47220
- //# sourceMappingURL=dist-8iDh9UbP.js.map
47286
+ //# sourceMappingURL=dist-DOpm-tIl.js.map