@mastra/server 1.82.0 → 1.83.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.
Files changed (347) hide show
  1. package/dist/_types/@internal_core@0.1.4/dist/storage/index.d.ts +24 -2
  2. package/dist/_types/@mastra_schema-compat@1.3.17/dist/_types/@internal_ai-v6@0.0.95/dist/index.d.ts +96 -15
  3. package/dist/{a2a-CoiG3TAj.js → a2a-CQlJ-SZr.js} +4 -4
  4. package/dist/{a2a-CoiG3TAj.js.map → a2a-CQlJ-SZr.js.map} +1 -1
  5. package/dist/{a2a-DvqRdny6.cjs → a2a-mDspNbWX.cjs} +4 -4
  6. package/dist/{a2a-DvqRdny6.cjs.map → a2a-mDspNbWX.cjs.map} +1 -1
  7. package/dist/{agent-builder-D0Up9Fw1.cjs → agent-builder-B9gEkbch.cjs} +8 -8
  8. package/dist/{agent-builder-D0Up9Fw1.cjs.map → agent-builder-B9gEkbch.cjs.map} +1 -1
  9. package/dist/{agent-builder-C_L1i2eE.js → agent-builder-BF7OAl_R.js} +8 -8
  10. package/dist/{agent-builder-C_L1i2eE.js.map → agent-builder-BF7OAl_R.js.map} +1 -1
  11. package/dist/{agent-versions-BccL4mEW.cjs → agent-versions-CwWhEoU5.cjs} +2 -2
  12. package/dist/{agent-versions-BccL4mEW.cjs.map → agent-versions-CwWhEoU5.cjs.map} +1 -1
  13. package/dist/{agent-versions-DFJyxWY1.js → agent-versions-DfcKpYNW.js} +2 -2
  14. package/dist/{agent-versions-DFJyxWY1.js.map → agent-versions-DfcKpYNW.js.map} +1 -1
  15. package/dist/{agents-BXqMKoOz.js → agents-BCgiMlDq.js} +2 -2
  16. package/dist/{agents-BXqMKoOz.js.map → agents-BCgiMlDq.js.map} +1 -1
  17. package/dist/{agents-DOHGWXDa.cjs → agents-CMEeZr5y.cjs} +223 -63
  18. package/dist/agents-CMEeZr5y.cjs.map +1 -0
  19. package/dist/{agents-DbnPZXIN.cjs → agents-CjcvdF2e.cjs} +2 -2
  20. package/dist/{agents-DbnPZXIN.cjs.map → agents-CjcvdF2e.cjs.map} +1 -1
  21. package/dist/{agents-CgcW6lHt.js → agents-DXlVewzD.js} +223 -63
  22. package/dist/agents-DXlVewzD.js.map +1 -0
  23. package/dist/{api-schema-manifest-DCHOlOuJ.cjs → api-schema-manifest-BKnghL_k.cjs} +3 -3
  24. package/dist/{api-schema-manifest-DCHOlOuJ.cjs.map → api-schema-manifest-BKnghL_k.cjs.map} +1 -1
  25. package/dist/{api-schema-manifest-Ci2qUYHc.js → api-schema-manifest-DOuSq4rG.js} +3 -3
  26. package/dist/{api-schema-manifest-Ci2qUYHc.js.map → api-schema-manifest-DOuSq4rG.js.map} +1 -1
  27. package/dist/{background-tasks-BHhn4YZA.js → background-tasks-BIuEr2of.js} +3 -3
  28. package/dist/{background-tasks-BHhn4YZA.js.map → background-tasks-BIuEr2of.js.map} +1 -1
  29. package/dist/{background-tasks-Ci2tlxJC.cjs → background-tasks-BXTIp0QV.cjs} +3 -3
  30. package/dist/{background-tasks-Ci2tlxJC.cjs.map → background-tasks-BXTIp0QV.cjs.map} +1 -1
  31. package/dist/{builder-registry-m_gHCe12.js → builder-registry-Dd7pbJ5A.js} +4 -4
  32. package/dist/{builder-registry-m_gHCe12.js.map → builder-registry-Dd7pbJ5A.js.map} +1 -1
  33. package/dist/{builder-registry-D1_hGKCJ.cjs → builder-registry-DrBUA6EZ.cjs} +4 -4
  34. package/dist/{builder-registry-D1_hGKCJ.cjs.map → builder-registry-DrBUA6EZ.cjs.map} +1 -1
  35. package/dist/{channels-hhQ3vD30.js → channels-B6hwVMbV.js} +4 -4
  36. package/dist/{channels-hhQ3vD30.js.map → channels-B6hwVMbV.js.map} +1 -1
  37. package/dist/{channels-Bfkp5vYI.cjs → channels-DbfSH5O2.cjs} +4 -4
  38. package/dist/{channels-Bfkp5vYI.cjs.map → channels-DbfSH5O2.cjs.map} +1 -1
  39. package/dist/{conversations-Ch_VuVwY.cjs → conversations-CFj4BnNb.cjs} +5 -5
  40. package/dist/{conversations-Ch_VuVwY.cjs.map → conversations-CFj4BnNb.cjs.map} +1 -1
  41. package/dist/{conversations-xS7yHuG1.js → conversations-DjTKtaUi.js} +5 -5
  42. package/dist/{conversations-xS7yHuG1.js.map → conversations-DjTKtaUi.js.map} +1 -1
  43. package/dist/{dist-BKNKucT9.cjs → dist-Ctfk9X6u.cjs} +208 -247
  44. package/dist/dist-Ctfk9X6u.cjs.map +1 -0
  45. package/dist/dist-DJjVMQiv.js +1 -0
  46. package/dist/{dist-CIYZuix4.js → dist-OKFDPspq.js} +208 -247
  47. package/dist/dist-OKFDPspq.js.map +1 -0
  48. package/dist/{dist-DgKeISkr.cjs → dist-ZYvqJK9p.cjs} +1 -1
  49. package/dist/docs/SKILL.md +5 -1
  50. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  51. package/dist/docs/references/docs-agents-resumable-streams.md +140 -0
  52. package/dist/docs/references/docs-knowledge-overview.md +106 -0
  53. package/dist/docs/references/docs-server-custom-adapters.md +4 -0
  54. package/dist/docs/references/docs-server-server-adapters.md +679 -0
  55. package/dist/docs/references/docs-studio-knowledge.md +45 -24
  56. package/dist/docs/references/reference-observability-tracing-advanced-queries.md +47 -58
  57. package/dist/docs/references/reference-server-invoke-route.md +86 -0
  58. package/dist/docs/references/reference-server-routes.md +63 -0
  59. package/dist/{dynamic-workflows-DDauBnDt.js → dynamic-workflows-CyaZLmHX.js} +2 -2
  60. package/dist/{dynamic-workflows-DDauBnDt.js.map → dynamic-workflows-CyaZLmHX.js.map} +1 -1
  61. package/dist/{dynamic-workflows-CpCkqM1g.cjs → dynamic-workflows-ZmzWJXxG.cjs} +2 -2
  62. package/dist/{dynamic-workflows-CpCkqM1g.cjs.map → dynamic-workflows-ZmzWJXxG.cjs.map} +1 -1
  63. package/dist/{editor-builder-CKfy5eZY.cjs → editor-builder-CBBZxQhO.cjs} +4 -4
  64. package/dist/{editor-builder-CKfy5eZY.cjs.map → editor-builder-CBBZxQhO.cjs.map} +1 -1
  65. package/dist/{editor-builder-Bln4Pg1U.js → editor-builder-fe70YP8g.js} +2 -2
  66. package/dist/{editor-builder-Bln4Pg1U.js.map → editor-builder-fe70YP8g.js.map} +1 -1
  67. package/dist/{editor-builder-Ceen28s8.js → editor-builder-o9xJHa96.js} +4 -4
  68. package/dist/{editor-builder-Ceen28s8.js.map → editor-builder-o9xJHa96.js.map} +1 -1
  69. package/dist/{editor-builder-BaI8pttR.cjs → editor-builder-xQmDgVgJ.cjs} +2 -2
  70. package/dist/{editor-builder-BaI8pttR.cjs.map → editor-builder-xQmDgVgJ.cjs.map} +1 -1
  71. package/dist/{helpers-DNq3LtLq.js → helpers-B29a1nM3.js} +51 -48
  72. package/dist/helpers-B29a1nM3.js.map +1 -0
  73. package/dist/{helpers-BKtUXhz2.cjs → helpers-CylvUIZm.cjs} +56 -47
  74. package/dist/helpers-CylvUIZm.cjs.map +1 -0
  75. package/dist/{knowledge-Ba74qr0v.js → knowledge-Cd2cCq-Y.js} +4 -4
  76. package/dist/{knowledge-Ba74qr0v.js.map → knowledge-Cd2cCq-Y.js.map} +1 -1
  77. package/dist/{knowledge-urR7FFG8.cjs → knowledge-Q_SCnD9m.cjs} +4 -4
  78. package/dist/{knowledge-urR7FFG8.cjs.map → knowledge-Q_SCnD9m.cjs.map} +1 -1
  79. package/dist/{logs-B57_NKDn.js → logs-C5L6gRGr.js} +4 -4
  80. package/dist/{logs-B57_NKDn.js.map → logs-C5L6gRGr.js.map} +1 -1
  81. package/dist/{logs-BJN3M88A.cjs → logs-DWIbFIw6.cjs} +4 -4
  82. package/dist/{logs-BJN3M88A.cjs.map → logs-DWIbFIw6.cjs.map} +1 -1
  83. package/dist/{mcp-B9BILfJP.cjs → mcp-CKvOVfHn.cjs} +3 -3
  84. package/dist/{mcp-B9BILfJP.cjs.map → mcp-CKvOVfHn.cjs.map} +1 -1
  85. package/dist/{mcp-BkmWZD6M.js → mcp-CntC59iU.js} +3 -3
  86. package/dist/{mcp-BkmWZD6M.js.map → mcp-CntC59iU.js.map} +1 -1
  87. package/dist/{memory-Dqod_AK9.cjs → memory-DIos0BE-.cjs} +57 -15
  88. package/dist/{memory-Dqod_AK9.cjs.map → memory-DIos0BE-.cjs.map} +1 -1
  89. package/dist/{memory-ipOCmg0C.js → memory-JzgWJevA.js} +57 -15
  90. package/dist/{memory-ipOCmg0C.js.map → memory-JzgWJevA.js.map} +1 -1
  91. package/dist/{observability-BtdW6mjq.cjs → observability-BB0DeGo4.cjs} +4 -3
  92. package/dist/{observability-BtdW6mjq.cjs.map → observability-BB0DeGo4.cjs.map} +1 -1
  93. package/dist/{observability-DBtyAJnb.js → observability-Cl3qZKTD.js} +4 -3
  94. package/dist/{observability-DBtyAJnb.js.map → observability-Cl3qZKTD.js.map} +1 -1
  95. package/dist/{observability-new-endpoints-jjCgXuTF.cjs → observability-new-endpoints-DugFsWBU.cjs} +154 -956
  96. package/dist/observability-new-endpoints-DugFsWBU.cjs.map +1 -0
  97. package/dist/{observability-new-endpoints-Di7m_-xc.js → observability-new-endpoints-qE2NutZ1.js} +72 -880
  98. package/dist/observability-new-endpoints-qE2NutZ1.js.map +1 -0
  99. package/dist/observability-signal-context-BYOFtbM_.cjs +1317 -0
  100. package/dist/observability-signal-context-BYOFtbM_.cjs.map +1 -0
  101. package/dist/observability-signal-context-CL5-rCWM.js +952 -0
  102. package/dist/observability-signal-context-CL5-rCWM.js.map +1 -0
  103. package/dist/{plans-Djcp3C0d.cjs → plans-CQijj_Am.cjs} +5 -5
  104. package/dist/{plans-Djcp3C0d.cjs.map → plans-CQijj_Am.cjs.map} +1 -1
  105. package/dist/{plans-nHOnlGzr.js → plans-DVx9N2re.js} +5 -5
  106. package/dist/{plans-nHOnlGzr.js.map → plans-DVx9N2re.js.map} +1 -1
  107. package/dist/{probe-image-size-DGTRKrgq.js → probe-image-size-Cxm5QtwO.js} +2 -2
  108. package/dist/{probe-image-size-DGTRKrgq.js.map → probe-image-size-Cxm5QtwO.js.map} +1 -1
  109. package/dist/{probe-image-size-BAwk1h6w.cjs → probe-image-size-bDuzMW0E.cjs} +2 -2
  110. package/dist/{probe-image-size-BAwk1h6w.cjs.map → probe-image-size-bDuzMW0E.cjs.map} +1 -1
  111. package/dist/{responses-BdOStKtX.cjs → responses-DYGS0aiI.cjs} +5 -5
  112. package/dist/{responses-BdOStKtX.cjs.map → responses-DYGS0aiI.cjs.map} +1 -1
  113. package/dist/{responses-CEet9y8G.js → responses-NM-kLq8b.js} +5 -5
  114. package/dist/{responses-CEet9y8G.js.map → responses-NM-kLq8b.js.map} +1 -1
  115. package/dist/{route-builder-BxPrwNog.js → route-builder-BKEzjw_M.js} +2 -2
  116. package/dist/{route-builder-BxPrwNog.js.map → route-builder-BKEzjw_M.js.map} +1 -1
  117. package/dist/{route-builder-CvARmqnA.cjs → route-builder-DHqDrSSy.cjs} +2 -2
  118. package/dist/{route-builder-CvARmqnA.cjs.map → route-builder-DHqDrSSy.cjs.map} +1 -1
  119. package/dist/{routes-5FpkkzND.js → routes-B2XGdvlv.js} +33 -32
  120. package/dist/routes-B2XGdvlv.js.map +1 -0
  121. package/dist/{routes-DU_FlwJP.cjs → routes-CWrdLnBc.cjs} +33 -32
  122. package/dist/routes-CWrdLnBc.cjs.map +1 -0
  123. package/dist/{schedules-D8ShgpY3.cjs → schedules-CvWX2yKR.cjs} +3 -3
  124. package/dist/{schedules-D8ShgpY3.cjs.map → schedules-CvWX2yKR.cjs.map} +1 -1
  125. package/dist/{schedules-CGViSLZC.js → schedules-D9CKB18-.js} +3 -3
  126. package/dist/{schedules-CGViSLZC.js.map → schedules-D9CKB18-.js.map} +1 -1
  127. package/dist/{schema-Bf12g7KC-DBc4NSds.js → schema-Bf12g7KC-5EUrrnSf.js} +96 -96
  128. package/dist/{schema-Bf12g7KC-DBc4NSds.js.map → schema-Bf12g7KC-5EUrrnSf.js.map} +1 -1
  129. package/dist/{schema-Bf12g7KC-plP4Ir6h.cjs → schema-Bf12g7KC-C5XzpQxe.cjs} +96 -96
  130. package/dist/{schema-Bf12g7KC-plP4Ir6h.cjs.map → schema-Bf12g7KC-C5XzpQxe.cjs.map} +1 -1
  131. package/dist/{scorer-versions-vQVWyYWA.cjs → scorer-versions-Bhdvt-cX.cjs} +2 -2
  132. package/dist/{scorer-versions-vQVWyYWA.cjs.map → scorer-versions-Bhdvt-cX.cjs.map} +1 -1
  133. package/dist/{scorer-versions-BZ58s09W.js → scorer-versions-DhT7Lj33.js} +2 -2
  134. package/dist/{scorer-versions-BZ58s09W.js.map → scorer-versions-DhT7Lj33.js.map} +1 -1
  135. package/dist/{scores-Bw6Tuga5.cjs → scores-CWx6H3Z8.cjs} +4 -4
  136. package/dist/{scores-Bw6Tuga5.cjs.map → scores-CWx6H3Z8.cjs.map} +1 -1
  137. package/dist/{scores-BaDFGpmr.js → scores-DTVV_OaX.js} +4 -4
  138. package/dist/{scores-BaDFGpmr.js.map → scores-DTVV_OaX.js.map} +1 -1
  139. package/dist/server/auth/helpers.d.ts +20 -0
  140. package/dist/server/auth/helpers.d.ts.map +1 -1
  141. package/dist/server/auth/index.cjs +2 -1
  142. package/dist/server/auth/index.js +2 -2
  143. package/dist/server/handlers/a2a.cjs +1 -1
  144. package/dist/server/handlers/a2a.js +1 -1
  145. package/dist/server/handlers/agent-builder.cjs +1 -1
  146. package/dist/server/handlers/agent-builder.js +1 -1
  147. package/dist/server/handlers/agent-controller.cjs +17 -6
  148. package/dist/server/handlers/agent-controller.cjs.map +1 -1
  149. package/dist/server/handlers/agent-controller.d.ts.map +1 -1
  150. package/dist/server/handlers/agent-controller.js +17 -6
  151. package/dist/server/handlers/agent-controller.js.map +1 -1
  152. package/dist/server/handlers/agent-versions.cjs +4 -4
  153. package/dist/server/handlers/agent-versions.js +4 -4
  154. package/dist/server/handlers/agents.cjs +1 -1
  155. package/dist/server/handlers/agents.d.ts.map +1 -1
  156. package/dist/server/handlers/agents.js +1 -1
  157. package/dist/server/handlers/auth.cjs +4 -4
  158. package/dist/server/handlers/auth.js +4 -4
  159. package/dist/server/handlers/authorship.cjs +1 -1
  160. package/dist/server/handlers/authorship.js +1 -1
  161. package/dist/server/handlers/background-tasks.cjs +1 -1
  162. package/dist/server/handlers/background-tasks.js +1 -1
  163. package/dist/server/handlers/builder-registry.cjs +1 -1
  164. package/dist/server/handlers/builder-registry.js +1 -1
  165. package/dist/server/handlers/channels.cjs +1 -1
  166. package/dist/server/handlers/channels.js +1 -1
  167. package/dist/server/handlers/conversations.cjs +1 -1
  168. package/dist/server/handlers/conversations.js +1 -1
  169. package/dist/server/handlers/datasets.cjs +7 -5
  170. package/dist/server/handlers/datasets.cjs.map +1 -1
  171. package/dist/server/handlers/datasets.d.ts.map +1 -1
  172. package/dist/server/handlers/datasets.js +7 -5
  173. package/dist/server/handlers/datasets.js.map +1 -1
  174. package/dist/server/handlers/dynamic-workflows.cjs +1 -1
  175. package/dist/server/handlers/dynamic-workflows.js +1 -1
  176. package/dist/server/handlers/editor-builder.cjs +1 -1
  177. package/dist/server/handlers/editor-builder.js +1 -1
  178. package/dist/server/handlers/error.cjs +1 -0
  179. package/dist/server/handlers/error.cjs.map +1 -1
  180. package/dist/server/handlers/error.d.ts.map +1 -1
  181. package/dist/server/handlers/error.js +1 -0
  182. package/dist/server/handlers/error.js.map +1 -1
  183. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  184. package/dist/server/handlers/favorites-enrichment.js +1 -1
  185. package/dist/server/handlers/gateway-memory-client.cjs +4 -1
  186. package/dist/server/handlers/gateway-memory-client.cjs.map +1 -1
  187. package/dist/server/handlers/gateway-memory-client.d.ts.map +1 -1
  188. package/dist/server/handlers/gateway-memory-client.js +4 -1
  189. package/dist/server/handlers/gateway-memory-client.js.map +1 -1
  190. package/dist/server/handlers/knowledge.cjs +1 -1
  191. package/dist/server/handlers/knowledge.js +1 -1
  192. package/dist/server/handlers/logs.cjs +1 -1
  193. package/dist/server/handlers/logs.js +1 -1
  194. package/dist/server/handlers/mcp-client-versions.cjs +3 -3
  195. package/dist/server/handlers/mcp-client-versions.js +3 -3
  196. package/dist/server/handlers/mcp.cjs +1 -1
  197. package/dist/server/handlers/mcp.js +1 -1
  198. package/dist/server/handlers/memory.cjs +1 -1
  199. package/dist/server/handlers/memory.d.ts.map +1 -1
  200. package/dist/server/handlers/memory.js +1 -1
  201. package/dist/server/handlers/observability-new-endpoints.cjs +2 -1
  202. package/dist/server/handlers/observability-new-endpoints.d.ts +328 -8
  203. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  204. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  205. package/dist/server/handlers/observability-shared.cjs +7 -1
  206. package/dist/server/handlers/observability-shared.cjs.map +1 -1
  207. package/dist/server/handlers/observability-shared.d.ts +6 -0
  208. package/dist/server/handlers/observability-shared.d.ts.map +1 -1
  209. package/dist/server/handlers/observability-shared.js +7 -1
  210. package/dist/server/handlers/observability-shared.js.map +1 -1
  211. package/dist/server/handlers/observability-signal-context.cjs +4 -0
  212. package/dist/server/handlers/observability-signal-context.d.ts +42 -0
  213. package/dist/server/handlers/observability-signal-context.d.ts.map +1 -0
  214. package/dist/server/handlers/observability-signal-context.js +1 -0
  215. package/dist/server/handlers/observability.cjs +3 -2
  216. package/dist/server/handlers/observability.js +3 -3
  217. package/dist/server/handlers/plans.cjs +1 -1
  218. package/dist/server/handlers/plans.js +1 -1
  219. package/dist/server/handlers/processor-providers.cjs +2 -2
  220. package/dist/server/handlers/processor-providers.js +2 -2
  221. package/dist/server/handlers/processors.cjs +2 -2
  222. package/dist/server/handlers/processors.js +2 -2
  223. package/dist/server/handlers/prompt-block-versions.cjs +3 -3
  224. package/dist/server/handlers/prompt-block-versions.js +3 -3
  225. package/dist/server/handlers/responses.cjs +1 -1
  226. package/dist/server/handlers/responses.js +1 -1
  227. package/dist/server/handlers/responses.storage.cjs +1 -1
  228. package/dist/server/handlers/responses.storage.js +1 -1
  229. package/dist/server/handlers/schedules.cjs +1 -1
  230. package/dist/server/handlers/schedules.js +1 -1
  231. package/dist/server/handlers/scorer-versions.cjs +3 -3
  232. package/dist/server/handlers/scorer-versions.js +3 -3
  233. package/dist/server/handlers/scores.cjs +1 -1
  234. package/dist/server/handlers/scores.js +1 -1
  235. package/dist/server/handlers/stored-agent-favorites.cjs +6 -6
  236. package/dist/server/handlers/stored-agent-favorites.js +6 -6
  237. package/dist/server/handlers/stored-agents.cjs +10 -9
  238. package/dist/server/handlers/stored-agents.cjs.map +1 -1
  239. package/dist/server/handlers/stored-agents.d.ts +2 -6
  240. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  241. package/dist/server/handlers/stored-agents.js +10 -9
  242. package/dist/server/handlers/stored-agents.js.map +1 -1
  243. package/dist/server/handlers/stored-mcp-clients.cjs +3 -3
  244. package/dist/server/handlers/stored-mcp-clients.js +3 -3
  245. package/dist/server/handlers/stored-prompt-blocks.cjs +3 -3
  246. package/dist/server/handlers/stored-prompt-blocks.js +3 -3
  247. package/dist/server/handlers/stored-scorers.cjs +3 -3
  248. package/dist/server/handlers/stored-scorers.js +3 -3
  249. package/dist/server/handlers/stored-skill-favorites.cjs +5 -5
  250. package/dist/server/handlers/stored-skill-favorites.js +5 -5
  251. package/dist/server/handlers/stored-skills.cjs +5 -5
  252. package/dist/server/handlers/stored-skills.js +5 -5
  253. package/dist/server/handlers/stored-workspaces.cjs +3 -3
  254. package/dist/server/handlers/stored-workspaces.js +3 -3
  255. package/dist/server/handlers/system.cjs +3 -3
  256. package/dist/server/handlers/system.js +3 -3
  257. package/dist/server/handlers/tool-providers.cjs +3 -3
  258. package/dist/server/handlers/tool-providers.js +3 -3
  259. package/dist/server/handlers/tools.cjs +1 -1
  260. package/dist/server/handlers/tools.js +1 -1
  261. package/dist/server/handlers/utils.cjs +1 -1
  262. package/dist/server/handlers/utils.js +1 -1
  263. package/dist/server/handlers/validate-agent-instructions.cjs +1 -1
  264. package/dist/server/handlers/validate-agent-instructions.js +1 -1
  265. package/dist/server/handlers/vector.cjs +1 -1
  266. package/dist/server/handlers/vector.js +1 -1
  267. package/dist/server/handlers/workflow-builder.cjs +1 -1
  268. package/dist/server/handlers/workflow-builder.js +1 -1
  269. package/dist/server/handlers/workflows.cjs +1 -1
  270. package/dist/server/handlers/workflows.d.ts.map +1 -1
  271. package/dist/server/handlers/workflows.js +1 -1
  272. package/dist/server/handlers/workspace.cjs +1 -1
  273. package/dist/server/handlers/workspace.d.ts +23 -23
  274. package/dist/server/handlers/workspace.js +1 -1
  275. package/dist/server/handlers.cjs +16 -16
  276. package/dist/server/handlers.js +16 -16
  277. package/dist/server/schemas/agents.d.ts.map +1 -1
  278. package/dist/server/schemas/feedback.d.ts +49 -0
  279. package/dist/server/schemas/feedback.d.ts.map +1 -1
  280. package/dist/server/schemas/index.cjs +23 -23
  281. package/dist/server/schemas/index.js +23 -23
  282. package/dist/server/schemas/stored-agents.d.ts +5 -10
  283. package/dist/server/schemas/stored-agents.d.ts.map +1 -1
  284. package/dist/server/server-adapter/index.cjs +231 -61
  285. package/dist/server/server-adapter/index.cjs.map +1 -1
  286. package/dist/server/server-adapter/index.d.ts +67 -1
  287. package/dist/server/server-adapter/index.d.ts.map +1 -1
  288. package/dist/server/server-adapter/index.js +226 -63
  289. package/dist/server/server-adapter/index.js.map +1 -1
  290. package/dist/server/server-adapter/mcp-auth.d.ts +16 -1
  291. package/dist/server/server-adapter/mcp-auth.d.ts.map +1 -1
  292. package/dist/server/server-adapter/routes/observability.d.ts +162 -3
  293. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  294. package/dist/server/utils/agent-stream-events.d.ts +2 -0
  295. package/dist/server/utils/agent-stream-events.d.ts.map +1 -1
  296. package/dist/{stored-agents-DA8Zx6o9.js → stored-agents-DmN_pIIl.js} +10 -10
  297. package/dist/stored-agents-DmN_pIIl.js.map +1 -0
  298. package/dist/{stored-agents-TQ2lIFbx.cjs → stored-agents-m0Knvv29.cjs} +10 -10
  299. package/dist/stored-agents-m0Knvv29.cjs.map +1 -0
  300. package/dist/{stored-scorers-DhOq8ZQC.js → stored-scorers-2F2k6XSx.js} +2 -2
  301. package/dist/{stored-scorers-DhOq8ZQC.js.map → stored-scorers-2F2k6XSx.js.map} +1 -1
  302. package/dist/{stored-scorers-FJOs5774.cjs → stored-scorers-iM2Qq9Nh.cjs} +2 -2
  303. package/dist/{stored-scorers-FJOs5774.cjs.map → stored-scorers-iM2Qq9Nh.cjs.map} +1 -1
  304. package/dist/{tools-CI5oeJWT.cjs → tools-7O8cd_4u.cjs} +7 -7
  305. package/dist/{tools-CI5oeJWT.cjs.map → tools-7O8cd_4u.cjs.map} +1 -1
  306. package/dist/{tools-BAmCNGM5.js → tools-Bf3vq-HD.js} +7 -7
  307. package/dist/{tools-BAmCNGM5.js.map → tools-Bf3vq-HD.js.map} +1 -1
  308. package/dist/{utils-9PRHHTGC.cjs → utils-BXEJ6FZC.cjs} +2 -2
  309. package/dist/{utils-9PRHHTGC.cjs.map → utils-BXEJ6FZC.cjs.map} +1 -1
  310. package/dist/{utils-BhBJHsqX.cjs → utils-CL-m2SWZ.cjs} +3 -3
  311. package/dist/{utils-BhBJHsqX.cjs.map → utils-CL-m2SWZ.cjs.map} +1 -1
  312. package/dist/{utils-B15w-1hm.js → utils-CTYtskHa.js} +2 -2
  313. package/dist/{utils-B15w-1hm.js.map → utils-CTYtskHa.js.map} +1 -1
  314. package/dist/{utils-Dy_dQTlK.js → utils-y-cW3mQU.js} +3 -3
  315. package/dist/{utils-Dy_dQTlK.js.map → utils-y-cW3mQU.js.map} +1 -1
  316. package/dist/{vector-BZ1bKtwM.cjs → vector-6k7Ft7EX.cjs} +3 -3
  317. package/dist/{vector-BZ1bKtwM.cjs.map → vector-6k7Ft7EX.cjs.map} +1 -1
  318. package/dist/{vector-BAs5o6mH.js → vector-BWFSDXvg.js} +3 -3
  319. package/dist/{vector-BAs5o6mH.js.map → vector-BWFSDXvg.js.map} +1 -1
  320. package/dist/{workflow-builder-CaSfD6oL.js → workflow-builder-BUQfzD4L.js} +5 -5
  321. package/dist/{workflow-builder-CaSfD6oL.js.map → workflow-builder-BUQfzD4L.js.map} +1 -1
  322. package/dist/{workflow-builder-tr_D_ZDN.cjs → workflow-builder-C6J_1s56.cjs} +5 -5
  323. package/dist/{workflow-builder-tr_D_ZDN.cjs.map → workflow-builder-C6J_1s56.cjs.map} +1 -1
  324. package/dist/{workflows-BxXS5AfE.js → workflows-BkTNzH-i.js} +24 -13
  325. package/dist/workflows-BkTNzH-i.js.map +1 -0
  326. package/dist/{workflows-Cdi6w8JW.cjs → workflows-CHUG5jh4.cjs} +76 -65
  327. package/dist/workflows-CHUG5jh4.cjs.map +1 -0
  328. package/dist/{workspace-BU6sQpbV.cjs → workspace-C7PytFzz.cjs} +3 -3
  329. package/dist/{workspace-BU6sQpbV.cjs.map → workspace-C7PytFzz.cjs.map} +1 -1
  330. package/dist/{workspace-CS-GYTve.js → workspace-CYwDvH0G.js} +3 -3
  331. package/dist/{workspace-CS-GYTve.js.map → workspace-CYwDvH0G.js.map} +1 -1
  332. package/package.json +4 -4
  333. package/dist/agents-CgcW6lHt.js.map +0 -1
  334. package/dist/agents-DOHGWXDa.cjs.map +0 -1
  335. package/dist/dist-BKNKucT9.cjs.map +0 -1
  336. package/dist/dist-CIYZuix4.js.map +0 -1
  337. package/dist/dist-mNQb9_wX.js +0 -1
  338. package/dist/helpers-BKtUXhz2.cjs.map +0 -1
  339. package/dist/helpers-DNq3LtLq.js.map +0 -1
  340. package/dist/observability-new-endpoints-Di7m_-xc.js.map +0 -1
  341. package/dist/observability-new-endpoints-jjCgXuTF.cjs.map +0 -1
  342. package/dist/routes-5FpkkzND.js.map +0 -1
  343. package/dist/routes-DU_FlwJP.cjs.map +0 -1
  344. package/dist/stored-agents-DA8Zx6o9.js.map +0 -1
  345. package/dist/stored-agents-TQ2lIFbx.cjs.map +0 -1
  346. package/dist/workflows-BxXS5AfE.js.map +0 -1
  347. package/dist/workflows-Cdi6w8JW.cjs.map +0 -1
@@ -1,15 +1,15 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-10nMEhjP.cjs");
2
- const require_http_exception = require("./http-exception-Co3MbFUf.cjs");
3
- const require_agents = require("./agents-DbnPZXIN.cjs");
4
- const require_schema_Bf12g7KC = require("./schema-Bf12g7KC-plP4Ir6h.cjs");
5
- const require_route_builder = require("./route-builder-CvARmqnA.cjs");
6
- const require_utils = require("./utils-BhBJHsqX.cjs");
2
+ const require_utils = require("./utils-CL-m2SWZ.cjs");
7
3
  const require_constants = require("./constants-DMg8hUOR.cjs");
8
- const require_server_handlers_error = require("./server/handlers/error.cjs");
9
- const require_utils$1 = require("./utils-9PRHHTGC.cjs");
10
- const require_stored_agents = require("./stored-agents-TQ2lIFbx.cjs");
4
+ const require_schema_Bf12g7KC = require("./schema-Bf12g7KC-C5XzpQxe.cjs");
5
+ const require_utils$1 = require("./utils-BXEJ6FZC.cjs");
6
+ const require_http_exception = require("./http-exception-Co3MbFUf.cjs");
7
+ const require_agents = require("./agents-CjcvdF2e.cjs");
8
+ const require_stored_agents = require("./stored-agents-m0Knvv29.cjs");
11
9
  const require_workspace = require("./workspace-C5BBUatQ.cjs");
10
+ const require_route_builder = require("./route-builder-DHqDrSSy.cjs");
12
11
  const require_server_handlers_authorship = require("./server/handlers/authorship.cjs");
12
+ const require_server_handlers_error = require("./server/handlers/error.cjs");
13
13
  const require_server_handlers_tool_schema_overrides = require("./server/handlers/tool-schema-overrides.cjs");
14
14
  let zod_v4 = require("zod/v4");
15
15
  let _mastra_core_utils_zod_to_json = require("@mastra/core/utils/zod-to-json");
@@ -23,6 +23,7 @@ let _mastra_core_llm = require("@mastra/core/llm");
23
23
  // src/server/utils/agent-stream-events.ts
24
24
  function toAgentStreamChunks(event) {
25
25
  const { runId } = event;
26
+ const logIndex = typeof event.index === "number" ? { index: event.index } : void 0;
26
27
  const abort = {
27
28
  type: "abort",
28
29
  runId,
@@ -30,10 +31,21 @@ function toAgentStreamChunks(event) {
30
31
  payload: {}
31
32
  };
32
33
  switch (event.type) {
33
- case "chunk": return [event.data];
34
+ case "chunk": {
35
+ const { index: _nestedIndex, ...data } = event.data;
36
+ return [{
37
+ ...data,
38
+ ...logIndex
39
+ }];
40
+ }
34
41
  case "step-start": {
35
42
  const chunk = event.data;
36
- return chunk && "type" in chunk ? [chunk] : [];
43
+ if (!chunk || !("type" in chunk)) return [];
44
+ const { index: _nestedIndex, ...data } = chunk;
45
+ return [{
46
+ ...data,
47
+ ...logIndex
48
+ }];
37
49
  }
38
50
  case "finish": {
39
51
  const data = event.data;
@@ -49,6 +61,7 @@ function toAgentStreamChunks(event) {
49
61
  type: "finish",
50
62
  runId,
51
63
  from: _mastra_core_stream.ChunkFrom.AGENT,
64
+ ...logIndex,
52
65
  payload: {
53
66
  output: raw === void 0 ? data.output : {
54
67
  ...data.output,
@@ -69,6 +82,7 @@ function toAgentStreamChunks(event) {
69
82
  type: "finish",
70
83
  runId,
71
84
  from: _mastra_core_stream.ChunkFrom.AGENT,
85
+ ...logIndex,
72
86
  payload: {
73
87
  output: {
74
88
  text: data.text,
@@ -87,10 +101,14 @@ function toAgentStreamChunks(event) {
87
101
  }
88
102
  }];
89
103
  }
90
- case "error": return [{
91
- type: "error",
92
- payload: { error: { ...event.data.error } }
93
- }];
104
+ case "error": {
105
+ const data = event.data;
106
+ return [{
107
+ type: "error",
108
+ ...logIndex,
109
+ payload: { error: { ...data.error } }
110
+ }];
111
+ }
94
112
  default: return [];
95
113
  }
96
114
  }
@@ -247,6 +265,12 @@ function hasSuspendedToolCall(snapshot, toolCallId) {
247
265
  };
248
266
  return visit(snapshot.context);
249
267
  }
268
+ /** A run-log entry that ends the run. An error *chunk* can precede the finish, so it does not count. */
269
+ const isRunTerminalEvent = (event) => {
270
+ if (event?.type === "error") return true;
271
+ const type = event?.type === "chunk" ? event.data?.type : event?.type;
272
+ return type === "finish" || type === "abort";
273
+ };
250
274
  const DURABLE_SNAPSHOT_WAIT_TIMEOUT_MS = 1e4;
251
275
  const DURABLE_SNAPSHOT_WAIT_INTERVAL_MS = 25;
252
276
  function getDurableLoopWorkflowName(agent) {
@@ -299,6 +323,50 @@ async function validateDurableToolCallAccess({ mastra, agent, runId, toolCallId,
299
323
  */
300
324
  const ALIASED_API_KEY_ENV_VAR_PROVIDERS = /* @__PURE__ */ new Set(["google"]);
301
325
  /**
326
+ * The shared ownership record of a plain agent run, readable from any server
327
+ * sharing the agent's record cache. Undefined when the run is unknown or
328
+ * expired. Falls back to the owner of a run executing in this process on a
329
+ * core without shared records. A record cache that cannot be read is a 503:
330
+ * the caller is refused, never let through.
331
+ */
332
+ async function getPlainRunRecord(agent, runId) {
333
+ const resumable = agent;
334
+ if (typeof resumable.__getRunRecord === "function") try {
335
+ return await resumable.__getRunRecord.call(agent, runId);
336
+ } catch {
337
+ throw new require_http_exception.HTTPException(503, { message: "Run ownership is temporarily unavailable" });
338
+ }
339
+ const owner = resumable.__getPublishedRunOwner?.call(agent, runId);
340
+ return owner ? {
341
+ ...owner,
342
+ status: "running"
343
+ } : void 0;
344
+ }
345
+ /** The caller must own the run and have `permission` on its thread. */
346
+ async function authorizeRunOwner({ mastra, agent, owner, requestContext, permission }) {
347
+ await require_utils$1.validateRunOwnership(owner, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
348
+ if (!owner.threadId) return;
349
+ const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId: owner.threadId });
350
+ await require_utils$1.enforceThreadAccess({
351
+ mastra,
352
+ requestContext,
353
+ threadId: owner.threadId,
354
+ thread,
355
+ effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
356
+ permission
357
+ });
358
+ }
359
+ /** Whether the agent publishes its runs, so a closed HTTP reader can detach instead of aborting. */
360
+ function hasResumableStreams(agent) {
361
+ if ((0, _mastra_core_agent.isDurableAgentLike)(agent)) return true;
362
+ const resumable = agent;
363
+ return typeof resumable.hasResumableStreams === "function" && resumable.hasResumableStreams();
364
+ }
365
+ /** The bus a plain Agent with resumable streams publishes its runs on. */
366
+ function getAgentStreamPubSub(agent) {
367
+ return agent.__getStreamBus?.()?.pubsub;
368
+ }
369
+ /**
302
370
  * Checks if a provider has its required API key environment variable(s) configured.
303
371
  * Handles provider IDs with suffixes (e.g., "openai.chat" -> "openai").
304
372
  * Also handles custom gateway providers that are stored with gateway prefix (e.g., "acme/acme-openai").
@@ -1432,8 +1500,8 @@ const STREAM_GENERATE_ROUTE = require_route_builder.createRoute({
1432
1500
  ...restOptions,
1433
1501
  requestContext: serverRequestContext,
1434
1502
  memory: authorizedMemoryOption,
1435
- abortSignal: (0, _mastra_core_agent.isDurableAgentLike)(agent) ? void 0 : abortSignal,
1436
- _detachObserverOnCancel: (0, _mastra_core_agent.isDurableAgentLike)(agent)
1503
+ abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
1504
+ _detachObserverOnCancel: hasResumableStreams(agent)
1437
1505
  };
1438
1506
  if (untilIdle) options.untilIdle = untilIdle;
1439
1507
  return (structuredOutput ? await agent.stream(messages, {
@@ -1690,6 +1758,91 @@ const QUEUE_AGENT_SIGNAL_ROUTE = require_route_builder.createRoute({
1690
1758
  }
1691
1759
  }
1692
1760
  });
1761
+ /**
1762
+ * Authorizes a request against a durable run through its workflow rows: the
1763
+ * caller must own the run, the run must belong to `agent`, and the caller must
1764
+ * have `permission` on its thread. Throws 403 when access is denied.
1765
+ * Returns 'missing' when no row exists and 'unverified' when the run has not
1766
+ * checkpointed its input yet, so ownership cannot be confirmed.
1767
+ */
1768
+ async function authorizeDurableRun({ mastra, agent, runId, requestContext, permission }) {
1769
+ const workflows = await mastra.getStorage()?.getStore("workflows");
1770
+ const run = await workflows?.getWorkflowRunById({
1771
+ workflowName: getDurableLoopWorkflowName(agent),
1772
+ runId
1773
+ });
1774
+ if (!run) return "missing";
1775
+ await require_utils$1.validateRunOwnership(run, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
1776
+ const ownershipSchema = zod_v4.z.object({ context: zod_v4.z.object({ input: zod_v4.z.object({
1777
+ agentId: zod_v4.z.string(),
1778
+ state: zod_v4.z.object({ threadId: zod_v4.z.string().optional() }).optional()
1779
+ }) }) });
1780
+ let parsed = ownershipSchema.safeParse(typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot);
1781
+ if (!parsed.success) {
1782
+ const execution = await workflows?.getWorkflowRunById({
1783
+ workflowName: getDurableLoopWorkflowName(agent).replace(_mastra_core_agent_durable.DurableStepIds.AGENTIC_LOOP, _mastra_core_agent_durable.DurableStepIds.AGENTIC_EXECUTION),
1784
+ runId
1785
+ });
1786
+ await require_utils$1.validateRunOwnership(execution, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
1787
+ parsed = ownershipSchema.safeParse(typeof execution?.snapshot === "string" ? JSON.parse(execution.snapshot) : execution?.snapshot);
1788
+ }
1789
+ if (!parsed.success) return "unverified";
1790
+ if (parsed.data.context.input.agentId !== agent.id) throw new require_http_exception.HTTPException(403, { message: "Access denied: run does not belong to this agent" });
1791
+ const threadId = parsed.data.context.input.state?.threadId;
1792
+ if (threadId) {
1793
+ const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId });
1794
+ await require_utils$1.enforceThreadAccess({
1795
+ mastra,
1796
+ requestContext,
1797
+ threadId,
1798
+ thread,
1799
+ effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
1800
+ permission
1801
+ });
1802
+ }
1803
+ return "ok";
1804
+ }
1805
+ /**
1806
+ * Authorizes observing a run: the caller must own it and have read access to
1807
+ * its thread. Plain agent runs are checked against their shared run record,
1808
+ * so any server sharing the agent's record cache can authorize them. Durable
1809
+ * runs use the owner the agent tracks in this process, then their workflow
1810
+ * rows. Throws 404 when the run cannot be found or verified.
1811
+ */
1812
+ async function authorizeRunObservation({ mastra, agent, runId, requestContext }) {
1813
+ const permission = require_utils$1.MastraFGAPermissions.MEMORY_READ;
1814
+ if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
1815
+ const record = await getPlainRunRecord(agent, runId);
1816
+ if (!record) throw new require_http_exception.HTTPException(404, { message: "Run not found" });
1817
+ await authorizeRunOwner({
1818
+ mastra,
1819
+ agent,
1820
+ owner: record,
1821
+ requestContext,
1822
+ permission
1823
+ });
1824
+ return;
1825
+ }
1826
+ const getOwner = agent.__getRunOwner;
1827
+ const owner = typeof getOwner === "function" ? getOwner.call(agent, runId) : void 0;
1828
+ if (owner) {
1829
+ await authorizeRunOwner({
1830
+ mastra,
1831
+ agent,
1832
+ owner,
1833
+ requestContext,
1834
+ permission
1835
+ });
1836
+ return;
1837
+ }
1838
+ if (await authorizeDurableRun({
1839
+ mastra,
1840
+ agent,
1841
+ runId,
1842
+ requestContext,
1843
+ permission
1844
+ }) !== "ok") throw new require_http_exception.HTTPException(404, { message: "Run not found" });
1845
+ }
1693
1846
  const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
1694
1847
  method: "POST",
1695
1848
  path: "/agents/:agentId/runs/:runId/abort",
@@ -1697,7 +1850,7 @@ const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
1697
1850
  pathParamSchema: require_agents.agentRunPathParams,
1698
1851
  responseSchema: require_agents.abortAgentThreadResponseSchema,
1699
1852
  summary: "Abort an agent run",
1700
- description: "Explicitly stop a durable run, including runs without a memory thread",
1853
+ description: "Explicitly stop a durable run or a run of an agent with resumable streams, including runs without a memory thread",
1701
1854
  tags: ["Agents"],
1702
1855
  requiresAuth: true,
1703
1856
  requiresPermission: require_utils$1.MastraFGAPermissions.AGENTS_EXECUTE,
@@ -1708,41 +1861,29 @@ const ABORT_AGENT_RUN_ROUTE = require_route_builder.createRoute({
1708
1861
  agentId,
1709
1862
  requestContext
1710
1863
  });
1711
- if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) throw new require_http_exception.HTTPException(501, { message: "Run-scoped cancellation requires a durable agent" });
1712
- const workflows = await mastra.getStorage()?.getStore("workflows");
1713
- const run = await workflows?.getWorkflowRunById({
1714
- workflowName: getDurableLoopWorkflowName(agent),
1715
- runId
1716
- });
1717
- if (!run) return { aborted: false };
1718
- await require_utils$1.validateRunOwnership(run, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
1719
- const ownershipSchema = zod_v4.z.object({ context: zod_v4.z.object({ input: zod_v4.z.object({
1720
- agentId: zod_v4.z.string(),
1721
- state: zod_v4.z.object({ threadId: zod_v4.z.string().optional() }).optional()
1722
- }) }) });
1723
- let parsed = ownershipSchema.safeParse(typeof run.snapshot === "string" ? JSON.parse(run.snapshot) : run.snapshot);
1724
- if (!parsed.success) {
1725
- const execution = await workflows?.getWorkflowRunById({
1726
- workflowName: getDurableLoopWorkflowName(agent).replace(_mastra_core_agent_durable.DurableStepIds.AGENTIC_LOOP, _mastra_core_agent_durable.DurableStepIds.AGENTIC_EXECUTION),
1727
- runId
1728
- });
1729
- await require_utils$1.validateRunOwnership(execution, require_utils$1.getContextResourceId(requestContext), mastra, requestContext);
1730
- parsed = ownershipSchema.safeParse(typeof execution?.snapshot === "string" ? JSON.parse(execution.snapshot) : execution?.snapshot);
1731
- }
1732
- if (!parsed.success) return { aborted: false };
1733
- if (parsed.data.context.input.agentId !== agent.id) throw new require_http_exception.HTTPException(403, { message: "Access denied: run does not belong to this agent" });
1734
- const threadId = parsed.data.context.input.state?.threadId;
1735
- if (threadId) {
1736
- const thread = await (await agent.getMemory({ requestContext }))?.getThreadById({ threadId });
1737
- await require_utils$1.enforceThreadAccess({
1864
+ if (!(0, _mastra_core_agent.isDurableAgentLike)(agent)) {
1865
+ const resumable = agent;
1866
+ if (typeof resumable.__getRunRecord !== "function" && typeof resumable.__getPublishedRunOwner !== "function" || !hasResumableStreams(agent)) throw new require_http_exception.HTTPException(501, { message: "Run-scoped cancellation requires a durable agent or an agent with resumable streams" });
1867
+ const record = await getPlainRunRecord(agent, runId);
1868
+ if (!record) throw new require_http_exception.HTTPException(404, { message: "Run not found" });
1869
+ await authorizeRunOwner({
1738
1870
  mastra,
1871
+ agent,
1872
+ owner: record,
1739
1873
  requestContext,
1740
- threadId,
1741
- thread,
1742
- effectiveResourceId: require_utils$1.getContextResourceId(requestContext),
1743
1874
  permission: require_utils$1.MastraFGAPermissions.MEMORY_WRITE
1744
1875
  });
1876
+ if (record.status === "finished") return { aborted: false };
1877
+ if (typeof resumable.__abortRunAcknowledged === "function") return { aborted: await resumable.__abortRunAcknowledged.call(agent, runId) };
1878
+ return { aborted: agent.abortRunStream(runId) };
1745
1879
  }
1880
+ if (await authorizeDurableRun({
1881
+ mastra,
1882
+ agent,
1883
+ runId,
1884
+ requestContext,
1885
+ permission: require_utils$1.MastraFGAPermissions.MEMORY_WRITE
1886
+ }) !== "ok") return { aborted: false };
1746
1887
  if (typeof agent.__abortRunAcknowledged === "function") return { aborted: await agent.__abortRunAcknowledged(runId) };
1747
1888
  return { aborted: await agent.abortRunStream(runId) };
1748
1889
  } catch (error) {
@@ -2005,8 +2146,8 @@ const STREAM_UNTIL_IDLE_GENERATE_ROUTE = require_route_builder.createRoute({
2005
2146
  context: restOptions.context,
2006
2147
  requestContext: serverRequestContext,
2007
2148
  memory: authorizedMemoryOption,
2008
- abortSignal: (0, _mastra_core_agent.isDurableAgentLike)(agent) ? void 0 : abortSignal,
2009
- _detachObserverOnCancel: (0, _mastra_core_agent.isDurableAgentLike)(agent)
2149
+ abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
2150
+ _detachObserverOnCancel: hasResumableStreams(agent)
2010
2151
  };
2011
2152
  return (structuredOutput ? await agent.streamUntilIdle(messages, {
2012
2153
  ...options,
@@ -2040,24 +2181,43 @@ const OBSERVE_AGENT_STREAM_ROUTE = require_route_builder.createRoute({
2040
2181
  bodySchema: require_agents.observeAgentBodySchema,
2041
2182
  responseSchema: require_agents.observeAgentResponseSchema,
2042
2183
  summary: "Observe agent stream",
2043
- description: "Reconnect to an existing agent stream to receive missed events. Supports position-based resume with offset for efficient reconnection.",
2184
+ description: "Reconnect to an existing agent stream to receive missed events. Every frame except abort carries the run-log `index` it came from; pass `offset` as the index + 1 of the last frame that has one to resume without repeating indexed frames. Frames whose replay-cache write failed, or all frames when caching is off, carry no index, so no offset can resume at them; omitting `offset` replays whatever the transport itself retains, which can repeat frames already received.",
2044
2185
  tags: ["Agents", "Streaming"],
2045
2186
  requiresAuth: true,
2046
- handler: async ({ mastra, agentId, runId, offset, abortSignal }) => {
2187
+ handler: async ({ mastra, agentId, runId, offset, abortSignal, requestContext }) => {
2047
2188
  try {
2048
2189
  const agent = await getAgentFromSystem({
2049
2190
  mastra,
2050
- agentId
2191
+ agentId,
2192
+ requestContext
2193
+ });
2194
+ await authorizeRunObservation({
2195
+ mastra,
2196
+ agent,
2197
+ runId,
2198
+ requestContext
2051
2199
  });
2052
2200
  const durableAgent = (0, _mastra_core_agent.isDurableAgentLike)(agent) ? agent : void 0;
2053
- const pubsub = durableAgent?.pubsub ?? mastra.pubsub;
2201
+ const pubsub = durableAgent?.pubsub ?? getAgentStreamPubSub(agent) ?? mastra.pubsub;
2054
2202
  const topic = (0, _mastra_core_agent_durable.AGENT_STREAM_TOPIC)(runId);
2055
2203
  const subscribe = (onEvent, onComplete) => {
2056
2204
  if (typeof durableAgent?.__subscribeToRunStream === "function") return durableAgent.__subscribeToRunStream(runId, {
2057
2205
  offset,
2058
2206
  onComplete
2059
2207
  }, onEvent);
2060
- return (offset !== void 0 ? pubsub.subscribeFromOffset(topic, offset, onEvent) : pubsub.subscribeWithReplay(topic, onEvent)).then(() => () => pubsub.unsubscribe(topic, onEvent));
2208
+ if (offset === void 0) return pubsub.subscribeWithReplay(topic, onEvent).then(() => () => pubsub.unsubscribe(topic, onEvent));
2209
+ return pubsub.subscribeFromOffset(topic, offset, onEvent).then(() => {
2210
+ if (offset > 0) {
2211
+ const readTail = async () => {
2212
+ const window = await pubsub.getHistory(topic, offset - 1);
2213
+ return window.length > 0 ? window.at(-1) : (await pubsub.getHistory(topic, 0)).at(-1);
2214
+ };
2215
+ readTail().catch(() => void 0).then((last) => {
2216
+ if (typeof last?.index === "number" && last.index < offset && isRunTerminalEvent(last)) onComplete();
2217
+ });
2218
+ }
2219
+ return () => pubsub.unsubscribe(topic, onEvent);
2220
+ });
2061
2221
  };
2062
2222
  let closed = false;
2063
2223
  let pendingRejection;
@@ -2186,8 +2346,8 @@ const APPROVE_TOOL_CALL_ROUTE = require_route_builder.createRoute({
2186
2346
  return (await agent.approveToolCall({
2187
2347
  ...params,
2188
2348
  requestContext,
2189
- abortSignal: (0, _mastra_core_agent.isDurableAgentLike)(agent) ? void 0 : abortSignal,
2190
- _detachObserverOnCancel: (0, _mastra_core_agent.isDurableAgentLike)(agent)
2349
+ abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
2350
+ _detachObserverOnCancel: hasResumableStreams(agent)
2191
2351
  })).fullStream;
2192
2352
  } catch (error) {
2193
2353
  return require_server_handlers_error.handleError(error, "error approving tool call");
@@ -2343,8 +2503,8 @@ const DECLINE_TOOL_CALL_ROUTE = require_route_builder.createRoute({
2343
2503
  return (await agent.declineToolCall({
2344
2504
  ...params,
2345
2505
  requestContext,
2346
- abortSignal: (0, _mastra_core_agent.isDurableAgentLike)(agent) ? void 0 : abortSignal,
2347
- _detachObserverOnCancel: (0, _mastra_core_agent.isDurableAgentLike)(agent)
2506
+ abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
2507
+ _detachObserverOnCancel: hasResumableStreams(agent)
2348
2508
  })).fullStream;
2349
2509
  } catch (error) {
2350
2510
  return require_server_handlers_error.handleError(error, "error declining tool call");
@@ -2428,8 +2588,8 @@ const RESUME_STREAM_ROUTE = require_route_builder.createRoute({
2428
2588
  ...restOptions,
2429
2589
  requestContext: serverRequestContext,
2430
2590
  memory: authorizedMemoryOption,
2431
- abortSignal: (0, _mastra_core_agent.isDurableAgentLike)(agent) ? void 0 : abortSignal,
2432
- _detachObserverOnCancel: (0, _mastra_core_agent.isDurableAgentLike)(agent)
2591
+ abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
2592
+ _detachObserverOnCancel: hasResumableStreams(agent)
2433
2593
  };
2434
2594
  if (untilIdle) options.untilIdle = untilIdle;
2435
2595
  return (structuredOutput ? await agent.resumeStream(resumeData, {
@@ -2558,8 +2718,8 @@ const RESUME_STREAM_UNTIL_IDLE_ROUTE = require_route_builder.createRoute({
2558
2718
  context: restOptions.context,
2559
2719
  requestContext: serverRequestContext,
2560
2720
  memory: authorizedMemoryOption,
2561
- abortSignal: (0, _mastra_core_agent.isDurableAgentLike)(agent) ? void 0 : abortSignal,
2562
- _detachObserverOnCancel: (0, _mastra_core_agent.isDurableAgentLike)(agent)
2721
+ abortSignal: hasResumableStreams(agent) ? void 0 : abortSignal,
2722
+ _detachObserverOnCancel: hasResumableStreams(agent)
2563
2723
  };
2564
2724
  return (structuredOutput ? await agent.resumeStreamUntilIdle(resumeData, {
2565
2725
  ...options,
@@ -3381,4 +3541,4 @@ Object.defineProperty(exports, "isProviderConnected", {
3381
3541
  }
3382
3542
  });
3383
3543
 
3384
- //# sourceMappingURL=agents-DOHGWXDa.cjs.map
3544
+ //# sourceMappingURL=agents-CMEeZr5y.cjs.map