@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
@@ -180,6 +180,22 @@ const { tool, instructions } = createCodeMode(
180
180
  )
181
181
  ```
182
182
 
183
+ Importing `@mastra/quickjs` doesn't initialize the default TypeScript stripper, so the import is safe on runtimes without Node.js globals such as Cloudflare Workers. The default stripper (`ts-blank-space`) loads on the first run that needs it, and on those runtimes it can't load at all: it pulls in `typescript`, which reads `__filename` while it initializes. Pass a stripper that runs there instead:
184
+
185
+ ```typescript
186
+ import { createCodeMode } from '@mastra/core/tools'
187
+ import { QuickJsCodeModeTransport } from '@mastra/quickjs'
188
+
189
+ // Programs that are already plain JavaScript need no transform, and nothing
190
+ // that depends on Node.js globals is loaded.
191
+ const { tool, instructions } = createCodeMode(
192
+ { tools },
193
+ new QuickJsCodeModeTransport({ stripTypes: code => code }),
194
+ )
195
+ ```
196
+
197
+ Where a build step can strip the types, send the program already stripped. To cap CPU-heavy programs on a host with a frozen clock, set `maxInterruptTicks` or `shouldInterrupt`. See the [QuickJsCodeModeTransport reference](https://mastra.ai/reference/tools/quickjs-transport).
198
+
183
199
  See [Choosing a transport](https://mastra.ai/reference/tools/quickjs-transport) for a side-by-side comparison.
184
200
 
185
201
  ## Related
@@ -98,6 +98,25 @@ export const researcher = new Agent({
98
98
 
99
99
  Set `tools: 'all'` to opt in every tool the agent has.
100
100
 
101
+ ### Agent-wide defaults
102
+
103
+ Agent-wide `defaultDisposition` and `modelOverrides` sit next to `tools` and apply to every tool the agent has opted in, so you don't have to repeat them per tool:
104
+
105
+ ```typescript
106
+ export const researcher = new Agent({
107
+ // ...
108
+ backgroundTasks: {
109
+ tools: 'all',
110
+ defaultDisposition: 'foreground',
111
+ modelOverrides: false,
112
+ },
113
+ })
114
+ ```
115
+
116
+ Both act as defaults. For each tool the agent has opted in, `defaultDisposition` resolves as the tool entry's own value, then the agent-wide value, then the tool's own `background` config, then `deferred`. `modelOverrides` resolves the same way but defaults to `true`. `enabled` is never inherited, so agent-wide fields can't opt a tool in on their own.
117
+
118
+ Agent-wide values apply to named entries too, so a plain `tools: { research: true }` inherits them. An entry can still opt out per tool with its own `defaultDisposition` or `modelOverrides`. `defaultDisposition` accepts `'foreground'` or `'deferred'`, so `awaited` remains a per-call `_background` choice.
119
+
101
120
  ### LLM per-call override
102
121
 
103
122
  When a tool is registered on an agent that has background tasks enabled, the model can include a `_background` field in the tool arguments to override the resolved configuration for that specific call. The model only includes what it wants to override, all fields in `_background` are optional. The override is stripped from the arguments before the tool runs.
@@ -119,6 +138,25 @@ For compatibility, `_background.enabled: true` selects `deferred`, and `_backgro
119
138
 
120
139
  The `_background` override only _modifies_ tools the developer has already opted in at the tool or agent layer. If a tool hasn't been opted in, a model-selected background disposition is ignored and the tool runs in the foreground. This keeps deterministic, foreground-only tools (calculators, lookups, schema validators) from being silently dispatched as tasks.
121
140
 
141
+ ### Disable the per-call override
142
+
143
+ The `_background` object adds five optional parameters to each eligible tool's input schema: the object itself plus `enabled`, `disposition`, `timeoutMs`, and `maxRetries`. Some providers cap optional parameters per request. Anthropic rejects strict tool schemas with more than 24 optional parameters in total, so five strict background tools exceed the limit before counting their own optional fields.
144
+
145
+ Set `modelOverrides: false` when a tool should always use its configured disposition. Mastra then leaves `_background` out of the tool's schema and the system prompt, and ignores any `_background` value the model sends:
146
+
147
+ ```typescript
148
+ const researchTool = createTool({
149
+ id: 'research',
150
+ description: 'Research a topic in depth',
151
+ strict: true,
152
+ inputSchema: z.object({ topic: z.string() }),
153
+ background: { enabled: true, modelOverrides: false },
154
+ execute: async ({ topic }) => runResearch(topic),
155
+ })
156
+ ```
157
+
158
+ You can also set `modelOverrides: false` on an agent's per-tool entry, for example `backgroundTasks: { tools: { research: { enabled: true, modelOverrides: false } } }`. The agent entry takes precedence over the tool definition. Tools with `modelOverrides: false` and `defaultDisposition: 'foreground'` always run in the foreground.
159
+
122
160
  ### Resolution order
123
161
 
124
162
  When a tool call is dispatched, agent-level and tool-level settings determine eligibility and fallback values. For an eligible tool, the LLM `_background` fields override the corresponding values for that call. Manager defaults fill timeout and retry values that remain unset. An `_background` field can't enable a tool that's not eligible.
@@ -83,7 +83,7 @@ These searches also return `more`:
83
83
 
84
84
  ## `knowledge_list`
85
85
 
86
- Lists the page tree under a starting point, so an agent can see how a scope or section is organized before it searches or reads. Without `from`, it lists the scopes the run can read. Scopes the run can't read are left out.
86
+ Lists the page tree under a starting point, so an agent can see how a scope or section is organized before it searches or reads. Without `from`, it lists every scope the run holds. Each entry has its `role` when there is one, and `can` says what the run may do there: `write`, `read` or `none`. Scopes with no page the run can read yet are listed too, with `empty: true`. A held scope the run can't read shows only its address, not its stored name or description.
87
87
 
88
88
  **from** (`string`): Where to start: a page reference.
89
89
 
@@ -95,13 +95,13 @@ Lists the page tree under a starting point, so an agent can see how a scope or s
95
95
 
96
96
  **cursor** (`string`): The previous result's nextCursor, or the cursor more gives. Pass the same from. A cursor keeps the depth and limit of the result it came from.
97
97
 
98
- Returns `{ from?, entries, nextCursor?, more? }`. `from` is `{ ref, name }`. Each entry is `{ ref, name, depth, children, scope? }`, plus `description` when `descriptions` is `true`: `depth` is 1 for the starting point's children, `children` counts the readable child pages (and child scopes, for a scope), and `scope` is `true` for a scope.
98
+ Returns `{ from?, entries, nextCursor?, more? }`. `from` is `{ ref, name }`. Each entry is `{ ref, name, depth, children, scope? }`, plus `description` when `descriptions` is `true`: `depth` is 1 for the starting point's children, `children` counts the readable child pages (and child scopes, for a scope), and `scope` is `true` for a scope. Held-scope entries also include `role?`, `can?` (`write`, `read` or `none`) and `empty?`. An `empty: true` entry has no page the run can read yet, and its `name` is the scope address.
99
99
 
100
100
  A result stops at `limit` entries or at the read cap (about 1,000 tokens of entries by default), whichever comes first, and always holds at least one entry. When it stops early, `more` says how many entries were left out and gives the cursor that continues where it stopped.
101
101
 
102
102
  ## `knowledge_read`
103
103
 
104
- Reads a page: its body, notes, child pages, and the notes on other pages that mention it. A scope address reads that scope's page, which lists its pages and child scopes. Without `page`, it lists the scopes the run holds.
104
+ Reads a page: its body, notes, child pages, and the notes on other pages that mention it. A scope address reads that scope's page, which lists its pages and child scopes. Without `page`, it returns `{ scopes }`: every scope the run holds, including scopes before any pages exist. Each scope is `{ address, name, description?, role?, can, empty? }`. `role` is there when the run has one. `can` says what the run may do there: `write`, `read` or `none`. A scope with no page the run can read yet has `empty: true`, and its `name` is the scope address. A held scope the run can't read shows only its address, not its stored name or description.
105
105
 
106
106
  **page** (`string`): A page reference.
107
107
 
@@ -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_constants = require("../constants-B9ZDvXZ4.cjs");
2
+ const require_run_registry = require("../run-registry-BRO8xz9z.cjs");
3
+ const require_constants = require("../constants-Bou0hEgY.cjs");
4
4
  const require_collect_tool_mocks = require("../collect-tool-mocks-k9fM6oDl.cjs");
5
5
  exports.MastraScorer = require_run_registry.MastraScorer;
6
6
  exports.SCORING_PREDICATE_ROOTS = require_run_registry.SCORING_PREDICATE_ROOTS;
@@ -1,4 +1,4 @@
1
- import { C as MastraScorer, D as isNotScorable, E as filterRun, Mc as evaluateScoringPredicate, Nc as validateScoringPredicate, O as notScorable, S as createClassifierScorer, T as createScorer, jc as SCORING_PREDICATE_ROOTS, v as runEvals, w as ScorerRunError } from "../run-registry-Cl2QbXgN.js";
2
- import { Ar as scoringEntityTypeSchema, Cr as extractTrajectory, Dr as saveScorePayloadSchema, Er as listScoresResponseSchema, Fr as scoringInputWithExtractStepResultAndScoreAndReasonSchema, Ir as scoringInputWithExtractStepResultSchema, Lr as scoringPromptsSchema, Mr as scoringHookInputSchema, Nr as scoringInputSchema, Or as scoreResultSchema, Pr as scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, Rr as scoringSourceSchema, Tr as extractWorkflowTrajectory, jr as scoringExtractStepResultSchema, kr as scoreRowDataSchema, wr as extractTrajectoryFromTrace, zr as scoringValueSchema } from "../constants-BmdTvEYN.js";
1
+ import { C as MastraScorer, D as isNotScorable, E as filterRun, Fc as evaluateScoringPredicate, Ic as validateScoringPredicate, O as notScorable, Pc as SCORING_PREDICATE_ROOTS, S as createClassifierScorer, T as createScorer, v as runEvals, w as ScorerRunError } from "../run-registry-H2qdwHni.js";
2
+ import { Ar as scoringEntityTypeSchema, Cr as extractTrajectory, Dr as saveScorePayloadSchema, Er as listScoresResponseSchema, Fr as scoringInputWithExtractStepResultAndScoreAndReasonSchema, Ir as scoringInputWithExtractStepResultSchema, Lr as scoringPromptsSchema, Mr as scoringHookInputSchema, Nr as scoringInputSchema, Or as scoreResultSchema, Pr as scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, Rr as scoringSourceSchema, Tr as extractWorkflowTrajectory, jr as scoringExtractStepResultSchema, kr as scoreRowDataSchema, wr as extractTrajectoryFromTrace, zr as scoringValueSchema } from "../constants-CFWgIaqA.js";
3
3
  import { t as collectToolMocks } from "../collect-tool-mocks-3s2BN8o7.js";
4
4
  export { MastraScorer, SCORING_PREDICATE_ROOTS, ScorerRunError, collectToolMocks, createClassifierScorer, createScorer, evaluateScoringPredicate, extractTrajectory, extractTrajectoryFromTrace, extractWorkflowTrajectory, filterRun, isNotScorable, listScoresResponseSchema, notScorable, runEvals, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema, validateScoringPredicate };
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_error = require("../../error-D90lJ6M7.cjs");
3
3
  const require_utils = require("../../utils-D-eNsgDM.cjs");
4
- const require_run_registry = require("../../run-registry-oixTpWpa.cjs");
5
- const require_constants = require("../../constants-B9ZDvXZ4.cjs");
4
+ const require_run_registry = require("../../run-registry-BRO8xz9z.cjs");
5
+ const require_constants = require("../../constants-Bou0hEgY.cjs");
6
6
  let zod_v4 = require("zod/v4");
7
7
  // src/evals/scoreTraces/scoreTraces.ts
8
8
  async function scoreTraces({ scorerId, targets, mastra }) {
@@ -1,7 +1,7 @@
1
1
  import { i as MastraError, n as ErrorDomain, t as ErrorCategory } from "../../error-oh2DLsP2.js";
2
2
  import { i as getEntityTypeForSpan } from "../../utils-DU_pU5SK.js";
3
- import { Hs as createStep, Us as createWorkflow } from "../../run-registry-Cl2QbXgN.js";
4
- import { Dr as saveScorePayloadSchema } from "../../constants-BmdTvEYN.js";
3
+ import { Us as createStep, Ws as createWorkflow } from "../../run-registry-H2qdwHni.js";
4
+ import { Dr as saveScorePayloadSchema } from "../../constants-CFWgIaqA.js";
5
5
  import { z } from "zod/v4";
6
6
  // src/evals/scoreTraces/scoreTraces.ts
7
7
  async function scoreTraces({ scorerId, targets, mastra }) {
@@ -656,7 +656,7 @@ var UnixSocketPubSub = class extends require_output_helpers.PubSub {
656
656
  }
657
657
  if (existing) await this.unsubscribe(topic, cb);
658
658
  const group = options?.group;
659
- const hadMembership = this.#hasLocalMembership(topic, group);
659
+ const hadMembership = [...subscriptions.values()].some((s) => s.group === group && !this.#leavingSubscriptions.has(s));
660
660
  const wasConnected = Boolean(this.#clientSocket && !this.#clientSocket.destroyed);
661
661
  subscriptions.set(cb, {
662
662
  callback: cb,
@@ -653,7 +653,7 @@ var UnixSocketPubSub = class extends PubSub {
653
653
  }
654
654
  if (existing) await this.unsubscribe(topic, cb);
655
655
  const group = options?.group;
656
- const hadMembership = this.#hasLocalMembership(topic, group);
656
+ const hadMembership = [...subscriptions.values()].some((s) => s.group === group && !this.#leavingSubscriptions.has(s));
657
657
  const wasConnected = Boolean(this.#clientSocket && !this.#clientSocket.destroyed);
658
658
  subscriptions.set(cb, {
659
659
  callback: cb,
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_state_processor = require("../state-processor-kRNZ38Nf.cjs");
3
3
  const require_tools = require("../tools-n9lqzDNe.cjs");
4
- const require_agent_controller = require("../agent-controller-CqcyudV6.cjs");
4
+ const require_agent_controller = require("../agent-controller-BL-0CKSF.cjs");
5
5
  // src/harness/index.ts
6
6
  /**
7
7
  * @deprecated Backwards-compatibility entrypoint.
@@ -1,6 +1,6 @@
1
1
  import { f as taskCheckTool, h as taskWriteTool, m as taskUpdateTool, o as assignTaskIds, p as taskCompleteTool } from "../state-processor-B9kxpM53.js";
2
2
  import { s as askUserTool, t as submitPlanTool } from "../tools-DDfA_ES4.js";
3
- import { a as Session, c as defaultDisplayState, l as defaultOMProgressState, n as parseSubagentMeta, t as AgentController } from "../agent-controller-VBMIPr6h.js";
3
+ import { a as Session, c as defaultDisplayState, l as defaultOMProgressState, n as parseSubagentMeta, t as AgentController } from "../agent-controller-BkG0M35j.js";
4
4
  // src/harness/index.ts
5
5
  /**
6
6
  * @deprecated Backwards-compatibility entrypoint.
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_mastra = require("./mastra-B60fJsMe.cjs");
2
+ const require_mastra = require("./mastra-CraMHXhw.cjs");
3
3
  exports.Mastra = require_mastra.Mastra;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { t as Mastra } from "./mastra-Bkpe1lBu.js";
1
+ export { t as Mastra } from "./mastra-DKjpNZ-1.js";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_base = require("../base-BIzR1D3_.cjs");
3
- const require_run_registry = require("../run-registry-oixTpWpa.cjs");
3
+ const require_run_registry = require("../run-registry-BRO8xz9z.cjs");
4
4
  const require_tool = require("../tool-CYlT2UA-.cjs");
5
5
  let crypto = require("crypto");
6
6
  let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
@@ -1213,20 +1213,24 @@ async function applyKnowledgeImportFlush(input) {
1213
1213
  const keyPath = async (page) => {
1214
1214
  const keys = [];
1215
1215
  const ids = [];
1216
- let at = page;
1217
- while (at && !at.isScope) {
1216
+ if (page.isScope) return page.id === scope.id ? {
1217
+ keys,
1218
+ ids
1219
+ } : null;
1220
+ const parents = page.parentId ? await storage.getPageParents({
1221
+ parentId: page.parentId,
1222
+ read: "all"
1223
+ }) : [];
1224
+ for (const at of [page, ...parents]) {
1225
+ if (at.isScope) return at.id === scope.id ? {
1226
+ keys,
1227
+ ids
1228
+ } : null;
1218
1229
  if (!live(at) || at.key === void 0) return null;
1219
1230
  keys.unshift(at.key);
1220
1231
  ids.unshift(at.id);
1221
- at = at.parentId ? await storage.getPage({
1222
- id: at.parentId,
1223
- read: "all"
1224
- }) : null;
1225
1232
  }
1226
- return at?.id === scope.id ? {
1227
- keys,
1228
- ids
1229
- } : null;
1233
+ return null;
1230
1234
  };
1231
1235
  const sameKeys = (a, b) => a.length === b.length && a.every((key, i) => key === b[i]);
1232
1236
  /**
@@ -1437,8 +1441,7 @@ async function applyKnowledgeImportFlush(input) {
1437
1441
  return node && !await gone(node) ? node : null;
1438
1442
  };
1439
1443
  const ref = (keys) => `${target.scope}#${keys.join("/")}`;
1440
- const linkLine = async (link) => {
1441
- const node = await importers.getNode(binding.id, link.sourceId);
1444
+ const linkLine = async (link, node) => {
1442
1445
  const page = node ? await storage.getPage({
1443
1446
  id: node.pageId,
1444
1447
  read: "all"
@@ -1449,11 +1452,30 @@ async function applyKnowledgeImportFlush(input) {
1449
1452
  const renderLinks = async (links) => {
1450
1453
  const lines = [];
1451
1454
  const unresolved = [];
1455
+ const getNodes = async (sourceIds) => {
1456
+ if (!sourceIds.length) return [];
1457
+ if (importers.getNodes) return importers.getNodes(binding.id, sourceIds);
1458
+ const nodes = [];
1459
+ for (const sourceId of new Set(sourceIds)) {
1460
+ const node = await importers.getNode(binding.id, sourceId);
1461
+ if (node) nodes.push(node);
1462
+ }
1463
+ return nodes;
1464
+ };
1465
+ const read = async (sourceIds) => new Map((await getNodes(sourceIds)).map((node) => [node.sourceId, node]));
1466
+ const before = await read(links.map((link) => link.sourceId));
1467
+ const rendered = [];
1452
1468
  for (const link of links) {
1453
- const line = await linkLine(link);
1454
- if (line) lines.push(line);
1455
- else unresolved.push(encodeLink(link));
1469
+ const node = before.get(link.sourceId);
1470
+ rendered.push({
1471
+ link,
1472
+ line: await linkLine(link, node),
1473
+ pageId: node?.pageId
1474
+ });
1456
1475
  }
1476
+ const after = await read(rendered.filter((each) => each.line).map((each) => each.link.sourceId));
1477
+ for (const { link, line, pageId } of rendered) if (line && after.get(link.sourceId)?.pageId === pageId) lines.push(line);
1478
+ else unresolved.push(encodeLink(link));
1457
1479
  return {
1458
1480
  section: linkSection(lines),
1459
1481
  unresolved
@@ -3400,6 +3422,19 @@ var KnowledgeScopeRuntime = class {
3400
3422
  };
3401
3423
  for (const address of addresses) await this.#materialize(address, principals, provenance, [], run);
3402
3424
  }
3425
+ /**
3426
+ * The parent address a first write would place a not-yet-created scope under, as `#materialize`
3427
+ * chooses it: a template child's own parent, or the one held `belongsTo` candidate. Undefined when
3428
+ * the scope would stay unlinked.
3429
+ */
3430
+ firstWriteParentAddress(address, principals) {
3431
+ const match = this.compiled.match(address);
3432
+ if (!match) return void 0;
3433
+ if (match.compiled.child) return address.slice(0, address.lastIndexOf("/"));
3434
+ if (!match.compiled.belongsTo) return void 0;
3435
+ const candidates = this.#belongsToCandidates(match, this.#held(principals));
3436
+ return candidates.length === 1 && candidates[0] !== address ? candidates[0] : void 0;
3437
+ }
3403
3438
  /** The run's distinct principals grouped by declaration key, matched once. */
3404
3439
  #held(principals) {
3405
3440
  const held = /* @__PURE__ */ new Map();
@@ -4345,9 +4380,19 @@ var Knowledge = class extends require_base.MastraBase {
4345
4380
  write
4346
4381
  };
4347
4382
  }
4348
- /** The run's principals as a stable key; throws when the run has none or holds an undeclared scope. @internal */
4349
- __principalsKey(context) {
4350
- return require_run_registry.knowledgeRunPrincipals(this.#runtime, context).sort().join("\n");
4383
+ /**
4384
+ * The run's principals as a stable key, or `undefined` when the run has no Knowledge view (no scopes,
4385
+ * or an undeclared scope). Loads the store's declarations first, so a scope only the store declares
4386
+ * counts; a failure loading them rejects. @internal
4387
+ */
4388
+ async __principalsKey(context) {
4389
+ await this.#runtime.resolve();
4390
+ try {
4391
+ return require_run_registry.knowledgeRunPrincipals(this.#runtime, context).sort().join("\n");
4392
+ } catch (error) {
4393
+ if (error instanceof require_run_registry.KnowledgeRunScopesError || error instanceof require_run_registry.KnowledgeDeclarationError) return void 0;
4394
+ throw error;
4395
+ }
4351
4396
  }
4352
4397
  /**
4353
4398
  * The pinned pages a host-run caller with these principals receives, rendered as an agent run
@@ -197,8 +197,12 @@ export declare class Knowledge extends MastraBase {
197
197
  read: boolean;
198
198
  write: boolean;
199
199
  };
200
- /** The run's principals as a stable key; throws when the run has none or holds an undeclared scope. @internal */
201
- __principalsKey(context: KnowledgeRunContext): string;
200
+ /**
201
+ * The run's principals as a stable key, or `undefined` when the run has no Knowledge view (no scopes,
202
+ * or an undeclared scope). Loads the store's declarations first, so a scope only the store declares
203
+ * counts; a failure loading them rejects. @internal
204
+ */
205
+ __principalsKey(context: KnowledgeRunContext): Promise<string | undefined>;
202
206
  /**
203
207
  * The pinned pages a host-run caller with these principals receives, rendered as an agent run
204
208
  * receives them: only pages they can read, within this instance's pin budget. For hosts that serve
@@ -1,5 +1,5 @@
1
1
  import { t as MastraBase } from "../base-CKLWBhDo.js";
2
- import { $t as knowledgeDeliveredPins, Ai as MAX_KNOWLEDGE_PAGE_BODY_LINKS, Bi as knowledgeLinkRefKey, Ci as parseKnowledgeWikilinks, Cn as knowledgeRunScopes, Di as KnowledgePageKeyConflictError, Dn as encodeKnowledgeScopeId, Ei as KnowledgePageHasChildrenError, En as decodeKnowledgeScopeId, Fi as MAX_KNOWLEDGE_PAGE_LIST_LIMIT, Gi as parseKnowledgePageRef, Hi as knowledgePinDepth, Ii as MAX_KNOWLEDGE_PIN_LIST_DEPTH, Ki as KnowledgeInvalidCursorError, Li as assertKnowledgeNoteTextWithinBound, Mi as MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS, Ni as MAX_KNOWLEDGE_PAGE_LINKS, Oi as MAX_KNOWLEDGE_MOVE_PAGES, On as buildKnowledgeInstructions, Pi as MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH, Qt as PINNED_READ_MEMO_KEY, Ri as assertKnowledgePageDescriptionWithinBound, Si as inspectKnowledgeSchema, Sn as knowledgeMemoryScopes, Ti as KnowledgePageDepthError, Tn as strongerKnowledgeRole, Ui as knowledgePositionBetween, Uo as augmentWithInit, Vi as knowledgePagePath, Wi as knowledgeScopeReadable, Wo as getStorageSource, _i as KnowledgeStorage, _n as knowledgeAccessGrants, _r as knowledgeScopeKey, an as removeKnowledgeNote, bi as assertKnowledgeSchemaCompatible, bn as KnowledgeDeclarationError, br as knowledgeVisibleScopeKeys, ci as InMemoryKnowledgeStorage, cn as upsertKnowledgePage, cr as MAX_KNOWLEDGE_SCOPE_TAGS, di as KnowledgeImportersStorage, dn as KnowledgeLinkRefreshIncompleteError, dr as assertKnowledgeRecordTextWithinBound, en as buildKnowledgePageTools, fi as KNOWLEDGE_STORAGE_CONTRACT_VERSION, fn as knowledgeSubtree, fr as assertKnowledgeScopeWithinCeiling, gi as KnowledgeSchemaResetRequiredError, gn as updateKnowledgeLinks, gr as isKnowledgeScopeVisible, hi as KnowledgeNotFoundError, hn as syncKnowledgePageBodyLinks, hr as expandKnowledgeScope, in as moveKnowledgePage, ji as MAX_KNOWLEDGE_PAGE_DEPTH, ki as MAX_KNOWLEDGE_NOTE_TOKENS, li as KnowledgeImporterBindingConflictError, ln as KnowledgeSemanticIndex, lr as assertKnowledgeCeilingRaised, mi as KnowledgeConflictError, mn as reindexKnowledgeLinks, mr as createKnowledgeNodeCursor, nn as knowledgeRunPrincipals, on as removeKnowledgePage, or as MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH, pi as KNOWLEDGE_STORAGE_SCHEMA_VERSION, pn as refreshKnowledgeLinksTo, pr as canonicalizeKnowledgeScope, rn as addKnowledgeNote, sn as updateKnowledgeNote, sr as MAX_KNOWLEDGE_RECORD_TEXT_LENGTH, tn as KnowledgeRun, ui as KnowledgeImporterRunStateError, ur as assertKnowledgeDescriptionWithinBound, vi as KnowledgeTransactionDeadlineError, vn as knowledgeReadScopeFor, vr as knowledgeSemanticDocumentId, wi as KnowledgeMoveTooLargeError, wn as knowledgeScopeAddress, xi as createKnowledgeUlid, xn as compileKnowledgeScopes, xr as parseKnowledgeNodeCursor, yi as KnowledgeUnsupportedCapabilityError, yn as knowledgeRoleOn, yr as knowledgeSemanticIdempotencyKey, zi as canonicalKnowledgeName } from "../run-registry-Cl2QbXgN.js";
2
+ import { $t as knowledgeDeliveredPins, Ai as MAX_KNOWLEDGE_NOTE_TOKENS, Bi as canonicalKnowledgeName, Ci as inspectKnowledgeSchema, Cn as knowledgeMemoryScopes, Di as KnowledgePageHasChildrenError, Dn as decodeKnowledgeScopeId, Ei as KnowledgePageDepthError, En as strongerKnowledgeRole, Fi as MAX_KNOWLEDGE_PAGE_LINK_REF_LENGTH, Gi as knowledgeScopeReadable, Go as getStorageSource, Hi as knowledgePagePath, Ii as MAX_KNOWLEDGE_PAGE_LIST_LIMIT, Ki as parseKnowledgePageRef, Li as MAX_KNOWLEDGE_PIN_LIST_DEPTH, Mi as MAX_KNOWLEDGE_PAGE_DEPTH, Ni as MAX_KNOWLEDGE_PAGE_DESCRIPTION_TOKENS, Oi as KnowledgePageKeyConflictError, On as encodeKnowledgeScopeId, Pi as MAX_KNOWLEDGE_PAGE_LINKS, Qt as PINNED_READ_MEMO_KEY, Ri as assertKnowledgeNoteTextWithinBound, Si as createKnowledgeUlid, Sn as compileKnowledgeScopes, Sr as parseKnowledgeNodeCursor, Ti as KnowledgeMoveTooLargeError, Tn as knowledgeScopeAddress, Ui as knowledgePinDepth, Vi as knowledgeLinkRefKey, Wi as knowledgePositionBetween, Wo as augmentWithInit, _i as KnowledgeSchemaResetRequiredError, _n as updateKnowledgeLinks, _r as isKnowledgeScopeVisible, an as moveKnowledgePage, bi as KnowledgeUnsupportedCapabilityError, bn as knowledgeRoleOn, br as knowledgeSemanticIdempotencyKey, cn as updateKnowledgeNote, cr as MAX_KNOWLEDGE_RECORD_TEXT_LENGTH, di as KnowledgeImporterRunStateError, dr as assertKnowledgeDescriptionWithinBound, en as buildKnowledgePageTools, fi as KnowledgeImportersStorage, fn as KnowledgeLinkRefreshIncompleteError, fr as assertKnowledgeRecordTextWithinBound, gi as KnowledgeNotFoundError, gn as syncKnowledgePageBodyLinks, gr as expandKnowledgeScope, hi as KnowledgeConflictError, hn as reindexKnowledgeLinks, hr as createKnowledgeNodeCursor, in as addKnowledgeNote, ji as MAX_KNOWLEDGE_PAGE_BODY_LINKS, ki as MAX_KNOWLEDGE_MOVE_PAGES, kn as buildKnowledgeInstructions, li as InMemoryKnowledgeStorage, ln as upsertKnowledgePage, lr as MAX_KNOWLEDGE_SCOPE_TAGS, mi as KNOWLEDGE_STORAGE_SCHEMA_VERSION, mn as refreshKnowledgeLinksTo, mr as canonicalizeKnowledgeScope, nn as KnowledgeRunScopesError, on as removeKnowledgeNote, pi as KNOWLEDGE_STORAGE_CONTRACT_VERSION, pn as knowledgeSubtree, pr as assertKnowledgeScopeWithinCeiling, qi as KnowledgeInvalidCursorError, rn as knowledgeRunPrincipals, sn as removeKnowledgePage, sr as MAX_KNOWLEDGE_NODE_DESCRIPTION_LENGTH, tn as KnowledgeRun, ui as KnowledgeImporterBindingConflictError, un as KnowledgeSemanticIndex, ur as assertKnowledgeCeilingRaised, vi as KnowledgeStorage, vn as knowledgeAccessGrants, vr as knowledgeScopeKey, wi as parseKnowledgeWikilinks, wn as knowledgeRunScopes, xi as assertKnowledgeSchemaCompatible, xn as KnowledgeDeclarationError, xr as knowledgeVisibleScopeKeys, yi as KnowledgeTransactionDeadlineError, yn as knowledgeReadScopeFor, yr as knowledgeSemanticDocumentId, zi as assertKnowledgePageDescriptionWithinBound } from "../run-registry-H2qdwHni.js";
3
3
  import { standardSchemaToJSONSchema, toStandardSchema } from "../schema/index.js";
4
4
  import { i as createStandardSchemaIssuesError } from "../tool-Z3bykc1m.js";
5
5
  import { randomUUID } from "crypto";
@@ -1212,20 +1212,24 @@ async function applyKnowledgeImportFlush(input) {
1212
1212
  const keyPath = async (page) => {
1213
1213
  const keys = [];
1214
1214
  const ids = [];
1215
- let at = page;
1216
- while (at && !at.isScope) {
1215
+ if (page.isScope) return page.id === scope.id ? {
1216
+ keys,
1217
+ ids
1218
+ } : null;
1219
+ const parents = page.parentId ? await storage.getPageParents({
1220
+ parentId: page.parentId,
1221
+ read: "all"
1222
+ }) : [];
1223
+ for (const at of [page, ...parents]) {
1224
+ if (at.isScope) return at.id === scope.id ? {
1225
+ keys,
1226
+ ids
1227
+ } : null;
1217
1228
  if (!live(at) || at.key === void 0) return null;
1218
1229
  keys.unshift(at.key);
1219
1230
  ids.unshift(at.id);
1220
- at = at.parentId ? await storage.getPage({
1221
- id: at.parentId,
1222
- read: "all"
1223
- }) : null;
1224
1231
  }
1225
- return at?.id === scope.id ? {
1226
- keys,
1227
- ids
1228
- } : null;
1232
+ return null;
1229
1233
  };
1230
1234
  const sameKeys = (a, b) => a.length === b.length && a.every((key, i) => key === b[i]);
1231
1235
  /**
@@ -1436,8 +1440,7 @@ async function applyKnowledgeImportFlush(input) {
1436
1440
  return node && !await gone(node) ? node : null;
1437
1441
  };
1438
1442
  const ref = (keys) => `${target.scope}#${keys.join("/")}`;
1439
- const linkLine = async (link) => {
1440
- const node = await importers.getNode(binding.id, link.sourceId);
1443
+ const linkLine = async (link, node) => {
1441
1444
  const page = node ? await storage.getPage({
1442
1445
  id: node.pageId,
1443
1446
  read: "all"
@@ -1448,11 +1451,30 @@ async function applyKnowledgeImportFlush(input) {
1448
1451
  const renderLinks = async (links) => {
1449
1452
  const lines = [];
1450
1453
  const unresolved = [];
1454
+ const getNodes = async (sourceIds) => {
1455
+ if (!sourceIds.length) return [];
1456
+ if (importers.getNodes) return importers.getNodes(binding.id, sourceIds);
1457
+ const nodes = [];
1458
+ for (const sourceId of new Set(sourceIds)) {
1459
+ const node = await importers.getNode(binding.id, sourceId);
1460
+ if (node) nodes.push(node);
1461
+ }
1462
+ return nodes;
1463
+ };
1464
+ const read = async (sourceIds) => new Map((await getNodes(sourceIds)).map((node) => [node.sourceId, node]));
1465
+ const before = await read(links.map((link) => link.sourceId));
1466
+ const rendered = [];
1451
1467
  for (const link of links) {
1452
- const line = await linkLine(link);
1453
- if (line) lines.push(line);
1454
- else unresolved.push(encodeLink(link));
1468
+ const node = before.get(link.sourceId);
1469
+ rendered.push({
1470
+ link,
1471
+ line: await linkLine(link, node),
1472
+ pageId: node?.pageId
1473
+ });
1455
1474
  }
1475
+ const after = await read(rendered.filter((each) => each.line).map((each) => each.link.sourceId));
1476
+ for (const { link, line, pageId } of rendered) if (line && after.get(link.sourceId)?.pageId === pageId) lines.push(line);
1477
+ else unresolved.push(encodeLink(link));
1456
1478
  return {
1457
1479
  section: linkSection(lines),
1458
1480
  unresolved
@@ -3399,6 +3421,19 @@ var KnowledgeScopeRuntime = class {
3399
3421
  };
3400
3422
  for (const address of addresses) await this.#materialize(address, principals, provenance, [], run);
3401
3423
  }
3424
+ /**
3425
+ * The parent address a first write would place a not-yet-created scope under, as `#materialize`
3426
+ * chooses it: a template child's own parent, or the one held `belongsTo` candidate. Undefined when
3427
+ * the scope would stay unlinked.
3428
+ */
3429
+ firstWriteParentAddress(address, principals) {
3430
+ const match = this.compiled.match(address);
3431
+ if (!match) return void 0;
3432
+ if (match.compiled.child) return address.slice(0, address.lastIndexOf("/"));
3433
+ if (!match.compiled.belongsTo) return void 0;
3434
+ const candidates = this.#belongsToCandidates(match, this.#held(principals));
3435
+ return candidates.length === 1 && candidates[0] !== address ? candidates[0] : void 0;
3436
+ }
3402
3437
  /** The run's distinct principals grouped by declaration key, matched once. */
3403
3438
  #held(principals) {
3404
3439
  const held = /* @__PURE__ */ new Map();
@@ -4344,9 +4379,19 @@ var Knowledge = class extends MastraBase {
4344
4379
  write
4345
4380
  };
4346
4381
  }
4347
- /** The run's principals as a stable key; throws when the run has none or holds an undeclared scope. @internal */
4348
- __principalsKey(context) {
4349
- return knowledgeRunPrincipals(this.#runtime, context).sort().join("\n");
4382
+ /**
4383
+ * The run's principals as a stable key, or `undefined` when the run has no Knowledge view (no scopes,
4384
+ * or an undeclared scope). Loads the store's declarations first, so a scope only the store declares
4385
+ * counts; a failure loading them rejects. @internal
4386
+ */
4387
+ async __principalsKey(context) {
4388
+ await this.#runtime.resolve();
4389
+ try {
4390
+ return knowledgeRunPrincipals(this.#runtime, context).sort().join("\n");
4391
+ } catch (error) {
4392
+ if (error instanceof KnowledgeRunScopesError || error instanceof KnowledgeDeclarationError) return void 0;
4393
+ throw error;
4394
+ }
4350
4395
  }
4351
4396
  /**
4352
4397
  * The pinned pages a host-run caller with these principals receives, rendered as an agent run
@@ -1,5 +1,6 @@
1
1
  import type { KnowledgePage, KnowledgeStorage } from '../storage/domains/knowledge/index.js';
2
2
  import type { ToolAction } from '../tools/index.js';
3
+ import type { KnowledgeRole } from './declarations.js';
3
4
  import { KnowledgeRun } from './run.js';
4
5
  import type { KnowledgeScopeRuntime } from './scope-runtime.js';
5
6
  import type { KnowledgeSemanticIndex } from './semantic.js';
@@ -24,6 +25,8 @@ export interface KnowledgePageToolGroups {
24
25
  pins: boolean;
25
26
  }
26
27
  type Tools = Record<string, ToolAction<any, any, any>>;
28
+ /** What a run can do in a scope it holds: contributors and up can write, viewers only read. */
29
+ type HeldScopeAccess = 'write' | 'read' | 'none';
27
30
  /** One entry of a `knowledge_list` result. */
28
31
  export interface ListEntry {
29
32
  ref: string;
@@ -34,6 +37,12 @@ export interface ListEntry {
34
37
  /** Readable child pages, plus readable child scopes for a scope. */
35
38
  children: number;
36
39
  scope?: true;
40
+ /** Held scopes only (a listing without `from`): the run's role there, if any. */
41
+ role?: KnowledgeRole;
42
+ /** Held scopes only: what the run can do there. */
43
+ can?: HeldScopeAccess;
44
+ /** Held scopes only: no page there this run can read yet. */
45
+ empty?: true;
37
46
  }
38
47
  /** What {@link listKnowledgeTree} found: the entries in tree order, and where the listing stopped. */
39
48
  export interface KnowledgeTreeListing {
@@ -34,8 +34,8 @@ export declare function applyPinOps(pins: PinEntry[], ops: PinDeltaOp[]): PinEnt
34
34
  export declare function effectivePriorPins(args: ComputeStateSignalArgs): PinEntry[];
35
35
  export declare function diffPins(prior: PinEntry[], current: PinEntry[]): PinDeltaOp[];
36
36
  export interface PinnedStateProcessorDeps {
37
- /** A key identifying the run's principals, for the per-turn memo. Throws when the run has no Knowledge view. */
38
- principalsKey(context: KnowledgeRunContext): string;
37
+ /** A key identifying the run's principals, for the per-turn memo; `undefined` when the run has no Knowledge view, so it gets no pins. */
38
+ principalsKey(context: KnowledgeRunContext): Promise<string | undefined> | string | undefined;
39
39
  /** The pins the run receives. */
40
40
  readPins(context: KnowledgeRunContext): Promise<PinEntry[]>;
41
41
  /** Whether the agent has `knowledge_search`, `knowledge_read` and `knowledge_list`; when `false` the guidance, the overflow suffix and pin descriptions name no read tool. Defaults to `true`. */
@@ -16,6 +16,10 @@ export type KnowledgeRunContext = {
16
16
  export declare class KnowledgeNotFoundError extends Error {
17
17
  constructor(ref: string, closeMatches?: string[]);
18
18
  }
19
+ /** A run with no scopes and no Memory identity: it has no Knowledge view. @internal */
20
+ export declare class KnowledgeRunScopesError extends Error {
21
+ constructor();
22
+ }
19
23
  /**
20
24
  * One call's view of Knowledge: the run's principals, its read scope and its provenance. Built per
21
25
  * tool call from the run's own scopes, so access always follows the current declarations.
@@ -77,5 +77,11 @@ export declare class KnowledgeScopeRuntime {
77
77
  * `belongsTo` link, has its child scopes and declares no template pages; warnings fire as before.
78
78
  */
79
79
  materializeScopes(addresses: readonly string[], principals: readonly string[], provenance: KnowledgeProvenance): Promise<void>;
80
+ /**
81
+ * The parent address a first write would place a not-yet-created scope under, as `#materialize`
82
+ * chooses it: a template child's own parent, or the one held `belongsTo` candidate. Undefined when
83
+ * the scope would stay unlinked.
84
+ */
85
+ firstWriteParentAddress(address: string, principals: readonly string[]): string | undefined;
80
86
  }
81
87
  //# sourceMappingURL=scope-runtime.d.ts.map
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_llm = require("../llm-D6N-WJwo.cjs");
3
- const require_netlify = require("../netlify-hasf5dLA.cjs");
4
- const require_provider_registry = require("../provider-registry-CeV5wjlF.cjs");
2
+ const require_llm = require("../llm-DQTGexjo.cjs");
3
+ const require_netlify = require("../netlify-BFgeBsaW.cjs");
4
+ const require_provider_registry = require("../provider-registry-BXDosXMN.cjs");
5
5
  exports.AzureOpenAIGateway = require_llm.AzureOpenAIGateway;
6
6
  exports.EMBEDDING_MODELS = require_llm.EMBEDDING_MODELS;
7
7
  exports.GATEWAY_AUTH_HEADER = require_netlify.GATEWAY_AUTH_HEADER;
package/dist/llm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as ModelRouterLanguageModel, c as AzureOpenAIGateway, i as resolveModelConfig, l as defaultGateways, n as ModelRouterEmbeddingModel, r as resolveModelAuth, t as EMBEDDING_MODELS } from "../llm-CsQOELh9.js";
2
- import { l as GATEWAY_AUTH_HEADER, m as getGatewayId, p as findGatewayForModel, r as ModelsDevGateway, t as NetlifyGateway, y as MastraModelGateway } from "../netlify-CW26UJrG.js";
3
- import { c as modelSupportsStructuredOutput, f as MastraGateway, i as getProviderConfig, l as modelSupportsTemperature, n as PROVIDER_REGISTRY, r as getModelReasoningOptions, s as modelSupportsAttachments, t as GatewayRegistry, u as parseModelString } from "../provider-registry-DnVkqIBw.js";
1
+ import { a as ModelRouterLanguageModel, c as AzureOpenAIGateway, i as resolveModelConfig, l as defaultGateways, n as ModelRouterEmbeddingModel, r as resolveModelAuth, t as EMBEDDING_MODELS } from "../llm-BdHdjrHp.js";
2
+ import { l as GATEWAY_AUTH_HEADER, m as getGatewayId, p as findGatewayForModel, r as ModelsDevGateway, t as NetlifyGateway, y as MastraModelGateway } from "../netlify-kxJSdqCW.js";
3
+ import { c as modelSupportsStructuredOutput, f as MastraGateway, i as getProviderConfig, l as modelSupportsTemperature, n as PROVIDER_REGISTRY, r as getModelReasoningOptions, s as modelSupportsAttachments, t as GatewayRegistry, u as parseModelString } from "../provider-registry-DgezoItQ.js";
4
4
  export { AzureOpenAIGateway, EMBEDDING_MODELS, GATEWAY_AUTH_HEADER, GatewayRegistry, MastraGateway, MastraModelGateway, ModelRouterEmbeddingModel, ModelRouterLanguageModel, ModelsDevGateway, NetlifyGateway, PROVIDER_REGISTRY, defaultGateways, findGatewayForModel, getGatewayId, getModelReasoningOptions, getProviderConfig, modelSupportsAttachments, modelSupportsStructuredOutput, modelSupportsTemperature, parseModelString, resolveModelAuth, resolveModelConfig };