@mastra/core 1.87.0-alpha.4 → 1.87.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/dist/agent/durable/index.cjs +1 -1
  2. package/dist/agent/durable/index.js +1 -1
  3. package/dist/agent/index.cjs +2 -2
  4. package/dist/agent/index.js +2 -2
  5. package/dist/agent-builder/ee/index.cjs +1 -1
  6. package/dist/agent-builder/ee/index.js +1 -1
  7. package/dist/agent-controller/agent-controller.d.ts +6 -0
  8. package/dist/agent-controller/index.cjs +1 -1
  9. package/dist/agent-controller/index.js +1 -1
  10. package/dist/agent-controller/worker-run-binding.d.ts +15 -0
  11. package/dist/{agent-controller-CqcyudV6.cjs → agent-controller-BL-0CKSF.cjs} +47 -5
  12. package/dist/{agent-controller-VBMIPr6h.js → agent-controller-BkG0M35j.js} +47 -5
  13. package/dist/background-tasks/index.cjs +2 -1
  14. package/dist/background-tasks/index.d.ts +1 -1
  15. package/dist/background-tasks/index.js +1 -1
  16. package/dist/background-tasks/resolve-config.d.ts +30 -1
  17. package/dist/background-tasks/system-prompt.d.ts +8 -2
  18. package/dist/background-tasks/types.d.ts +47 -1
  19. package/dist/{background-tasks-1tyymY2H.js → background-tasks-CQ1M8SHw.js} +156 -33
  20. package/dist/{background-tasks-FOaQ1LsS.cjs → background-tasks-DL-ATSvp.cjs} +167 -32
  21. package/dist/browser/index.cjs +1 -1
  22. package/dist/browser/index.js +1 -1
  23. package/dist/{builder-MLhVrFJw.cjs → builder-CVEDotdf.cjs} +2 -2
  24. package/dist/{builder-CUbE9d87.js → builder-DnbKjNuO.js} +2 -2
  25. package/dist/capabilities/302ai.json +194 -194
  26. package/dist/capabilities/abliteratedllm.json +34 -34
  27. package/dist/capabilities/abliteration-ai.json +9 -9
  28. package/dist/capabilities/above.json +19 -19
  29. package/dist/capabilities/adaption.json +8 -8
  30. package/dist/capabilities/adzuki.json +32 -32
  31. package/dist/capabilities/agentrouter.json +5 -5
  32. package/dist/capabilities/agnes.json +2 -2
  33. package/dist/capabilities/ai-router.json +6 -6
  34. package/dist/capabilities/aiand.json +21 -21
  35. package/dist/capabilities/aigrow.json +13 -13
  36. package/dist/capabilities/aimlapi.json +152 -152
  37. package/dist/capabilities/aixy.json +21 -21
  38. package/dist/capabilities/aki-io.json +16 -16
  39. package/dist/capabilities/alibaba-cn.json +104 -104
  40. package/dist/capabilities/alibaba-coding-plan-cn.json +5 -5
  41. package/dist/capabilities/alibaba-coding-plan.json +5 -5
  42. package/dist/capabilities/alibaba-token-plan-cn.json +54 -54
  43. package/dist/capabilities/alibaba-token-plan.json +56 -56
  44. package/dist/capabilities/alibaba.json +101 -67
  45. package/dist/capabilities/ambient.json +7 -7
  46. package/dist/capabilities/amd.json +6 -6
  47. package/dist/capabilities/anthropic.json +50 -50
  48. package/dist/capabilities/anyapi.json +46 -46
  49. package/dist/capabilities/apiko.json +4 -4
  50. package/dist/capabilities/arcee.json +7 -7
  51. package/dist/capabilities/augure.json +6 -6
  52. package/dist/capabilities/auriko.json +19 -19
  53. package/dist/capabilities/bailing.json +5 -5
  54. package/dist/capabilities/baseten.json +34 -34
  55. package/dist/capabilities/bee.json +4 -4
  56. package/dist/capabilities/berget.json +6 -6
  57. package/dist/capabilities/bothub.json +11 -11
  58. package/dist/capabilities/boundless.json +40 -40
  59. package/dist/capabilities/bumo.json +44 -44
  60. package/dist/capabilities/byteplus.json +28 -28
  61. package/dist/capabilities/cerebras.json +4 -4
  62. package/dist/capabilities/cheapaimodel.json +10 -10
  63. package/dist/capabilities/cheapest-token.json +30 -30
  64. package/dist/capabilities/chutes.json +10 -10
  65. package/dist/capabilities/cline-pass.json +38 -38
  66. package/dist/capabilities/cloudcode.json +8 -8
  67. package/dist/capabilities/cloudflare-workers-ai.json +13 -13
  68. package/dist/capabilities/commandcode.json +132 -132
  69. package/dist/capabilities/concentrate.json +273 -293
  70. package/dist/capabilities/cortecs.json +111 -111
  71. package/dist/capabilities/crossmodel.json +206 -206
  72. package/dist/capabilities/crusoe.json +4 -4
  73. package/dist/capabilities/daoxe.json +7 -7
  74. package/dist/capabilities/databricks.json +127 -127
  75. package/dist/capabilities/deepinfra.json +93 -93
  76. package/dist/capabilities/deepseek.json +3 -3
  77. package/dist/capabilities/digitalocean.json +111 -111
  78. package/dist/capabilities/dothoosh.json +31 -31
  79. package/dist/capabilities/doubleword.json +26 -26
  80. package/dist/capabilities/edenai.json +279 -286
  81. package/dist/capabilities/empiriolabs.json +173 -173
  82. package/dist/capabilities/engy.json +18 -18
  83. package/dist/capabilities/entrim.json +8 -8
  84. package/dist/capabilities/evroc.json +16 -16
  85. package/dist/capabilities/ezkielyna.json +11 -11
  86. package/dist/capabilities/fastrouter.json +89 -89
  87. package/dist/capabilities/fireworks-ai.json +82 -82
  88. package/dist/capabilities/freemodel.json +20 -20
  89. package/dist/capabilities/friendli.json +7 -7
  90. package/dist/capabilities/frogbot.json +99 -99
  91. package/dist/capabilities/gisoo.json +20 -20
  92. package/dist/capabilities/gmicloud.json +23 -23
  93. package/dist/capabilities/google.json +49 -49
  94. package/dist/capabilities/graphn.json +12 -12
  95. package/dist/capabilities/greenpt.json +35 -35
  96. package/dist/capabilities/groq.json +2 -2
  97. package/dist/capabilities/helicone.json +78 -78
  98. package/dist/capabilities/hopper.json +2 -2
  99. package/dist/capabilities/hostinger-router.json +4 -4
  100. package/dist/capabilities/hpc-ai.json +11 -11
  101. package/dist/capabilities/huawei-maas.json +10 -10
  102. package/dist/capabilities/hubris.json +29 -29
  103. package/dist/capabilities/huggingface.json +106 -106
  104. package/dist/capabilities/humain.json +2 -2
  105. package/dist/capabilities/hyper.json +24 -24
  106. package/dist/capabilities/impossibl.json +148 -148
  107. package/dist/capabilities/inception.json +2 -2
  108. package/dist/capabilities/inceptron.json +8 -8
  109. package/dist/capabilities/inco.json +4 -4
  110. package/dist/capabilities/infer.json +16 -16
  111. package/dist/capabilities/inferall.json +9 -9
  112. package/dist/capabilities/inference-coop.json +15 -15
  113. package/dist/capabilities/inferenceapis.json +19 -19
  114. package/dist/capabilities/inferris.json +3 -3
  115. package/dist/capabilities/infersia.json +9 -9
  116. package/dist/capabilities/inferx.json +3 -3
  117. package/dist/capabilities/infomaniak.json +2 -2
  118. package/dist/capabilities/io-net.json +2 -2
  119. package/dist/capabilities/isoquant.json +4 -4
  120. package/dist/capabilities/iteracompute.json +48 -48
  121. package/dist/capabilities/jad-ai.json +3 -3
  122. package/dist/capabilities/jalapeno.json +12 -12
  123. package/dist/capabilities/jiekou.json +64 -64
  124. package/dist/capabilities/joingonka.json +4 -4
  125. package/dist/capabilities/jzstoken.json +47 -47
  126. package/dist/capabilities/keln.json +20 -20
  127. package/dist/capabilities/kenari.json +124 -124
  128. package/dist/capabilities/kilo.json +607 -607
  129. package/dist/capabilities/kimi-code-plan-cn.json +6 -6
  130. package/dist/capabilities/kimi-code-plan-global.json +6 -6
  131. package/dist/capabilities/kitani.json +6 -6
  132. package/dist/capabilities/klavo.json +12 -12
  133. package/dist/capabilities/korouter.json +33 -33
  134. package/dist/capabilities/kunavo.json +9 -9
  135. package/dist/capabilities/liquid.json +12 -12
  136. package/dist/capabilities/lithosai.json +2 -2
  137. package/dist/capabilities/llmgateway-providers.json +924 -919
  138. package/dist/capabilities/llmgateway.json +343 -344
  139. package/dist/capabilities/llmtr.json +22 -22
  140. package/dist/capabilities/logits.json +2 -2
  141. package/dist/capabilities/lowrouter.json +66 -66
  142. package/dist/capabilities/lyceum.json +9 -9
  143. package/dist/capabilities/melious.json +14 -14
  144. package/dist/capabilities/merge-gateway.json +259 -259
  145. package/dist/capabilities/meta.json +13 -13
  146. package/dist/capabilities/minimax-cn-coding-plan.json +2 -2
  147. package/dist/capabilities/minimax-coding-plan.json +2 -2
  148. package/dist/capabilities/mistral.json +21 -21
  149. package/dist/capabilities/mixlayer.json +5 -5
  150. package/dist/capabilities/modal.json +13 -13
  151. package/dist/capabilities/model-oracle-ai.json +24 -24
  152. package/dist/capabilities/modelis.json +17 -17
  153. package/dist/capabilities/modular.json +5 -5
  154. package/dist/capabilities/moneo.json +16 -16
  155. package/dist/capabilities/moonshotai-cn.json +5 -5
  156. package/dist/capabilities/moonshotai.json +5 -5
  157. package/dist/capabilities/morph.json +13 -13
  158. package/dist/capabilities/munito-eu.json +6 -6
  159. package/dist/capabilities/munito.json +10 -10
  160. package/dist/capabilities/nan.json +34 -34
  161. package/dist/capabilities/nano-gpt.json +581 -578
  162. package/dist/capabilities/nearai.json +100 -100
  163. package/dist/capabilities/nebius.json +30 -30
  164. package/dist/capabilities/neon.json +135 -135
  165. package/dist/capabilities/neuralwatt.json +41 -41
  166. package/dist/capabilities/novita-ai.json +115 -115
  167. package/dist/capabilities/nvidia.json +27 -27
  168. package/dist/capabilities/obscurify.json +24 -24
  169. package/dist/capabilities/oci.json +7 -7
  170. package/dist/capabilities/ofox.json +325 -325
  171. package/dist/capabilities/ollama-cloud.json +56 -56
  172. package/dist/capabilities/openai.json +55 -55
  173. package/dist/capabilities/opencode-go.json +87 -87
  174. package/dist/capabilities/openreason.json +5 -5
  175. package/dist/capabilities/openrouter.json +522 -522
  176. package/dist/capabilities/opper.json +28 -28
  177. package/dist/capabilities/orcarouter.json +197 -197
  178. package/dist/capabilities/outerlabs.json +25 -25
  179. package/dist/capabilities/ovhcloud.json +22 -22
  180. package/dist/capabilities/pareto.json +6 -6
  181. package/dist/capabilities/perplexity-agent.json +63 -63
  182. package/dist/capabilities/phala.json +24 -24
  183. package/dist/capabilities/pioneer.json +27 -27
  184. package/dist/capabilities/poe.json +139 -139
  185. package/dist/capabilities/poolside.json +3 -3
  186. package/dist/capabilities/powerspring.json +11 -11
  187. package/dist/capabilities/primalabs.json +10 -10
  188. package/dist/capabilities/prime.json +114 -114
  189. package/dist/capabilities/privatemode-ai.json +9 -9
  190. package/dist/capabilities/proxystacks.json +3 -3
  191. package/dist/capabilities/qiniu-ai.json +11 -11
  192. package/dist/capabilities/refuseless.json +10 -10
  193. package/dist/capabilities/regolo-ai.json +10 -10
  194. package/dist/capabilities/requesty.json +201 -167
  195. package/dist/capabilities/ruapi.json +18 -18
  196. package/dist/capabilities/runcrate.json +14 -14
  197. package/dist/capabilities/runinfra.json +21 -21
  198. package/dist/capabilities/sakana.json +6 -6
  199. package/dist/capabilities/sambanova.json +4 -4
  200. package/dist/capabilities/sandbase.json +25 -25
  201. package/dist/capabilities/sarvam.json +9 -9
  202. package/dist/capabilities/scaleway.json +18 -18
  203. package/dist/capabilities/scnet-token-plan.json +9 -9
  204. package/dist/capabilities/scx-ai.json +21 -21
  205. package/dist/capabilities/sensenova.json +13 -13
  206. package/dist/capabilities/siliconflow-cn.json +56 -56
  207. package/dist/capabilities/siliconflow.json +54 -54
  208. package/dist/capabilities/snowflake-cortex.json +25 -25
  209. package/dist/capabilities/sokkan.json +7 -7
  210. package/dist/capabilities/sparrowcodes.json +19 -19
  211. package/dist/capabilities/standardcompute.json +81 -81
  212. package/dist/capabilities/steadyrouter.json +43 -43
  213. package/dist/capabilities/stepfun-ai-step-plan.json +5 -5
  214. package/dist/capabilities/stepfun-ai.json +5 -5
  215. package/dist/capabilities/stepfun-step-plan.json +5 -5
  216. package/dist/capabilities/stepfun.json +5 -5
  217. package/dist/capabilities/stepping-stone.json +20 -20
  218. package/dist/capabilities/synthetic.json +13 -13
  219. package/dist/capabilities/synthorai.json +29 -29
  220. package/dist/capabilities/teamorouter.json +22 -22
  221. package/dist/capabilities/teapot-router.json +13 -13
  222. package/dist/capabilities/tencent-token-plan-intl.json +126 -0
  223. package/dist/capabilities/tencent-token-plan.json +42 -42
  224. package/dist/capabilities/tencent-tokenhub.json +45 -45
  225. package/dist/capabilities/tensorx.json +40 -40
  226. package/dist/capabilities/tenstorrent.json +6 -6
  227. package/dist/capabilities/the-grid-ai.json +24 -24
  228. package/dist/capabilities/thinkingmachines.json +62 -62
  229. package/dist/capabilities/tinfoil.json +12 -12
  230. package/dist/capabilities/toapis.json +3 -3
  231. package/dist/capabilities/togetherai.json +54 -54
  232. package/dist/capabilities/tokengo.json +24 -24
  233. package/dist/capabilities/tokenify.json +10 -10
  234. package/dist/capabilities/trustedrouter.json +5 -5
  235. package/dist/capabilities/trustedtokens.json +18 -18
  236. package/dist/capabilities/umans-ai-coding-plan.json +14 -14
  237. package/dist/capabilities/umans-ai.json +15 -15
  238. package/dist/capabilities/uncensuredai.json +5 -5
  239. package/dist/capabilities/unrestricted.json +6 -6
  240. package/dist/capabilities/uplinkswitch.json +18 -18
  241. package/dist/capabilities/upstage.json +7 -7
  242. package/dist/capabilities/vancine.json +22 -22
  243. package/dist/capabilities/vercel.json +586 -584
  244. package/dist/capabilities/vivgrid.json +80 -80
  245. package/dist/capabilities/volcengine-coding-plan.json +29 -29
  246. package/dist/capabilities/volcengine.json +24 -24
  247. package/dist/capabilities/vultr.json +27 -27
  248. package/dist/capabilities/wafer.ai.json +17 -17
  249. package/dist/capabilities/wally.json +10 -10
  250. package/dist/capabilities/wandb.json +21 -21
  251. package/dist/capabilities/watt.json +24 -24
  252. package/dist/capabilities/xai.json +6 -6
  253. package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
  254. package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
  255. package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
  256. package/dist/capabilities/xiaomi.json +3 -3
  257. package/dist/capabilities/xpersona.json +10 -10
  258. package/dist/capabilities/xxapi.json +26 -26
  259. package/dist/capabilities/zai-coding-plan.json +16 -16
  260. package/dist/capabilities/zai.json +31 -31
  261. package/dist/capabilities/zenifra.json +30 -30
  262. package/dist/capabilities/zenmux.json +185 -185
  263. package/dist/capabilities/zerogpu.json +12 -12
  264. package/dist/capabilities/zhipuai-coding-plan.json +7 -7
  265. package/dist/capabilities/zhipuai.json +30 -30
  266. package/dist/capabilities/zro.json +5 -5
  267. package/dist/channels/index.cjs +2 -2
  268. package/dist/channels/index.js +2 -2
  269. package/dist/{channels-CZ0iY2yh.cjs → channels-DCd_dDOB.cjs} +1 -1
  270. package/dist/{channels-hBppCRhl.js → channels-DwAd1RtQ.js} +1 -1
  271. package/dist/coding-agent/index.cjs +1 -1
  272. package/dist/coding-agent/index.js +1 -1
  273. package/dist/{constants-B9ZDvXZ4.cjs → constants-Bou0hEgY.cjs} +4 -0
  274. package/dist/{constants-BmdTvEYN.js → constants-CFWgIaqA.js} +4 -0
  275. package/dist/datasets/experiment/scorer.d.ts +16 -5
  276. package/dist/datasets/index.cjs +2 -2
  277. package/dist/datasets/index.js +2 -2
  278. package/dist/docs/SKILL.md +1 -1
  279. package/dist/docs/assets/SOURCE_MAP.json +950 -950
  280. package/dist/docs/references/docs-agents-code-mode.md +16 -0
  281. package/dist/docs/references/docs-harness-background-tasks.md +38 -0
  282. package/dist/docs/references/reference-knowledge-knowledge-tools.md +3 -3
  283. package/dist/evals/index.cjs +2 -2
  284. package/dist/evals/index.js +2 -2
  285. package/dist/evals/scoreTraces/index.cjs +2 -2
  286. package/dist/evals/scoreTraces/index.js +2 -2
  287. package/dist/events/index.cjs +1 -1
  288. package/dist/events/index.js +1 -1
  289. package/dist/harness/index.cjs +1 -1
  290. package/dist/harness/index.js +1 -1
  291. package/dist/index.cjs +1 -1
  292. package/dist/index.js +1 -1
  293. package/dist/knowledge/index.cjs +64 -19
  294. package/dist/knowledge/index.d.ts +6 -2
  295. package/dist/knowledge/index.js +64 -19
  296. package/dist/knowledge/page-tools.d.ts +9 -0
  297. package/dist/knowledge/pinned-state-processor.d.ts +2 -2
  298. package/dist/knowledge/run.d.ts +4 -0
  299. package/dist/knowledge/scope-runtime.d.ts +6 -0
  300. package/dist/llm/index.cjs +3 -3
  301. package/dist/llm/index.js +3 -3
  302. package/dist/llm/model/provider-types.generated.d.ts +7383 -7372
  303. package/dist/{llm-CsQOELh9.js → llm-BdHdjrHp.js} +2 -2
  304. package/dist/{llm-D6N-WJwo.cjs → llm-DQTGexjo.cjs} +2 -2
  305. package/dist/loop/index.cjs +2 -2
  306. package/dist/loop/index.js +2 -2
  307. package/dist/{manager-DBVDNjO2.js → manager-BxE49QHe.js} +106 -35
  308. package/dist/{manager-CtsjlKP7.cjs → manager-CjT4ivOl.cjs} +106 -35
  309. package/dist/mastra/index.cjs +1 -1
  310. package/dist/mastra/index.js +1 -1
  311. package/dist/{mastra-B60fJsMe.cjs → mastra-CraMHXhw.cjs} +17 -17
  312. package/dist/{mastra-Bkpe1lBu.js → mastra-DKjpNZ-1.js} +17 -17
  313. package/dist/memory/index.cjs +2 -2
  314. package/dist/memory/index.js +2 -2
  315. package/dist/{model-CAbL0zRc.cjs → model-BEFQWHnG.cjs} +1 -1
  316. package/dist/{model-Da_pawSI.js → model-X2gWHlAy.js} +1 -1
  317. package/dist/{netlify-hasf5dLA.cjs → netlify-BFgeBsaW.cjs} +1 -1
  318. package/dist/{netlify-CW26UJrG.js → netlify-kxJSdqCW.js} +1 -1
  319. package/dist/notifications/index.cjs +1 -1
  320. package/dist/notifications/index.js +1 -1
  321. package/dist/processor-provider/index.cjs +1 -1
  322. package/dist/processor-provider/index.js +1 -1
  323. package/dist/processors/index.cjs +2 -2
  324. package/dist/processors/index.js +2 -2
  325. package/dist/{provider-registry-CeV5wjlF.cjs → provider-registry-BXDosXMN.cjs} +21907 -21876
  326. package/dist/{provider-registry-DnVkqIBw.js → provider-registry-DgezoItQ.js} +21907 -21876
  327. package/dist/provider-registry.json +22118 -22087
  328. package/dist/{registry-generator-DSR56u5H.js → registry-generator-B50FrVGs.js} +1 -1
  329. package/dist/{registry-generator-G4PZCqrS.cjs → registry-generator-BMXgTdbx.cjs} +1 -1
  330. package/dist/{rehydrate-BLJ-q_V6.cjs → rehydrate-CBcjKKGA.cjs} +2 -2
  331. package/dist/{rehydrate-zXo3Wo60.js → rehydrate-Dp8f_1MN.js} +2 -2
  332. package/dist/relevance/index.cjs +2 -2
  333. package/dist/relevance/index.js +2 -2
  334. package/dist/{run-registry-oixTpWpa.cjs → run-registry-BRO8xz9z.cjs} +213 -43
  335. package/dist/{run-registry-Cl2QbXgN.js → run-registry-H2qdwHni.js} +196 -44
  336. package/dist/storage/constants.cjs +1 -1
  337. package/dist/storage/constants.js +1 -1
  338. package/dist/storage/domains/knowledge/base.d.ts +16 -1
  339. package/dist/storage/domains/knowledge/importers-inmemory.d.ts +1 -0
  340. package/dist/storage/domains/knowledge/importers.d.ts +8 -0
  341. package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
  342. package/dist/storage/domains/knowledge/pages-inmemory.d.ts +5 -1
  343. package/dist/storage/index.cjs +3 -3
  344. package/dist/storage/index.js +3 -3
  345. package/dist/storage/types.d.ts +8 -0
  346. package/dist/stream/index.cjs +2 -2
  347. package/dist/stream/index.js +2 -2
  348. package/dist/{stream-DUUfwH38.js → stream-DcYRY4r3.js} +1 -1
  349. package/dist/{stream-DaZh0apo.cjs → stream-nABk9CJK.cjs} +1 -1
  350. package/dist/test-utils/llm-mock.cjs +1 -1
  351. package/dist/test-utils/llm-mock.js +1 -1
  352. package/dist/tool-loop-agent/index.cjs +1 -1
  353. package/dist/tool-loop-agent/index.js +1 -1
  354. package/dist/{tool-loop-agent-DDowWQyO.cjs → tool-loop-agent-D1Rufbcz.cjs} +3 -3
  355. package/dist/{tool-loop-agent-C4NvGYnM.js → tool-loop-agent-DO-GkLD_.js} +3 -3
  356. package/dist/{utils-CmNJO2xP.cjs → utils-DY0lTRKE.cjs} +7 -6
  357. package/dist/{utils-CVN-336o.js → utils-DlsFs_sO.js} +7 -6
  358. package/dist/utils.cjs +1 -1
  359. package/dist/utils.js +1 -1
  360. package/dist/{validate-CgNNzqgp.js → validate-D4nqo7Ri.js} +1 -1
  361. package/dist/{validate-LpK3-p_O.cjs → validate-DP9DxgFq.cjs} +1 -1
  362. package/dist/vector/index.cjs +1 -1
  363. package/dist/vector/index.js +1 -1
  364. package/dist/worker/index.cjs +1 -1
  365. package/dist/worker/index.js +1 -1
  366. package/dist/worker/workers/orchestration-worker.d.ts +1 -0
  367. package/dist/{worker-BdPUoHXa.js → worker-8MNVG9Ja.js} +2 -2
  368. package/dist/{worker-ChoZX7rg.js → worker-Ckryk6RZ.js} +5 -5
  369. package/dist/{worker-6qR81hZZ.cjs → worker-CqEMDlAQ.cjs} +2 -2
  370. package/dist/{worker-BN2odJzu.cjs → worker-LryffZas.cjs} +10 -4
  371. package/dist/{workflow-D2MsV-JA.js → workflow-B0mhMnuQ.js} +3 -3
  372. package/dist/{workflow-ww-N09bR.cjs → workflow-BN6YiI09.cjs} +3 -3
  373. package/dist/workflows/builder/index.cjs +1 -1
  374. package/dist/workflows/builder/index.js +1 -1
  375. package/dist/workflows/evented/index.cjs +1 -1
  376. package/dist/workflows/evented/index.js +1 -1
  377. package/dist/workflows/index.cjs +4 -4
  378. package/dist/workflows/index.js +4 -4
  379. package/package.json +7 -7
  380. package/src/llm/model/provider-types.generated.d.ts +7383 -7372
@@ -1,4 +1,4 @@
1
- import { _ as getCapabilityFileName, g as shouldEnableGateway, m as getGatewayId } from "./netlify-CW26UJrG.js";
1
+ import { _ as getCapabilityFileName, g as shouldEnableGateway, m as getGatewayId } from "./netlify-kxJSdqCW.js";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
4
  // src/llm/model/registry-generator.ts
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BrhgMLW6.cjs");
2
- const require_netlify = require("./netlify-hasf5dLA.cjs");
2
+ const require_netlify = require("./netlify-BFgeBsaW.cjs");
3
3
  let path = require("path");
4
4
  path = require_rolldown_runtime.__toESM(path, 1);
5
5
  let fs_promises = require("fs/promises");
@@ -1,6 +1,6 @@
1
- const require_run_registry = require("./run-registry-oixTpWpa.cjs");
1
+ const require_run_registry = require("./run-registry-BRO8xz9z.cjs");
2
2
  const require_predicate_index = require("./predicate/index.cjs");
3
- const require_validate = require("./validate-LpK3-p_O.cjs");
3
+ const require_validate = require("./validate-DP9DxgFq.cjs");
4
4
  let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { Cc as predicateToCondition, Fs as cloneWorkflow, Gc as createStepFromTool, Is as createEventedWorkflow, Ls as createWorkflow, Sc as mapVariable, Uc as createStepFromAgent, al as getSingleStepEntryId } from "./run-registry-Cl2QbXgN.js";
1
+ import { Ec as predicateToCondition, Is as cloneWorkflow, Jc as createStepFromTool, Kc as createStepFromAgent, Ls as createEventedWorkflow, Rs as createWorkflow, Tc as mapVariable, cl as getSingleStepEntryId } from "./run-registry-H2qdwHni.js";
2
2
  import { derivePredicateLabel } from "./predicate/index.js";
3
- import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-CgNNzqgp.js";
3
+ import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-D4nqo7Ri.js";
4
4
  import { standardSchemaToJSONSchema, toStandardSchema } from "./schema/index.js";
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_run_registry = require("../run-registry-oixTpWpa.cjs");
3
- const require_stream = require("../stream-DaZh0apo.cjs");
2
+ const require_run_registry = require("../run-registry-BRO8xz9z.cjs");
3
+ const require_stream = require("../stream-nABk9CJK.cjs");
4
4
  // src/relevance/relevance-score-provider.ts
5
5
  function createSimilarityPrompt(query, text) {
6
6
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -1,5 +1,5 @@
1
- import { P as Agent } from "../run-registry-Cl2QbXgN.js";
2
- import { ln as isSupportedLanguageModel } from "../stream-DUUfwH38.js";
1
+ import { P as Agent } from "../run-registry-H2qdwHni.js";
2
+ import { ln as isSupportedLanguageModel } from "../stream-DcYRY4r3.js";
3
3
  // src/relevance/relevance-score-provider.ts
4
4
  function createSimilarityPrompt(query, text) {
5
5
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -4,14 +4,14 @@ const require_base = require("./base-BIzR1D3_.cjs");
4
4
  const require_observability = require("./observability-B0R_D1PZ.cjs");
5
5
  const require_error = require("./error-D90lJ6M7.cjs");
6
6
  const require_error$1 = require("./error-L1V4uUbd.cjs");
7
- const require_stream = require("./stream-DaZh0apo.cjs");
7
+ const require_stream = require("./stream-nABk9CJK.cjs");
8
8
  const require_request_context = require("./request-context-D9RXYCy8.cjs");
9
9
  const require_output_helpers = require("./output-helpers-DgsH4aTb.cjs");
10
10
  const require_message_list = require("./message-list-vR3uLAHL.cjs");
11
11
  const require_storage = require("./storage-CfG0I2aF.cjs");
12
12
  const require_utils = require("./utils-D-eNsgDM.cjs");
13
13
  const require_error_count = require("./error-count-DeDpeWU2.cjs");
14
- const require_llm = require("./llm-D6N-WJwo.cjs");
14
+ const require_llm = require("./llm-DQTGexjo.cjs");
15
15
  const require_payload_transform = require("./payload-transform-CWgnsO9w.cjs");
16
16
  const require_utils_safe_stringify = require("./utils/safe-stringify.cjs");
17
17
  const require_signals = require("./signals-CWxAMEmE.cjs");
@@ -23,13 +23,13 @@ const require_tool = require("./tool-CYlT2UA-.cjs");
23
23
  const require_toolchecks = require("./toolchecks-MFU48cit.cjs");
24
24
  const require_fetchWithRetry = require("./fetchWithRetry-f5k4p7_1.cjs");
25
25
  const require_model = require("./model-jBymoqGa.cjs");
26
- const require_provider_registry = require("./provider-registry-CeV5wjlF.cjs");
26
+ const require_provider_registry = require("./provider-registry-BXDosXMN.cjs");
27
27
  const require_inmemory = require("./inmemory-Dc86VWGB.cjs");
28
28
  const require_dynamic_argument = require("./dynamic-argument-CUc1BBOS.cjs");
29
- const require_model$1 = require("./model-CAbL0zRc.cjs");
30
- const require_utils$1 = require("./utils-CmNJO2xP.cjs");
29
+ const require_model$1 = require("./model-BEFQWHnG.cjs");
30
+ const require_utils$1 = require("./utils-DY0lTRKE.cjs");
31
31
  const require_ee_iTj2bRDt = require("./ee-iTj2bRDt-D3-QLGDF.cjs");
32
- const require_background_tasks = require("./background-tasks-FOaQ1LsS.cjs");
32
+ const require_background_tasks = require("./background-tasks-DL-ATSvp.cjs");
33
33
  const require_stream$1 = require("./stream-BGbj9jAU.cjs");
34
34
  const require_predicate_index = require("./predicate/index.cjs");
35
35
  const require_classifier_index = require("./classifier/index.cjs");
@@ -38,7 +38,7 @@ const require_workflows_constants = require("./workflows/constants.cjs");
38
38
  const require_hooks = require("./hooks-D7VDBETj.cjs");
39
39
  const require_schedules = require("./schedules-BZS8McF7.cjs");
40
40
  const require_state_processor = require("./state-processor-kRNZ38Nf.cjs");
41
- const require_constants = require("./constants-B9ZDvXZ4.cjs");
41
+ const require_constants = require("./constants-Bou0hEgY.cjs");
42
42
  const require_signal_provider = require("./signal-provider-BFAvh_AJ.cjs");
43
43
  const require_slugify = require("./slugify-B_WzG9IY.cjs");
44
44
  const require_workspace = require("./workspace-Pv3J8K0c.cjs");
@@ -11714,6 +11714,21 @@ function warnUnsupportedEventedSetup(mastra, workflowsStore) {
11714
11714
  warnedHosts.add(mastra);
11715
11715
  mastra.getLogger()?.warn(`Evented workflows and agents aren't supported on several processes with this setup: ${missing}. See ${DOCS_URL}`);
11716
11716
  }
11717
+ // src/agent-controller/worker-run-binding.ts
11718
+ const CONTROLLER_RUN_BINDING_KEY = "mastra__controllerRunBinding";
11719
+ const controllerRunBindingSchema = zod_v4.z.object({
11720
+ controllerId: zod_v4.z.string().min(1),
11721
+ agentId: zod_v4.z.string().min(1),
11722
+ sessionId: zod_v4.z.string().min(1),
11723
+ ownerId: zod_v4.z.string(),
11724
+ resourceId: zod_v4.z.string().min(1),
11725
+ threadId: zod_v4.z.string().min(1),
11726
+ modeId: zod_v4.z.string().min(1)
11727
+ });
11728
+ const restoredWorkerControllerContexts = /* @__PURE__ */ new WeakSet();
11729
+ function isRestoredWorkerControllerContext(value) {
11730
+ return typeof value === "object" && value !== null && restoredWorkerControllerContexts.has(value);
11731
+ }
11717
11732
  // src/agent/scopes.ts
11718
11733
  /**
11719
11734
  * Scope types Memory reads as the run's identity. Every other scope type is
@@ -12029,6 +12044,8 @@ function restoreRequestContext(entries, runLevel, liveRunContext) {
12029
12044
  if (liveRunContext) return liveRunContext;
12030
12045
  if (entries) {
12031
12046
  const restored = new require_request_context.RequestContext([...Object.entries(require_request_context.withoutLiveRequestKeys(entries)), ...liveRequestEntries(runLevel)]);
12047
+ const controller = runLevel?.get("controller");
12048
+ if (isRestoredWorkerControllerContext(controller)) restored.set("controller", controller);
12032
12049
  restoreRunAgentScopes(restored);
12033
12050
  return restored;
12034
12051
  }
@@ -15492,7 +15509,8 @@ var StepExecutor = class extends require_base.MastraBase {
15492
15509
  return require_stream.storageV2StepResultAccessors((step) => require_stream.getHydratedStepResult(stepResults, step, hydrate));
15493
15510
  }
15494
15511
  async execute(params) {
15495
- const { entry, stepResults, runId, requestContext, retryCount = 0, perStep } = params;
15512
+ const { entry, stepResults, runId, retryCount = 0, perStep } = params;
15513
+ let { requestContext } = params;
15496
15514
  const stepId = getEntryId(entry);
15497
15515
  const errorAttemptId = `${runId}:${stepId}:${params.foreachIdx ?? ""}:attempt:${retryCount}`;
15498
15516
  const schemas = getEntrySchemas(entry, this.mastra);
@@ -15548,6 +15566,18 @@ var StepExecutor = class extends require_base.MastraBase {
15548
15566
  const stepTracingContext = workflowStepSpan ? { currentSpan: workflowStepSpan } : params.tracingContext ?? {};
15549
15567
  try {
15550
15568
  if (validationError) throw validationError;
15569
+ if (params.workflowId === DurableStepIds.AGENTIC_LOOP || params.workflowId === DurableStepIds.AGENTIC_EXECUTION) {
15570
+ const live = requestContext.get("controller");
15571
+ const initial = stepResults.input;
15572
+ const binding = initial?.requestContextEntries?.[CONTROLLER_RUN_BINDING_KEY];
15573
+ if (initial && binding !== void 0 && typeof live?.getState !== "function") {
15574
+ const parsed = controllerRunBindingSchema.parse(binding);
15575
+ if (initial.agentId !== parsed.agentId || initial.state?.threadId !== parsed.threadId || initial.state.resourceId !== parsed.resourceId) throw new Error("Controller binding does not match this durable run");
15576
+ const controller = this.mastra?.getAgentControllerById(parsed.controllerId);
15577
+ if (!controller) throw new Error("Controller is not registered on this worker");
15578
+ requestContext = await controller.__restoreWorkerRequestContext(requestContext, parsed, abortController.signal, initial.runId);
15579
+ }
15580
+ }
15551
15581
  const callId = globalThis.crypto.randomUUID();
15552
15582
  const outputWriter = this.createOutputWriter(runId);
15553
15583
  const stepOutput = await require_utils.executeWithContext({
@@ -38737,6 +38767,7 @@ var ExperimentsInMemory = class extends ExperimentsStorage {
38737
38767
  targetType: input.targetType ?? null,
38738
38768
  targetId: input.targetId ?? null,
38739
38769
  scorerIds: input.scorerIds ?? null,
38770
+ scorerVersions: input.scorerVersions ?? null,
38740
38771
  name: input.name,
38741
38772
  description: input.description,
38742
38773
  metadata: input.metadata,
@@ -39643,6 +39674,31 @@ var KnowledgeStorage = class extends require_filesystem_versioned.StorageDomain
39643
39674
  getPages(_input) {
39644
39675
  return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPages"));
39645
39676
  }
39677
+ /**
39678
+ * The page `parentId` and its ancestors, nearest first: for each row what {@link getPage} would
39679
+ * return with the same `read`, deleted rows included. Stops after the first scope page, before
39680
+ * the first row `getPage` would return null for, or after {@link MAX_KNOWLEDGE_PAGE_DEPTH} + 1
39681
+ * rows. Lets a caller holding a page walk its parents in one call instead of one per level.
39682
+ *
39683
+ * The base class reads one {@link getPage} per level; adapters that can read the chain in one
39684
+ * query override it.
39685
+ *
39686
+ * @experimental
39687
+ */
39688
+ async getPageParents(input) {
39689
+ const parents = [];
39690
+ let id = input.parentId;
39691
+ while (id && parents.length <= 10) {
39692
+ const page = await this.getPage({
39693
+ id,
39694
+ read: input.read
39695
+ });
39696
+ if (!page) break;
39697
+ parents.push(page);
39698
+ id = page.isScope ? null : page.parentId;
39699
+ }
39700
+ return parents;
39701
+ }
39646
39702
  getPageByPath(_input) {
39647
39703
  return Promise.reject(new KnowledgeUnsupportedCapabilityError("getPageByPath"));
39648
39704
  }
@@ -39960,6 +40016,12 @@ var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage
39960
40016
  const node = this.#s.nodes.get(key(bindingId, sourceId));
39961
40017
  return node ? structuredClone(node) : null;
39962
40018
  }
40019
+ async getNodes(bindingId, sourceIds) {
40020
+ return [...new Set(sourceIds)].flatMap((sourceId) => {
40021
+ const node = this.#s.nodes.get(key(bindingId, sourceId));
40022
+ return node ? [structuredClone(node)] : [];
40023
+ });
40024
+ }
39963
40025
  async getNodeByPage(pageId) {
39964
40026
  const node = [...this.#s.nodes.values()].find((n) => n.pageId === pageId);
39965
40027
  return node ? structuredClone(node) : null;
@@ -40350,6 +40412,15 @@ var InMemoryKnowledgePageStore = class {
40350
40412
  const page = this.#pages.get(input.id);
40351
40413
  return page && this.#pageReadable(page, input.read) ? clone$1(page) : null;
40352
40414
  }
40415
+ async getPageParents(input) {
40416
+ const parents = [];
40417
+ let page = this.#pages.get(input.parentId);
40418
+ while (page && this.#pageReadable(page, input.read) && parents.length <= 10) {
40419
+ parents.push(clone$1(page));
40420
+ page = page.isScope || !page.parentId ? void 0 : this.#pages.get(page.parentId);
40421
+ }
40422
+ return parents;
40423
+ }
40353
40424
  async getPages(input) {
40354
40425
  return [...new Set(input.ids)].map((id) => this.#pages.get(id)).filter((page) => !!page && !page.deletedAt && this.#pageReadable(page, input.read)).map(clone$1);
40355
40426
  }
@@ -40857,6 +40928,9 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
40857
40928
  getPage(input) {
40858
40929
  return this.#pageStore.getPage(input);
40859
40930
  }
40931
+ getPageParents(input) {
40932
+ return this.#pageStore.getPageParents(input);
40933
+ }
40860
40934
  listScopeDeclarations() {
40861
40935
  return this.#pageStore.listScopeDeclarations();
40862
40936
  }
@@ -53499,17 +53573,19 @@ async function pageRefKeys(storage, page) {
53499
53573
  if (page.address) keys.push(knowledgeLinkRefKey(page.address));
53500
53574
  return keys;
53501
53575
  }
53576
+ if (!page.key || !page.parentId) return keys;
53502
53577
  const path = [];
53503
- let current = page;
53504
- while (current && !current.isScope) {
53578
+ for (const current of [page, ...await storage.getPageParents({
53579
+ parentId: page.parentId,
53580
+ read: "all"
53581
+ })]) {
53582
+ if (current.isScope) {
53583
+ if (current.address) keys.push(knowledgeLinkRefKey(`${current.address}#${path.join("/")}`));
53584
+ return keys;
53585
+ }
53505
53586
  if (!current.key || !current.parentId) return keys;
53506
53587
  path.unshift(current.key);
53507
- current = await storage.getPage({
53508
- id: current.parentId,
53509
- read: "all"
53510
- });
53511
53588
  }
53512
- if (current?.address) keys.push(knowledgeLinkRefKey(`${current.address}#${path.join("/")}`));
53513
53589
  return keys;
53514
53590
  }
53515
53591
  /** The page and its live ordinary descendants, at most {@link MAX_KNOWLEDGE_MOVE_PAGES} + 1. */
@@ -63010,6 +63086,13 @@ var KnowledgeNotFoundError = class extends Error {
63010
63086
  this.name = "KnowledgeNotFoundError";
63011
63087
  }
63012
63088
  };
63089
+ /** A run with no scopes and no Memory identity: it has no Knowledge view. @internal */
63090
+ var KnowledgeRunScopesError = class extends Error {
63091
+ constructor() {
63092
+ super("Knowledge tools need run scopes: give the agent or the call `scopes`, or run it with Memory.");
63093
+ this.name = "KnowledgeRunScopesError";
63094
+ }
63095
+ };
63013
63096
  const NAME_CANDIDATES = 5;
63014
63097
  const CLOSE_MATCHES = 3;
63015
63098
  /**
@@ -63161,7 +63244,7 @@ function knowledgeRunPrincipals(runtime, context) {
63161
63244
  const memory = [];
63162
63245
  if (context?.agent?.resourceId) memory.push(knowledgeScopeAddress("resource:$resourceId", { resourceId: context.agent.resourceId }));
63163
63246
  if (context?.agent?.threadId) memory.push(knowledgeScopeAddress("thread:$threadId", { threadId: context.agent.threadId }));
63164
- if (raw.length === 0 && memory.length === 0) throw new Error("Knowledge tools need run scopes: give the agent or the call `scopes`, or run it with Memory.");
63247
+ if (raw.length === 0 && memory.length === 0) throw new KnowledgeRunScopesError();
63165
63248
  for (const address of memory) if (!runtime.compiled.match(address)) throw new KnowledgeDeclarationError(`Knowledge run scope "${address}" does not match a declared scope type. Declare it in Knowledge \`scopes\` (for Memory's resource:/thread: scopes, spread \`...knowledgeMemoryScopes()\`).`);
63166
63249
  return [.../* @__PURE__ */ new Set([...knowledgeRunScopes(runtime.compiled, raw), ...memory])];
63167
63250
  }
@@ -63537,6 +63620,30 @@ async function noteSummaries(run, notes, cache = /* @__PURE__ */ new Map()) {
63537
63620
  for (const note of notes) summaries.push(noteSummary(note, await noteMentions(run, note, cache)));
63538
63621
  return summaries;
63539
63622
  }
63623
+ /**
63624
+ * Every scope the run holds, in principal order, with its role and what it can do there. A held scope
63625
+ * gets its page on the first write, so before that its role comes from the declarations and the parent
63626
+ * that write would link it under: without it a model sees no scopes on its first turn and concludes it
63627
+ * has nowhere to write. A stored scope it can't read keeps only its address.
63628
+ */
63629
+ async function heldScopes(run) {
63630
+ const stored = await run.storage.getScopesByAddress(run.principals);
63631
+ return Promise.all(run.principals.map(async (address) => {
63632
+ const found = stored.find((scope) => scope.address === address);
63633
+ const page = found && knowledgeScopeReadable(found, run.read) ? found : void 0;
63634
+ const role = found ? await run.roleOn(found) : knowledgeRoleOn(run.runtime.compiled, run.principals, {
63635
+ address,
63636
+ parentAddress: run.runtime.firstWriteParentAddress(address, run.principals)
63637
+ });
63638
+ const can = !role ? "none" : knowledgeRoleAtLeast(role, "contributor") ? "write" : "read";
63639
+ return {
63640
+ address,
63641
+ ...page ? { page } : {},
63642
+ role,
63643
+ can
63644
+ };
63645
+ }));
63646
+ }
63540
63647
  /** Scope pages for addresses the run names; each must be readable. */
63541
63648
  async function readableScopes(run, addresses) {
63542
63649
  const page = addresses.find((address) => address.includes("#"));
@@ -63817,7 +63924,7 @@ function bodyView(body, input) {
63817
63924
  function readTool(host, canEdit) {
63818
63925
  return require_tool.createTool({
63819
63926
  id: "knowledge_read",
63820
- description: `Read a page: its body, its notes, its child pages and the notes on other pages that mention it. Read a scope address (org:acme) to browse that scope. Without \`page\`, lists the scopes this run holds. When a page's notes, or the notes mentioning it, come to more than ${KNOWLEDGE_READ_INLINE_TOKENS.toLocaleString("en-US")} tokens, a whole read leaves them out and counts them in \`more\`; read them on their own with \`notes\` or \`mentionedIn\`. A body returns at most ${maxTokensOf(host).toLocaleString("en-US")} tokens at a time. A body that fits comes whole as \`body\`; a longer one comes as numbered \`lines\` (\`12\u2502text\`) with the \`range\` they cover, and \`more\` says where to read on; a first read of a long page shows every heading with its line number and the first lines under it, so you can pick the part to read. For a long page, ask for its \`outline\` of headings with their line numbers, read one \`section\`, or \`match\` terms to see only the lines that contain them, with \`context\` lines around each. Those part reads return just that part of the body.` + (canEdit ? " To edit part of a long body, pass the `range` a read gave you to knowledge_page." : ""),
63927
+ description: `Read a page: its body, its notes, its child pages and the notes on other pages that mention it. Read a scope address (org:acme) to browse that scope. Without \`page\`, lists every scope this run holds, with its role and whether it can read or write there, including scopes with no page this run can read yet (\`empty\`). When a page's notes, or the notes mentioning it, come to more than ${KNOWLEDGE_READ_INLINE_TOKENS.toLocaleString("en-US")} tokens, a whole read leaves them out and counts them in \`more\`; read them on their own with \`notes\` or \`mentionedIn\`. A body returns at most ${maxTokensOf(host).toLocaleString("en-US")} tokens at a time. A body that fits comes whole as \`body\`; a longer one comes as numbered \`lines\` (\`12\u2502text\`) with the \`range\` they cover, and \`more\` says where to read on; a first read of a long page shows every heading with its line number and the first lines under it, so you can pick the part to read. For a long page, ask for its \`outline\` of headings with their line numbers, read one \`section\`, or \`match\` terms to see only the lines that contain them, with \`context\` lines around each. Those part reads return just that part of the body.` + (canEdit ? " To edit part of a long body, pass the `range` a read gave you to knowledge_page." : ""),
63821
63928
  inputSchema: {
63822
63929
  type: "object",
63823
63930
  properties: {
@@ -63899,10 +64006,13 @@ function readTool(host, canEdit) {
63899
64006
  if (outline && from) throw new Error("knowledge_read: an outline covers the whole body; pass it without from.");
63900
64007
  const run = await start(host, context);
63901
64008
  const limit = limitOf(requested);
63902
- if (!ref) return { scopes: (await run.storage.getScopesByAddress(run.principals)).filter((scope) => knowledgeScopeReadable(scope, run.read)).map((scope) => ({
63903
- address: scope.address,
63904
- name: scope.name,
63905
- ...scope.description ? { description: scope.description } : {}
64009
+ if (!ref) return { scopes: (await heldScopes(run)).map(({ address, page, role, can }) => ({
64010
+ address,
64011
+ name: page?.name ?? address,
64012
+ ...page?.description ? { description: page.description } : {},
64013
+ ...role ? { role } : {},
64014
+ can,
64015
+ ...page ? {} : { empty: true }
63906
64016
  })) };
63907
64017
  const page = await run.pageOrCloseMatches(ref);
63908
64018
  if (outline || section || match || from) {
@@ -64116,12 +64226,13 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
64116
64226
  let scopes = [];
64117
64227
  if (!origin) {
64118
64228
  if (cursor?.startsWith("p")) throw new Error("knowledge_list: a page cursor needs the `from` it came from.");
64119
- const held = await run.storage.getScopesByAddress(run.principals);
64120
- const order = (scope) => run.principals.indexOf(scope.address ?? "");
64121
- scopes = held.filter((scope) => knowledgeScopeReadable(scope, run.read)).sort((a, b) => order(a) - order(b));
64229
+ scopes = (await heldScopes(run)).map((held) => ({
64230
+ ...held.page ? { page: held.page } : {},
64231
+ held
64232
+ }));
64122
64233
  } else {
64123
64234
  originRef = (await pageRefs(run, [origin])).refs.get(origin.id) ?? origin.id;
64124
- if (origin.isScope && !cursor?.startsWith("p")) scopes = await childScopes(origin.id);
64235
+ if (origin.isScope && !cursor?.startsWith("p")) scopes = (await childScopes(origin.id)).map((page) => ({ page }));
64125
64236
  }
64126
64237
  const shownScopes = scopes.slice(scopeOffset, scopeOffset + limit);
64127
64238
  let roots = shownScopes;
@@ -64131,7 +64242,7 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
64131
64242
  const room = limit - shownScopes.length;
64132
64243
  if (room > 0) {
64133
64244
  const pages = await childPages(origin.id, room, pageCursor);
64134
- roots = [...shownScopes, ...pages.pages];
64245
+ roots = [...shownScopes, ...pages.pages.map((page) => ({ page }))];
64135
64246
  if (pages.nextCursor) nextCursor = `p${pages.nextCursor}`;
64136
64247
  } else if ((await run.storage.countChildPages({
64137
64248
  parentIds: [origin.id],
@@ -64145,10 +64256,19 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
64145
64256
  children: 0,
64146
64257
  below: []
64147
64258
  });
64148
- const top = roots.map((page) => nodeOf(page, origin && originRef ? childRef(origin, originRef, page) : page.address ?? page.id, 1));
64259
+ const top = roots.map(({ page, held }) => page ? {
64260
+ ...nodeOf(page, origin && originRef ? childRef(origin, originRef, page) : page.address ?? page.id, 1),
64261
+ ...held ? { held } : {}
64262
+ } : {
64263
+ held,
64264
+ ref: held.address,
64265
+ depth: 1,
64266
+ children: 0,
64267
+ below: []
64268
+ });
64149
64269
  let budget = Math.max(limit - top.length, 0);
64150
64270
  let truncated = false;
64151
- let level = top;
64271
+ let level = top.filter((node) => node.page);
64152
64272
  for (let current = 1; current <= depth && level.length; current++) {
64153
64273
  const parentIds = level.map((node) => node.page.id);
64154
64274
  const scopeParents = level.filter((node) => node.page.isScope).map((node) => node.page.id);
@@ -64172,22 +64292,30 @@ async function listKnowledgeTree(run, { origin, depth, limit, cursor, descriptio
64172
64292
  budget -= scopes.length;
64173
64293
  const pages = budget > 0 ? (await childPages(node.page.id, budget)).pages : [];
64174
64294
  budget -= pages.length;
64175
- node.below = [...scopes, ...pages].map((child) => nodeOf(child, childRef(node.page, node.ref, child), current + 1));
64176
- if (node.below.length < node.children) truncated = true;
64177
- nextLevel.push(...node.below);
64295
+ const below = [...scopes, ...pages].map((child) => ({
64296
+ ...nodeOf(child, childRef(node.page, node.ref, child), current + 1),
64297
+ page: child
64298
+ }));
64299
+ node.below = below;
64300
+ if (below.length < node.children) truncated = true;
64301
+ nextLevel.push(...below);
64178
64302
  }
64179
64303
  level = nextLevel;
64180
64304
  }
64181
64305
  const entries = [];
64182
64306
  const flatten = (nodes) => {
64183
64307
  for (const node of nodes) {
64308
+ const { page, held } = node;
64184
64309
  entries.push({
64185
64310
  ref: node.ref,
64186
- name: node.page.name,
64187
- ...descriptions && node.page.description ? { description: node.page.description } : {},
64311
+ name: page?.name ?? node.ref,
64312
+ ...descriptions && page?.description ? { description: page.description } : {},
64188
64313
  depth: node.depth,
64189
64314
  children: node.children,
64190
- ...node.page.isScope ? { scope: true } : {}
64315
+ ...!page || page.isScope ? { scope: true } : {},
64316
+ ...held?.role ? { role: held.role } : {},
64317
+ ...held ? { can: held.can } : {},
64318
+ ...page ? {} : { empty: true }
64191
64319
  });
64192
64320
  flatten(node.below);
64193
64321
  }
@@ -64204,7 +64332,7 @@ function listTool(host) {
64204
64332
  const maxTokens = maxTokensOf(host);
64205
64333
  return require_tool.createTool({
64206
64334
  id: "knowledge_list",
64207
- description: `List the page tree under a starting point: each child with its ref (pass it to knowledge_read or knowledge_list), name and how many children it has. Pass \`descriptions: true\` to include page descriptions too. Without \`from\`, lists the scopes this run can read. Use it to find your way around a scope before searching or reading. One result holds at most \`limit\` entries and about ${maxTokens.toLocaleString("en-US")} tokens of them; when it stops early, \`more\` says how many entries were left out and gives the \`cursor\` to list the rest (pass the same \`from\`).`,
64335
+ description: `List the page tree under a starting point: each child with its ref (pass it to knowledge_read or knowledge_list), name and how many children it has. Pass \`descriptions: true\` to include page descriptions too. Without \`from\`, lists every scope this run holds, with its role and whether it can read or write there, including scopes with no page this run can read yet (\`empty\`). Use it to find your way around a scope before searching or reading. One result holds at most \`limit\` entries and about ${maxTokens.toLocaleString("en-US")} tokens of them; when it stops early, \`more\` says how many entries were left out and gives the \`cursor\` to list the rest (pass the same \`from\`).`,
64208
64336
  inputSchema: {
64209
64337
  type: "object",
64210
64338
  properties: {
@@ -65376,12 +65504,8 @@ var PinnedStateProcessor = class {
65376
65504
  threadId: args.threadId
65377
65505
  }
65378
65506
  };
65379
- let key;
65380
- try {
65381
- key = this.deps.principalsKey(context);
65382
- } catch {
65383
- return;
65384
- }
65507
+ const key = await this.deps.principalsKey(context);
65508
+ if (key === void 0) return void 0;
65385
65509
  if (memo && memo.key === key && stepNumber > memo.atStep) return memo.entries;
65386
65510
  const entries = await this.deps.readPins(context);
65387
65511
  args.requestContext?.set?.(MEMO_KEY, {
@@ -73704,6 +73828,15 @@ function recordRunSavedMessages(runId) {
73704
73828
  };
73705
73829
  }
73706
73830
  // src/agent/durable/utils/resolve-runtime.ts
73831
+ async function restoreWorkerToolsets(mastra, context, names) {
73832
+ const controller = context.get("controller");
73833
+ if (!isRestoredWorkerControllerContext(controller) || !names?.length) return;
73834
+ const toolsets = await mastra.getAgentControllerById(controller.controllerId)?.__restoreWorkerToolsets(context);
73835
+ if (!toolsets) return;
73836
+ const allowed = new Set(names);
73837
+ for (const [key, tools] of Object.entries(toolsets)) if (tools) toolsets[key] = Object.fromEntries(Object.entries(tools).filter(([name]) => allowed.has(name)));
73838
+ return toolsets;
73839
+ }
73707
73840
  /**
73708
73841
  * Build a SaveQueueManager for a run's memory, or `undefined` when no memory
73709
73842
  * is configured. Shared by `resolveRuntimeDependencies` and
@@ -73866,6 +73999,7 @@ async function resolveRuntimeDependencies(options) {
73866
73999
  backgroundTasks = resolveBackgroundTasks(mastra, agent, input.options);
73867
74000
  tools = await agent.getToolsForExecution({
73868
74001
  runId,
74002
+ toolsets: await restoreWorkerToolsets(mastra, resolveRequestContext, input.options?.toolsetToolNames),
73869
74003
  threadId: input.state.threadId,
73870
74004
  resourceId: input.state.resourceId,
73871
74005
  requestContext: resolveRequestContext,
@@ -73987,6 +74121,7 @@ async function rebuildRunToolsFromMastra(options) {
73987
74121
  const backgroundTasks = resolveBackgroundTasks(mastra, agent, execOptions);
73988
74122
  const tools = await agent.getToolsForExecution({
73989
74123
  runId,
74124
+ toolsets: await restoreWorkerToolsets(mastra, resolveRequestContext, execOptions?.toolsetToolNames),
73990
74125
  threadId: state.threadId,
73991
74126
  resourceId: state.resourceId,
73992
74127
  requestContext: resolveRequestContext,
@@ -74456,7 +74591,11 @@ function mergeRequestContextForFinalization(entries, fallback, liveRunContext) {
74456
74591
  if (liveRunContext) return liveRunContext;
74457
74592
  if (!entries) return fallback ?? new require_request_context.RequestContext();
74458
74593
  const restored = new require_request_context.RequestContext(fallback?.entries());
74459
- for (const [key, value] of Object.entries(require_request_context.withoutLiveRequestKeys(entries))) restored.set(key, value);
74594
+ const controller = fallback?.get("controller");
74595
+ for (const [key, value] of Object.entries(require_request_context.withoutLiveRequestKeys(entries))) {
74596
+ if (key === "controller" && isRestoredWorkerControllerContext(controller)) continue;
74597
+ restored.set(key, value);
74598
+ }
74460
74599
  restoreRunAgentScopes(restored);
74461
74600
  return restored;
74462
74601
  }
@@ -74497,6 +74636,7 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
74497
74636
  ...initData,
74498
74637
  messageListState
74499
74638
  },
74639
+ requestContext,
74500
74640
  logger: effectiveLogger
74501
74641
  });
74502
74642
  rebuiltSaveQueueManager = resolved.saveQueueManager;
@@ -80049,6 +80189,12 @@ function createDurableToolCallStep() {
80049
80189
  error
80050
80190
  };
80051
80191
  }
80192
+ if (typeof args === "object" && args !== null) args = require_background_tasks.sanitizeToolArguments({
80193
+ args,
80194
+ toolName,
80195
+ toolConfig: tool?.backgroundConfig,
80196
+ agentConfig: registryEntry?.backgroundTasksConfig
80197
+ });
80052
80198
  const saveQueueManager = registryEntry?.saveQueueManager ?? rebuiltSaveQueueManager;
80053
80199
  const memory = registryEntry?.memory ?? rebuiltMemory;
80054
80200
  const workspace = registryEntry?.workspace ?? rebuiltWorkspace;
@@ -84185,7 +84331,7 @@ async function prepareForDurableExecution(options) {
84185
84331
  });
84186
84332
  let tripwireData;
84187
84333
  if (inputProcessors.length > 0) try {
84188
- const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-DaZh0apo.cjs")).then((n) => n.runner_exports);
84334
+ const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-nABk9CJK.cjs")).then((n) => n.runner_exports);
84189
84335
  await new ProcessorRunner({
84190
84336
  inputProcessors,
84191
84337
  outputProcessors,
@@ -103213,6 +103359,12 @@ function createToolCallStep({ tools, messageList, options, outputWriter, control
103213
103359
  args = argsFromInput;
103214
103360
  resumeDataFromArgs = resumeDataFromInput;
103215
103361
  }
103362
+ if (typeof args === "object" && args !== null) args = require_background_tasks.sanitizeToolArguments({
103363
+ args,
103364
+ toolName: inputData.toolName,
103365
+ toolConfig: tool?.backgroundConfig,
103366
+ agentConfig: readScoped(scopeCtx, AGENT_BACKGROUND_CONFIG_KEY, "agentBackgroundConfig")
103367
+ });
103216
103368
  const resumeData = resumeDataFromArgs ?? workflowResumeData;
103217
103369
  const isResumeToolCall = resumeDataFromArgs != null;
103218
103370
  const approvalVerdicts = readScoped(scopeCtx, TOOL_APPROVAL_VERDICTS_KEY, "toolApprovalVerdicts");
@@ -110939,6 +111091,12 @@ Object.defineProperty(exports, "CONTINUE_RUN_MESSAGE", {
110939
111091
  return CONTINUE_RUN_MESSAGE;
110940
111092
  }
110941
111093
  });
111094
+ Object.defineProperty(exports, "CONTROLLER_RUN_BINDING_KEY", {
111095
+ enumerable: true,
111096
+ get: function() {
111097
+ return CONTROLLER_RUN_BINDING_KEY;
111098
+ }
111099
+ });
110942
111100
  Object.defineProperty(exports, "ChannelSessionRejectedError", {
110943
111101
  enumerable: true,
110944
111102
  get: function() {
@@ -111305,6 +111463,12 @@ Object.defineProperty(exports, "KnowledgeRun", {
111305
111463
  return KnowledgeRun;
111306
111464
  }
111307
111465
  });
111466
+ Object.defineProperty(exports, "KnowledgeRunScopesError", {
111467
+ enumerable: true,
111468
+ get: function() {
111469
+ return KnowledgeRunScopesError;
111470
+ }
111471
+ });
111308
111472
  Object.defineProperty(exports, "KnowledgeSchemaResetRequiredError", {
111309
111473
  enumerable: true,
111310
111474
  get: function() {
@@ -113687,6 +113851,12 @@ Object.defineProperty(exports, "resolveWaitUntil", {
113687
113851
  return resolveWaitUntil;
113688
113852
  }
113689
113853
  });
113854
+ Object.defineProperty(exports, "restoredWorkerControllerContexts", {
113855
+ enumerable: true,
113856
+ get: function() {
113857
+ return restoredWorkerControllerContexts;
113858
+ }
113859
+ });
113690
113860
  Object.defineProperty(exports, "retentionCutoffMs", {
113691
113861
  enumerable: true,
113692
113862
  get: function() {