@mastra/core 1.86.0-alpha.7 → 1.86.0-alpha.9

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 (509) hide show
  1. package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +363 -0
  2. package/dist/a2a/index.cjs +1 -1
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/agent/agent.d.ts +72 -1
  5. package/dist/agent/agent.types.d.ts +30 -2
  6. package/dist/agent/durable/create-evented-agent.d.ts +6 -0
  7. package/dist/agent/durable/durable-agent.d.ts +1 -15
  8. package/dist/agent/durable/index.cjs +7 -26
  9. package/dist/agent/durable/index.js +7 -26
  10. package/dist/agent/durable/preparation.d.ts +2 -0
  11. package/dist/agent/durable/utils/resolve-runtime.d.ts +9 -0
  12. package/dist/agent/durable/workflows/durable-loop-builder.d.ts +4 -0
  13. package/dist/agent/durable/workflows/finalize-run.d.ts +3 -1
  14. package/dist/agent/durable/workflows/steps/llm-execution.d.ts +1 -0
  15. package/dist/agent/index.cjs +3 -3
  16. package/dist/agent/index.js +3 -3
  17. package/dist/agent/message-list/index.cjs +1 -1
  18. package/dist/agent/message-list/index.js +1 -1
  19. package/dist/agent/message-list/message-list.d.ts +11 -0
  20. package/dist/agent/message-list/utils/provider-compat.d.ts +1 -0
  21. package/dist/agent/request-context-snapshot.d.ts +1 -1
  22. package/dist/agent/streams/types.d.ts +10 -0
  23. package/dist/agent/thread-stream-runtime.d.ts +5 -0
  24. package/dist/agent/types.d.ts +25 -0
  25. package/dist/agent-builder/ee/index.cjs +1 -1
  26. package/dist/agent-builder/ee/index.js +1 -1
  27. package/dist/agent-controller/index.cjs +1 -1
  28. package/dist/agent-controller/index.js +1 -1
  29. package/dist/{agent-controller-K5vHtqfO.cjs → agent-controller-CrQ9OF80.cjs} +8 -8
  30. package/dist/{agent-controller-Cf3_IuY8.js → agent-controller-SSlKzE6A.js} +8 -8
  31. package/dist/background-tasks/index.cjs +1 -1
  32. package/dist/background-tasks/index.js +1 -1
  33. package/dist/{background-tasks-DqnQMfuf.cjs → background-tasks-BDrYBis-.cjs} +5 -3
  34. package/dist/{background-tasks-BgpX1P_s.js → background-tasks-BnJfNLFo.js} +5 -3
  35. package/dist/browser/index.cjs +2 -2
  36. package/dist/browser/index.js +2 -2
  37. package/dist/{builder-x295GDL6.js → builder-Cl-0BWkh.js} +2 -2
  38. package/dist/{builder-D8Osghdo.cjs → builder-Cw8u3pPl.cjs} +2 -2
  39. package/dist/capabilities/302ai.json +192 -192
  40. package/dist/capabilities/abliteratedllm.json +34 -34
  41. package/dist/capabilities/abliteration-ai.json +11 -11
  42. package/dist/capabilities/above.json +17 -17
  43. package/dist/capabilities/adaption.json +12 -12
  44. package/dist/capabilities/adzuki.json +30 -30
  45. package/dist/capabilities/agentrouter.json +10 -10
  46. package/dist/capabilities/agnes.json +4 -4
  47. package/dist/capabilities/ai-router.json +9 -9
  48. package/dist/capabilities/aiand.json +19 -11
  49. package/dist/capabilities/aigrow.json +11 -11
  50. package/dist/capabilities/aimlapi.json +146 -149
  51. package/dist/capabilities/aipg.json +2 -2
  52. package/dist/capabilities/aixy.json +14 -14
  53. package/dist/capabilities/aki-io.json +11 -11
  54. package/dist/capabilities/alibaba-cn.json +128 -109
  55. package/dist/capabilities/alibaba-coding-plan-cn.json +7 -19
  56. package/dist/capabilities/alibaba-coding-plan.json +7 -19
  57. package/dist/capabilities/alibaba-token-plan-cn.json +49 -67
  58. package/dist/capabilities/alibaba-token-plan.json +51 -69
  59. package/dist/capabilities/alibaba.json +71 -118
  60. package/dist/capabilities/ambient.json +14 -14
  61. package/dist/capabilities/amd.json +11 -11
  62. package/dist/capabilities/anthropic.json +48 -48
  63. package/dist/capabilities/anyapi.json +18 -18
  64. package/dist/capabilities/apiko.json +2 -2
  65. package/dist/capabilities/arcee.json +10 -10
  66. package/dist/capabilities/augure.json +6 -6
  67. package/dist/capabilities/auriko.json +20 -20
  68. package/dist/capabilities/bailing.json +5 -5
  69. package/dist/capabilities/baseten.json +46 -16
  70. package/dist/capabilities/bee.json +5 -5
  71. package/dist/capabilities/berget.json +4 -4
  72. package/dist/capabilities/bothub.json +16 -16
  73. package/dist/capabilities/boundless.json +36 -36
  74. package/dist/capabilities/bumo.json +40 -40
  75. package/dist/capabilities/byteplus.json +32 -32
  76. package/dist/capabilities/cerebras.json +4 -4
  77. package/dist/capabilities/cheapaimodel.json +5 -5
  78. package/dist/capabilities/cheapest-token.json +24 -24
  79. package/dist/capabilities/chutes.json +9 -9
  80. package/dist/capabilities/cline-pass.json +37 -37
  81. package/dist/capabilities/cloudcode.json +4 -4
  82. package/dist/capabilities/cloudflare-workers-ai.json +24 -24
  83. package/dist/capabilities/commandcode.json +152 -152
  84. package/dist/capabilities/concentrate.json +290 -266
  85. package/dist/capabilities/cortecs.json +105 -105
  86. package/dist/capabilities/crossmodel.json +160 -160
  87. package/dist/capabilities/crusoe.json +10 -10
  88. package/dist/capabilities/daoxe.json +7 -7
  89. package/dist/capabilities/databricks.json +318 -62
  90. package/dist/capabilities/deepinfra.json +73 -129
  91. package/dist/capabilities/deepseek.json +2 -2
  92. package/dist/capabilities/digitalocean.json +114 -114
  93. package/dist/capabilities/dothoosh.json +28 -28
  94. package/dist/capabilities/doubleword.json +24 -24
  95. package/dist/capabilities/edenai.json +458 -458
  96. package/dist/capabilities/empiriolabs.json +166 -166
  97. package/dist/capabilities/engy.json +20 -20
  98. package/dist/capabilities/evroc.json +8 -8
  99. package/dist/capabilities/ezkielyna.json +8 -8
  100. package/dist/capabilities/fastrouter.json +85 -85
  101. package/dist/capabilities/fireworks-ai.json +107 -44
  102. package/dist/capabilities/freemodel.json +23 -23
  103. package/dist/capabilities/friendli.json +9 -9
  104. package/dist/capabilities/frogbot.json +94 -94
  105. package/dist/capabilities/gisoo.json +16 -16
  106. package/dist/capabilities/gmicloud.json +17 -17
  107. package/dist/capabilities/google.json +57 -57
  108. package/dist/capabilities/graphn.json +10 -10
  109. package/dist/capabilities/greenpt.json +36 -36
  110. package/dist/capabilities/groq.json +2 -2
  111. package/dist/capabilities/helicone.json +68 -68
  112. package/dist/capabilities/hopper.json +2 -2
  113. package/dist/capabilities/hostinger-router.json +12 -12
  114. package/dist/capabilities/hpc-ai.json +13 -13
  115. package/dist/capabilities/huawei-maas.json +17 -17
  116. package/dist/capabilities/hubris.json +30 -30
  117. package/dist/capabilities/huggingface.json +193 -37
  118. package/dist/capabilities/hyper.json +23 -23
  119. package/dist/capabilities/impossibl.json +140 -140
  120. package/dist/capabilities/inception.json +2 -2
  121. package/dist/capabilities/inceptron.json +4 -4
  122. package/dist/capabilities/inco.json +3 -3
  123. package/dist/capabilities/infer.json +15 -15
  124. package/dist/capabilities/inferall.json +10 -10
  125. package/dist/capabilities/inference-coop.json +9 -9
  126. package/dist/capabilities/inferenceapis.json +9 -9
  127. package/dist/capabilities/inferris.json +3 -3
  128. package/dist/capabilities/infersia.json +2 -2
  129. package/dist/capabilities/inferx.json +3 -3
  130. package/dist/capabilities/infomaniak.json +4 -4
  131. package/dist/capabilities/io-net.json +2 -2
  132. package/dist/capabilities/isoquant.json +4 -4
  133. package/dist/capabilities/iteracompute.json +60 -60
  134. package/dist/capabilities/jad-ai.json +3 -3
  135. package/dist/capabilities/jalapeno.json +12 -12
  136. package/dist/capabilities/jiekou.json +63 -63
  137. package/dist/capabilities/jzstoken.json +50 -50
  138. package/dist/capabilities/keln.json +14 -21
  139. package/dist/capabilities/kenari.json +123 -120
  140. package/dist/capabilities/kilo.json +622 -647
  141. package/dist/capabilities/kimi-code-plan-cn.json +5 -5
  142. package/dist/capabilities/kimi-code-plan-global.json +5 -5
  143. package/dist/capabilities/kitani.json +6 -6
  144. package/dist/capabilities/klavo.json +18 -18
  145. package/dist/capabilities/korouter.json +29 -29
  146. package/dist/capabilities/kunavo.json +10 -10
  147. package/dist/capabilities/liquid.json +11 -11
  148. package/dist/capabilities/lithosai.json +2 -2
  149. package/dist/capabilities/llmgateway-providers.json +932 -905
  150. package/dist/capabilities/llmgateway.json +336 -336
  151. package/dist/capabilities/llmtr.json +22 -22
  152. package/dist/capabilities/logits.json +2 -2
  153. package/dist/capabilities/longcat.json +2 -7
  154. package/dist/capabilities/lowrouter.json +54 -54
  155. package/dist/capabilities/lyceum.json +12 -12
  156. package/dist/capabilities/melious.json +13 -13
  157. package/dist/capabilities/merge-gateway.json +260 -260
  158. package/dist/capabilities/meta.json +7 -7
  159. package/dist/capabilities/mistral.json +20 -20
  160. package/dist/capabilities/mixlayer.json +4 -4
  161. package/dist/capabilities/modal.json +10 -10
  162. package/dist/capabilities/model-oracle-ai.json +25 -25
  163. package/dist/capabilities/modelis.json +20 -20
  164. package/dist/capabilities/modular.json +6 -6
  165. package/dist/capabilities/moneo.json +16 -16
  166. package/dist/capabilities/moonshotai-cn.json +7 -7
  167. package/dist/capabilities/moonshotai.json +7 -7
  168. package/dist/capabilities/morph.json +11 -11
  169. package/dist/capabilities/munito-eu.json +6 -6
  170. package/dist/capabilities/munito.json +6 -6
  171. package/dist/capabilities/nan.json +27 -27
  172. package/dist/capabilities/nano-gpt.json +578 -578
  173. package/dist/capabilities/nearai.json +84 -84
  174. package/dist/capabilities/nebius.json +37 -28
  175. package/dist/capabilities/neon.json +126 -126
  176. package/dist/capabilities/neuralwatt.json +41 -41
  177. package/dist/capabilities/nokeep.json +4 -4
  178. package/dist/capabilities/novita-ai.json +154 -154
  179. package/dist/capabilities/nvidia.json +35 -35
  180. package/dist/capabilities/oathbreaker.json +2 -2
  181. package/dist/capabilities/obscurify.json +32 -32
  182. package/dist/capabilities/oci.json +7 -7
  183. package/dist/capabilities/ofox.json +357 -357
  184. package/dist/capabilities/ollama-cloud.json +56 -56
  185. package/dist/capabilities/openai.json +51 -51
  186. package/dist/capabilities/opencode-go.json +85 -84
  187. package/dist/capabilities/openrouter.json +542 -567
  188. package/dist/capabilities/opper.json +30 -24
  189. package/dist/capabilities/orcarouter.json +236 -236
  190. package/dist/capabilities/outerlabs.json +32 -32
  191. package/dist/capabilities/ovhcloud.json +7 -7
  192. package/dist/capabilities/pareto.json +6 -6
  193. package/dist/capabilities/pendra.json +4 -4
  194. package/dist/capabilities/perplexity-agent.json +61 -61
  195. package/dist/capabilities/phala.json +34 -34
  196. package/dist/capabilities/pioneer.json +30 -30
  197. package/dist/capabilities/poe.json +136 -136
  198. package/dist/capabilities/powerspring.json +13 -13
  199. package/dist/capabilities/primalabs.json +10 -10
  200. package/dist/capabilities/prime.json +124 -107
  201. package/dist/capabilities/privatemode-ai.json +14 -14
  202. package/dist/capabilities/proxystacks.json +6 -6
  203. package/dist/capabilities/qiniu-ai.json +16 -16
  204. package/dist/capabilities/refuseless.json +6 -6
  205. package/dist/capabilities/regolo-ai.json +6 -6
  206. package/dist/capabilities/requesty.json +172 -172
  207. package/dist/capabilities/ruapi.json +17 -17
  208. package/dist/capabilities/runcrate.json +5 -5
  209. package/dist/capabilities/runinfra.json +13 -13
  210. package/dist/capabilities/sakana.json +6 -6
  211. package/dist/capabilities/sambanova.json +9 -9
  212. package/dist/capabilities/sandbase.json +27 -27
  213. package/dist/capabilities/sarvam.json +12 -12
  214. package/dist/capabilities/scaleway.json +14 -14
  215. package/dist/capabilities/scnet-token-plan.json +9 -9
  216. package/dist/capabilities/scx-ai.json +26 -26
  217. package/dist/capabilities/sensenova.json +12 -12
  218. package/dist/capabilities/siliconflow-cn.json +49 -49
  219. package/dist/capabilities/siliconflow.json +46 -46
  220. package/dist/capabilities/snowflake-cortex.json +20 -20
  221. package/dist/capabilities/sokkan.json +7 -7
  222. package/dist/capabilities/sparrowcodes.json +25 -25
  223. package/dist/capabilities/standardcompute.json +102 -102
  224. package/dist/capabilities/steadyrouter.json +40 -40
  225. package/dist/capabilities/stepfun-ai-step-plan.json +6 -6
  226. package/dist/capabilities/stepfun-ai.json +15 -8
  227. package/dist/capabilities/stepfun-step-plan.json +15 -8
  228. package/dist/capabilities/stepfun.json +15 -8
  229. package/dist/capabilities/stepping-stone.json +16 -16
  230. package/dist/capabilities/synthetic.json +13 -13
  231. package/dist/capabilities/synthorai.json +19 -19
  232. package/dist/capabilities/teamorouter.json +24 -24
  233. package/dist/capabilities/teapot-router.json +13 -13
  234. package/dist/capabilities/tencent-coding-plan.json +1 -23
  235. package/dist/capabilities/tencent-token-plan.json +60 -23
  236. package/dist/capabilities/tencent-tokenhub.json +182 -7
  237. package/dist/capabilities/tensorx.json +50 -50
  238. package/dist/capabilities/tenstorrent.json +6 -6
  239. package/dist/capabilities/the-grid-ai.json +28 -28
  240. package/dist/capabilities/thinkingmachines.json +72 -55
  241. package/dist/capabilities/tinfoil.json +13 -13
  242. package/dist/capabilities/toapis.json +2 -2
  243. package/dist/capabilities/togetherai.json +54 -83
  244. package/dist/capabilities/tokengo.json +25 -25
  245. package/dist/capabilities/tokenify.json +9 -9
  246. package/dist/capabilities/trustedrouter.json +4 -4
  247. package/dist/capabilities/trustedtokens.json +17 -17
  248. package/dist/capabilities/umans-ai-coding-plan.json +13 -13
  249. package/dist/capabilities/umans-ai.json +10 -10
  250. package/dist/capabilities/unrestricted.json +6 -6
  251. package/dist/capabilities/uplinkswitch.json +21 -21
  252. package/dist/capabilities/upstage.json +4 -4
  253. package/dist/capabilities/vancine.json +23 -23
  254. package/dist/capabilities/vercel.json +540 -527
  255. package/dist/capabilities/vivgrid.json +80 -80
  256. package/dist/capabilities/volcengine-coding-plan.json +24 -54
  257. package/dist/capabilities/volcengine.json +55 -60
  258. package/dist/capabilities/vultr.json +24 -24
  259. package/dist/capabilities/wafer.ai.json +19 -19
  260. package/dist/capabilities/wallaby.json +5 -5
  261. package/dist/capabilities/wally.json +11 -11
  262. package/dist/capabilities/wandb.json +21 -21
  263. package/dist/capabilities/watt.json +24 -24
  264. package/dist/capabilities/xai.json +7 -7
  265. package/dist/capabilities/xiaomi-token-plan-ams.json +2 -12
  266. package/dist/capabilities/xiaomi-token-plan-cn.json +2 -12
  267. package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -12
  268. package/dist/capabilities/xiaomi.json +3 -25
  269. package/dist/capabilities/xpersona.json +13 -13
  270. package/dist/capabilities/xxapi.json +31 -31
  271. package/dist/capabilities/zai-coding-plan.json +18 -18
  272. package/dist/capabilities/zai.json +49 -26
  273. package/dist/capabilities/zenifra.json +26 -26
  274. package/dist/capabilities/zenmux.json +205 -205
  275. package/dist/capabilities/zerogpu.json +11 -11
  276. package/dist/capabilities/zhipuai-coding-plan.json +6 -6
  277. package/dist/capabilities/zhipuai.json +39 -24
  278. package/dist/capabilities/zro.json +6 -6
  279. package/dist/channels/index.cjs +2 -2
  280. package/dist/channels/index.js +2 -2
  281. package/dist/{channels-Dx4jiXeK.js → channels-Cz1y3W6u.js} +1 -1
  282. package/dist/{channels-q6qnuRNV.cjs → channels-DQg4v_gm.cjs} +1 -1
  283. package/dist/coding-agent/index.cjs +2 -2
  284. package/dist/coding-agent/index.js +2 -2
  285. package/dist/datasets/dataset.d.ts +13 -6
  286. package/dist/datasets/experiment/durable.d.ts +16 -0
  287. package/dist/datasets/experiment/index.d.ts +2 -1
  288. package/dist/datasets/experiment/item.d.ts +26 -4
  289. package/dist/datasets/experiment/retries.d.ts +18 -0
  290. package/dist/datasets/experiment/types.d.ts +18 -0
  291. package/dist/datasets/experiment/workflow-id.d.ts +7 -0
  292. package/dist/datasets/experiment/workflow.d.ts +74 -0
  293. package/dist/datasets/index.cjs +3 -2
  294. package/dist/datasets/index.d.ts +2 -1
  295. package/dist/datasets/index.js +3 -3
  296. package/dist/docs/SKILL.md +4 -3
  297. package/dist/docs/assets/SOURCE_MAP.json +928 -903
  298. package/dist/docs/references/docs-deployment-workers.md +1 -1
  299. package/dist/docs/references/docs-evals-experiments.md +29 -1
  300. package/dist/docs/references/docs-harness-background-tasks.md +4 -1
  301. package/dist/docs/references/docs-harness-durable-agents.md +9 -5
  302. package/dist/docs/references/docs-knowledge-agents-and-tools.md +1 -0
  303. package/dist/docs/references/docs-knowledge-importers.md +195 -0
  304. package/dist/docs/references/docs-knowledge-load-your-content.md +2 -2
  305. package/dist/docs/references/docs-knowledge-overview.md +1 -1
  306. package/dist/docs/references/docs-mastra-platform-observability-overview.md +1 -1
  307. package/dist/docs/references/docs-sandbox-filesystem.md +1 -1
  308. package/dist/docs/references/docs-server-pubsub.md +51 -8
  309. package/dist/docs/references/docs-signals-running-across-processes.md +2 -0
  310. package/dist/docs/references/docs-signals-thread-streams.md +1 -1
  311. package/dist/docs/references/docs-studio-auth.md +54 -7
  312. package/dist/docs/references/docs-workflows-overview.md +1 -1
  313. package/dist/docs/references/docs-workflows-scheduled-workflows.md +1 -1
  314. package/dist/docs/references/integrations-auth-clerk.md +48 -4
  315. package/dist/docs/references/integrations-channels-slack.md +4 -2
  316. package/dist/docs/references/integrations.md +6 -0
  317. package/dist/docs/references/reference-agents-agent.md +3 -1
  318. package/dist/docs/references/reference-agents-channels.md +116 -27
  319. package/dist/docs/references/reference-agents-durable-agent.md +12 -4
  320. package/dist/docs/references/reference-auth-clerk.md +21 -1
  321. package/dist/docs/references/reference-datasets-runExperimentItem.md +13 -1
  322. package/dist/docs/references/reference-datasets-startExperimentAsync.md +3 -1
  323. package/dist/docs/references/reference-editor-mastra-editor.md +3 -1
  324. package/dist/docs/references/reference-knowledge-knowledge-class.md +13 -6
  325. package/dist/docs/references/reference-knowledge-knowledge-tools.md +43 -20
  326. package/dist/docs/references/reference-memory-observational-memory.md +2 -2
  327. package/dist/docs/references/reference-processors-moderation-processor.md +2 -2
  328. package/dist/docs/references/reference-pubsub-base.md +5 -1
  329. package/dist/docs/references/reference-pubsub-event-emitter.md +2 -0
  330. package/dist/docs/references/reference-pubsub-redis-streams.md +1 -1
  331. package/dist/docs/references/reference-pubsub-unix-socket-pubsub.md +2 -0
  332. package/dist/docs/references/reference-streaming-ChunkType.md +3 -3
  333. package/dist/docs/references/reference-workers-overview.md +1 -1
  334. package/dist/docs/references/reference-workflows-run-methods-start.md +23 -0
  335. package/dist/docs/references/reference-workflows-run-methods-timeTravel.md +4 -0
  336. package/dist/docs/references/reference-workflows-run.md +1 -1
  337. package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
  338. package/dist/error/index.cjs +1 -1
  339. package/dist/error/index.js +1 -1
  340. package/dist/{error-C9d_24w-.js → error-BLwEXqOK.js} +2 -2
  341. package/dist/{error-BRQf2ku0.cjs → error-BdEvO8za.cjs} +2 -2
  342. package/dist/evals/index.cjs +1 -1
  343. package/dist/evals/index.js +1 -1
  344. package/dist/evals/scoreTraces/index.cjs +1 -1
  345. package/dist/evals/scoreTraces/index.js +1 -1
  346. package/dist/events/caching-pubsub.d.ts +1 -0
  347. package/dist/events/event-emitter/index.d.ts +12 -5
  348. package/dist/events/index.cjs +15 -1
  349. package/dist/events/index.js +15 -1
  350. package/dist/events/pubsub.d.ts +29 -0
  351. package/dist/events/reach.d.ts +11 -0
  352. package/dist/events/unix-socket-pubsub.d.ts +14 -0
  353. package/dist/features/index.cjs +1 -0
  354. package/dist/features/index.js +1 -0
  355. package/dist/{filesystem-B5X-5G0x.js → filesystem-B8ad6kAW.js} +1 -1
  356. package/dist/{filesystem-BDSpwBke.cjs → filesystem-BB5YWXH-.cjs} +1 -1
  357. package/dist/{filesystem-DzM9pcQ8.js → filesystem-BDHUxbHn.js} +1 -1
  358. package/dist/{filesystem-B0AZrbj8.cjs → filesystem-BP5yz5LG.cjs} +1 -1
  359. package/dist/{filesystem-BsdkC311.js → filesystem-B_afSgYk.js} +1 -1
  360. package/dist/{filesystem-C-cyJfi1.cjs → filesystem-BaOJOc-V.cjs} +1 -1
  361. package/dist/{filesystem-B3s0WRud.js → filesystem-BhYgU8qg.js} +1 -1
  362. package/dist/{filesystem-DzfqVTO_.js → filesystem-CLBVmR5j.js} +1 -1
  363. package/dist/{filesystem-CEbD_77-.cjs → filesystem-Cgxc2a_-.cjs} +1 -1
  364. package/dist/{filesystem-Cv79mHRk.js → filesystem-ClBOBoDc.js} +1 -1
  365. package/dist/{filesystem-DsCQiBl2.cjs → filesystem-DVVecqZt.cjs} +1 -1
  366. package/dist/{filesystem-CUAgLugE.cjs → filesystem-Fpsu7e24.cjs} +1 -1
  367. package/dist/{filesystem-versioned-Bijb_p9l.js → filesystem-versioned-BL1ojJLo.js} +1 -1
  368. package/dist/{filesystem-versioned-DZGyPbNC.cjs → filesystem-versioned-BavRtYWJ.cjs} +1 -1
  369. package/dist/harness/index.cjs +1 -1
  370. package/dist/harness/index.js +1 -1
  371. package/dist/index.cjs +1 -1
  372. package/dist/index.js +1 -1
  373. package/dist/knowledge/config.d.ts +10 -0
  374. package/dist/knowledge/host-writes.d.ts +10 -0
  375. package/dist/knowledge/importers/conformance.d.ts +25 -0
  376. package/dist/knowledge/importers/define.d.ts +204 -0
  377. package/dist/knowledge/importers/host.d.ts +143 -0
  378. package/dist/knowledge/importers/index.d.ts +12 -0
  379. package/dist/knowledge/importers/local-host.d.ts +106 -0
  380. package/dist/knowledge/importers/manifest.d.ts +25 -0
  381. package/dist/knowledge/importers/runner.d.ts +61 -0
  382. package/dist/knowledge/importers/sink.d.ts +105 -0
  383. package/dist/knowledge/importers/types.d.ts +144 -0
  384. package/dist/knowledge/index.cjs +2715 -8
  385. package/dist/knowledge/index.d.ts +54 -4
  386. package/dist/knowledge/index.js +2692 -9
  387. package/dist/knowledge/instructions.d.ts +1 -1
  388. package/dist/knowledge/links.d.ts +8 -0
  389. package/dist/knowledge/pinned-state-processor.d.ts +5 -0
  390. package/dist/knowledge/pinned.d.ts +4 -1
  391. package/dist/knowledge/scope-runtime.d.ts +10 -0
  392. package/dist/llm/index.cjs +3 -3
  393. package/dist/llm/index.js +3 -3
  394. package/dist/llm/model/provider-types.generated.d.ts +7812 -7831
  395. package/dist/llm/model/shared.types.d.ts +31 -0
  396. package/dist/{llm-CsQuqKPc.cjs → llm-8Av3mSjD.cjs} +2 -2
  397. package/dist/{llm-DnXK3Pmw.js → llm-B5A5cwJr.js} +2 -2
  398. package/dist/loop/index.cjs +2 -2
  399. package/dist/loop/index.js +2 -2
  400. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +2 -2
  401. package/dist/{manager-BsghM-UL.js → manager-DfWQCJUK.js} +460 -94
  402. package/dist/{manager-DwFnIrI6.cjs → manager-sv35JY-z.cjs} +476 -92
  403. package/dist/mastra/index.cjs +1 -1
  404. package/dist/mastra/index.d.ts +13 -0
  405. package/dist/mastra/index.js +1 -1
  406. package/dist/mastra/resolve-agent.d.ts +3 -1
  407. package/dist/{mastra-B8i1UDZs.js → mastra-CigBrT7X.js} +32 -23
  408. package/dist/{mastra-Cn5NC6Es.cjs → mastra-D4hvfuxX.cjs} +34 -25
  409. package/dist/memory/index.cjs +3 -3
  410. package/dist/memory/index.js +3 -3
  411. package/dist/{message-list-DPXPXvin.cjs → message-list-Cj0Sq_JP.cjs} +63 -8
  412. package/dist/{message-list-DEuRl82K.js → message-list-KRbg-TnI.js} +63 -8
  413. package/dist/{model-CNPfry_X.cjs → model-BK93CMtl.cjs} +1 -1
  414. package/dist/{model-CsOcWMUt.js → model-CYtXw861.js} +1 -1
  415. package/dist/{netlify-C-83Fxus.cjs → netlify-BAnn3ouY.cjs} +1 -1
  416. package/dist/{netlify-C-OpNSGp.js → netlify-CuI1ZrwR.js} +1 -1
  417. package/dist/notifications/index.cjs +1 -1
  418. package/dist/notifications/index.js +1 -1
  419. package/dist/{output-helpers-JL-HeCbT.cjs → output-helpers-1Zu4Vt9C.cjs} +68 -25
  420. package/dist/{output-helpers-D4II19No.js → output-helpers-CedRCE17.js} +69 -26
  421. package/dist/processor-provider/index.cjs +1 -1
  422. package/dist/processor-provider/index.js +1 -1
  423. package/dist/processors/abort-signal-scope.d.ts +6 -0
  424. package/dist/processors/index.cjs +2 -2
  425. package/dist/processors/index.js +2 -2
  426. package/dist/{provider-registry-9O-H9osy.cjs → provider-registry-BwuI_IpT.cjs} +21690 -21811
  427. package/dist/{provider-registry-RZ8EgSe8.js → provider-registry-CmQLzLF_.js} +21690 -21811
  428. package/dist/provider-registry.json +22113 -22215
  429. package/dist/{registry-generator-e8sltJls.js → registry-generator-C17V4WfG.js} +1 -1
  430. package/dist/{registry-generator-DxCX-FiO.cjs → registry-generator-C_0ae7Ce.cjs} +1 -1
  431. package/dist/{rehydrate-B-wrAN7C.cjs → rehydrate-CDQ4dOYj.cjs} +2 -2
  432. package/dist/{rehydrate-D3fPgJwp.js → rehydrate-PnaVawGX.js} +2 -2
  433. package/dist/relevance/index.cjs +2 -2
  434. package/dist/relevance/index.js +2 -2
  435. package/dist/{run-registry-5_LQBGn_.cjs → run-registry-BmckDVBk.cjs} +1698 -497
  436. package/dist/{run-registry-DC03XLeZ.js → run-registry-BwEcwYlU.js} +1614 -467
  437. package/dist/{source-DDwx-87N.cjs → source-BVOi8Xhp.cjs} +1 -1
  438. package/dist/{source-Did_2XQc.js → source-fNa6u1kH.js} +1 -1
  439. package/dist/storage/domains/agents/index.cjs +1 -1
  440. package/dist/storage/domains/agents/index.js +1 -1
  441. package/dist/storage/domains/knowledge/base.d.ts +72 -0
  442. package/dist/storage/domains/knowledge/importers-inmemory.d.ts +146 -0
  443. package/dist/storage/domains/knowledge/importers.d.ts +287 -0
  444. package/dist/storage/domains/knowledge/index.d.ts +1 -0
  445. package/dist/storage/domains/knowledge/inmemory.d.ts +12 -0
  446. package/dist/storage/domains/knowledge/pages-inmemory.d.ts +12 -1
  447. package/dist/storage/domains/knowledge/pages.d.ts +25 -7
  448. package/dist/storage/domains/mcp-clients/index.cjs +1 -1
  449. package/dist/storage/domains/mcp-clients/index.js +1 -1
  450. package/dist/storage/domains/mcp-servers/index.cjs +1 -1
  451. package/dist/storage/domains/mcp-servers/index.js +1 -1
  452. package/dist/storage/domains/prompt-blocks/index.cjs +1 -1
  453. package/dist/storage/domains/prompt-blocks/index.js +1 -1
  454. package/dist/storage/domains/scorer-definitions/index.cjs +1 -1
  455. package/dist/storage/domains/scorer-definitions/index.js +1 -1
  456. package/dist/storage/domains/skills/index.cjs +1 -1
  457. package/dist/storage/domains/skills/index.js +1 -1
  458. package/dist/storage/domains/workspaces/index.cjs +1 -1
  459. package/dist/storage/domains/workspaces/index.js +1 -1
  460. package/dist/storage/index.cjs +15 -10
  461. package/dist/storage/index.js +11 -11
  462. package/dist/stream/base/output.d.ts +59 -15
  463. package/dist/stream/index.cjs +2 -2
  464. package/dist/stream/index.js +2 -2
  465. package/dist/stream/types.d.ts +24 -2
  466. package/dist/{stream-4aNIw_TQ.cjs → stream-0kdqBOOn.cjs} +64 -9
  467. package/dist/{stream-CJUm6EAH.js → stream-D1y9GzoD.js} +29 -10
  468. package/dist/test-utils/llm-mock.cjs +1 -1
  469. package/dist/test-utils/llm-mock.js +1 -1
  470. package/dist/tool-loop-agent/index.cjs +1 -1
  471. package/dist/tool-loop-agent/index.js +1 -1
  472. package/dist/{tool-loop-agent-FEEwHfmg.js → tool-loop-agent-BdjWGVIb.js} +4 -4
  473. package/dist/{tool-loop-agent-Dn0QCB9n.cjs → tool-loop-agent-kWaZAT6Q.cjs} +4 -4
  474. package/dist/tools/types.d.ts +27 -1
  475. package/dist/{utils-DY01hxVd.cjs → utils-BKUCaZ12.cjs} +1 -1
  476. package/dist/{utils-Bd_y1_a-.js → utils-GHY3hmLx.js} +1 -1
  477. package/dist/utils.cjs +1 -1
  478. package/dist/utils.js +1 -1
  479. package/dist/{validate-CX0yQo_q.js → validate-CB-q-R2F.js} +1 -1
  480. package/dist/{validate-CuB_1Zd3.cjs → validate-De92squ7.cjs} +1 -1
  481. package/dist/vector/index.cjs +2 -2
  482. package/dist/vector/index.js +2 -2
  483. package/dist/worker/index.cjs +1 -1
  484. package/dist/worker/index.js +1 -1
  485. package/dist/{worker-CbaSmip-.cjs → worker-BbWPQuPR.cjs} +2 -2
  486. package/dist/{worker-B80xkcKG.js → worker-C3u_xzY2.js} +2 -2
  487. package/dist/{worker-GsGIxPMa.cjs → worker-CAKvQj9_.cjs} +2 -2
  488. package/dist/{worker-DSEfMPmq.js → worker-Kwm8EKcj.js} +2 -2
  489. package/dist/{workflow-CnBPXTpv.cjs → workflow-CSjXeNcR.cjs} +4 -4
  490. package/dist/{workflow-CZHY_C85.js → workflow-CVmI1Sw-.js} +4 -4
  491. package/dist/workflows/builder/index.cjs +1 -1
  492. package/dist/workflows/builder/index.js +1 -1
  493. package/dist/workflows/evented/index.cjs +1 -1
  494. package/dist/workflows/evented/index.js +1 -1
  495. package/dist/workflows/evented/setup-warning.d.ts +18 -0
  496. package/dist/workflows/evented/workflow-event-processor/run-status.d.ts +37 -0
  497. package/dist/workflows/evented/workflow.d.ts +10 -0
  498. package/dist/workflows/index.cjs +4 -4
  499. package/dist/workflows/index.js +4 -4
  500. package/dist/workflows/workflow.d.ts +6 -1
  501. package/dist/workspace/filesystem/filesystem.d.ts +5 -0
  502. package/dist/workspace/index.cjs +1 -1
  503. package/dist/workspace/index.js +1 -1
  504. package/dist/workspace/sandbox/local-sandbox.d.ts +16 -7
  505. package/dist/workspace/sandbox/native-sandbox/types.d.ts +11 -1
  506. package/dist/{workspace-D7TIleIt.js → workspace-DY2Nxiyi.js} +235 -34
  507. package/dist/{workspace-D2drutNg.cjs → workspace-X2RHJZU9.cjs} +235 -34
  508. package/package.json +7 -7
  509. package/src/llm/model/provider-types.generated.d.ts +7812 -7831
@@ -3839,6 +3839,7 @@ function generateSeatbeltProfile(workspacePath, config) {
3839
3839
  ]) if (config.readOnly) lines.push(`(allow file-write* (require-all (subpath ${escapePath(tempPath)}) (require-not (subpath ${escapePath(canonicalWorkspacePath)}))))`);
3840
3840
  else lines.push(`(allow file-write* (subpath ${escapePath(tempPath)}))`);
3841
3841
  for (const p of config.readWritePaths ?? []) lines.push(`(allow file-write* (subpath ${escapePath(canonicalizePath(p))}))`);
3842
+ for (const p of config.denyWritePaths ?? []) lines.push(`(deny file-write* (subpath ${escapePath(canonicalizePath(p))}))`);
3842
3843
  lines.push("");
3843
3844
  lines.push("; Network");
3844
3845
  if (config.allowNetwork) lines.push("(allow network*)");
@@ -3933,6 +3934,7 @@ function buildBwrapCommand(command, workspacePath, config) {
3933
3934
  if (config.readOnly) bwrapArgs.push("--ro-bind", workspacePath, workspacePath);
3934
3935
  else bwrapArgs.push("--bind", workspacePath, workspacePath);
3935
3936
  for (const path of config.readWritePaths ?? []) bwrapArgs.push("--bind", path, path);
3937
+ for (const path of config.denyWritePaths ?? []) bwrapArgs.push("--ro-bind", path, path);
3936
3938
  bwrapArgs.push("--dev", "/dev");
3937
3939
  bwrapArgs.push("--chdir", workspacePath);
3938
3940
  bwrapArgs.push("--die-with-parent");
@@ -4057,9 +4059,11 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
4057
4059
  _activeMountPaths = /* @__PURE__ */ new Set();
4058
4060
  /** Snapshot of `readWritePaths` from ctor; entries here are never removed on unmount. */
4059
4061
  _initialReadWritePaths;
4060
- /** Refcount for isolation paths added by mounts (not present in `_initialReadWritePaths`). */
4062
+ /** Snapshot of `denyWritePaths` from ctor; entries here are never removed on unmount. */
4063
+ _initialDenyWritePaths;
4064
+ /** Refcount for isolation paths added by mounts, keyed by `<list>:<path>`. */
4061
4065
  _mountIsolationRefCount = /* @__PURE__ */ new Map();
4062
- /** Normalized mount path → canonical isolation path recorded for that mount. */
4066
+ /** Normalized mount path → canonical isolation path and the list it was added to. */
4063
4067
  _mountPathToIsolationPath = /* @__PURE__ */ new Map();
4064
4068
  /** Named checkpoint to seed from on start and persist to on snapshot. */
4065
4069
  _checkpointName;
@@ -4099,9 +4103,11 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
4099
4103
  this._nativeSandboxConfig = {
4100
4104
  ...options.nativeSandbox,
4101
4105
  readWritePaths: [...options.nativeSandbox?.readWritePaths ?? []],
4102
- readOnlyPaths: [...options.nativeSandbox?.readOnlyPaths ?? []]
4106
+ readOnlyPaths: [...options.nativeSandbox?.readOnlyPaths ?? []],
4107
+ denyWritePaths: [...options.nativeSandbox?.denyWritePaths ?? []]
4103
4108
  };
4104
4109
  this._initialReadWritePaths = new Set(this._nativeSandboxConfig.readWritePaths ?? []);
4110
+ this._initialDenyWritePaths = new Set(this._nativeSandboxConfig.denyWritePaths ?? []);
4105
4111
  this.isolation = requestedIsolation;
4106
4112
  this._instructionsOverride = options.instructions;
4107
4113
  this._checkpointName = options.checkpointName;
@@ -4129,7 +4135,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
4129
4135
  nativeSandbox: {
4130
4136
  ...this._nativeSandboxConfig,
4131
4137
  readWritePaths: [...this._initialReadWritePaths],
4132
- readOnlyPaths: [...this._nativeSandboxConfig.readOnlyPaths ?? []]
4138
+ readOnlyPaths: [...this._nativeSandboxConfig.readOnlyPaths ?? []],
4139
+ denyWritePaths: [...this._initialDenyWritePaths]
4133
4140
  },
4134
4141
  ...this._instructionsOverride !== void 0 && { instructions: this._instructionsOverride },
4135
4142
  ...(options.checkpointName ?? this._checkpointName) !== void 0 && { checkpointName: options.checkpointName ?? this._checkpointName },
@@ -4367,7 +4374,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
4367
4374
  isolationConfig: this.isolation !== "none" ? {
4368
4375
  allowNetwork: this._nativeSandboxConfig.allowNetwork ?? false,
4369
4376
  readOnlyPaths: this._nativeSandboxConfig.readOnlyPaths,
4370
- readWritePaths: this._nativeSandboxConfig.readWritePaths
4377
+ readWritePaths: this._nativeSandboxConfig.readWritePaths,
4378
+ denyWritePaths: this._nativeSandboxConfig.denyWritePaths
4371
4379
  } : void 0
4372
4380
  }
4373
4381
  };
@@ -4438,7 +4446,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
4438
4446
  config
4439
4447
  });
4440
4448
  this._activeMountPaths.add(mountPath);
4441
- this.addMountPathToIsolation(mountPath, hostPath);
4449
+ const isolationError = this.addMountPathToIsolation(mountPath, hostPath, filesystem.readOnly === true);
4450
+ if (isolationError) return this.failMountIsolation(filesystem, mountPath, config, isolationError);
4442
4451
  return {
4443
4452
  success: true,
4444
4453
  mountPath
@@ -4549,7 +4558,8 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
4549
4558
  });
4550
4559
  this._activeMountPaths.add(mountPath);
4551
4560
  await this.writeMarkerFile(mountPath, hostPath);
4552
- this.addMountPathToIsolation(mountPath, hostPath);
4561
+ const isolationError = this.addMountPathToIsolation(mountPath, hostPath, filesystem.readOnly === true);
4562
+ if (isolationError) return this.failMountIsolation(filesystem, mountPath, config, isolationError);
4553
4563
  this.logger.debug("Mounted", {
4554
4564
  mountPath,
4555
4565
  hostPath
@@ -4662,53 +4672,91 @@ var LocalSandbox = class LocalSandbox extends MastraSandbox {
4662
4672
  }
4663
4673
  }
4664
4674
  /**
4665
- * Dynamically add a mount path to the sandbox isolation allowlist.
4675
+ * Dynamically add a mount path to the sandbox isolation config.
4666
4676
  *
4667
- * - Seatbelt: pushes to readWritePaths (wrapCommand reads config each call)
4668
- * - Bwrap: pushes to readWritePaths (buildBwrapCommand reads config each call)
4677
+ * Read-write mounts go to `readWritePaths`; mounts whose filesystem is
4678
+ * `readOnly` go to `denyWritePaths` so subprocesses can read but never write
4679
+ * them, matching what file tools enforce. Both backends read the config on
4680
+ * every wrapCommand() call, so the change takes effect immediately.
4669
4681
  *
4670
4682
  * Local mounts are symlinks under `workingDirectory`. Bubblewrap cannot
4671
4683
  * `--bind` a symlink (it fails with "Unable to mount source on destination"),
4672
4684
  * so we store the canonical path (`realpath`) of the mount point — the same
4673
4685
  * directory the symlink refers to.
4686
+ *
4687
+ * Returns an error when a read-only mount can't be resolved: a write denial on
4688
+ * the unresolved symlink wouldn't cover the directory writes actually land in.
4674
4689
  */
4675
- addMountPathToIsolation(mountPath, hostPath) {
4690
+ addMountPathToIsolation(mountPath, hostPath, readOnly) {
4676
4691
  if (this.isolation === "none") return;
4677
4692
  const normMount = normalizeMountPath(mountPath);
4678
- if (this._mountPathToIsolationPath.has(normMount)) return;
4693
+ const list = readOnly ? "denyWritePaths" : "readWritePaths";
4694
+ const existing = this._mountPathToIsolationPath.get(normMount);
4695
+ if (existing?.list === list) return;
4696
+ if (existing) this.removeMountIsolationForPath(normMount);
4679
4697
  let isolationPath = hostPath;
4680
4698
  try {
4681
4699
  isolationPath = (0, fs.realpathSync)(hostPath);
4682
- } catch {}
4683
- if (!this._nativeSandboxConfig.readWritePaths) this._nativeSandboxConfig = {
4700
+ } catch {
4701
+ if (readOnly) return `Cannot mount read-only filesystem at ${hostPath}: its source could not be resolved, so writes to it can't be denied to sandboxed commands.`;
4702
+ this.logger.warn("Could not resolve mount path for isolation; using unresolved path", { hostPath });
4703
+ }
4704
+ if (!this._nativeSandboxConfig[list]) this._nativeSandboxConfig = {
4684
4705
  ...this._nativeSandboxConfig,
4685
- readWritePaths: []
4706
+ [list]: []
4686
4707
  };
4687
- const paths = this._nativeSandboxConfig.readWritePaths;
4708
+ const paths = this._nativeSandboxConfig[list];
4688
4709
  if (!paths.includes(isolationPath)) paths.push(isolationPath);
4689
- if (!this._initialReadWritePaths.has(isolationPath)) this._mountIsolationRefCount.set(isolationPath, (this._mountIsolationRefCount.get(isolationPath) ?? 0) + 1);
4690
- this._mountPathToIsolationPath.set(normMount, isolationPath);
4710
+ if (!(readOnly ? this._initialDenyWritePaths : this._initialReadWritePaths).has(isolationPath)) {
4711
+ const key = `${list}:${isolationPath}`;
4712
+ this._mountIsolationRefCount.set(key, (this._mountIsolationRefCount.get(key) ?? 0) + 1);
4713
+ }
4714
+ this._mountPathToIsolationPath.set(normMount, {
4715
+ path: isolationPath,
4716
+ list
4717
+ });
4718
+ }
4719
+ /** Undo a mount whose isolation couldn't be applied and record it as failed. */
4720
+ async failMountIsolation(filesystem, mountPath, config, error) {
4721
+ this.logger.error("Could not apply mount isolation", {
4722
+ mountPath,
4723
+ error
4724
+ });
4725
+ await this.unmount(mountPath);
4726
+ this.mounts.set(mountPath, {
4727
+ filesystem,
4728
+ state: "error",
4729
+ config,
4730
+ error
4731
+ });
4732
+ return {
4733
+ success: false,
4734
+ mountPath,
4735
+ error
4736
+ };
4691
4737
  }
4692
4738
  /**
4693
- * Reverse {@link addMountPathToIsolation}: drop refcounted paths from the allowlist on unmount
4694
- * while preserving user-provided `readWritePaths` from construction.
4739
+ * Reverse {@link addMountPathToIsolation}: drop refcounted paths from the isolation
4740
+ * config on unmount while preserving user-provided paths from construction.
4695
4741
  */
4696
4742
  removeMountIsolationForPath(mountPath) {
4697
4743
  if (this.isolation === "none") return;
4698
4744
  const normMount = normalizeMountPath(mountPath);
4699
- const isolationPath = this._mountPathToIsolationPath.get(normMount);
4700
- if (isolationPath === void 0) return;
4745
+ const entry = this._mountPathToIsolationPath.get(normMount);
4746
+ if (entry === void 0) return;
4701
4747
  this._mountPathToIsolationPath.delete(normMount);
4702
- if (this._initialReadWritePaths.has(isolationPath)) return;
4703
- const next = (this._mountIsolationRefCount.get(isolationPath) ?? 0) - 1;
4748
+ const { path: isolationPath, list } = entry;
4749
+ if ((list === "denyWritePaths" ? this._initialDenyWritePaths : this._initialReadWritePaths).has(isolationPath)) return;
4750
+ const key = `${list}:${isolationPath}`;
4751
+ const next = (this._mountIsolationRefCount.get(key) ?? 0) - 1;
4704
4752
  if (next <= 0) {
4705
- this._mountIsolationRefCount.delete(isolationPath);
4706
- const paths = this._nativeSandboxConfig.readWritePaths;
4753
+ this._mountIsolationRefCount.delete(key);
4754
+ const paths = this._nativeSandboxConfig[list];
4707
4755
  if (paths) {
4708
4756
  const idx = paths.indexOf(isolationPath);
4709
4757
  if (idx !== -1) paths.splice(idx, 1);
4710
4758
  }
4711
- } else this._mountIsolationRefCount.set(isolationPath, next);
4759
+ } else this._mountIsolationRefCount.set(key, next);
4712
4760
  }
4713
4761
  /**
4714
4762
  * Resolve a virtual mount path to a host filesystem path.
@@ -6690,6 +6738,159 @@ function splitTail(output, tail) {
6690
6738
  };
6691
6739
  }
6692
6740
  /**
6741
+ * tokenx is synchronous and allocates per word, so running it over a multi-MB
6742
+ * output blocks the event loop for seconds. Outputs up to this many chars per
6743
+ * token of budget are counted and cut exactly as before; longer ones never reach
6744
+ * tokenx whole (see `countTokensOver` and `sliceEdge`).
6745
+ */
6746
+ const WINDOW_CHARS_PER_TOKEN = 32;
6747
+ /**
6748
+ * tokenx never gives a non-whitespace segment fewer than one token per this many
6749
+ * UTF-16 chars: 6 by default, and up to 4 code points (8 chars when astral) for
6750
+ * its language rules. So text with more non-whitespace chars than
6751
+ * `limit * MAX_CHARS_PER_TOKEN` is over `limit`.
6752
+ */
6753
+ const MAX_CHARS_PER_TOKEN = 8;
6754
+ const WHITESPACE_RUN_RE = /\s+/g;
6755
+ const STRUCTURED_WHITESPACE_RE = /\n\s/;
6756
+ const WS = 0;
6757
+ const PUNCT = 1;
6758
+ const DIGIT = 2;
6759
+ const WORD = 3;
6760
+ const CHAR_CLASS = (/* @__PURE__ */ new Uint8Array(128)).fill(WORD);
6761
+ for (const c of " \n\r\v\f") CHAR_CLASS[c.charCodeAt(0)] = WS;
6762
+ for (const c of ".,!?;(){}[]<>:/\\|@#$%^&*+=`~_\"-") CHAR_CLASS[c.charCodeAt(0)] = PUNCT;
6763
+ for (let c = 48; c <= 57; c++) CHAR_CLASS[c] = DIGIT;
6764
+ /** Same set as the regex `\s`, which is what tokenx splits words on. */
6765
+ function isWhitespace(code) {
6766
+ return code === 160 || code === 5760 || code >= 8192 && code <= 8202 || code === 8232 || code === 8233 || code === 8239 || code === 8287 || code === 12288 || code === 65279;
6767
+ }
6768
+ function runTokens(kind, length, onlyDigits) {
6769
+ if (kind === WS) return 0;
6770
+ if (length <= 3) return 1;
6771
+ if (kind === PUNCT) return Math.ceil(length / 2);
6772
+ return onlyDigits ? Math.ceil(length / 3) : Math.ceil(length / 6);
6773
+ }
6774
+ /**
6775
+ * One pass over char codes with no allocations: an approximate token count
6776
+ * (tokenx's rules for ASCII text, used only for the "of ~N tokens" total) and
6777
+ * the number of non-whitespace chars.
6778
+ */
6779
+ function scanTokens(text) {
6780
+ let approx = 0;
6781
+ let nonWhitespace = 0;
6782
+ let kind = -1;
6783
+ let length = 0;
6784
+ let onlyDigits = true;
6785
+ for (let i = 0; i < text.length; i++) {
6786
+ const code = text.charCodeAt(i);
6787
+ const cls = code < 128 ? CHAR_CLASS[code] : isWhitespace(code) ? WS : WORD;
6788
+ const runKind = cls === DIGIT ? WORD : cls;
6789
+ if (runKind !== kind) {
6790
+ if (length) approx += runTokens(kind, length, onlyDigits);
6791
+ kind = runKind;
6792
+ length = 0;
6793
+ onlyDigits = true;
6794
+ }
6795
+ length++;
6796
+ if (cls !== WS) nonWhitespace++;
6797
+ if (cls !== DIGIT) onlyDigits = false;
6798
+ }
6799
+ if (length) approx += runTokens(kind, length, onlyDigits);
6800
+ return {
6801
+ approx,
6802
+ nonWhitespace
6803
+ };
6804
+ }
6805
+ /**
6806
+ * Exact token count of `output` when it may fit `limit`, else an approximation.
6807
+ * Returns `undefined` when the output fits, so callers return it as is.
6808
+ */
6809
+ function countTokensOver(output, limit) {
6810
+ if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) {
6811
+ const exact = estimateTokenCount(output);
6812
+ return exact <= limit ? void 0 : exact;
6813
+ }
6814
+ const { approx, nonWhitespace } = scanTokens(output);
6815
+ if (nonWhitespace > limit * MAX_CHARS_PER_TOKEN) return approx;
6816
+ const exact = estimateTokenCount(output.replace(WHITESPACE_RUN_RE, (run) => STRUCTURED_WHITESPACE_RE.test(run) ? "\n " : " "));
6817
+ return exact <= limit ? void 0 : exact;
6818
+ }
6819
+ /**
6820
+ * `budget` tokens from one end of `output`. Outputs within the overall `limit`'s
6821
+ * size cap are cut exactly as before, by `sliceByTokensSafe(output, 0, budget)`
6822
+ * (`'head'`) or `sliceByTokensSafe(output, -budget)` (`'tail'`). Longer ones hand
6823
+ * tokenx only a window at that end, measured as tokenx sees it: whitespace runs
6824
+ * are collapsed (see `countTokensOver`), so padding can't crowd real text out of
6825
+ * the window. The cut is mapped back to the original text, whitespace and all.
6826
+ *
6827
+ * For those longer outputs the cut is approximate: it fits `budget` by tokenx's
6828
+ * count of the kept text, but can land elsewhere than tokenizing the whole output
6829
+ * would. tokenx counts a segment by its whole length, so a window that ends inside
6830
+ * a long segment counts it differently (at a 2,000-token budget, 65,000 'a' then
6831
+ * 'é' keeps 12,000 chars here and 6,000 when the whole output is tokenized).
6832
+ */
6833
+ function sliceEdge(output, budget, limit, side) {
6834
+ if (output.length <= Math.max(limit, 1) * WINDOW_CHARS_PER_TOKEN) return side === "head" ? sliceByTokensSafe(output, 0, budget) : sliceByTokensSafe(output, -budget);
6835
+ const target = Math.max(budget, 1) * WINDOW_CHARS_PER_TOKEN;
6836
+ let size = 0;
6837
+ let inWhitespace = false;
6838
+ let edge = side === "head" ? 0 : output.length;
6839
+ while (side === "head" ? edge < output.length : edge > 0) {
6840
+ const code = output.charCodeAt(side === "head" ? edge : edge - 1);
6841
+ const whitespace = code < 128 ? CHAR_CLASS[code] === WS : isWhitespace(code);
6842
+ const cost = whitespace ? inWhitespace ? 0 : 2 : 1;
6843
+ if (size + cost > target) break;
6844
+ size += cost;
6845
+ inWhitespace = whitespace;
6846
+ edge += side === "head" ? 1 : -1;
6847
+ }
6848
+ const window = side === "head" ? output.slice(0, edge) : output.slice(edge);
6849
+ const runs = [];
6850
+ let collapsed = "";
6851
+ let last = 0;
6852
+ for (const match of window.matchAll(WHITESPACE_RUN_RE)) {
6853
+ collapsed += window.slice(last, match.index);
6854
+ const replacement = STRUCTURED_WHITESPACE_RE.test(match[0]) ? "\n " : " ";
6855
+ runs.push({
6856
+ collapsedStart: collapsed.length,
6857
+ collapsedEnd: collapsed.length + replacement.length,
6858
+ start: match.index,
6859
+ end: match.index + match[0].length
6860
+ });
6861
+ collapsed += replacement;
6862
+ last = match.index + match[0].length;
6863
+ }
6864
+ collapsed += window.slice(last);
6865
+ const toWindowIndex = (index) => {
6866
+ let shift = 0;
6867
+ for (const run of runs) {
6868
+ if (index < run.collapsedStart) break;
6869
+ if (index <= run.collapsedEnd) return index === run.collapsedEnd ? run.end : run.start;
6870
+ shift = run.end - run.collapsedEnd;
6871
+ }
6872
+ return index + shift;
6873
+ };
6874
+ if (side === "head") return sliceSafe(window, 0, toWindowIndex(fitBudget(sliceByTokensSafe(collapsed, 0, budget), budget, side).length));
6875
+ const kept = fitBudget(sliceByTokensSafe(collapsed, -budget), budget, side);
6876
+ return sliceSafe(window, toWindowIndex(collapsed.length - kept.length));
6877
+ }
6878
+ /**
6879
+ * tokenx slices a segment by the chars-per-token of its language, picked from the
6880
+ * chars it contains, so a cut that drops the char that picked it (a lone 'ж' in a run
6881
+ * of CJK) can count several times over `budget` on its own. Recount the kept text,
6882
+ * which is no longer than the bounded input it was cut from, and cut it again until
6883
+ * it fits.
6884
+ */
6885
+ function fitBudget(kept, budget, side) {
6886
+ for (let tokens = estimateTokenCount(kept); kept.length > 0 && tokens > budget; tokens = estimateTokenCount(kept)) {
6887
+ const next = side === "head" ? sliceByTokensSafe(kept, 0, budget) : sliceByTokensSafe(kept, -budget);
6888
+ const length = next.length < kept.length ? next.length : Math.floor(kept.length * budget / tokens);
6889
+ kept = side === "head" ? sliceSafe(kept, 0, length) : sliceSafe(kept, kept.length - length);
6890
+ }
6891
+ return kept;
6892
+ }
6893
+ /**
6693
6894
  * Token-based output limit. Truncates output to fit within a token budget.
6694
6895
  * Uses tokenx for fast token estimation and truncates at the token level
6695
6896
  * (not line boundaries) to maximise use of the budget.
@@ -6702,9 +6903,9 @@ function splitTail(output, tail) {
6702
6903
  */
6703
6904
  async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from = "start") {
6704
6905
  if (!output) return output;
6705
- const totalTokens = estimateTokenCount(output);
6706
- if (totalTokens <= limit) return output;
6707
- const kept = from === "start" ? sliceByTokensSafe(output, -limit) : sliceByTokensSafe(output, 0, limit);
6906
+ const totalTokens = countTokensOver(output, limit);
6907
+ if (totalTokens === void 0) return output;
6908
+ const kept = from === "start" ? sliceEdge(output, limit, limit, "tail") : sliceEdge(output, limit, limit, "head");
6708
6909
  const position = from === "start" ? "last" : "first";
6709
6910
  return from === "start" ? `[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]\n${kept}` : `${kept}\n[output truncated: showing ${position} ~${limit} of ~${totalTokens} tokens]`;
6710
6911
  }
@@ -6714,12 +6915,12 @@ async function applyTokenLimit(output, limit = DEFAULT_MAX_OUTPUT_TOKENS, from =
6714
6915
  */
6715
6916
  function sandwich(output, limit, headRatio, firstLine) {
6716
6917
  if (!output) return output;
6717
- const totalTokens = estimateTokenCount(output);
6718
- if (totalTokens <= limit) return output;
6918
+ const totalTokens = countTokensOver(output, limit);
6919
+ if (totalTokens === void 0) return output;
6719
6920
  const headBudget = Math.floor(limit * headRatio);
6720
6921
  const tailBudget = limit - headBudget;
6721
- let head = headBudget > 0 ? sliceByTokensSafe(output, 0, headBudget) : "";
6722
- let tail = tailBudget > 0 ? sliceByTokensSafe(output, -tailBudget) : "";
6922
+ let head = headBudget > 0 ? sliceEdge(output, headBudget, limit, "head") : "";
6923
+ let tail = tailBudget > 0 ? sliceEdge(output, tailBudget, limit, "tail") : "";
6723
6924
  const headEnd = head.length;
6724
6925
  let tailStart = output.length - tail.length;
6725
6926
  head = head.replace(/\r?\n$/, "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/core",
3
- "version": "1.86.0-alpha.7",
3
+ "version": "1.86.0-alpha.9",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -968,17 +968,17 @@
968
968
  "zod-v3": "npm:zod@3.25.76",
969
969
  "@internal/ai-sdk-v4": "0.0.98",
970
970
  "@internal/ai-sdk-v5": "0.0.98",
971
- "@internal/auth": "0.0.39",
972
971
  "@internal/ai-v6": "0.0.98",
972
+ "@internal/ai-v7": "0.0.98",
973
+ "@internal/auth": "0.0.39",
973
974
  "@internal/core": "0.1.4",
974
- "@internal/deployer": "0.0.4",
975
975
  "@internal/external-types": "0.0.101",
976
- "@internal/llm-recorder": "0.0.87",
977
- "@internal/ai-v7": "0.0.98",
976
+ "@internal/deployer": "0.0.4",
978
977
  "@internal/lint": "0.0.151",
979
- "@internal/voice": "0.0.47",
978
+ "@internal/llm-recorder": "0.0.87",
980
979
  "@internal/test-utils": "0.0.87",
981
- "@internal/types-builder": "0.0.126"
980
+ "@internal/types-builder": "0.0.126",
981
+ "@internal/voice": "0.0.47"
982
982
  },
983
983
  "engines": {
984
984
  "node": ">=22.13.0"