@mastra/core 1.87.0-alpha.2 → 1.87.0-alpha.20

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 (760) hide show
  1. package/dist/_types/@ai-sdk_openai@4.0.106/dist/index.d.ts +2034 -0
  2. package/dist/_types/@ai-sdk_openai@4.0.106/package.json +1 -0
  3. package/dist/_types/@internal_ai-v6@0.0.99/dist/index.d.ts +2075 -123
  4. package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +79 -3
  5. package/dist/a2a/index.cjs +1 -1
  6. package/dist/a2a/index.js +1 -1
  7. package/dist/agent/active-run-signal-queues.d.ts +49 -0
  8. package/dist/agent/agent.d.ts +22 -6
  9. package/dist/agent/agent.types.d.ts +1 -0
  10. package/dist/agent/durable/abort-transport.d.ts +1 -1
  11. package/dist/agent/durable/durable-agent.d.ts +1 -0
  12. package/dist/agent/durable/execution-engine.d.ts +12 -0
  13. package/dist/agent/durable/index.cjs +86 -86
  14. package/dist/agent/durable/index.js +2 -2
  15. package/dist/agent/durable/preparation.d.ts +17 -0
  16. package/dist/agent/durable/run-message-refs.d.ts +3 -2
  17. package/dist/agent/durable/run-registry.d.ts +56 -25
  18. package/dist/agent/durable/stored-signal-drain.d.ts +100 -0
  19. package/dist/agent/durable/types.d.ts +43 -0
  20. package/dist/agent/durable/utils/resolve-runtime.d.ts +16 -0
  21. package/dist/agent/durable/utils/serialize-state.d.ts +1 -0
  22. package/dist/agent/durable/workflows/create-durable-agentic-workflow.d.ts +1 -0
  23. package/dist/agent/durable/workflows/durable-loop-builder.d.ts +5 -0
  24. package/dist/agent/durable/workflows/finalize-run.d.ts +7 -1
  25. package/dist/agent/durable/workflows/shared/message-list-state.d.ts +6 -2
  26. package/dist/agent/durable/workflows/shared/schemas.d.ts +2 -0
  27. package/dist/agent/durable/workflows/steps/llm-execution.d.ts +1 -0
  28. package/dist/agent/index.cjs +18 -17
  29. package/dist/agent/index.d.ts +3 -0
  30. package/dist/agent/index.js +6 -6
  31. package/dist/agent/merge-persona.d.ts +15 -0
  32. package/dist/agent/message-list/adapters/AIV5Adapter.d.ts +15 -1
  33. package/dist/agent/message-list/index.cjs +2 -2
  34. package/dist/agent/message-list/index.js +2 -2
  35. package/dist/agent/message-list/state/MessageStateManager.d.ts +5 -0
  36. package/dist/agent/message-list/state/types.d.ts +5 -1
  37. package/dist/agent/message-list/types.d.ts +1 -1
  38. package/dist/agent/message-list/utils/provider-compat.d.ts +9 -1
  39. package/dist/agent/scopes.d.ts +8 -0
  40. package/dist/agent/signals.d.ts +7 -3
  41. package/dist/agent/stored-run-signals.d.ts +93 -0
  42. package/dist/agent/stored-signals.d.ts +40 -0
  43. package/dist/agent/streams/abort-transport.d.ts +10 -1
  44. package/dist/agent/streams/constants.d.ts +9 -0
  45. package/dist/agent/streams/publisher.d.ts +3 -1
  46. package/dist/agent/thread-stream-runtime.d.ts +46 -4
  47. package/dist/agent/tool-name.d.ts +21 -0
  48. package/dist/agent/types.d.ts +1 -0
  49. package/dist/agent-builder/ee/index.cjs +1 -1
  50. package/dist/agent-builder/ee/index.js +1 -1
  51. package/dist/agent-controller/agent-controller.d.ts +14 -1
  52. package/dist/agent-controller/index.cjs +3 -3
  53. package/dist/agent-controller/index.js +3 -3
  54. package/dist/agent-controller/session.d.ts +38 -1
  55. package/dist/agent-controller/types.d.ts +6 -0
  56. package/dist/agent-controller/worker-run-binding.d.ts +15 -0
  57. package/dist/{agent-controller-Dc58ARqw.js → agent-controller-D2d_qiJr.js} +159 -217
  58. package/dist/{agent-controller-v64JbuDa.cjs → agent-controller-WTjY0HJM.cjs} +181 -239
  59. package/dist/{agent-skills-resolver-BMoCDoaK.cjs → agent-skills-resolver-2d8k7ioj.cjs} +134 -109
  60. package/dist/{agent-skills-resolver-CUEIMDbx.js → agent-skills-resolver-D2HktP6Y.js} +134 -109
  61. package/dist/background-tasks/index.cjs +2 -1
  62. package/dist/background-tasks/index.d.ts +1 -1
  63. package/dist/background-tasks/index.js +1 -1
  64. package/dist/background-tasks/manager.d.ts +3 -1
  65. package/dist/background-tasks/resolve-config.d.ts +30 -1
  66. package/dist/background-tasks/system-prompt.d.ts +8 -2
  67. package/dist/background-tasks/types.d.ts +47 -1
  68. package/dist/background-tasks/workflow-id.d.ts +42 -0
  69. package/dist/{background-tasks-E-Jjxks4.js → background-tasks-CgspqU_S.js} +393 -59
  70. package/dist/{background-tasks-DgiQNKh7.cjs → background-tasks-DJ6x1bn-.cjs} +428 -58
  71. package/dist/browser/index.cjs +17 -8
  72. package/dist/browser/index.js +17 -8
  73. package/dist/browser/processor.d.ts +1 -0
  74. package/dist/{builder-Dfp6Ckjr.cjs → builder-B2P49nT9.cjs} +3 -3
  75. package/dist/{builder-Dh175HnQ.js → builder-MymUxyDK.js} +2 -2
  76. package/dist/capabilities/302ai.json +203 -203
  77. package/dist/capabilities/abacus.json +2 -96
  78. package/dist/capabilities/abliteratedllm.json +39 -30
  79. package/dist/capabilities/abliteration-ai.json +9 -9
  80. package/dist/capabilities/above.json +18 -18
  81. package/dist/capabilities/adaption.json +16 -16
  82. package/dist/capabilities/adzuki.json +20 -20
  83. package/dist/capabilities/agentrouter.json +11 -11
  84. package/dist/capabilities/agnes.json +3 -3
  85. package/dist/capabilities/ai-router.json +5 -5
  86. package/dist/capabilities/aiand.json +10 -27
  87. package/dist/capabilities/aigrow.json +11 -11
  88. package/dist/capabilities/aimlapi.json +153 -158
  89. package/dist/capabilities/aipg.json +2 -2
  90. package/dist/capabilities/aixy.json +14 -14
  91. package/dist/capabilities/aki-io.json +15 -15
  92. package/dist/capabilities/alibaba-cn.json +117 -120
  93. package/dist/capabilities/alibaba-coding-plan-cn.json +5 -10
  94. package/dist/capabilities/alibaba-coding-plan.json +5 -10
  95. package/dist/capabilities/alibaba-token-plan-cn.json +60 -56
  96. package/dist/capabilities/alibaba-token-plan.json +59 -55
  97. package/dist/capabilities/alibaba.json +122 -57
  98. package/dist/capabilities/ambient.json +17 -28
  99. package/dist/capabilities/amd-tokenlab.json +41 -0
  100. package/dist/capabilities/amd.json +6 -6
  101. package/dist/capabilities/anthropic.json +33 -57
  102. package/dist/capabilities/anyapi.json +15 -15
  103. package/dist/capabilities/apiko.json +5 -5
  104. package/dist/capabilities/arcee.json +7 -7
  105. package/dist/capabilities/augure.json +6 -6
  106. package/dist/capabilities/auriko.json +19 -19
  107. package/dist/capabilities/bailing.json +5 -5
  108. package/dist/capabilities/baseten.json +25 -25
  109. package/dist/capabilities/bee.json +4 -4
  110. package/dist/capabilities/berget.json +4 -24
  111. package/dist/capabilities/bothub.json +11 -11
  112. package/dist/capabilities/boundless.json +39 -39
  113. package/dist/capabilities/bumo.json +40 -40
  114. package/dist/capabilities/byteplus.json +29 -29
  115. package/dist/capabilities/cheapaimodel.json +10 -10
  116. package/dist/capabilities/cheapest-token.json +28 -28
  117. package/dist/capabilities/chutes.json +83 -4
  118. package/dist/capabilities/claudinio.json +10 -1
  119. package/dist/capabilities/cline-pass.json +33 -46
  120. package/dist/capabilities/cloudcode.json +12 -19
  121. package/dist/capabilities/cloudflare-workers-ai.json +13 -13
  122. package/dist/capabilities/commandcode.json +137 -152
  123. package/dist/capabilities/concentrate.json +282 -291
  124. package/dist/capabilities/cortecs.json +105 -105
  125. package/dist/capabilities/crossmodel.json +191 -191
  126. package/dist/capabilities/crusoe.json +37 -8
  127. package/dist/capabilities/daoxe.json +9 -9
  128. package/dist/capabilities/databricks.json +124 -124
  129. package/dist/capabilities/deepinfra.json +107 -88
  130. package/dist/capabilities/deepseek.json +3 -3
  131. package/dist/capabilities/digitalocean.json +114 -114
  132. package/dist/capabilities/dinference.json +1 -2
  133. package/dist/capabilities/dothoosh.json +30 -30
  134. package/dist/capabilities/doubleword.json +22 -22
  135. package/dist/capabilities/edenai.json +279 -291
  136. package/dist/capabilities/empiriolabs.json +177 -163
  137. package/dist/capabilities/engy.json +22 -22
  138. package/dist/capabilities/evroc.json +11 -11
  139. package/dist/capabilities/ezkielyna.json +10 -10
  140. package/dist/capabilities/fastrouter.json +85 -89
  141. package/dist/capabilities/fireworks-ai.json +130 -69
  142. package/dist/capabilities/fortytwo.json +9 -3
  143. package/dist/capabilities/freemodel.json +5 -49
  144. package/dist/capabilities/frogbot.json +94 -102
  145. package/dist/capabilities/gisoo.json +20 -20
  146. package/dist/capabilities/gmicloud.json +17 -17
  147. package/dist/capabilities/google.json +54 -54
  148. package/dist/capabilities/graphn.json +15 -15
  149. package/dist/capabilities/greenpt.json +36 -36
  150. package/dist/capabilities/groq.json +4 -17
  151. package/dist/capabilities/helicone.json +83 -85
  152. package/dist/capabilities/hetzner.json +35 -3
  153. package/dist/capabilities/hostinger-router.json +6 -13
  154. package/dist/capabilities/hpc-ai.json +9 -25
  155. package/dist/capabilities/huawei-maas.json +12 -12
  156. package/dist/capabilities/hubris.json +33 -33
  157. package/dist/capabilities/huggingface.json +105 -155
  158. package/dist/capabilities/hyper.json +25 -33
  159. package/dist/capabilities/impossibl.json +147 -194
  160. package/dist/capabilities/inception.json +2 -2
  161. package/dist/capabilities/inceptron.json +4 -4
  162. package/dist/capabilities/inco.json +4 -21
  163. package/dist/capabilities/infer.json +18 -18
  164. package/dist/capabilities/inferall.json +2 -18
  165. package/dist/capabilities/inference-coop.json +15 -15
  166. package/dist/capabilities/inference.json +2 -11
  167. package/dist/capabilities/inferenceapis.json +14 -14
  168. package/dist/capabilities/inferris.json +4 -4
  169. package/dist/capabilities/infersia.json +13 -13
  170. package/dist/capabilities/inferx.json +2 -2
  171. package/dist/capabilities/infomaniak.json +4 -4
  172. package/dist/capabilities/io-net.json +3 -13
  173. package/dist/capabilities/iteracompute.json +43 -81
  174. package/dist/capabilities/jalapeno.json +12 -12
  175. package/dist/capabilities/jiekou.json +23 -171
  176. package/dist/capabilities/jzstoken.json +47 -48
  177. package/dist/capabilities/keln.json +16 -16
  178. package/dist/capabilities/kenari.json +142 -126
  179. package/dist/capabilities/kilo.json +636 -656
  180. package/dist/capabilities/kimi-code-plan-cn.json +5 -5
  181. package/dist/capabilities/kimi-code-plan-global.json +5 -5
  182. package/dist/capabilities/kitani.json +2 -2
  183. package/dist/capabilities/klavo.json +19 -19
  184. package/dist/capabilities/korouter.json +36 -36
  185. package/dist/capabilities/kunavo.json +6 -6
  186. package/dist/capabilities/liquid.json +11 -11
  187. package/dist/capabilities/lithosai.json +2 -2
  188. package/dist/capabilities/llmgateway-providers.json +929 -912
  189. package/dist/capabilities/llmgateway.json +344 -335
  190. package/dist/capabilities/llmtr.json +16 -54
  191. package/dist/capabilities/lowrouter.json +58 -58
  192. package/dist/capabilities/lyceum.json +12 -4
  193. package/dist/capabilities/meganova.json +0 -1
  194. package/dist/capabilities/melious.json +10 -10
  195. package/dist/capabilities/merge-gateway.json +296 -289
  196. package/dist/capabilities/meta.json +7 -7
  197. package/dist/capabilities/minimax-cn-coding-plan.json +5 -5
  198. package/dist/capabilities/minimax-cn.json +5 -5
  199. package/dist/capabilities/minimax-coding-plan.json +5 -5
  200. package/dist/capabilities/minimax.json +5 -5
  201. package/dist/capabilities/mistral.json +14 -30
  202. package/dist/capabilities/mixlayer.json +5 -5
  203. package/dist/capabilities/moark.json +0 -2
  204. package/dist/capabilities/modal.json +11 -11
  205. package/dist/capabilities/model-oracle-ai.json +23 -31
  206. package/dist/capabilities/modelis.json +18 -18
  207. package/dist/capabilities/modular.json +30 -8
  208. package/dist/capabilities/moneo.json +5 -36
  209. package/dist/capabilities/morph.json +15 -15
  210. package/dist/capabilities/munito-eu.json +4 -4
  211. package/dist/capabilities/munito.json +4 -4
  212. package/dist/capabilities/nan.json +23 -23
  213. package/dist/capabilities/nano-gpt.json +602 -595
  214. package/dist/capabilities/nearai.json +97 -97
  215. package/dist/capabilities/nebius.json +24 -25
  216. package/dist/capabilities/neon.json +132 -132
  217. package/dist/capabilities/neuralwatt.json +41 -41
  218. package/dist/capabilities/nokeep.json +4 -4
  219. package/dist/capabilities/novita-ai.json +90 -204
  220. package/dist/capabilities/nvidia.json +28 -69
  221. package/dist/capabilities/oathbreaker.json +24 -1
  222. package/dist/capabilities/obscurify.json +31 -31
  223. package/dist/capabilities/oci.json +6 -6
  224. package/dist/capabilities/ofox.json +219 -583
  225. package/dist/capabilities/ollama-cloud.json +57 -57
  226. package/dist/capabilities/openai.json +57 -57
  227. package/dist/capabilities/opencode-go.json +97 -89
  228. package/dist/capabilities/openreason.json +4 -4
  229. package/dist/capabilities/openrouter.json +555 -564
  230. package/dist/capabilities/opper.json +26 -31
  231. package/dist/capabilities/orcarouter.json +409 -210
  232. package/dist/capabilities/outerlabs.json +25 -25
  233. package/dist/capabilities/ovhcloud.json +21 -22
  234. package/dist/capabilities/pareto.json +2 -7
  235. package/dist/capabilities/perplexity-agent.json +50 -105
  236. package/dist/capabilities/phala.json +30 -30
  237. package/dist/capabilities/pioneer.json +3 -120
  238. package/dist/capabilities/poe.json +129 -129
  239. package/dist/capabilities/powerspring.json +14 -14
  240. package/dist/capabilities/primalabs.json +9 -9
  241. package/dist/capabilities/prime.json +139 -121
  242. package/dist/capabilities/privatemode-ai.json +12 -40
  243. package/dist/capabilities/proxystacks.json +6 -6
  244. package/dist/capabilities/qihang-ai.json +3 -15
  245. package/dist/capabilities/qiniu-ai.json +13 -87
  246. package/dist/capabilities/refuseless.json +4 -11
  247. package/dist/capabilities/regolo-ai.json +10 -14
  248. package/dist/capabilities/requesty.json +439 -183
  249. package/dist/capabilities/routing-run.json +3 -40
  250. package/dist/capabilities/ruapi.json +36 -20
  251. package/dist/capabilities/runcrate.json +5 -5
  252. package/dist/capabilities/runinfra.json +9 -9
  253. package/dist/capabilities/sakana.json +7 -7
  254. package/dist/capabilities/sambanova.json +9 -9
  255. package/dist/capabilities/sandbase.json +25 -25
  256. package/dist/capabilities/sarvam.json +18 -9
  257. package/dist/capabilities/scaleway.json +19 -19
  258. package/dist/capabilities/scnet-token-plan.json +10 -10
  259. package/dist/capabilities/scx-ai.json +24 -40
  260. package/dist/capabilities/sensenova.json +15 -15
  261. package/dist/capabilities/siliconflow-cn.json +43 -77
  262. package/dist/capabilities/siliconflow.json +45 -45
  263. package/dist/capabilities/snowflake-cortex.json +18 -18
  264. package/dist/capabilities/sokkan.json +7 -19
  265. package/dist/capabilities/sparrowcodes.json +23 -23
  266. package/dist/capabilities/stackit.json +1 -2
  267. package/dist/capabilities/standardcompute.json +79 -115
  268. package/dist/capabilities/steadyrouter.json +42 -42
  269. package/dist/capabilities/stepfun-ai-step-plan.json +13 -7
  270. package/dist/capabilities/stepfun-ai.json +20 -6
  271. package/dist/capabilities/stepfun-step-plan.json +13 -6
  272. package/dist/capabilities/stepfun.json +20 -6
  273. package/dist/capabilities/stepping-stone.json +18 -18
  274. package/dist/capabilities/synthetic.json +8 -17
  275. package/dist/capabilities/synthorai.json +27 -27
  276. package/dist/capabilities/teamorouter.json +19 -19
  277. package/dist/capabilities/teapot-router.json +10 -10
  278. package/dist/capabilities/tencent-token-plan-intl.json +126 -0
  279. package/dist/capabilities/tencent-token-plan.json +37 -37
  280. package/dist/capabilities/tencent-tokenhub.json +52 -37
  281. package/dist/capabilities/tensorx.json +38 -38
  282. package/dist/capabilities/tenstorrent.json +4 -4
  283. package/dist/capabilities/the-grid-ai.json +29 -29
  284. package/dist/capabilities/thinkingmachines.json +77 -77
  285. package/dist/capabilities/tinfoil.json +10 -10
  286. package/dist/capabilities/toapis.json +3 -3
  287. package/dist/capabilities/togetherai.json +45 -53
  288. package/dist/capabilities/tokengo.json +20 -20
  289. package/dist/capabilities/tokenify.json +3 -3
  290. package/dist/capabilities/tokenwatt.json +10 -2
  291. package/dist/capabilities/trustedrouter.json +7 -7
  292. package/dist/capabilities/trustedtokens.json +15 -15
  293. package/dist/capabilities/umans-ai-coding-plan.json +11 -11
  294. package/dist/capabilities/umans-ai.json +10 -10
  295. package/dist/capabilities/uncensuredai.json +5 -5
  296. package/dist/capabilities/unorouter.json +1 -22
  297. package/dist/capabilities/unrestricted.json +8 -24
  298. package/dist/capabilities/uplinkswitch.json +20 -20
  299. package/dist/capabilities/upstage.json +1 -13
  300. package/dist/capabilities/vancine.json +23 -23
  301. package/dist/capabilities/vercel.json +593 -563
  302. package/dist/capabilities/verda.json +8 -1
  303. package/dist/capabilities/vivgrid.json +56 -127
  304. package/dist/capabilities/volcengine-coding-plan.json +26 -26
  305. package/dist/capabilities/volcengine.json +25 -24
  306. package/dist/capabilities/vultr.json +14 -67
  307. package/dist/capabilities/wafer.ai.json +16 -16
  308. package/dist/capabilities/wally.json +11 -11
  309. package/dist/capabilities/wandb.json +20 -20
  310. package/dist/capabilities/watt.json +19 -19
  311. package/dist/capabilities/xai.json +6 -6
  312. package/dist/capabilities/xiaomi.json +3 -3
  313. package/dist/capabilities/xpersona.json +11 -11
  314. package/dist/capabilities/xxapi.json +26 -26
  315. package/dist/capabilities/zai-coding-plan.json +18 -18
  316. package/dist/capabilities/zai.json +33 -33
  317. package/dist/capabilities/zenifra.json +33 -33
  318. package/dist/capabilities/zenmux.json +171 -214
  319. package/dist/capabilities/zerogpu.json +11 -11
  320. package/dist/capabilities/zhipuai-coding-plan.json +6 -17
  321. package/dist/capabilities/zhipuai.json +32 -32
  322. package/dist/capabilities/zro.json +6 -6
  323. package/dist/channels/agent-channels.d.ts +22 -0
  324. package/dist/channels/index.cjs +24 -24
  325. package/dist/channels/index.js +2 -2
  326. package/dist/channels/output-processor.d.ts +12 -0
  327. package/dist/channels/reply-tool.d.ts +5 -1
  328. package/dist/channels/state-adapter.d.ts +3 -1
  329. package/dist/channels/stream-helpers.d.ts +17 -0
  330. package/dist/{channels-BZL9RT2i.cjs → channels-CKRPQRmF.cjs} +6 -6
  331. package/dist/{channels-0AO7PMJF.js → channels-nnBeh58G.js} +2 -2
  332. package/dist/coding-agent/index.cjs +7 -7
  333. package/dist/coding-agent/index.js +4 -4
  334. package/dist/{constants-B9ZDvXZ4.cjs → constants-B2FVV_2e.cjs} +13 -1
  335. package/dist/{constants-BmdTvEYN.js → constants-Dro9fuhk.js} +13 -1
  336. package/dist/datasets/experiment/scorer.d.ts +16 -5
  337. package/dist/datasets/index.cjs +9 -9
  338. package/dist/datasets/index.js +2 -2
  339. package/dist/docs/SKILL.md +3 -1
  340. package/dist/docs/assets/SOURCE_MAP.json +1289 -1234
  341. package/dist/docs/references/docs-agents-code-mode.md +38 -2
  342. package/dist/docs/references/docs-agents-human-in-the-loop.md +2 -2
  343. package/dist/docs/references/docs-agents-networks.md +2 -2
  344. package/dist/docs/references/docs-agents-overview.md +15 -6
  345. package/dist/docs/references/docs-agents-processors.md +9 -9
  346. package/dist/docs/references/docs-agents-resumable-streams.md +2 -2
  347. package/dist/docs/references/docs-agents-structured-output.md +6 -6
  348. package/dist/docs/references/docs-agents-tools.md +15 -9
  349. package/dist/docs/references/docs-auth-simple-auth.md +8 -8
  350. package/dist/docs/references/docs-browser.md +4 -2
  351. package/dist/docs/references/docs-channels.md +5 -5
  352. package/dist/docs/references/docs-classifier.md +1 -1
  353. package/dist/docs/references/docs-connections-a2a.md +1 -1
  354. package/dist/docs/references/docs-connections-acp.md +2 -2
  355. package/dist/docs/references/docs-connections-overview.md +1 -1
  356. package/dist/docs/references/docs-connections-sdk-agents.md +6 -6
  357. package/dist/docs/references/docs-deployment-workers.md +2 -2
  358. package/dist/docs/references/docs-develop.md +1 -1
  359. package/dist/docs/references/docs-evals-custom-scorers.md +2 -2
  360. package/dist/docs/references/docs-evals-multi-turn.md +2 -2
  361. package/dist/docs/references/docs-guides-build-an-eval-loop.md +2 -2
  362. package/dist/docs/references/docs-guides-context-engineering.md +3 -3
  363. package/dist/docs/references/docs-guides-streaming.md +1 -1
  364. package/dist/docs/references/docs-harness-agent-controller.md +6 -3
  365. package/dist/docs/references/docs-harness-background-tasks.md +48 -7
  366. package/dist/docs/references/docs-harness-durable-agents.md +6 -5
  367. package/dist/docs/references/docs-harness-goals.md +2 -2
  368. package/dist/docs/references/docs-harness-schedules.md +35 -1
  369. package/dist/docs/references/docs-knowledge-agents-and-tools.md +4 -2
  370. package/dist/docs/references/docs-knowledge-importers.md +22 -1
  371. package/dist/docs/references/docs-knowledge-overview.md +1 -1
  372. package/dist/docs/references/docs-knowledge-scopes-and-access.md +1 -1
  373. package/dist/docs/references/docs-knowledge-search.md +1 -1
  374. package/dist/docs/references/docs-mastra-platform-observability-overview.md +3 -189
  375. package/dist/docs/references/docs-memory-memory-processors.md +8 -8
  376. package/dist/docs/references/docs-memory-message-history.md +28 -3
  377. package/dist/docs/references/docs-memory-observational-memory.md +1 -1
  378. package/dist/docs/references/docs-memory-semantic-recall.md +2 -2
  379. package/dist/docs/references/docs-memory-working-memory.md +3 -2
  380. package/dist/docs/references/docs-sandbox-lsp.md +5 -6
  381. package/dist/docs/references/docs-sandbox-overview.md +21 -1
  382. package/dist/docs/references/docs-sandbox-skills.md +3 -1
  383. package/dist/docs/references/docs-server-mastra-client.md +1 -1
  384. package/dist/docs/references/docs-server-mcp.md +23 -0
  385. package/dist/docs/references/docs-server-pubsub.md +22 -2
  386. package/dist/docs/references/docs-server-request-context.md +4 -4
  387. package/dist/docs/references/docs-signals-notifications.md +2 -2
  388. package/dist/docs/references/docs-signals-overview.md +1 -1
  389. package/dist/docs/references/docs-signals-running-across-processes.md +3 -0
  390. package/dist/docs/references/docs-signals-sending-signals.md +20 -7
  391. package/dist/docs/references/docs-signals-signal-providers.md +18 -2
  392. package/dist/docs/references/docs-signals-state-signals.md +1 -0
  393. package/dist/docs/references/docs-signals-thread-streams.md +12 -0
  394. package/dist/docs/references/docs-skills.md +8 -5
  395. package/dist/docs/references/docs-storage.md +12 -12
  396. package/dist/docs/references/docs-studio-editor.md +2 -2
  397. package/dist/docs/references/docs-subagents.md +26 -3
  398. package/dist/docs/references/docs-workflows-overview.md +2 -0
  399. package/dist/docs/references/integrations-agentic-ui-copilotkit.md +1 -1
  400. package/dist/docs/references/integrations-agentic-ui-openui.md +1 -1
  401. package/dist/docs/references/integrations-channels-discord.md +1 -1
  402. package/dist/docs/references/integrations-channels-github.md +1 -1
  403. package/dist/docs/references/integrations-channels-imessage.md +2 -2
  404. package/dist/docs/references/integrations-channels-ring.md +2 -2
  405. package/dist/docs/references/integrations-channels-slack.md +1 -1
  406. package/dist/docs/references/integrations-channels-teams.md +1 -1
  407. package/dist/docs/references/integrations-channels-telegram.md +1 -1
  408. package/dist/docs/references/integrations-channels-whatsapp.md +1 -1
  409. package/dist/docs/references/integrations-tools-firecrawl.md +1 -1
  410. package/dist/docs/references/integrations.md +1 -0
  411. package/dist/docs/references/reference-acp-acp-agent.md +1 -1
  412. package/dist/docs/references/reference-acp-create-acp-tool.md +1 -1
  413. package/dist/docs/references/reference-agent-controller-agent-controller-class.md +3 -1
  414. package/dist/docs/references/reference-agent-controller-session.md +55 -8
  415. package/dist/docs/references/reference-agents-agent.md +40 -14
  416. package/dist/docs/references/reference-agents-channels.md +11 -11
  417. package/dist/docs/references/reference-agents-createSkill.md +20 -1
  418. package/dist/docs/references/reference-agents-durable-agent.md +2 -2
  419. package/dist/docs/references/reference-agents-generate.md +1 -1
  420. package/dist/docs/references/reference-agents-getLLM.md +2 -2
  421. package/dist/docs/references/reference-agents-getMetadata.md +2 -2
  422. package/dist/docs/references/reference-agents-network.md +3 -3
  423. package/dist/docs/references/reference-browser-mastra-browser.md +1 -1
  424. package/dist/docs/references/reference-channels-thread-link.md +1 -1
  425. package/dist/docs/references/reference-classifier-classifier.md +2 -0
  426. package/dist/docs/references/reference-coding-agent-build-base-prompt.md +1 -1
  427. package/dist/docs/references/reference-coding-agent-create-coding-agent.md +7 -7
  428. package/dist/docs/references/reference-configuration.md +15 -14
  429. package/dist/docs/references/reference-core-getAgentById.md +1 -1
  430. package/dist/docs/references/reference-core-getWorkspaceById.md +37 -0
  431. package/dist/docs/references/reference-core-mastra-model-gateway.md +1 -1
  432. package/dist/docs/references/reference-datasets-startExperiment.md +1 -1
  433. package/dist/docs/references/reference-editor-mastra-editor.md +2 -2
  434. package/dist/docs/references/reference-evals-create-scorer.md +5 -5
  435. package/dist/docs/references/reference-evals-run-evals.md +1 -1
  436. package/dist/docs/references/reference-file-based-agents-config.md +3 -3
  437. package/dist/docs/references/reference-file-based-agents-schedules.md +1 -1
  438. package/dist/docs/references/reference-file-based-agents-subagents.md +3 -3
  439. package/dist/docs/references/reference-file-based-agents-workspace.md +1 -1
  440. package/dist/docs/references/reference-knowledge-knowledge-class.md +12 -0
  441. package/dist/docs/references/reference-knowledge-knowledge-tools.md +4 -5
  442. package/dist/docs/references/reference-knowledge-limits.md +16 -16
  443. package/dist/docs/references/reference-manual-install.md +2 -2
  444. package/dist/docs/references/reference-memory-memory-class.md +3 -3
  445. package/dist/docs/references/reference-memory-observational-memory.md +15 -3
  446. package/dist/docs/references/reference-observability-metrics-metrics-context.md +63 -3
  447. package/dist/docs/references/reference-observability-tracing-bridges-datadog.md +12 -11
  448. package/dist/docs/references/reference-observability-tracing-configuration.md +2 -2
  449. package/dist/docs/references/reference-observability-tracing-exporters-datadog.md +14 -12
  450. package/dist/docs/references/reference-observability-tracing-interfaces.md +10 -6
  451. package/dist/docs/references/reference-processors-batch-parts-processor.md +1 -1
  452. package/dist/docs/references/reference-processors-classifier-processor.md +2 -2
  453. package/dist/docs/references/reference-processors-cyber-refusal-handler.md +1 -1
  454. package/dist/docs/references/reference-processors-language-detector.md +1 -1
  455. package/dist/docs/references/reference-processors-message-history-processor.md +1 -1
  456. package/dist/docs/references/reference-processors-model-selection-processor.md +3 -3
  457. package/dist/docs/references/reference-processors-moderation-processor.md +4 -4
  458. package/dist/docs/references/reference-processors-pii-detector.md +2 -2
  459. package/dist/docs/references/reference-processors-prefill-error-handler.md +2 -2
  460. package/dist/docs/references/reference-processors-processor-interface.md +22 -10
  461. package/dist/docs/references/reference-processors-prompt-injection-detector.md +1 -1
  462. package/dist/docs/references/reference-processors-provider-history-compat.md +1 -1
  463. package/dist/docs/references/reference-processors-response-cache.md +1 -1
  464. package/dist/docs/references/reference-processors-semantic-recall-processor.md +1 -1
  465. package/dist/docs/references/reference-processors-skill-search-processor.md +1 -1
  466. package/dist/docs/references/reference-processors-skills-processor.md +1 -1
  467. package/dist/docs/references/reference-processors-stream-error-retry-processor.md +3 -3
  468. package/dist/docs/references/reference-processors-system-prompt-scrubber.md +2 -2
  469. package/dist/docs/references/reference-processors-token-limiter-processor.md +3 -3
  470. package/dist/docs/references/reference-processors-tool-call-filter.md +2 -2
  471. package/dist/docs/references/reference-processors-tool-search-processor.md +6 -6
  472. package/dist/docs/references/reference-processors-unicode-normalizer.md +1 -1
  473. package/dist/docs/references/reference-processors-working-memory-processor.md +1 -1
  474. package/dist/docs/references/reference-pubsub-base.md +6 -4
  475. package/dist/docs/references/reference-pubsub-caching-pubsub.md +3 -1
  476. package/dist/docs/references/reference-pubsub-redis-streams.md +3 -5
  477. package/dist/docs/references/reference-pubsub-valkey-streams.md +2 -2
  478. package/dist/docs/references/reference-rag-chunking-and-embedding.md +1 -1
  479. package/dist/docs/references/reference-rag-graph-rag-guide.md +2 -2
  480. package/dist/docs/references/reference-rag-retrieval.md +13 -13
  481. package/dist/docs/references/reference-signals-create-notification-inbox-tool.md +1 -1
  482. package/dist/docs/references/reference-signals-time-signal-provider.md +137 -0
  483. package/dist/docs/references/reference-storage-composite.md +4 -0
  484. package/dist/docs/references/reference-storage-overview.md +30 -30
  485. package/dist/docs/references/reference-storage-retention.md +20 -20
  486. package/dist/docs/references/reference-templates-overview.md +31 -1
  487. package/dist/docs/references/reference-tools-create-code-mode.md +23 -1
  488. package/dist/docs/references/reference-tools-vector-query-tool.md +11 -3
  489. package/dist/docs/references/reference-voice-overview.md +39 -54
  490. package/dist/docs/references/reference-voice-speech-to-speech.md +11 -11
  491. package/dist/docs/references/reference-voice-speech-to-text.md +1 -1
  492. package/dist/docs/references/reference-voice-text-to-speech.md +1 -1
  493. package/dist/docs/references/reference-voice-voice.addInstructions.md +1 -1
  494. package/dist/docs/references/reference-voice-voice.listen.md +2 -1
  495. package/dist/docs/references/reference-voice-voice.speak.md +1 -3
  496. package/dist/docs/references/reference-workers-overview.md +3 -1
  497. package/dist/docs/references/reference-workflows-run-methods-restart.md +2 -0
  498. package/dist/docs/references/reference-workflows-step.md +1 -1
  499. package/dist/docs/references/reference-workflows-workflow-methods-map.md +1 -1
  500. package/dist/docs/references/reference-workflows-workflow.md +1 -1
  501. package/dist/docs/references/reference-workspace-factory-sandbox.md +8 -6
  502. package/dist/docs/references/reference-workspace-local-filesystem.md +1 -1
  503. package/dist/docs/references/reference-workspace-local-sandbox.md +1 -1
  504. package/dist/docs/references/reference-workspace-sandbox.md +14 -0
  505. package/dist/docs/references/reference.md +3 -0
  506. package/dist/evals/index.cjs +13 -13
  507. package/dist/evals/index.js +2 -2
  508. package/dist/evals/scoreTraces/index.cjs +4 -4
  509. package/dist/evals/scoreTraces/index.js +2 -2
  510. package/dist/events/index.cjs +2 -2
  511. package/dist/events/index.js +2 -2
  512. package/dist/events/pubsub.d.ts +1 -3
  513. package/dist/{run-registry-lLRc7EE6.cjs → execution-fence-CKFtgb2u.cjs} +13789 -9619
  514. package/dist/{run-registry-DhOKJtlb.js → execution-fence-DTrAehtv.js} +14769 -10677
  515. package/dist/harness/index.cjs +3 -3
  516. package/dist/harness/index.js +3 -3
  517. package/dist/index.cjs +1 -1
  518. package/dist/index.d.ts +1 -0
  519. package/dist/index.js +1 -1
  520. package/dist/integration/index.cjs +1 -1
  521. package/dist/integration/index.js +1 -1
  522. package/dist/knowledge/agent-scopes.d.ts +17 -0
  523. package/dist/knowledge/declarations.d.ts +2 -0
  524. package/dist/knowledge/held-scopes-state-processor.d.ts +50 -0
  525. package/dist/knowledge/importers/overlay.d.ts +170 -0
  526. package/dist/knowledge/importers/sink.d.ts +17 -1
  527. package/dist/knowledge/importers/types.d.ts +16 -0
  528. package/dist/knowledge/index.cjs +2156 -290
  529. package/dist/knowledge/index.d.ts +18 -2
  530. package/dist/knowledge/index.js +2043 -179
  531. package/dist/knowledge/links.d.ts +27 -0
  532. package/dist/knowledge/page-tools.d.ts +25 -0
  533. package/dist/knowledge/pinned-state-processor.d.ts +2 -2
  534. package/dist/knowledge/run.d.ts +5 -0
  535. package/dist/knowledge/scope-runtime.d.ts +6 -0
  536. package/dist/llm/index.cjs +3 -3
  537. package/dist/llm/index.js +3 -3
  538. package/dist/llm/model/base.types.d.ts +3 -1
  539. package/dist/llm/model/gateways/opencode-session-header.d.ts +28 -0
  540. package/dist/llm/model/mastra-gateway-provider-tools.d.ts +9 -6
  541. package/dist/llm/model/model.d.ts +1 -1
  542. package/dist/llm/model/model.loop.d.ts +1 -1
  543. package/dist/llm/model/model.loop.types.d.ts +3 -1
  544. package/dist/llm/model/provider-options.d.ts +4 -3
  545. package/dist/llm/model/provider-types.generated.d.ts +7184 -7514
  546. package/dist/llm/model/resolve-model.d.ts +1 -0
  547. package/dist/llm/model/shared.types.d.ts +1 -0
  548. package/dist/llm/reasoning/anthropic-thinking.d.ts +5 -0
  549. package/dist/llm/reasoning/gemini-thinking.d.ts +24 -0
  550. package/dist/llm/reasoning/index.cjs +389 -0
  551. package/dist/llm/reasoning/index.d.ts +8 -0
  552. package/dist/llm/reasoning/index.js +362 -0
  553. package/dist/llm/reasoning/model-fallback.d.ts +75 -0
  554. package/dist/llm/reasoning/model-ids.d.ts +5 -0
  555. package/dist/llm/reasoning/thinking-provider-options.d.ts +10 -0
  556. package/dist/llm/reasoning/thinking-request.d.ts +14 -0
  557. package/dist/llm/reasoning/thinking.d.ts +37 -0
  558. package/dist/{llm-B46V7Mi7.js → llm-B6EYEbYf.js} +68 -90
  559. package/dist/{llm-B4AeSFvV.cjs → llm-P6sWWNc6.cjs} +68 -90
  560. package/dist/loop/index.cjs +15 -15
  561. package/dist/loop/index.js +2 -2
  562. package/dist/loop/loop-runtime.d.ts +1 -1
  563. package/dist/loop/server.cjs +1 -1
  564. package/dist/loop/server.js +1 -1
  565. package/dist/loop/shared/signal-outcome.d.ts +1 -1
  566. package/dist/loop/shared/steps/signal-drain-core.d.ts +9 -3
  567. package/dist/{manager-BRAvwB9b.js → manager-BvnXZAFj.js} +112 -39
  568. package/dist/{manager-BwDxA1Nn.cjs → manager-tQrH4_MZ.cjs} +124 -51
  569. package/dist/mastra/index.cjs +1 -1
  570. package/dist/mastra/index.d.ts +35 -4
  571. package/dist/mastra/index.js +1 -1
  572. package/dist/{mastra-CIx6qEq2.js → mastra-BhPympcg.js} +84 -28
  573. package/dist/{mastra-DBhdD172.cjs → mastra-CtL0diD6.cjs} +124 -68
  574. package/dist/memory/index.cjs +25 -25
  575. package/dist/memory/index.js +3 -3
  576. package/dist/memory/mock.d.ts +2 -3
  577. package/dist/memory/om-events/index.cjs +189 -0
  578. package/dist/memory/om-events/index.d.ts +17 -0
  579. package/dist/memory/om-events/index.js +188 -0
  580. package/dist/{message-list-DfN9mWeN.cjs → message-list-C0F2sDNC.cjs} +233 -131
  581. package/dist/{message-list-wI71UGxk.js → message-list-RgFlLrxG.js} +233 -131
  582. package/dist/{model-CYhAa5qO.cjs → model-Cy0Z_3FQ.cjs} +5 -4
  583. package/dist/{model-CJMsDU8w.js → model-D2XwLRQi.js} +5 -4
  584. package/dist/{netlify-Bw7Vd58y.cjs → netlify-DgHrsLpJ.cjs} +41446 -30449
  585. package/dist/{netlify-C9aJA6Cv.js → netlify-d2fyniAS.js} +31257 -20278
  586. package/dist/notifications/index.cjs +18 -18
  587. package/dist/notifications/index.js +2 -2
  588. package/dist/observability/index.cjs +1 -1
  589. package/dist/observability/index.js +1 -1
  590. package/dist/observability/types/tracing.d.ts +1 -1
  591. package/dist/{observability-D7RNOAPx.js → observability-DPDWibyH.js} +648 -648
  592. package/dist/{output-helpers-DgsH4aTb.cjs → output-helpers-By5FbLpp.cjs} +71 -73
  593. package/dist/{output-helpers-CVzhy1Y0.js → output-helpers-k2-48ssH.js} +72 -74
  594. package/dist/processor-provider/index.cjs +10 -10
  595. package/dist/processor-provider/index.js +1 -1
  596. package/dist/processors/index.cjs +65 -65
  597. package/dist/processors/index.js +2 -2
  598. package/dist/processors/processors/tool-search.d.ts +2 -2
  599. package/dist/processors/runner.d.ts +12 -0
  600. package/dist/{provider-registry-DOfYSEju.js → provider-registry-B9UP28b4.js} +20113 -21015
  601. package/dist/{provider-registry-Bn_7VvZ8.cjs → provider-registry-Brcz84P1.cjs} +20113 -21015
  602. package/dist/provider-registry.json +21135 -22118
  603. package/dist/{registry-generator-Cw594Ttt.js → registry-generator-BDZrKvMb.js} +1 -1
  604. package/dist/{registry-generator-BnK5Npgr.cjs → registry-generator-DSvbAYar.cjs} +1 -1
  605. package/dist/{rehydrate-Dgqkw7Py.js → rehydrate-Cme19iOk.js} +2 -2
  606. package/dist/{rehydrate-BWnd_TEx.cjs → rehydrate-vAlkgCKL.cjs} +14 -14
  607. package/dist/relevance/index.cjs +3 -3
  608. package/dist/relevance/index.js +2 -2
  609. package/dist/{scheduler-B-VZUvv_.js → scheduler-0ShtMM1I.js} +71 -21
  610. package/dist/{scheduler-D00X03jQ.cjs → scheduler-CMjK0LoQ.cjs} +82 -20
  611. package/dist/server/types.d.ts +6 -0
  612. package/dist/{signal-provider-BslnAjWG.js → signal-provider-B_mfW-J4.js} +1 -1
  613. package/dist/{signal-provider-BFAvh_AJ.cjs → signal-provider-D9gbevHN.cjs} +1 -1
  614. package/dist/signals/index.cjs +4 -3
  615. package/dist/signals/index.d.ts +1 -0
  616. package/dist/signals/index.js +4 -4
  617. package/dist/signals/time-signal-provider.d.ts +70 -0
  618. package/dist/signals-BwDXGqxc.cjs +358 -0
  619. package/dist/signals-TznxWfM3.js +347 -0
  620. package/dist/skills/create-skill.d.ts +3 -0
  621. package/dist/skills/index.cjs +1 -1
  622. package/dist/skills/index.js +1 -1
  623. package/dist/skills/inline-skill-source.d.ts +5 -1
  624. package/dist/skills/types.d.ts +16 -1
  625. package/dist/{source-fNa6u1kH.js → source-B3He4_mz.js} +7 -0
  626. package/dist/{source-BVOi8Xhp.cjs → source-C_nWbqI0.cjs} +7 -0
  627. package/dist/{state-processor-B9kxpM53.js → state-processor-B_KsS82m.js} +1 -1
  628. package/dist/{state-processor-kRNZ38Nf.cjs → state-processor-DaSmhVUX.cjs} +1 -1
  629. package/dist/storage/constants.cjs +1 -1
  630. package/dist/storage/constants.js +1 -1
  631. package/dist/storage/domains/agents/index.cjs +1 -1
  632. package/dist/storage/domains/agents/index.js +1 -1
  633. package/dist/storage/domains/inmemory-db.d.ts +6 -0
  634. package/dist/storage/domains/knowledge/base.d.ts +155 -5
  635. package/dist/storage/domains/knowledge/importers-inmemory.d.ts +10 -0
  636. package/dist/storage/domains/knowledge/importers.d.ts +39 -0
  637. package/dist/storage/domains/knowledge/inmemory.d.ts +12 -0
  638. package/dist/storage/domains/knowledge/pages-inmemory.d.ts +54 -12
  639. package/dist/storage/domains/knowledge/pages.d.ts +90 -1
  640. package/dist/storage/domains/memory/base.d.ts +117 -0
  641. package/dist/storage/domains/memory/index.d.ts +1 -0
  642. package/dist/storage/domains/memory/inmemory.d.ts +39 -0
  643. package/dist/storage/domains/memory/queue-thread.d.ts +42 -0
  644. package/dist/storage/domains/schedules/base.d.ts +31 -2
  645. package/dist/storage/domains/schedules/inmemory.d.ts +9 -2
  646. package/dist/storage/domains/workflows/base.d.ts +32 -5
  647. package/dist/storage/domains/workflows/inmemory.d.ts +7 -6
  648. package/dist/storage/domains/workflows/journal.d.ts +16 -1
  649. package/dist/storage/index.cjs +192 -186
  650. package/dist/storage/index.js +6 -6
  651. package/dist/storage/types.d.ts +14 -0
  652. package/dist/storage/workflow-snapshot.d.ts +4 -0
  653. package/dist/storage/workflow-step-guard.d.ts +5 -0
  654. package/dist/stream/base/output.d.ts +8 -0
  655. package/dist/stream/index.cjs +2 -2
  656. package/dist/stream/index.js +2 -2
  657. package/dist/{stream-BIDts1fZ.cjs → stream-B9y9VYqr.cjs} +179 -22
  658. package/dist/{stream-C8HKG3qC.js → stream-DSVk0bct.js} +138 -23
  659. package/dist/telemetry/index.cjs +1 -1
  660. package/dist/telemetry/index.js +1 -1
  661. package/dist/test-utils/llm-mock.cjs +1 -1
  662. package/dist/test-utils/llm-mock.js +1 -1
  663. package/dist/{to-prompt-B9eZo2U5.cjs → to-prompt-CG-LyaBY.cjs} +9 -0
  664. package/dist/{to-prompt-BsDtVXrf.js → to-prompt-CMlVGYxC.js} +9 -0
  665. package/dist/{tool-Z3bykc1m.js → tool-DIFduuTw.js} +2 -5
  666. package/dist/{tool-CYlT2UA-.cjs → tool-Dn9WSDVn.cjs} +2 -5
  667. package/dist/tool-loop-agent/index.cjs +1 -1
  668. package/dist/tool-loop-agent/index.js +1 -1
  669. package/dist/{tool-loop-agent-PEY5a1R6.cjs → tool-loop-agent-C3wj9NhP.cjs} +5 -5
  670. package/dist/{tool-loop-agent-DM5V_0XS.js → tool-loop-agent-e2Bi-mrf.js} +4 -4
  671. package/dist/{toolchecks-DrsZdc3S.js → toolchecks-CRAfUe9H.js} +1 -1
  672. package/dist/{toolchecks-MFU48cit.cjs → toolchecks-DbBsQGHW.cjs} +1 -1
  673. package/dist/tools/code-mode/index.d.ts +2 -0
  674. package/dist/tools/code-mode/log-collector.d.ts +49 -0
  675. package/dist/tools/code-mode/types.d.ts +71 -0
  676. package/dist/tools/index.cjs +7 -5
  677. package/dist/tools/index.d.ts +1 -0
  678. package/dist/tools/index.js +6 -6
  679. package/dist/tools/is-vercel-tool.cjs +1 -1
  680. package/dist/tools/is-vercel-tool.js +1 -1
  681. package/dist/tools/tool.d.ts +2 -4
  682. package/dist/tools/types.d.ts +1 -0
  683. package/dist/{tools-CGF5Ik6j.cjs → tools-C2q0ougI.cjs} +430 -62
  684. package/dist/{tools-CDfyMpzN.js → tools-ybbz1YKg.js} +419 -63
  685. package/dist/{utils-CxMSu_wc.cjs → utils-B87rm4F-.cjs} +12 -10
  686. package/dist/{utils-DcnKVK34.js → utils-DCDsj1CG.js} +12 -10
  687. package/dist/utils.cjs +3 -3
  688. package/dist/utils.js +3 -3
  689. package/dist/{validate-RVKgazCf.cjs → validate-XPZLQRoc.cjs} +1 -1
  690. package/dist/{validate-Dn750ciE.js → validate-_e8OoEh5.js} +1 -1
  691. package/dist/vector/index.cjs +9 -9
  692. package/dist/vector/index.js +2 -2
  693. package/dist/worker/index.cjs +1 -1
  694. package/dist/worker/index.js +1 -1
  695. package/dist/worker/workers/orchestration-worker.d.ts +1 -0
  696. package/dist/{worker-SDi9jbP5.js → worker-BAstsOqw.js} +12 -7
  697. package/dist/{worker-CFPu9qwV.cjs → worker-CGWclXz3.cjs} +25 -14
  698. package/dist/{worker-DJPAdazC.js → worker-DvI9J9Qw.js} +2 -2
  699. package/dist/{worker-Dx0ZHMGX.cjs → worker-DzMDk--h.cjs} +3 -3
  700. package/dist/{workflow-ZFOz_365.cjs → workflow-BFF2mNDa.cjs} +30 -38
  701. package/dist/{workflow-DkBqNn7X.js → workflow-DcpI9eNC.js} +26 -34
  702. package/dist/workflows/builder/index.cjs +1 -1
  703. package/dist/workflows/builder/index.js +1 -1
  704. package/dist/workflows/evented/execution-engine.d.ts +3 -1
  705. package/dist/workflows/evented/index.cjs +10 -10
  706. package/dist/workflows/evented/index.js +1 -1
  707. package/dist/workflows/evented/setup-warning.d.ts +11 -0
  708. package/dist/workflows/evented/workflow-event-processor/index.d.ts +10 -4
  709. package/dist/workflows/evented/workflow-event-processor/loop.d.ts +1 -1
  710. package/dist/workflows/evented/workflow-event-processor/parallel.d.ts +2 -2
  711. package/dist/workflows/evented/workflow-event-processor/sleep.d.ts +2 -2
  712. package/dist/workflows/evented/workflow.d.ts +8 -3
  713. package/dist/workflows/handlers/entry.d.ts +8 -0
  714. package/dist/workflows/index.cjs +57 -55
  715. package/dist/workflows/index.js +6 -6
  716. package/dist/workflows/run-storage.d.ts +27 -3
  717. package/dist/workflows/scheduler/claim.d.ts +51 -0
  718. package/dist/workflows/scheduler/index.d.ts +2 -0
  719. package/dist/workflows/step.d.ts +2 -0
  720. package/dist/workflows/types.d.ts +16 -0
  721. package/dist/workflows/workflow.d.ts +90 -11
  722. package/dist/workspace/filesystem/local-filesystem.d.ts +13 -0
  723. package/dist/workspace/index.cjs +3 -1
  724. package/dist/workspace/index.d.ts +1 -1
  725. package/dist/workspace/index.js +2 -2
  726. package/dist/workspace/lsp/manager.d.ts +19 -4
  727. package/dist/workspace/sandbox/local-sandbox.d.ts +11 -0
  728. package/dist/workspace/sandbox/mastra-sandbox.d.ts +17 -0
  729. package/dist/workspace/sandbox/sandbox.d.ts +2 -0
  730. package/dist/workspace/sandbox/teardown-context.d.ts +74 -0
  731. package/dist/workspace/tools/index.d.ts +1 -0
  732. package/dist/workspace/tools/media.d.ts +20 -1
  733. package/dist/workspace/tools/recreate-sandbox.d.ts +24 -0
  734. package/dist/{workspace-X2RHJZU9.cjs → workspace-BQD4tcQi.cjs} +614 -135
  735. package/dist/{workspace-DY2Nxiyi.js → workspace-sqcfdZRR.js} +602 -135
  736. package/llm/reasoning.d.ts +1 -0
  737. package/memory/om-events.d.ts +1 -0
  738. package/package.json +29 -8
  739. package/skills/mastra/SKILL.md +171 -0
  740. package/skills/mastra/references/common-errors.md +557 -0
  741. package/skills/mastra/references/core-concepts.md +21 -0
  742. package/skills/mastra/references/create-mastra.md +233 -0
  743. package/skills/mastra/references/embedded-docs.md +103 -0
  744. package/skills/mastra/references/feedback.md +69 -0
  745. package/skills/mastra/references/gateway.md +66 -0
  746. package/skills/mastra/references/mastra-api.md +222 -0
  747. package/skills/mastra/references/migration-guide.md +185 -0
  748. package/skills/mastra/references/model-selection.md +29 -0
  749. package/skills/mastra/references/platform.md +164 -0
  750. package/skills/mastra/references/remote-docs.md +193 -0
  751. package/skills/mastra/references/trace-query.md +150 -0
  752. package/skills/mastra/scripts/provider-registry.mjs +271 -0
  753. package/src/llm/model/provider-types.generated.d.ts +7184 -7514
  754. package/dist/capabilities/ai21.json +0 -4
  755. package/dist/capabilities/clarifai.json +0 -42
  756. package/dist/capabilities/jad-ai.json +0 -20
  757. package/dist/capabilities/llmtech.json +0 -16
  758. package/dist/signals-B1JSj-Ew.cjs +0 -58
  759. package/dist/signals-De9VnwL2.js +0 -53
  760. package/dist/{observability-B0R_D1PZ.cjs → observability-VaoaeadK.cjs} +647 -647
@@ -1,6 +1,17 @@
1
1
  import { t as EntityType } from "./storage-Cc50aQAp.js";
2
2
  import { a as getOrCreateSpan } from "./utils-DU_pU5SK.js";
3
3
  import { z } from "zod/v4";
4
+ // src/observability/types/core.ts
5
+ /**
6
+ * Sampling strategy types
7
+ */
8
+ let SamplingStrategyType = /* @__PURE__ */ function(SamplingStrategyType) {
9
+ SamplingStrategyType["ALWAYS"] = "always";
10
+ SamplingStrategyType["NEVER"] = "never";
11
+ SamplingStrategyType["RATIO"] = "ratio";
12
+ SamplingStrategyType["CUSTOM"] = "custom";
13
+ return SamplingStrategyType;
14
+ }({});
4
15
  // src/observability/types/outcome.ts
5
16
  /** An individual execution's result, reported by its runtime (OBS-724). */
6
17
  const SPAN_OUTCOMES = [
@@ -33,671 +44,134 @@ const SPAN_STOP_REASONS = {
33
44
  authentication: true,
34
45
  authorization: true
35
46
  };
36
- // src/observability/outcome-schema.ts
37
- const label = z.string().max(128).optional();
38
- const reason = z.enum(Object.keys(SPAN_STOP_REASONS));
39
- const failure = {
40
- provider: label,
41
- errorCode: label,
42
- retryable: z.boolean().optional()
43
- };
44
- const cause = {
45
- causeOutcome: z.enum(SPAN_OUTCOMES).optional(),
46
- causeStopReason: reason.optional()
47
+ // src/observability/no-op.ts
48
+ const noOpCounter = { add() {} };
49
+ const noOpGauge = { set() {} };
50
+ const noOpHistogram = { record() {} };
51
+ /**
52
+ * No-op tracing context used when observability is not configured.
53
+ */
54
+ const noOpTracingContext = { currentSpan: void 0 };
55
+ /**
56
+ * No-op logger context that silently discards all log calls.
57
+ * Used when observability is not configured.
58
+ */
59
+ const noOpLoggerContext = {
60
+ debug() {},
61
+ info() {},
62
+ warn() {},
63
+ error() {},
64
+ fatal() {}
47
65
  };
48
- const contexts = {
49
- max_steps: z.strictObject({
50
- maxSteps: z.number().optional(),
51
- completedSteps: z.number().optional()
52
- }),
53
- max_tokens: z.strictObject({ maxTokens: z.number().optional() }),
54
- timeout: z.strictObject({
55
- timeoutMs: z.number().optional(),
56
- timeoutType: z.enum([
57
- "step",
58
- "total",
59
- "firstChunk"
60
- ]).optional()
61
- }),
62
- runtime_error: z.strictObject(failure),
63
- model_error: z.strictObject(failure),
64
- caller_cancelled: z.strictObject({}),
65
- observer_failed: z.strictObject({
66
- observerSpanId: label,
67
- ...cause
68
- }),
69
- context_window_exceeded: z.strictObject({
70
- provider: label,
71
- errorCode: label,
72
- contextWindow: z.number().optional()
73
- }),
74
- guardrail: z.strictObject({ processorId: label }),
75
- content_filter: z.strictObject({ provider: label }),
76
- approval_required: z.strictObject({
77
- toolCallId: label,
78
- toolName: label
79
- }),
80
- signal_received: z.strictObject({
81
- signalId: label,
82
- signalType: z.enum([
83
- "user",
84
- "state",
85
- "reactive",
86
- "notification"
87
- ]).optional()
88
- }),
89
- stop_condition: z.strictObject({}),
90
- iteration_hook: z.strictObject({ feedbackCompleted: z.boolean().optional() }),
91
- delegation_bail: z.strictObject(cause),
92
- authentication: z.strictObject(failure),
93
- authorization: z.strictObject(failure)
66
+ /**
67
+ * No-op metrics context that silently discards all metric operations.
68
+ * Used when observability is not configured.
69
+ */
70
+ const noOpMetricsContext = {
71
+ emit() {},
72
+ counter() {
73
+ return noOpCounter;
74
+ },
75
+ gauge() {
76
+ return noOpGauge;
77
+ },
78
+ histogram() {
79
+ return noOpHistogram;
80
+ }
94
81
  };
95
- /** @internal Allowlist tooltip facts for framework producers, including untyped runtime inputs. */
96
- function compactStopReasonContext(stopReason, context) {
97
- if (!stopReason || !Object.hasOwn(contexts, stopReason) || !context || typeof context !== "object") return null;
98
- try {
99
- const result = {};
100
- for (const [key, schema] of Object.entries(contexts[stopReason].shape)) {
101
- const value = context[key];
102
- const parsed = schema.safeParse(value);
103
- if (parsed.success && parsed.data !== void 0) result[key] = parsed.data;
104
- }
105
- return Object.keys(result).length ? result : null;
106
- } catch {
82
+ /** No-op observability entrypoint that silently discards all operations. */
83
+ var NoOpObservability = class {
84
+ setMastraContext(_options) {}
85
+ setLogger(_options) {}
86
+ getSelectedInstance(_options) {}
87
+ async getRecordedTrace(_args) {
107
88
  return null;
108
89
  }
109
- }
110
- function termination(stopReason) {
111
- return z.object({
112
- outcome: z.enum(SPAN_OUTCOMES),
113
- stopReason: z.literal(stopReason),
114
- stopReasonContext: contexts[stopReason].nullish()
115
- });
116
- }
117
- z.union([...Object.keys(SPAN_STOP_REASONS).map(termination), z.object({
118
- outcome: z.enum(SPAN_OUTCOMES),
119
- stopReason: z.null().optional(),
120
- stopReasonContext: z.null().optional()
121
- })]);
122
- // src/observability/execution-outcome.ts
123
- /** Read a provider's structured code without inferring a cause from diagnostic text. */
124
- function providerFailureCode(value) {
125
- if (typeof value.code === "string") return value.code;
126
- let data = value.data;
127
- if (data == null && typeof value.responseBody === "string") try {
128
- data = JSON.parse(value.responseBody);
129
- } catch {
130
- return;
90
+ async addScore(_args) {}
91
+ async addFeedback(_args) {}
92
+ registerInstance(_name, _instance, _isDefault = false) {}
93
+ getInstance(_name) {}
94
+ getDefaultInstance() {}
95
+ listInstances() {
96
+ return /* @__PURE__ */ new Map();
131
97
  }
132
- if (!data || typeof data !== "object") return void 0;
133
- const record = data;
134
- const error = record.error && typeof record.error === "object" ? record.error : record;
135
- return typeof error.code === "string" ? error.code : void 0;
136
- }
137
- /** @internal Classify explicit failure facts, including wrapped/serialized causes. Never match error-message text. */
138
- function executionFailureTermination(error, layer = "runtime_error") {
139
- try {
140
- const termination = classifyExecutionFailure(error, layer);
141
- return {
142
- ...termination,
143
- stopReasonContext: compactStopReasonContext(termination.stopReason, termination.stopReasonContext)
144
- };
145
- } catch {
146
- return {
147
- outcome: "error",
148
- stopReason: layer
149
- };
98
+ unregisterInstance(_name) {
99
+ return false;
150
100
  }
151
- }
152
- function classifyExecutionFailure(error, layer) {
153
- const seen = /* @__PURE__ */ new Set();
154
- let current = error;
155
- let failure;
156
- let modelFailure = layer === "model_error";
157
- while (current && typeof current === "object" && !seen.has(current)) {
158
- seen.add(current);
159
- const value = current;
160
- if (value.status === "failed" && value.error && typeof value.error === "object") {
161
- current = value.error;
162
- continue;
163
- }
164
- if (value.name === "TripWire" && (value.processorId === void 0 || typeof value.processorId === "string") && value.options && typeof value.options === "object" && typeof value.message === "string") {
165
- const options = value.options;
166
- return tripwireTermination({
167
- processorId: value.processorId,
168
- reason: value.message,
169
- ...options
170
- });
171
- }
172
- failure = value;
173
- if (value.name === "MastraTimeoutError" && typeof value.timeoutMs === "number") return {
174
- outcome: "limit",
175
- stopReason: "timeout",
176
- stopReasonContext: {
177
- timeoutMs: value.timeoutMs,
178
- ...value.timeoutType === "step" || value.timeoutType === "total" || value.timeoutType === "firstChunk" ? { timeoutType: value.timeoutType } : {}
179
- }
180
- };
181
- if (value.name === "FGADeniedError") return {
182
- outcome: "blocked",
183
- stopReason: "authorization"
184
- };
185
- const apiError = value[Symbol.for("vercel.ai.error.AI_APICallError")] === true || value.name === "AI_APICallError";
186
- if (apiError) modelFailure = true;
187
- if (apiError && (value.statusCode === 401 || value.statusCode === 403)) return {
188
- outcome: "blocked",
189
- stopReason: value.statusCode === 401 ? "authentication" : "authorization",
190
- stopReasonContext: {
191
- errorCode: String(value.statusCode),
192
- provider: typeof value.provider === "string" ? value.provider : void 0
193
- }
194
- };
195
- if (apiError) {
196
- const errorCode = providerFailureCode(value);
197
- if (errorCode === "content_filter") return {
198
- outcome: "blocked",
199
- stopReason: "content_filter",
200
- stopReasonContext: { provider: typeof value.provider === "string" ? value.provider : void 0 }
201
- };
202
- if (errorCode === "context_length_exceeded" || errorCode === "context_window_exceeded") return {
203
- outcome: "limit",
204
- stopReason: "context_window_exceeded",
205
- stopReasonContext: { errorCode }
206
- };
207
- }
208
- current = value.cause;
101
+ hasInstance(_name) {
102
+ return false;
209
103
  }
104
+ setConfigSelector(_selector) {}
105
+ clear() {}
106
+ async flush() {}
107
+ async shutdown() {}
108
+ };
109
+ // src/observability/w3c.ts
110
+ /**
111
+ * W3C Trace Context `traceparent` parsing and formatting.
112
+ * @see https://www.w3.org/TR/trace-context/#traceparent-header
113
+ */
114
+ const TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;
115
+ /** Parses a W3C `traceparent`. Values that aren't strings, are malformed, or use all-zero IDs yield `null`. */
116
+ function parseTraceparent(value) {
117
+ if (typeof value !== "string") return null;
118
+ const match = TRACEPARENT_RE.exec(value.trim());
119
+ if (!match) return null;
120
+ const [, version, traceId, spanId, flags] = match;
121
+ if (version === "ff" || /^0+$/.test(traceId) || /^0+$/.test(spanId)) return null;
210
122
  return {
211
- outcome: "error",
212
- stopReason: modelFailure ? "model_error" : "runtime_error",
213
- stopReasonContext: {
214
- provider: typeof failure?.provider === "string" ? failure.provider : void 0,
215
- errorCode: typeof failure?.code === "string" ? failure.code : typeof failure?.id === "string" ? failure.id : void 0,
216
- retryable: typeof failure?.isRetryable === "boolean" ? failure.isRetryable : void 0
217
- }
218
- };
219
- }
220
- /** Link to the observer's diagnostics without copying its payload into the interrupted span. */
221
- function tripwireTermination(tripwire) {
222
- try {
223
- const metadata = tripwire?.metadata;
224
- const observer = metadata && typeof metadata === "object" && "observerFailure" in metadata ? metadata.observerFailure : void 0;
225
- if (observer && typeof observer === "object" && "cause" in observer && observer.cause && typeof observer.cause === "object") {
226
- const cause = observer.cause;
227
- if (SPAN_OUTCOMES.includes(cause.outcome) && cause.outcome !== "success" && cause.outcome !== "suspend") return {
228
- outcome: "interrupted",
229
- stopReason: "observer_failed",
230
- stopReasonContext: compactStopReasonContext("observer_failed", {
231
- observerSpanId: "observerSpanId" in observer ? observer.observerSpanId : void 0,
232
- causeOutcome: cause.outcome,
233
- causeStopReason: typeof cause.stopReason === "string" && Object.hasOwn(SPAN_STOP_REASONS, cause.stopReason) ? cause.stopReason : void 0
234
- })
235
- };
236
- }
237
- return {
238
- outcome: "blocked",
239
- stopReason: "guardrail",
240
- stopReasonContext: compactStopReasonContext("guardrail", { processorId: tripwire?.processorId })
241
- };
242
- } catch {
243
- return {
244
- outcome: "blocked",
245
- stopReason: "guardrail"
246
- };
247
- }
248
- }
249
- // src/loop/shared/execution-outcome.ts
250
- /**
251
- * @internal
252
- * Classify a settled agent loop using its runtime stop boundary. A provider
253
- * finish reason refines the result; it cannot establish successful execution
254
- * without a continuation decision. Call only after finish-time work succeeds.
255
- */
256
- function agentLoopTermination(input) {
257
- const { stopCause, finishReason, maxSteps, tripwire } = input;
258
- if (tripwire || finishReason === "tripwire") return tripwireTermination(tripwire);
259
- if (finishReason === "suspended") {
260
- const suspension = input.suspension;
261
- if (suspension?.approvalRequired) return {
262
- outcome: "suspend",
263
- stopReason: "approval_required",
264
- stopReasonContext: compactStopReasonContext("approval_required", {
265
- toolCallId: suspension.toolCallId,
266
- toolName: suspension.toolName
267
- })
268
- };
269
- return {
270
- outcome: "suspend",
271
- stopReason: null,
272
- stopReasonContext: null
273
- };
274
- }
275
- if (finishReason === "length") return {
276
- outcome: "limit",
277
- stopReason: "max_tokens"
278
- };
279
- if (finishReason === "content-filter") return {
280
- outcome: "blocked",
281
- stopReason: "content_filter"
282
- };
283
- if (finishReason === "abort" || finishReason === "aborted") return {
284
- outcome: "abort",
285
- stopReason: "caller_cancelled"
286
- };
287
- if (finishReason === "error") return {
288
- outcome: "error",
289
- stopReason: "model_error"
290
- };
291
- switch (stopCause) {
292
- case "max_steps": return {
293
- outcome: "limit",
294
- stopReason: "max_steps",
295
- stopReasonContext: { maxSteps }
296
- };
297
- case "stop_condition": return {
298
- outcome: "success",
299
- stopReason: "stop_condition"
300
- };
301
- case "iteration_hook":
302
- case "feedback_complete": return {
303
- outcome: "success",
304
- stopReason: "iteration_hook",
305
- stopReasonContext: { feedbackCompleted: stopCause === "feedback_complete" }
306
- };
307
- case "delegation":
308
- if (input.delegationFailure) return {
309
- outcome: "interrupted",
310
- stopReason: "delegation_bail",
311
- stopReasonContext: {
312
- causeOutcome: input.delegationFailure.outcome,
313
- causeStopReason: input.delegationFailure.stopReason ?? void 0
314
- }
315
- };
316
- return {
317
- outcome: "success",
318
- stopReason: "delegation_bail"
319
- };
320
- case "model_finished": if (finishReason === "stop" || finishReason === "tool-calls") return {
321
- outcome: "success",
322
- stopReason: null,
323
- stopReasonContext: null
324
- };
325
- }
326
- return {
327
- outcome: "unknown",
328
- stopReason: null,
329
- stopReasonContext: null
123
+ version,
124
+ traceId,
125
+ spanId,
126
+ flags
330
127
  };
331
128
  }
332
- // src/observability/no-op.ts
333
- const noOpCounter = { add() {} };
334
- const noOpGauge = { set() {} };
335
- const noOpHistogram = { record() {} };
336
- /**
337
- * No-op tracing context used when observability is not configured.
338
- */
339
- const noOpTracingContext = { currentSpan: void 0 };
340
- /**
341
- * No-op logger context that silently discards all log calls.
342
- * Used when observability is not configured.
343
- */
344
- const noOpLoggerContext = {
345
- debug() {},
346
- info() {},
347
- warn() {},
348
- error() {},
349
- fatal() {}
350
- };
351
- /**
352
- * No-op metrics context that silently discards all metric operations.
353
- * Used when observability is not configured.
354
- */
355
- const noOpMetricsContext = {
356
- emit() {},
357
- counter() {
358
- return noOpCounter;
359
- },
360
- gauge() {
361
- return noOpGauge;
362
- },
363
- histogram() {
364
- return noOpHistogram;
365
- }
366
- };
367
- /** No-op observability entrypoint that silently discards all operations. */
368
- var NoOpObservability = class {
369
- setMastraContext(_options) {}
370
- setLogger(_options) {}
371
- getSelectedInstance(_options) {}
372
- async getRecordedTrace(_args) {
373
- return null;
374
- }
375
- async addScore(_args) {}
376
- async addFeedback(_args) {}
377
- registerInstance(_name, _instance, _isDefault = false) {}
378
- getInstance(_name) {}
379
- getDefaultInstance() {}
380
- listInstances() {
381
- return /* @__PURE__ */ new Map();
382
- }
383
- unregisterInstance(_name) {
384
- return false;
385
- }
386
- hasInstance(_name) {
387
- return false;
388
- }
389
- setConfigSelector(_selector) {}
390
- clear() {}
391
- async flush() {}
392
- async shutdown() {}
393
- };
394
- // src/observability/context-factory.ts
395
- /**
396
- * Derives a LoggerContext from the current span's ObservabilityInstance.
397
- * Falls back to no-op when there is no span or the instance doesn't support logging.
398
- */
399
- function deriveLoggerContext(tracing) {
400
- const span = tracing.currentSpan;
401
- return span?.observabilityInstance?.getLoggerContext?.(span) ?? noOpLoggerContext;
129
+ /** Formats a W3C `traceparent` for a span. */
130
+ function formatTraceparent(traceId, spanId, sampled) {
131
+ return `00-${traceId}-${spanId}-${sampled ? "01" : "00"}`;
402
132
  }
133
+ // src/observability/processor-span-record.ts
134
+ /** Phase names as they are shown to a reader. */
135
+ const PROCESSOR_PHASE_LABELS = {
136
+ input: "Input",
137
+ inputStep: "Input step",
138
+ llmRequest: "LLM request",
139
+ llmResponse: "LLM response",
140
+ outputStream: "Output stream",
141
+ outputResult: "Output result",
142
+ outputStep: "Output step",
143
+ toolResult: "Tool result",
144
+ requestError: "Request error"
145
+ };
403
146
  /**
404
- * Derives a MetricsContext from the current span's ObservabilityInstance.
405
- * Falls back to no-op when there is no span or the instance doesn't support metrics.
147
+ * The phase a processor span recorded, or `undefined` when it recorded none.
148
+ *
149
+ * Read from `attributes` rather than `spanType`, so a processor that retyped
150
+ * its span (`Processor.spanType`) still describes its payloads — the runner
151
+ * writes the same shapes either way. Spans stored before the attribute existed,
152
+ * and spans a newer version wrote with a phase this one does not know, return
153
+ * `undefined` and fall back to JSON.
406
154
  */
407
- function deriveMetricsContext(tracing) {
408
- const span = tracing.currentSpan;
409
- return span?.observabilityInstance?.getMetricsContext?.(span) ?? noOpMetricsContext;
155
+ function describeProcessorPhase(span) {
156
+ const phase = span.attributes?.processorPhase;
157
+ return typeof phase === "string" && Object.hasOwn(PROCESSOR_PHASE_LABELS, phase) ? phase : void 0;
410
158
  }
411
159
  /**
412
- * Creates an observability context with real or no-op implementations for
413
- * tracing, logging, and metrics.
414
- *
415
- * When a TracingContext with a current span is provided, the logger and metrics
416
- * contexts are derived from the span's ObservabilityInstance so that log entries
417
- * and metric data points are automatically correlated to the active trace.
160
+ * Tags a processor payload with the phase that recorded it.
418
161
  *
419
- * @param tracingContext - TracingContext with current span, or undefined for no-op
420
- * @returns ObservabilityContext with all three signals (tracing, logger, metrics)
162
+ * The payload itself is not validated, matching what `isSpanRecordOfType` and
163
+ * the other `describeSpan*` helpers already do: the typed view trusts that the
164
+ * producer for a phase wrote the shape core declares. Renderers guard each
165
+ * field they read, so a partially populated span shows what it has rather than
166
+ * losing the whole view to one unexpected value.
421
167
  */
422
- function createObservabilityContext(tracingContext) {
423
- const tracing = tracingContext ?? noOpTracingContext;
168
+ function describeProcessorPayload(span, data) {
169
+ const phase = describeProcessorPhase(span);
170
+ if (!phase || Object.keys(data).length === 0) return void 0;
424
171
  return {
425
- tracing,
426
- loggerVNext: deriveLoggerContext(tracing),
427
- metrics: deriveMetricsContext(tracing),
428
- tracingContext: tracing
429
- };
430
- }
431
- /**
432
- * Resolves a partial observability context (from execute params) into a
433
- * complete ObservabilityContext with no-op defaults for any missing fields.
434
- *
435
- * Explicitly provided logger/metrics contexts are preserved (e.g. when set
436
- * upstream). When missing, they are derived from the tracing context's span,
437
- * following the same derivation logic as createObservabilityContext().
438
- *
439
- * @param partial - Partial context from ExecuteFunctionParams
440
- * @returns Complete ObservabilityContext
441
- */
442
- function resolveObservabilityContext(partial) {
443
- const tracing = partial.tracing ?? partial.tracingContext ?? noOpTracingContext;
444
- return {
445
- tracing,
446
- loggerVNext: partial.loggerVNext ?? deriveLoggerContext(tracing),
447
- metrics: partial.metrics ?? deriveMetricsContext(tracing),
448
- tracingContext: tracing
449
- };
450
- }
451
- // src/observability/context.ts
452
- const AGENT_GETTERS = ["getAgent", "getAgentById"];
453
- const AGENT_METHODS_TO_WRAP = [
454
- "generate",
455
- "stream",
456
- "generateLegacy",
457
- "streamLegacy"
458
- ];
459
- const WORKFLOW_GETTERS = ["getWorkflow", "getWorkflowById"];
460
- const WORKFLOW_METHODS_TO_WRAP = [
461
- "execute",
462
- "createRun",
463
- "createRun"
464
- ];
465
- /**
466
- * Maps a tracing proxy back to the instance it wraps. `wrapMastra` returns a
467
- * Proxy that forwards property reads but is a distinct object identity from its
468
- * target, so identity-sensitive lookups keyed on the Mastra instance would treat
469
- * the proxy as a different Mastra. Cycles are impossible: a proxy's recorded
470
- * target always existed before the proxy was created.
471
- */
472
- const tracingProxyTargets = /* @__PURE__ */ new WeakMap();
473
- /**
474
- * Helper function to detect NoOp spans to avoid unnecessary wrapping
475
- */
476
- function isNoOpSpan(span) {
477
- return span.constructor.name === "NoOpSpan" || span.__isNoOp === true;
478
- }
479
- /**
480
- * Checks to see if a passed object is an actual instance of Mastra
481
- * (for the purposes of wrapping it for Tracing)
482
- */
483
- function isMastra(mastra) {
484
- const hasAgentGetters = AGENT_GETTERS.every((method) => typeof mastra?.[method] === "function");
485
- const hasWorkflowGetters = WORKFLOW_GETTERS.every((method) => typeof mastra?.[method] === "function");
486
- return hasAgentGetters && hasWorkflowGetters;
487
- }
488
- /**
489
- * Creates a tracing-aware Mastra proxy that automatically injects
490
- * tracing context into agent and workflow method calls
491
- */
492
- function wrapMastra(mastra, tracingContext) {
493
- if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return mastra;
494
- if (!isMastra(mastra)) return mastra;
495
- try {
496
- const proxy = new Proxy(mastra, { get(target, prop) {
497
- try {
498
- if (AGENT_GETTERS.includes(prop)) return (...args) => {
499
- return wrapAgent(target[prop](...args), tracingContext);
500
- };
501
- if (WORKFLOW_GETTERS.includes(prop)) return (...args) => {
502
- return wrapWorkflow(target[prop](...args), tracingContext);
503
- };
504
- const value = target[prop];
505
- return typeof value === "function" ? value.bind(target) : value;
506
- } catch (error) {
507
- console.warn("Tracing: Failed to wrap method, falling back to original", error);
508
- const value = target[prop];
509
- return typeof value === "function" ? value.bind(target) : value;
510
- }
511
- } });
512
- tracingProxyTargets.set(proxy, mastra);
513
- return proxy;
514
- } catch (error) {
515
- console.warn("Tracing: Failed to create proxy, using original Mastra instance", error);
516
- return mastra;
517
- }
518
- }
519
- /**
520
- * Resolve a tracing proxy back to the underlying instance. Returns the argument
521
- * unchanged when it is not a proxy this module created. Transitive: a tool
522
- * executed inside a traced workflow step receives an already-wrapped mastra and
523
- * `tools/tool-builder/builder.ts` wraps it again, so nesting is real.
524
- */
525
- function unwrapMastraTracingProxy(mastra) {
526
- let current = mastra;
527
- let target = tracingProxyTargets.get(current);
528
- while (target) {
529
- current = target;
530
- target = tracingProxyTargets.get(current);
531
- }
532
- return current;
533
- }
534
- /**
535
- * Creates a tracing-aware Agent proxy that automatically injects
536
- * tracing context into generation method calls
537
- */
538
- function wrapAgent(agent, tracingContext) {
539
- if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return agent;
540
- try {
541
- return new Proxy(agent, { get(target, prop) {
542
- try {
543
- if (AGENT_METHODS_TO_WRAP.includes(prop)) return (input, options = {}) => {
544
- return target[prop](input, {
545
- ...options,
546
- ...createObservabilityContext(tracingContext)
547
- });
548
- };
549
- const value = target[prop];
550
- return typeof value === "function" ? value.bind(target) : value;
551
- } catch (error) {
552
- console.warn("Tracing: Failed to wrap agent method, falling back to original", error);
553
- const value = target[prop];
554
- return typeof value === "function" ? value.bind(target) : value;
555
- }
556
- } });
557
- } catch (error) {
558
- console.warn("Tracing: Failed to create agent proxy, using original instance", error);
559
- return agent;
560
- }
561
- }
562
- /**
563
- * Creates a tracing-aware Workflow proxy that automatically injects
564
- * tracing context into execution method calls
565
- */
566
- function wrapWorkflow(workflow, tracingContext) {
567
- if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return workflow;
568
- try {
569
- return new Proxy(workflow, { get(target, prop) {
570
- try {
571
- if (WORKFLOW_METHODS_TO_WRAP.includes(prop)) {
572
- if (prop === "createRun" || prop === "createRun") return async (options = {}) => {
573
- const run = await target[prop](options);
574
- return run ? wrapRun(run, tracingContext) : run;
575
- };
576
- return (input, options = {}) => {
577
- return target[prop](input, {
578
- ...options,
579
- ...createObservabilityContext(tracingContext)
580
- });
581
- };
582
- }
583
- const value = target[prop];
584
- return typeof value === "function" ? value.bind(target) : value;
585
- } catch (error) {
586
- console.warn("Tracing: Failed to wrap workflow method, falling back to original", error);
587
- const value = target[prop];
588
- return typeof value === "function" ? value.bind(target) : value;
589
- }
590
- } });
591
- } catch (error) {
592
- console.warn("Tracing: Failed to create workflow proxy, using original instance", error);
593
- return workflow;
594
- }
595
- }
596
- /**
597
- * Creates a tracing-aware Run proxy that automatically injects
598
- * tracing context into start method calls
599
- */
600
- function wrapRun(run, tracingContext) {
601
- if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return run;
602
- try {
603
- return new Proxy(run, { get(target, prop) {
604
- try {
605
- if (prop === "start") return (startOptions = {}) => {
606
- return target.start({
607
- ...startOptions,
608
- ...createObservabilityContext(startOptions.tracingContext ?? tracingContext)
609
- });
610
- };
611
- const value = target[prop];
612
- return typeof value === "function" ? value.bind(target) : value;
613
- } catch (error) {
614
- console.warn("Tracing: Failed to wrap run method, falling back to original", error);
615
- const value = target[prop];
616
- return typeof value === "function" ? value.bind(target) : value;
617
- }
618
- } });
619
- } catch (error) {
620
- console.warn("Tracing: Failed to create run proxy, using original instance", error);
621
- return run;
622
- }
623
- }
624
- // src/observability/types/core.ts
625
- /**
626
- * Sampling strategy types
627
- */
628
- let SamplingStrategyType = /* @__PURE__ */ function(SamplingStrategyType) {
629
- SamplingStrategyType["ALWAYS"] = "always";
630
- SamplingStrategyType["NEVER"] = "never";
631
- SamplingStrategyType["RATIO"] = "ratio";
632
- SamplingStrategyType["CUSTOM"] = "custom";
633
- return SamplingStrategyType;
634
- }({});
635
- // src/observability/w3c.ts
636
- /**
637
- * W3C Trace Context `traceparent` parsing and formatting.
638
- * @see https://www.w3.org/TR/trace-context/#traceparent-header
639
- */
640
- const TRACEPARENT_RE = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/;
641
- /** Parses a W3C `traceparent`. Values that aren't strings, are malformed, or use all-zero IDs yield `null`. */
642
- function parseTraceparent(value) {
643
- if (typeof value !== "string") return null;
644
- const match = TRACEPARENT_RE.exec(value.trim());
645
- if (!match) return null;
646
- const [, version, traceId, spanId, flags] = match;
647
- if (version === "ff" || /^0+$/.test(traceId) || /^0+$/.test(spanId)) return null;
648
- return {
649
- version,
650
- traceId,
651
- spanId,
652
- flags
653
- };
654
- }
655
- /** Formats a W3C `traceparent` for a span. */
656
- function formatTraceparent(traceId, spanId, sampled) {
657
- return `00-${traceId}-${spanId}-${sampled ? "01" : "00"}`;
658
- }
659
- // src/observability/processor-span-record.ts
660
- /** Phase names as they are shown to a reader. */
661
- const PROCESSOR_PHASE_LABELS = {
662
- input: "Input",
663
- inputStep: "Input step",
664
- llmRequest: "LLM request",
665
- llmResponse: "LLM response",
666
- outputStream: "Output stream",
667
- outputResult: "Output result",
668
- outputStep: "Output step",
669
- toolResult: "Tool result",
670
- requestError: "Request error"
671
- };
672
- /**
673
- * The phase a processor span recorded, or `undefined` when it recorded none.
674
- *
675
- * Read from `attributes` rather than `spanType`, so a processor that retyped
676
- * its span (`Processor.spanType`) still describes its payloads — the runner
677
- * writes the same shapes either way. Spans stored before the attribute existed,
678
- * and spans a newer version wrote with a phase this one does not know, return
679
- * `undefined` and fall back to JSON.
680
- */
681
- function describeProcessorPhase(span) {
682
- const phase = span.attributes?.processorPhase;
683
- return typeof phase === "string" && Object.hasOwn(PROCESSOR_PHASE_LABELS, phase) ? phase : void 0;
684
- }
685
- /**
686
- * Tags a processor payload with the phase that recorded it.
687
- *
688
- * The payload itself is not validated, matching what `isSpanRecordOfType` and
689
- * the other `describeSpan*` helpers already do: the typed view trusts that the
690
- * producer for a phase wrote the shape core declares. Renderers guard each
691
- * field they read, so a partially populated span shows what it has rather than
692
- * losing the whole view to one unexpected value.
693
- */
694
- function describeProcessorPayload(span, data) {
695
- const phase = describeProcessorPhase(span);
696
- if (!phase || Object.keys(data).length === 0) return void 0;
697
- return {
698
- phase,
699
- phaseLabel: PROCESSOR_PHASE_LABELS[phase],
700
- data
172
+ phase,
173
+ phaseLabel: PROCESSOR_PHASE_LABELS[phase],
174
+ data
701
175
  };
702
176
  }
703
177
  /** The `input` a processor span recorded, tagged by the phase that produced it. */
@@ -915,6 +389,236 @@ const isSpanErrorInfo = (value) => isRecord(value) && typeof value.message === "
915
389
  function describeSpanError(span) {
916
390
  return isSpanErrorInfo(span.error) ? span.error : void 0;
917
391
  }
392
+ // src/observability/context-factory.ts
393
+ /**
394
+ * Derives a LoggerContext from the current span's ObservabilityInstance.
395
+ * Falls back to no-op when there is no span or the instance doesn't support logging.
396
+ */
397
+ function deriveLoggerContext(tracing) {
398
+ const span = tracing.currentSpan;
399
+ return span?.observabilityInstance?.getLoggerContext?.(span) ?? noOpLoggerContext;
400
+ }
401
+ /**
402
+ * Derives a MetricsContext from the current span's ObservabilityInstance.
403
+ * Falls back to no-op when there is no span or the instance doesn't support metrics.
404
+ */
405
+ function deriveMetricsContext(tracing) {
406
+ const span = tracing.currentSpan;
407
+ return span?.observabilityInstance?.getMetricsContext?.(span) ?? noOpMetricsContext;
408
+ }
409
+ /**
410
+ * Creates an observability context with real or no-op implementations for
411
+ * tracing, logging, and metrics.
412
+ *
413
+ * When a TracingContext with a current span is provided, the logger and metrics
414
+ * contexts are derived from the span's ObservabilityInstance so that log entries
415
+ * and metric data points are automatically correlated to the active trace.
416
+ *
417
+ * @param tracingContext - TracingContext with current span, or undefined for no-op
418
+ * @returns ObservabilityContext with all three signals (tracing, logger, metrics)
419
+ */
420
+ function createObservabilityContext(tracingContext) {
421
+ const tracing = tracingContext ?? noOpTracingContext;
422
+ return {
423
+ tracing,
424
+ loggerVNext: deriveLoggerContext(tracing),
425
+ metrics: deriveMetricsContext(tracing),
426
+ tracingContext: tracing
427
+ };
428
+ }
429
+ /**
430
+ * Resolves a partial observability context (from execute params) into a
431
+ * complete ObservabilityContext with no-op defaults for any missing fields.
432
+ *
433
+ * Explicitly provided logger/metrics contexts are preserved (e.g. when set
434
+ * upstream). When missing, they are derived from the tracing context's span,
435
+ * following the same derivation logic as createObservabilityContext().
436
+ *
437
+ * @param partial - Partial context from ExecuteFunctionParams
438
+ * @returns Complete ObservabilityContext
439
+ */
440
+ function resolveObservabilityContext(partial) {
441
+ const tracing = partial.tracing ?? partial.tracingContext ?? noOpTracingContext;
442
+ return {
443
+ tracing,
444
+ loggerVNext: partial.loggerVNext ?? deriveLoggerContext(tracing),
445
+ metrics: partial.metrics ?? deriveMetricsContext(tracing),
446
+ tracingContext: tracing
447
+ };
448
+ }
449
+ // src/observability/context.ts
450
+ const AGENT_GETTERS = ["getAgent", "getAgentById"];
451
+ const AGENT_METHODS_TO_WRAP = [
452
+ "generate",
453
+ "stream",
454
+ "generateLegacy",
455
+ "streamLegacy"
456
+ ];
457
+ const WORKFLOW_GETTERS = ["getWorkflow", "getWorkflowById"];
458
+ const WORKFLOW_METHODS_TO_WRAP = [
459
+ "execute",
460
+ "createRun",
461
+ "createRun"
462
+ ];
463
+ /**
464
+ * Maps a tracing proxy back to the instance it wraps. `wrapMastra` returns a
465
+ * Proxy that forwards property reads but is a distinct object identity from its
466
+ * target, so identity-sensitive lookups keyed on the Mastra instance would treat
467
+ * the proxy as a different Mastra. Cycles are impossible: a proxy's recorded
468
+ * target always existed before the proxy was created.
469
+ */
470
+ const tracingProxyTargets = /* @__PURE__ */ new WeakMap();
471
+ /**
472
+ * Helper function to detect NoOp spans to avoid unnecessary wrapping
473
+ */
474
+ function isNoOpSpan(span) {
475
+ return span.constructor.name === "NoOpSpan" || span.__isNoOp === true;
476
+ }
477
+ /**
478
+ * Checks to see if a passed object is an actual instance of Mastra
479
+ * (for the purposes of wrapping it for Tracing)
480
+ */
481
+ function isMastra(mastra) {
482
+ const hasAgentGetters = AGENT_GETTERS.every((method) => typeof mastra?.[method] === "function");
483
+ const hasWorkflowGetters = WORKFLOW_GETTERS.every((method) => typeof mastra?.[method] === "function");
484
+ return hasAgentGetters && hasWorkflowGetters;
485
+ }
486
+ /**
487
+ * Creates a tracing-aware Mastra proxy that automatically injects
488
+ * tracing context into agent and workflow method calls
489
+ */
490
+ function wrapMastra(mastra, tracingContext) {
491
+ if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return mastra;
492
+ if (!isMastra(mastra)) return mastra;
493
+ try {
494
+ const proxy = new Proxy(mastra, { get(target, prop) {
495
+ try {
496
+ if (AGENT_GETTERS.includes(prop)) return (...args) => {
497
+ return wrapAgent(target[prop](...args), tracingContext);
498
+ };
499
+ if (WORKFLOW_GETTERS.includes(prop)) return (...args) => {
500
+ return wrapWorkflow(target[prop](...args), tracingContext);
501
+ };
502
+ const value = target[prop];
503
+ return typeof value === "function" ? value.bind(target) : value;
504
+ } catch (error) {
505
+ console.warn("Tracing: Failed to wrap method, falling back to original", error);
506
+ const value = target[prop];
507
+ return typeof value === "function" ? value.bind(target) : value;
508
+ }
509
+ } });
510
+ tracingProxyTargets.set(proxy, mastra);
511
+ return proxy;
512
+ } catch (error) {
513
+ console.warn("Tracing: Failed to create proxy, using original Mastra instance", error);
514
+ return mastra;
515
+ }
516
+ }
517
+ /**
518
+ * Resolve a tracing proxy back to the underlying instance. Returns the argument
519
+ * unchanged when it is not a proxy this module created. Transitive: a tool
520
+ * executed inside a traced workflow step receives an already-wrapped mastra and
521
+ * `tools/tool-builder/builder.ts` wraps it again, so nesting is real.
522
+ */
523
+ function unwrapMastraTracingProxy(mastra) {
524
+ let current = mastra;
525
+ let target = tracingProxyTargets.get(current);
526
+ while (target) {
527
+ current = target;
528
+ target = tracingProxyTargets.get(current);
529
+ }
530
+ return current;
531
+ }
532
+ /**
533
+ * Creates a tracing-aware Agent proxy that automatically injects
534
+ * tracing context into generation method calls
535
+ */
536
+ function wrapAgent(agent, tracingContext) {
537
+ if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return agent;
538
+ try {
539
+ return new Proxy(agent, { get(target, prop) {
540
+ try {
541
+ if (AGENT_METHODS_TO_WRAP.includes(prop)) return (input, options = {}) => {
542
+ return target[prop](input, {
543
+ ...options,
544
+ ...createObservabilityContext(tracingContext)
545
+ });
546
+ };
547
+ const value = target[prop];
548
+ return typeof value === "function" ? value.bind(target) : value;
549
+ } catch (error) {
550
+ console.warn("Tracing: Failed to wrap agent method, falling back to original", error);
551
+ const value = target[prop];
552
+ return typeof value === "function" ? value.bind(target) : value;
553
+ }
554
+ } });
555
+ } catch (error) {
556
+ console.warn("Tracing: Failed to create agent proxy, using original instance", error);
557
+ return agent;
558
+ }
559
+ }
560
+ /**
561
+ * Creates a tracing-aware Workflow proxy that automatically injects
562
+ * tracing context into execution method calls
563
+ */
564
+ function wrapWorkflow(workflow, tracingContext) {
565
+ if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return workflow;
566
+ try {
567
+ return new Proxy(workflow, { get(target, prop) {
568
+ try {
569
+ if (WORKFLOW_METHODS_TO_WRAP.includes(prop)) {
570
+ if (prop === "createRun" || prop === "createRun") return async (options = {}) => {
571
+ const run = await target[prop](options);
572
+ return run ? wrapRun(run, tracingContext) : run;
573
+ };
574
+ return (input, options = {}) => {
575
+ return target[prop](input, {
576
+ ...options,
577
+ ...createObservabilityContext(tracingContext)
578
+ });
579
+ };
580
+ }
581
+ const value = target[prop];
582
+ return typeof value === "function" ? value.bind(target) : value;
583
+ } catch (error) {
584
+ console.warn("Tracing: Failed to wrap workflow method, falling back to original", error);
585
+ const value = target[prop];
586
+ return typeof value === "function" ? value.bind(target) : value;
587
+ }
588
+ } });
589
+ } catch (error) {
590
+ console.warn("Tracing: Failed to create workflow proxy, using original instance", error);
591
+ return workflow;
592
+ }
593
+ }
594
+ /**
595
+ * Creates a tracing-aware Run proxy that automatically injects
596
+ * tracing context into start method calls
597
+ */
598
+ function wrapRun(run, tracingContext) {
599
+ if (!tracingContext.currentSpan || isNoOpSpan(tracingContext.currentSpan)) return run;
600
+ try {
601
+ return new Proxy(run, { get(target, prop) {
602
+ try {
603
+ if (prop === "start") return (startOptions = {}) => {
604
+ return target.start({
605
+ ...startOptions,
606
+ ...createObservabilityContext(startOptions.tracingContext ?? tracingContext)
607
+ });
608
+ };
609
+ const value = target[prop];
610
+ return typeof value === "function" ? value.bind(target) : value;
611
+ } catch (error) {
612
+ console.warn("Tracing: Failed to wrap run method, falling back to original", error);
613
+ const value = target[prop];
614
+ return typeof value === "function" ? value.bind(target) : value;
615
+ }
616
+ } });
617
+ } catch (error) {
618
+ console.warn("Tracing: Failed to create run proxy, using original instance", error);
619
+ return run;
620
+ }
621
+ }
918
622
  // src/observability/rag-ingestion.ts
919
623
  /**
920
624
  * RAG ingestion helpers.
@@ -1342,6 +1046,302 @@ function buildSpanPreviews(span) {
1342
1046
  errorPreview: error
1343
1047
  };
1344
1048
  }
1049
+ // src/observability/outcome-schema.ts
1050
+ const label = z.string().max(128).optional();
1051
+ const reason = z.enum(Object.keys(SPAN_STOP_REASONS));
1052
+ const failure = {
1053
+ provider: label,
1054
+ errorCode: label,
1055
+ retryable: z.boolean().optional()
1056
+ };
1057
+ const cause = {
1058
+ causeOutcome: z.enum(SPAN_OUTCOMES).optional(),
1059
+ causeStopReason: reason.optional()
1060
+ };
1061
+ const contexts = {
1062
+ max_steps: z.strictObject({
1063
+ maxSteps: z.number().optional(),
1064
+ completedSteps: z.number().optional()
1065
+ }),
1066
+ max_tokens: z.strictObject({ maxTokens: z.number().optional() }),
1067
+ timeout: z.strictObject({
1068
+ timeoutMs: z.number().optional(),
1069
+ timeoutType: z.enum([
1070
+ "step",
1071
+ "total",
1072
+ "firstChunk"
1073
+ ]).optional()
1074
+ }),
1075
+ runtime_error: z.strictObject(failure),
1076
+ model_error: z.strictObject(failure),
1077
+ caller_cancelled: z.strictObject({}),
1078
+ observer_failed: z.strictObject({
1079
+ observerSpanId: label,
1080
+ ...cause
1081
+ }),
1082
+ context_window_exceeded: z.strictObject({
1083
+ provider: label,
1084
+ errorCode: label,
1085
+ contextWindow: z.number().optional()
1086
+ }),
1087
+ guardrail: z.strictObject({ processorId: label }),
1088
+ content_filter: z.strictObject({ provider: label }),
1089
+ approval_required: z.strictObject({
1090
+ toolCallId: label,
1091
+ toolName: label
1092
+ }),
1093
+ signal_received: z.strictObject({
1094
+ signalId: label,
1095
+ signalType: z.enum([
1096
+ "user",
1097
+ "state",
1098
+ "reactive",
1099
+ "notification"
1100
+ ]).optional()
1101
+ }),
1102
+ stop_condition: z.strictObject({}),
1103
+ iteration_hook: z.strictObject({ feedbackCompleted: z.boolean().optional() }),
1104
+ delegation_bail: z.strictObject(cause),
1105
+ authentication: z.strictObject(failure),
1106
+ authorization: z.strictObject(failure)
1107
+ };
1108
+ /** @internal Allowlist tooltip facts for framework producers, including untyped runtime inputs. */
1109
+ function compactStopReasonContext(stopReason, context) {
1110
+ if (!stopReason || !Object.hasOwn(contexts, stopReason) || !context || typeof context !== "object") return null;
1111
+ try {
1112
+ const result = {};
1113
+ for (const [key, schema] of Object.entries(contexts[stopReason].shape)) {
1114
+ const value = context[key];
1115
+ const parsed = schema.safeParse(value);
1116
+ if (parsed.success && parsed.data !== void 0) result[key] = parsed.data;
1117
+ }
1118
+ return Object.keys(result).length ? result : null;
1119
+ } catch {
1120
+ return null;
1121
+ }
1122
+ }
1123
+ function termination(stopReason) {
1124
+ return z.object({
1125
+ outcome: z.enum(SPAN_OUTCOMES),
1126
+ stopReason: z.literal(stopReason),
1127
+ stopReasonContext: contexts[stopReason].nullish()
1128
+ });
1129
+ }
1130
+ z.union([...Object.keys(SPAN_STOP_REASONS).map(termination), z.object({
1131
+ outcome: z.enum(SPAN_OUTCOMES),
1132
+ stopReason: z.null().optional(),
1133
+ stopReasonContext: z.null().optional()
1134
+ })]);
1135
+ // src/observability/execution-outcome.ts
1136
+ /** Read a provider's structured code without inferring a cause from diagnostic text. */
1137
+ function providerFailureCode(value) {
1138
+ if (typeof value.code === "string") return value.code;
1139
+ let data = value.data;
1140
+ if (data == null && typeof value.responseBody === "string") try {
1141
+ data = JSON.parse(value.responseBody);
1142
+ } catch {
1143
+ return;
1144
+ }
1145
+ if (!data || typeof data !== "object") return void 0;
1146
+ const record = data;
1147
+ const error = record.error && typeof record.error === "object" ? record.error : record;
1148
+ return typeof error.code === "string" ? error.code : void 0;
1149
+ }
1150
+ /** @internal Classify explicit failure facts, including wrapped/serialized causes. Never match error-message text. */
1151
+ function executionFailureTermination(error, layer = "runtime_error") {
1152
+ try {
1153
+ const termination = classifyExecutionFailure(error, layer);
1154
+ return {
1155
+ ...termination,
1156
+ stopReasonContext: compactStopReasonContext(termination.stopReason, termination.stopReasonContext)
1157
+ };
1158
+ } catch {
1159
+ return {
1160
+ outcome: "error",
1161
+ stopReason: layer
1162
+ };
1163
+ }
1164
+ }
1165
+ function classifyExecutionFailure(error, layer) {
1166
+ const seen = /* @__PURE__ */ new Set();
1167
+ let current = error;
1168
+ let failure;
1169
+ let modelFailure = layer === "model_error";
1170
+ while (current && typeof current === "object" && !seen.has(current)) {
1171
+ seen.add(current);
1172
+ const value = current;
1173
+ if (value.status === "failed" && value.error && typeof value.error === "object") {
1174
+ current = value.error;
1175
+ continue;
1176
+ }
1177
+ if (value.name === "TripWire" && (value.processorId === void 0 || typeof value.processorId === "string") && value.options && typeof value.options === "object" && typeof value.message === "string") {
1178
+ const options = value.options;
1179
+ return tripwireTermination({
1180
+ processorId: value.processorId,
1181
+ reason: value.message,
1182
+ ...options
1183
+ });
1184
+ }
1185
+ failure = value;
1186
+ if (value.name === "MastraTimeoutError" && typeof value.timeoutMs === "number") return {
1187
+ outcome: "limit",
1188
+ stopReason: "timeout",
1189
+ stopReasonContext: {
1190
+ timeoutMs: value.timeoutMs,
1191
+ ...value.timeoutType === "step" || value.timeoutType === "total" || value.timeoutType === "firstChunk" ? { timeoutType: value.timeoutType } : {}
1192
+ }
1193
+ };
1194
+ if (value.name === "FGADeniedError") return {
1195
+ outcome: "blocked",
1196
+ stopReason: "authorization"
1197
+ };
1198
+ const apiError = value[Symbol.for("vercel.ai.error.AI_APICallError")] === true || value.name === "AI_APICallError";
1199
+ if (apiError) modelFailure = true;
1200
+ if (apiError && (value.statusCode === 401 || value.statusCode === 403)) return {
1201
+ outcome: "blocked",
1202
+ stopReason: value.statusCode === 401 ? "authentication" : "authorization",
1203
+ stopReasonContext: {
1204
+ errorCode: String(value.statusCode),
1205
+ provider: typeof value.provider === "string" ? value.provider : void 0
1206
+ }
1207
+ };
1208
+ if (apiError) {
1209
+ const errorCode = providerFailureCode(value);
1210
+ if (errorCode === "content_filter") return {
1211
+ outcome: "blocked",
1212
+ stopReason: "content_filter",
1213
+ stopReasonContext: { provider: typeof value.provider === "string" ? value.provider : void 0 }
1214
+ };
1215
+ if (errorCode === "context_length_exceeded" || errorCode === "context_window_exceeded") return {
1216
+ outcome: "limit",
1217
+ stopReason: "context_window_exceeded",
1218
+ stopReasonContext: { errorCode }
1219
+ };
1220
+ }
1221
+ current = value.cause;
1222
+ }
1223
+ return {
1224
+ outcome: "error",
1225
+ stopReason: modelFailure ? "model_error" : "runtime_error",
1226
+ stopReasonContext: {
1227
+ provider: typeof failure?.provider === "string" ? failure.provider : void 0,
1228
+ errorCode: typeof failure?.code === "string" ? failure.code : typeof failure?.id === "string" ? failure.id : void 0,
1229
+ retryable: typeof failure?.isRetryable === "boolean" ? failure.isRetryable : void 0
1230
+ }
1231
+ };
1232
+ }
1233
+ /** Link to the observer's diagnostics without copying its payload into the interrupted span. */
1234
+ function tripwireTermination(tripwire) {
1235
+ try {
1236
+ const metadata = tripwire?.metadata;
1237
+ const observer = metadata && typeof metadata === "object" && "observerFailure" in metadata ? metadata.observerFailure : void 0;
1238
+ if (observer && typeof observer === "object" && "cause" in observer && observer.cause && typeof observer.cause === "object") {
1239
+ const cause = observer.cause;
1240
+ if (SPAN_OUTCOMES.includes(cause.outcome) && cause.outcome !== "success" && cause.outcome !== "suspend") return {
1241
+ outcome: "interrupted",
1242
+ stopReason: "observer_failed",
1243
+ stopReasonContext: compactStopReasonContext("observer_failed", {
1244
+ observerSpanId: "observerSpanId" in observer ? observer.observerSpanId : void 0,
1245
+ causeOutcome: cause.outcome,
1246
+ causeStopReason: typeof cause.stopReason === "string" && Object.hasOwn(SPAN_STOP_REASONS, cause.stopReason) ? cause.stopReason : void 0
1247
+ })
1248
+ };
1249
+ }
1250
+ return {
1251
+ outcome: "blocked",
1252
+ stopReason: "guardrail",
1253
+ stopReasonContext: compactStopReasonContext("guardrail", { processorId: tripwire?.processorId })
1254
+ };
1255
+ } catch {
1256
+ return {
1257
+ outcome: "blocked",
1258
+ stopReason: "guardrail"
1259
+ };
1260
+ }
1261
+ }
1262
+ // src/loop/shared/execution-outcome.ts
1263
+ /**
1264
+ * @internal
1265
+ * Classify a settled agent loop using its runtime stop boundary. A provider
1266
+ * finish reason refines the result; it cannot establish successful execution
1267
+ * without a continuation decision. Call only after finish-time work succeeds.
1268
+ */
1269
+ function agentLoopTermination(input) {
1270
+ const { stopCause, finishReason, maxSteps, tripwire } = input;
1271
+ if (tripwire || finishReason === "tripwire") return tripwireTermination(tripwire);
1272
+ if (finishReason === "suspended") {
1273
+ const suspension = input.suspension;
1274
+ if (suspension?.approvalRequired) return {
1275
+ outcome: "suspend",
1276
+ stopReason: "approval_required",
1277
+ stopReasonContext: compactStopReasonContext("approval_required", {
1278
+ toolCallId: suspension.toolCallId,
1279
+ toolName: suspension.toolName
1280
+ })
1281
+ };
1282
+ return {
1283
+ outcome: "suspend",
1284
+ stopReason: null,
1285
+ stopReasonContext: null
1286
+ };
1287
+ }
1288
+ if (finishReason === "length") return {
1289
+ outcome: "limit",
1290
+ stopReason: "max_tokens"
1291
+ };
1292
+ if (finishReason === "content-filter") return {
1293
+ outcome: "blocked",
1294
+ stopReason: "content_filter"
1295
+ };
1296
+ if (finishReason === "abort" || finishReason === "aborted") return {
1297
+ outcome: "abort",
1298
+ stopReason: "caller_cancelled"
1299
+ };
1300
+ if (finishReason === "error") return {
1301
+ outcome: "error",
1302
+ stopReason: "model_error"
1303
+ };
1304
+ switch (stopCause) {
1305
+ case "max_steps": return {
1306
+ outcome: "limit",
1307
+ stopReason: "max_steps",
1308
+ stopReasonContext: { maxSteps }
1309
+ };
1310
+ case "stop_condition": return {
1311
+ outcome: "success",
1312
+ stopReason: "stop_condition"
1313
+ };
1314
+ case "iteration_hook":
1315
+ case "feedback_complete": return {
1316
+ outcome: "success",
1317
+ stopReason: "iteration_hook",
1318
+ stopReasonContext: { feedbackCompleted: stopCause === "feedback_complete" }
1319
+ };
1320
+ case "delegation":
1321
+ if (input.delegationFailure) return {
1322
+ outcome: "interrupted",
1323
+ stopReason: "delegation_bail",
1324
+ stopReasonContext: {
1325
+ causeOutcome: input.delegationFailure.outcome,
1326
+ causeStopReason: input.delegationFailure.stopReason ?? void 0
1327
+ }
1328
+ };
1329
+ return {
1330
+ outcome: "success",
1331
+ stopReason: "delegation_bail"
1332
+ };
1333
+ case "model_finished": if (finishReason === "stop" || finishReason === "tool-calls") return {
1334
+ outcome: "success",
1335
+ stopReason: null,
1336
+ stopReasonContext: null
1337
+ };
1338
+ }
1339
+ return {
1340
+ outcome: "unknown",
1341
+ stopReason: null,
1342
+ stopReasonContext: null
1343
+ };
1344
+ }
1345
1345
  // src/observability/usage.ts
1346
1346
  const usageCountKeys = [
1347
1347
  "inputTokens",
@@ -1469,4 +1469,4 @@ function extractUsageMetrics(usage, providerMetadata) {
1469
1469
  function sumDefinedValues(obj, keys) {
1470
1470
  return keys.reduce((sum, key) => sum + (obj[key] ?? 0), 0);
1471
1471
  }
1472
- export { compactStopReasonContext as A, NoOpObservability as C, agentLoopTermination as D, noOpTracingContext as E, SPAN_STOP_REASONS as M, executionFailureTermination as O, resolveObservabilityContext as S, noOpMetricsContext as T, parseTraceparent as _, PREVIEW_MAX_LENGTH as a, wrapMastra as b, startRagIngestion as c, describeSpanInput as d, describeSpanOutput as f, formatTraceparent as g, describeProcessorPipeline as h, subtractReportedUsage as i, SPAN_OUTCOMES as j, tripwireTermination as k, withRagIngestion as l, describeProcessorPhase as m, extractUsageMetrics as n, buildSpanPreviews as o, isSpanRecordOfType as p, isUsageIncomplete as r, truncatePreview as s, calculateObservedUsage as t, describeSpanError as u, SamplingStrategyType as v, noOpLoggerContext as w, createObservabilityContext as x, unwrapMastraTracingProxy as y };
1472
+ export { SPAN_OUTCOMES as A, describeProcessorPipeline as C, noOpLoggerContext as D, NoOpObservability as E, SamplingStrategyType as M, noOpMetricsContext as O, describeProcessorPhase as S, parseTraceparent as T, resolveObservabilityContext as _, agentLoopTermination as a, describeSpanOutput as b, compactStopReasonContext as c, truncatePreview as d, startRagIngestion as f, createObservabilityContext as g, wrapMastra as h, subtractReportedUsage as i, SPAN_STOP_REASONS as j, noOpTracingContext as k, PREVIEW_MAX_LENGTH as l, unwrapMastraTracingProxy as m, extractUsageMetrics as n, executionFailureTermination as o, withRagIngestion as p, isUsageIncomplete as r, tripwireTermination as s, calculateObservedUsage as t, buildSpanPreviews as u, describeSpanError as v, formatTraceparent as w, isSpanRecordOfType as x, describeSpanInput as y };