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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (388) hide show
  1. package/dist/agent/agent.d.ts +3 -1
  2. package/dist/agent/durable/index.cjs +1 -1
  3. package/dist/agent/durable/index.js +1 -1
  4. package/dist/agent/index.cjs +3 -2
  5. package/dist/agent/index.d.ts +2 -0
  6. package/dist/agent/index.js +3 -3
  7. package/dist/agent/merge-persona.d.ts +15 -0
  8. package/dist/agent-builder/ee/index.cjs +1 -1
  9. package/dist/agent-builder/ee/index.js +1 -1
  10. package/dist/agent-controller/index.cjs +2 -2
  11. package/dist/agent-controller/index.js +2 -2
  12. package/dist/{agent-controller-QGBVBDRi.cjs → agent-controller-ZCQy7cOG.cjs} +7 -7
  13. package/dist/{agent-controller-GM-2_7C2.js → agent-controller-fazk0U_b.js} +7 -7
  14. package/dist/background-tasks/index.cjs +1 -1
  15. package/dist/background-tasks/index.js +1 -1
  16. package/dist/{background-tasks-C-3AqSKL.cjs → background-tasks-B63welNM.cjs} +1 -1
  17. package/dist/{background-tasks-lHCVpHbm.js → background-tasks-DlLB_pJR.js} +1 -1
  18. package/dist/browser/index.cjs +2 -2
  19. package/dist/browser/index.js +2 -2
  20. package/dist/{builder-C9UYOrxv.js → builder-D82iR2oQ.js} +2 -2
  21. package/dist/{builder-mGGr3IhH.cjs → builder-DCaL4xmU.cjs} +2 -2
  22. package/dist/capabilities/302ai.json +196 -196
  23. package/dist/capabilities/abliteratedllm.json +43 -34
  24. package/dist/capabilities/abliteration-ai.json +9 -9
  25. package/dist/capabilities/above.json +18 -18
  26. package/dist/capabilities/adaption.json +12 -12
  27. package/dist/capabilities/adzuki.json +28 -28
  28. package/dist/capabilities/agentrouter.json +10 -10
  29. package/dist/capabilities/agnes.json +2 -2
  30. package/dist/capabilities/ai-router.json +6 -6
  31. package/dist/capabilities/aiand.json +20 -20
  32. package/dist/capabilities/aigrow.json +10 -10
  33. package/dist/capabilities/aimlapi.json +143 -143
  34. package/dist/capabilities/aipg.json +2 -2
  35. package/dist/capabilities/aixy.json +23 -23
  36. package/dist/capabilities/aki-io.json +14 -14
  37. package/dist/capabilities/alibaba-cn.json +100 -94
  38. package/dist/capabilities/alibaba-coding-plan-cn.json +4 -4
  39. package/dist/capabilities/alibaba-coding-plan.json +4 -4
  40. package/dist/capabilities/alibaba-token-plan-cn.json +47 -47
  41. package/dist/capabilities/alibaba-token-plan.json +47 -47
  42. package/dist/capabilities/alibaba.json +63 -63
  43. package/dist/capabilities/ambient.json +14 -14
  44. package/dist/capabilities/amd.json +10 -10
  45. package/dist/capabilities/anthropic.json +42 -42
  46. package/dist/capabilities/anyapi.json +47 -47
  47. package/dist/capabilities/arcee.json +10 -10
  48. package/dist/capabilities/augure.json +5 -5
  49. package/dist/capabilities/auriko.json +21 -21
  50. package/dist/capabilities/bailing.json +4 -4
  51. package/dist/capabilities/baseten.json +34 -34
  52. package/dist/capabilities/bee.json +3 -3
  53. package/dist/capabilities/berget.json +18 -5
  54. package/dist/capabilities/bothub.json +15 -15
  55. package/dist/capabilities/boundless.json +35 -35
  56. package/dist/capabilities/bumo.json +43 -43
  57. package/dist/capabilities/byteplus.json +29 -29
  58. package/dist/capabilities/cheapaimodel.json +6 -6
  59. package/dist/capabilities/cheapest-token.json +28 -28
  60. package/dist/capabilities/chutes.json +9 -9
  61. package/dist/capabilities/clarifai.json +2 -2
  62. package/dist/capabilities/claudinio.json +10 -1
  63. package/dist/capabilities/cline-pass.json +40 -40
  64. package/dist/capabilities/cloudcode.json +10 -17
  65. package/dist/capabilities/cloudferro-sherlock.json +4 -4
  66. package/dist/capabilities/cloudflare-workers-ai.json +20 -20
  67. package/dist/capabilities/commandcode.json +148 -148
  68. package/dist/capabilities/concentrate.json +268 -268
  69. package/dist/capabilities/cortecs.json +104 -104
  70. package/dist/capabilities/crossmodel.json +172 -172
  71. package/dist/capabilities/crusoe.json +35 -6
  72. package/dist/capabilities/daoxe.json +8 -8
  73. package/dist/capabilities/databricks.json +126 -126
  74. package/dist/capabilities/deepinfra.json +105 -105
  75. package/dist/capabilities/deepseek.json +4 -4
  76. package/dist/capabilities/digitalocean.json +115 -115
  77. package/dist/capabilities/dothoosh.json +32 -32
  78. package/dist/capabilities/doubleword.json +26 -26
  79. package/dist/capabilities/edenai.json +281 -277
  80. package/dist/capabilities/empiriolabs.json +164 -164
  81. package/dist/capabilities/engy.json +10 -10
  82. package/dist/capabilities/entrim.json +5 -5
  83. package/dist/capabilities/evroc.json +13 -13
  84. package/dist/capabilities/ezkielyna.json +8 -8
  85. package/dist/capabilities/fastrouter.json +88 -88
  86. package/dist/capabilities/fireworks-ai.json +92 -92
  87. package/dist/capabilities/fortytwo.json +9 -3
  88. package/dist/capabilities/freemodel.json +18 -18
  89. package/dist/capabilities/friendli.json +8 -8
  90. package/dist/capabilities/frogbot.json +100 -100
  91. package/dist/capabilities/gisoo.json +20 -20
  92. package/dist/capabilities/gmicloud.json +16 -16
  93. package/dist/capabilities/google.json +48 -48
  94. package/dist/capabilities/graphn.json +13 -13
  95. package/dist/capabilities/greenpt.json +37 -37
  96. package/dist/capabilities/groq.json +2 -2
  97. package/dist/capabilities/helicone.json +78 -78
  98. package/dist/capabilities/hetzner.json +35 -3
  99. package/dist/capabilities/hostinger-router.json +14 -14
  100. package/dist/capabilities/hpc-ai.json +11 -11
  101. package/dist/capabilities/huawei-maas.json +14 -14
  102. package/dist/capabilities/hubris.json +31 -31
  103. package/dist/capabilities/huggingface.json +84 -174
  104. package/dist/capabilities/humain.json +2 -2
  105. package/dist/capabilities/hyper.json +19 -19
  106. package/dist/capabilities/impossibl.json +171 -171
  107. package/dist/capabilities/inception.json +3 -3
  108. package/dist/capabilities/inceptron.json +4 -4
  109. package/dist/capabilities/inco.json +4 -4
  110. package/dist/capabilities/infer.json +19 -19
  111. package/dist/capabilities/inferall.json +11 -11
  112. package/dist/capabilities/inference-coop.json +15 -15
  113. package/dist/capabilities/inferenceapis.json +24 -24
  114. package/dist/capabilities/inferris.json +4 -4
  115. package/dist/capabilities/infersia.json +13 -13
  116. package/dist/capabilities/inferx.json +2 -2
  117. package/dist/capabilities/infomaniak.json +2 -2
  118. package/dist/capabilities/io-net.json +4 -4
  119. package/dist/capabilities/isoquant.json +4 -4
  120. package/dist/capabilities/iteracompute.json +56 -56
  121. package/dist/capabilities/jad-ai.json +3 -3
  122. package/dist/capabilities/jalapeno.json +10 -10
  123. package/dist/capabilities/jiekou.json +64 -64
  124. package/dist/capabilities/jzstoken.json +50 -51
  125. package/dist/capabilities/keln.json +22 -22
  126. package/dist/capabilities/kenari.json +123 -123
  127. package/dist/capabilities/kilo.json +601 -601
  128. package/dist/capabilities/kimi-code-plan-cn.json +6 -6
  129. package/dist/capabilities/kimi-code-plan-global.json +6 -6
  130. package/dist/capabilities/kitani.json +6 -6
  131. package/dist/capabilities/klavo.json +22 -22
  132. package/dist/capabilities/korouter.json +34 -34
  133. package/dist/capabilities/kunavo.json +7 -7
  134. package/dist/capabilities/liquid.json +12 -12
  135. package/dist/capabilities/llmgateway-providers.json +934 -934
  136. package/dist/capabilities/llmgateway.json +334 -334
  137. package/dist/capabilities/llmtr.json +34 -34
  138. package/dist/capabilities/lowrouter.json +58 -58
  139. package/dist/capabilities/lyceum.json +18 -10
  140. package/dist/capabilities/melious.json +17 -17
  141. package/dist/capabilities/merge-gateway.json +255 -254
  142. package/dist/capabilities/meta.json +10 -10
  143. package/dist/capabilities/minimax-cn-coding-plan.json +5 -5
  144. package/dist/capabilities/minimax-cn.json +5 -5
  145. package/dist/capabilities/minimax-coding-plan.json +5 -5
  146. package/dist/capabilities/minimax.json +5 -5
  147. package/dist/capabilities/mistral.json +22 -22
  148. package/dist/capabilities/mixlayer.json +2 -2
  149. package/dist/capabilities/modal.json +12 -12
  150. package/dist/capabilities/model-oracle-ai.json +26 -26
  151. package/dist/capabilities/modelis.json +17 -17
  152. package/dist/capabilities/modelscope.json +2 -2
  153. package/dist/capabilities/modular.json +30 -8
  154. package/dist/capabilities/moneo.json +11 -11
  155. package/dist/capabilities/moonshotai-cn.json +6 -6
  156. package/dist/capabilities/moonshotai.json +6 -6
  157. package/dist/capabilities/morph.json +18 -18
  158. package/dist/capabilities/munito-eu.json +6 -6
  159. package/dist/capabilities/munito.json +8 -8
  160. package/dist/capabilities/nan.json +23 -23
  161. package/dist/capabilities/nano-gpt.json +565 -571
  162. package/dist/capabilities/nearai.json +93 -93
  163. package/dist/capabilities/nebius.json +32 -32
  164. package/dist/capabilities/neon.json +129 -129
  165. package/dist/capabilities/neuralwatt.json +42 -42
  166. package/dist/capabilities/nokeep.json +5 -5
  167. package/dist/capabilities/novita-ai.json +135 -135
  168. package/dist/capabilities/nvidia.json +49 -32
  169. package/dist/capabilities/oathbreaker.json +26 -3
  170. package/dist/capabilities/obscurify.json +27 -27
  171. package/dist/capabilities/oci.json +6 -6
  172. package/dist/capabilities/ofox.json +302 -302
  173. package/dist/capabilities/ollama-cloud.json +59 -59
  174. package/dist/capabilities/openai.json +58 -58
  175. package/dist/capabilities/opencode-go.json +78 -78
  176. package/dist/capabilities/openreason.json +5 -5
  177. package/dist/capabilities/openrouter.json +526 -526
  178. package/dist/capabilities/opper.json +27 -27
  179. package/dist/capabilities/orcarouter.json +243 -243
  180. package/dist/capabilities/outerlabs.json +32 -32
  181. package/dist/capabilities/ovhcloud.json +21 -21
  182. package/dist/capabilities/pareto.json +6 -6
  183. package/dist/capabilities/perplexity-agent.json +57 -57
  184. package/dist/capabilities/perplexity.json +2 -2
  185. package/dist/capabilities/phala.json +34 -34
  186. package/dist/capabilities/pioneer.json +34 -34
  187. package/dist/capabilities/poe.json +129 -129
  188. package/dist/capabilities/poolside.json +3 -3
  189. package/dist/capabilities/powerspring.json +12 -12
  190. package/dist/capabilities/primalabs.json +10 -10
  191. package/dist/capabilities/prime.json +113 -113
  192. package/dist/capabilities/privatemode-ai.json +14 -14
  193. package/dist/capabilities/proxystacks.json +7 -7
  194. package/dist/capabilities/qiniu-ai.json +14 -14
  195. package/dist/capabilities/refuseless.json +6 -6
  196. package/dist/capabilities/regolo-ai.json +10 -10
  197. package/dist/capabilities/requesty.json +371 -167
  198. package/dist/capabilities/ruapi.json +33 -17
  199. package/dist/capabilities/runcrate.json +10 -10
  200. package/dist/capabilities/runinfra.json +14 -14
  201. package/dist/capabilities/sakana.json +7 -7
  202. package/dist/capabilities/sambanova.json +9 -9
  203. package/dist/capabilities/sandbase.json +18 -18
  204. package/dist/capabilities/sarvam.json +11 -11
  205. package/dist/capabilities/scaleway.json +19 -19
  206. package/dist/capabilities/scnet-token-plan.json +11 -11
  207. package/dist/capabilities/scx-ai.json +27 -27
  208. package/dist/capabilities/sensenova.json +13 -13
  209. package/dist/capabilities/siliconflow-cn.json +55 -55
  210. package/dist/capabilities/siliconflow.json +63 -63
  211. package/dist/capabilities/snowflake-cortex.json +25 -25
  212. package/dist/capabilities/sokkan.json +2 -2
  213. package/dist/capabilities/sparrowcodes.json +22 -22
  214. package/dist/capabilities/standardcompute.json +97 -97
  215. package/dist/capabilities/steadyrouter.json +36 -36
  216. package/dist/capabilities/stepfun-ai-step-plan.json +4 -4
  217. package/dist/capabilities/stepfun-ai.json +4 -4
  218. package/dist/capabilities/stepfun-step-plan.json +4 -4
  219. package/dist/capabilities/stepfun.json +4 -4
  220. package/dist/capabilities/stepping-stone.json +19 -19
  221. package/dist/capabilities/superbot-gg.json +4 -4
  222. package/dist/capabilities/synthetic.json +9 -9
  223. package/dist/capabilities/synthorai.json +26 -26
  224. package/dist/capabilities/teamorouter.json +16 -16
  225. package/dist/capabilities/teapot-router.json +14 -14
  226. package/dist/capabilities/tencent-token-plan-intl.json +21 -21
  227. package/dist/capabilities/tencent-token-plan.json +42 -42
  228. package/dist/capabilities/tencent-tokenhub.json +49 -49
  229. package/dist/capabilities/tensorx.json +48 -48
  230. package/dist/capabilities/tenstorrent.json +8 -8
  231. package/dist/capabilities/the-grid-ai.json +34 -34
  232. package/dist/capabilities/thinkingmachines.json +78 -78
  233. package/dist/capabilities/tinfoil.json +13 -13
  234. package/dist/capabilities/togetherai.json +44 -44
  235. package/dist/capabilities/tokengo.json +25 -25
  236. package/dist/capabilities/tokenify.json +9 -9
  237. package/dist/capabilities/tokenwatt.json +10 -2
  238. package/dist/capabilities/trustedrouter.json +7 -7
  239. package/dist/capabilities/trustedtokens.json +19 -19
  240. package/dist/capabilities/umans-ai-coding-plan.json +14 -14
  241. package/dist/capabilities/umans-ai.json +10 -10
  242. package/dist/capabilities/unrestricted.json +6 -6
  243. package/dist/capabilities/uplinkswitch.json +20 -20
  244. package/dist/capabilities/upstage.json +6 -6
  245. package/dist/capabilities/vancine.json +25 -25
  246. package/dist/capabilities/vercel.json +552 -551
  247. package/dist/capabilities/vivgrid.json +74 -65
  248. package/dist/capabilities/volcengine-coding-plan.json +27 -27
  249. package/dist/capabilities/volcengine.json +29 -28
  250. package/dist/capabilities/vultr.json +25 -25
  251. package/dist/capabilities/wafer.ai.json +17 -17
  252. package/dist/capabilities/wallaby.json +4 -4
  253. package/dist/capabilities/wally.json +14 -14
  254. package/dist/capabilities/wandb.json +19 -19
  255. package/dist/capabilities/watt.json +25 -25
  256. package/dist/capabilities/xai.json +6 -6
  257. package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
  258. package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
  259. package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
  260. package/dist/capabilities/xiaomi.json +2 -2
  261. package/dist/capabilities/xpersona.json +12 -12
  262. package/dist/capabilities/xxapi.json +27 -27
  263. package/dist/capabilities/zai-coding-plan.json +12 -12
  264. package/dist/capabilities/zai.json +32 -32
  265. package/dist/capabilities/zenifra.json +27 -27
  266. package/dist/capabilities/zenmux.json +190 -190
  267. package/dist/capabilities/zerogpu.json +14 -14
  268. package/dist/capabilities/zhipuai-coding-plan.json +8 -8
  269. package/dist/capabilities/zhipuai.json +31 -31
  270. package/dist/capabilities/zro.json +6 -6
  271. package/dist/channels/index.cjs +2 -2
  272. package/dist/channels/index.js +2 -2
  273. package/dist/{channels-dBz-1Oy7.cjs → channels-BXZbY7TL.cjs} +1 -1
  274. package/dist/{channels-CyJ0PpSg.js → channels-Bs8wDPDl.js} +1 -1
  275. package/dist/coding-agent/index.cjs +2 -2
  276. package/dist/coding-agent/index.js +2 -2
  277. package/dist/datasets/index.cjs +2 -2
  278. package/dist/datasets/index.js +2 -2
  279. package/dist/docs/SKILL.md +1 -1
  280. package/dist/docs/assets/SOURCE_MAP.json +722 -707
  281. package/dist/docs/references/docs-agents-code-mode.md +20 -0
  282. package/dist/docs/references/docs-browser.md +3 -1
  283. package/dist/docs/references/docs-knowledge-agents-and-tools.md +2 -0
  284. package/dist/docs/references/integrations.md +1 -0
  285. package/dist/docs/references/reference-processors-tool-search-processor.md +3 -3
  286. package/dist/docs/references/reference-tools-create-code-mode.md +22 -0
  287. package/dist/evals/index.cjs +1 -1
  288. package/dist/evals/index.js +1 -1
  289. package/dist/evals/scoreTraces/index.cjs +1 -1
  290. package/dist/evals/scoreTraces/index.js +1 -1
  291. package/dist/harness/index.cjs +2 -2
  292. package/dist/harness/index.js +2 -2
  293. package/dist/index.cjs +1 -1
  294. package/dist/index.js +1 -1
  295. package/dist/knowledge/agent-scopes.d.ts +17 -0
  296. package/dist/knowledge/declarations.d.ts +2 -0
  297. package/dist/knowledge/held-scopes-state-processor.d.ts +50 -0
  298. package/dist/knowledge/importers/types.d.ts +2 -0
  299. package/dist/knowledge/index.cjs +65 -15
  300. package/dist/knowledge/index.d.ts +6 -0
  301. package/dist/knowledge/index.js +64 -16
  302. package/dist/knowledge/page-tools.d.ts +14 -0
  303. package/dist/knowledge/run.d.ts +1 -0
  304. package/dist/llm/index.cjs +3 -3
  305. package/dist/llm/index.js +3 -3
  306. package/dist/llm/model/provider-types.generated.d.ts +8041 -8014
  307. package/dist/{llm-Du8yTHDN.js → llm-9xmy8HlF.js} +2 -2
  308. package/dist/{llm-BiSuGioB.cjs → llm-ypGNjEom.cjs} +2 -2
  309. package/dist/loop/index.cjs +2 -2
  310. package/dist/loop/index.js +2 -2
  311. package/dist/{manager-CiKAT1GP.js → manager-B-QrBhhd.js} +2 -2
  312. package/dist/{manager-Bd8By72w.cjs → manager-CYXV5_vY.cjs} +2 -2
  313. package/dist/mastra/index.cjs +1 -1
  314. package/dist/mastra/index.js +1 -1
  315. package/dist/{mastra-GjJdwKF7.js → mastra-DPSwJ5ae.js} +16 -16
  316. package/dist/{mastra-BD1Hqrb2.cjs → mastra-zszeli0N.cjs} +16 -16
  317. package/dist/memory/index.cjs +2 -2
  318. package/dist/memory/index.js +2 -2
  319. package/dist/{model-Bvfq1yB9.js → model-UYJb8Zel.js} +1 -1
  320. package/dist/{model-CI05YYPx.cjs → model-WLujr8OR.cjs} +1 -1
  321. package/dist/{netlify-DQ-v2Run.js → netlify-DTWAZGpA.js} +1 -1
  322. package/dist/{netlify-DkSS4nuo.cjs → netlify-wZafLKoe.cjs} +1 -1
  323. package/dist/notifications/index.cjs +1 -1
  324. package/dist/notifications/index.js +1 -1
  325. package/dist/processor-provider/index.cjs +1 -1
  326. package/dist/processor-provider/index.js +1 -1
  327. package/dist/processors/index.cjs +2 -2
  328. package/dist/processors/index.js +2 -2
  329. package/dist/processors/processors/tool-search.d.ts +2 -2
  330. package/dist/{provider-registry-K3a83H9-.cjs → provider-registry-BvpUdOiq.cjs} +21504 -21437
  331. package/dist/{provider-registry-D7D3C2RI.js → provider-registry-COT79RLh.js} +21504 -21437
  332. package/dist/provider-registry.json +22003 -21942
  333. package/dist/{registry-generator-BgHaZqDZ.js → registry-generator-BKjTPD6B.js} +1 -1
  334. package/dist/{registry-generator-RfPwMlUl.cjs → registry-generator-Dn1Tuacv.cjs} +1 -1
  335. package/dist/{rehydrate-C4-5kM6Z.js → rehydrate-BK1v65H7.js} +2 -2
  336. package/dist/{rehydrate-DwfzaTOg.cjs → rehydrate-C0xrJUBu.cjs} +2 -2
  337. package/dist/relevance/index.cjs +2 -2
  338. package/dist/relevance/index.js +2 -2
  339. package/dist/{run-registry-Bj_lW9M3.js → run-registry-DKiudqVU.js} +351 -36
  340. package/dist/{run-registry-BJa47sa2.cjs → run-registry-DX_EyboB.cjs} +374 -35
  341. package/dist/storage/index.cjs +2 -2
  342. package/dist/storage/index.js +2 -2
  343. package/dist/stream/index.cjs +2 -2
  344. package/dist/stream/index.js +2 -2
  345. package/dist/{stream-DaIpS6ky.js → stream-B4LzC6Sz.js} +1 -1
  346. package/dist/{stream-CWE0h7Yc.cjs → stream-BmtBm_-L.cjs} +1 -1
  347. package/dist/test-utils/llm-mock.cjs +1 -1
  348. package/dist/test-utils/llm-mock.js +1 -1
  349. package/dist/tool-loop-agent/index.cjs +1 -1
  350. package/dist/tool-loop-agent/index.js +1 -1
  351. package/dist/{tool-loop-agent-BGBhn5xS.cjs → tool-loop-agent-BIbw3quM.cjs} +3 -3
  352. package/dist/{tool-loop-agent-B12lpXBl.js → tool-loop-agent-CR2AgmkF.js} +3 -3
  353. package/dist/tools/code-mode/index.d.ts +2 -0
  354. package/dist/tools/code-mode/log-collector.d.ts +49 -0
  355. package/dist/tools/code-mode/types.d.ts +71 -0
  356. package/dist/tools/index.cjs +3 -1
  357. package/dist/tools/index.js +2 -2
  358. package/dist/{tools-n9lqzDNe.cjs → tools-BEYxowf0.cjs} +316 -30
  359. package/dist/{tools-DDfA_ES4.js → tools-tPy2FwMI.js} +305 -31
  360. package/dist/{utils-dueX8ECq.js → utils-BnG4bq6k.js} +1 -1
  361. package/dist/{utils-CPOlvXFL.cjs → utils-D2Bj0C2E.cjs} +1 -1
  362. package/dist/utils.cjs +1 -1
  363. package/dist/utils.js +1 -1
  364. package/dist/{validate-DdirQd9u.cjs → validate-BxgKlbt7.cjs} +1 -1
  365. package/dist/{validate-x3wcpuT8.js → validate-DHEGALaE.js} +1 -1
  366. package/dist/vector/index.cjs +1 -1
  367. package/dist/vector/index.js +1 -1
  368. package/dist/worker/index.cjs +1 -1
  369. package/dist/worker/index.js +1 -1
  370. package/dist/{worker-CfMtR2cV.js → worker-1lHN6hT1.js} +2 -2
  371. package/dist/{worker-CPZ3HqQn.cjs → worker-BRKHC9hv.cjs} +2 -2
  372. package/dist/{worker-NYiueScR.js → worker-C-xoXGOt.js} +2 -2
  373. package/dist/{worker-GrFJJ7Y0.cjs → worker-DYBrWSDX.cjs} +2 -2
  374. package/dist/{workflow-BgAes9PI.js → workflow-79JneaJP.js} +3 -3
  375. package/dist/{workflow-BNUED985.cjs → workflow-DGRDgyhs.cjs} +3 -3
  376. package/dist/workflows/builder/index.cjs +1 -1
  377. package/dist/workflows/builder/index.js +1 -1
  378. package/dist/workflows/evented/index.cjs +1 -1
  379. package/dist/workflows/evented/index.js +1 -1
  380. package/dist/workflows/index.cjs +4 -4
  381. package/dist/workflows/index.js +4 -4
  382. package/dist/workspace/index.cjs +1 -1
  383. package/dist/workspace/index.js +1 -1
  384. package/dist/workspace/sandbox/teardown-context.d.ts +74 -0
  385. package/dist/{workspace-Pv3J8K0c.cjs → workspace-C8Zo5_qK.cjs} +106 -5
  386. package/dist/{workspace-BK9ltbSa.js → workspace-DOAil8mG.js} +106 -5
  387. package/package.json +7 -7
  388. package/src/llm/model/provider-types.generated.d.ts +8041 -8014
@@ -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-CWE0h7Yc.cjs");
7
+ const require_stream = require("./stream-BmtBm_-L.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-BiSuGioB.cjs");
14
+ const require_llm = require("./llm-ypGNjEom.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-K3a83H9-.cjs");
26
+ const require_provider_registry = require("./provider-registry-BvpUdOiq.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-CI05YYPx.cjs");
30
- const require_utils$1 = require("./utils-CPOlvXFL.cjs");
29
+ const require_model$1 = require("./model-WLujr8OR.cjs");
30
+ const require_utils$1 = require("./utils-D2Bj0C2E.cjs");
31
31
  const require_ee_iTj2bRDt = require("./ee-iTj2bRDt-D3-QLGDF.cjs");
32
- const require_background_tasks = require("./background-tasks-C-3AqSKL.cjs");
32
+ const require_background_tasks = require("./background-tasks-B63welNM.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");
@@ -41,8 +41,8 @@ const require_state_processor = require("./state-processor-kRNZ38Nf.cjs");
41
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
- const require_workspace = require("./workspace-Pv3J8K0c.cjs");
45
- const require_tools = require("./tools-n9lqzDNe.cjs");
44
+ const require_workspace = require("./workspace-C8Zo5_qK.cjs");
45
+ const require_tools = require("./tools-BEYxowf0.cjs");
46
46
  const require_workspace_skills = require("./workspace-skills-BcquhPDn.cjs");
47
47
  const require_filesystem_versioned = require("./filesystem-versioned-BavRtYWJ.cjs");
48
48
  const require_features_index = require("./features/index.cjs");
@@ -30373,19 +30373,24 @@ var ToolSearchProcessor = class {
30373
30373
  });
30374
30374
  }
30375
30375
  async processInputStep(args) {
30376
- const { tools, messageList } = args;
30376
+ const { tools, messageList, activeTools } = args;
30377
30377
  const catalog = this.catalogForStep(tools);
30378
30378
  const storeContext = this.makeStoreContext(args);
30379
30379
  const loadedToolNames = await this.store.getLoadedNames(storeContext);
30380
30380
  const autoLoad = this.searchConfig.autoLoad;
30381
- messageList.addSystem(autoLoad ? "To discover available tools, call search_tools with a keyword query. Matching tools are loaded automatically and become available on your next turn \u2014 there is no separate load step. After searching, use the tool directly." : "To discover available tools, call search_tools with a keyword query. To add one or more tools to the conversation, call load_tool with a toolName or toolNames array. Tools must be loaded before they can be used.");
30382
- if (this.injectCatalog) {
30381
+ const searchAvailable = !activeTools || activeTools.includes("search_tools");
30382
+ const loadAvailable = !autoLoad && (!activeTools || activeTools.includes("load_tool"));
30383
+ const instructionParts = [];
30384
+ if (searchAvailable) instructionParts.push(autoLoad ? "To discover available tools, call search_tools with a keyword query. Matching tools are loaded automatically and become available on your next turn \u2014 there is no separate load step. After searching, use the tool directly." : "To discover available tools, call search_tools with a keyword query.");
30385
+ if (loadAvailable) instructionParts.push("To add one or more tools to the conversation, call load_tool with a toolName or toolNames array. Tools must be loaded before they can be used.");
30386
+ if (instructionParts.length > 0) messageList.addSystem(instructionParts.join(" "));
30387
+ if (this.injectCatalog && (autoLoad ? searchAvailable : loadAvailable)) {
30383
30388
  const catalogList = await this.formatCatalog(catalog, args.requestContext);
30384
- if (catalogList) messageList.addSystem((autoLoad ? "The following tools are available. Call search_tools with a keyword to load one \u2014 matching tools are loaded automatically and become available on your next turn." : "The following tools are available to load. Call load_tool with a toolName or toolNames array to add one or more before using them \u2014 no search step is required. search_tools is also available if you need to rediscover tools by keyword.") + "\n\nAvailable tools:\n" + catalogList);
30389
+ if (catalogList) messageList.addSystem((autoLoad ? "The following tools are available. Call search_tools with a keyword to load one \u2014 matching tools are loaded automatically and become available on your next turn." : "The following tools are available to load. Call load_tool with a toolName or toolNames array to add one or more before using them \u2014 no search step is required." + (searchAvailable ? " search_tools is also available if you need to rediscover tools by keyword." : "")) + "\n\nAvailable tools:\n" + catalogList);
30385
30390
  }
30386
30391
  const searchTool = require_tool.createTool({
30387
30392
  id: "search_tools",
30388
- description: autoLoad ? "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools, which are loaded automatically and become available on your next turn \u2014 no separate load step is required." : "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools with their names and descriptions. After finding a useful tool, use load_tool to make it available.",
30393
+ description: autoLoad ? "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools, which are loaded automatically and become available on your next turn \u2014 no separate load step is required." : "Search for available tools by keyword. Use this when you need a capability you don't currently have. Returns a list of matching tools with their names and descriptions." + (loadAvailable ? " After finding a useful tool, use load_tool to make it available." : ""),
30389
30394
  inputSchema: zod_v4.z.object({ query: zod_v4.z.string().describe("Search keywords (e.g., \"weather\", \"github issue\", \"database query\")") }),
30390
30395
  outputSchema: zod_v4.z.object({
30391
30396
  results: zod_v4.z.array(zod_v4.z.object({
@@ -30415,13 +30420,13 @@ var ToolSearchProcessor = class {
30415
30420
  }
30416
30421
  return {
30417
30422
  results,
30418
- message: `Found ${results.length} tool(s). Use load_tool with an exact toolName or a toolNames array to make them available.`
30423
+ message: loadAvailable ? `Found ${results.length} tool(s). Use load_tool with an exact toolName or a toolNames array to make them available.` : `Found ${results.length} tool(s): ${results.map((r) => r.name).join(", ")}.`
30419
30424
  };
30420
30425
  }
30421
30426
  });
30422
30427
  const loadTool = require_tool.createTool({
30423
30428
  id: "load_tool",
30424
- description: "Load one or more tools into your context. Call this after finding tools with search_tools. Once loaded, tools will be available for use. Pass a single toolName or an array of toolNames to load multiple tools at once.",
30429
+ description: "Load one or more tools into your context. " + (searchAvailable ? "Call this after finding tools with search_tools. " : "") + "Once loaded, tools will be available for use. Pass a single toolName or an array of toolNames to load multiple tools at once.",
30425
30430
  inputSchema: zod_v4.z.object({
30426
30431
  toolName: zod_v4.z.string().optional().describe("The exact name of a tool to load (from search results)"),
30427
30432
  toolNames: zod_v4.z.array(zod_v4.z.string()).optional().describe("Array of exact tool names to load in one call (from search results)")
@@ -30478,7 +30483,7 @@ var ToolSearchProcessor = class {
30478
30483
  const suggestions = await this.getSuggestedToolNames(catalog, name, args.requestContext);
30479
30484
  let message = `Tool "${name}" not found.`;
30480
30485
  if (suggestions.length > 0) message += ` Did you mean: ${suggestions.slice(0, 3).join(", ")}?`;
30481
- else message += " Use search_tools to find available tools.";
30486
+ else if (searchAvailable) message += " Use search_tools to find available tools.";
30482
30487
  return {
30483
30488
  success: false,
30484
30489
  message,
@@ -30512,8 +30517,8 @@ var ToolSearchProcessor = class {
30512
30517
  });
30513
30518
  const loadedTools = await this.getLoadedTools(catalog, loadedToolNames, args.requestContext);
30514
30519
  return { tools: {
30515
- search_tools: searchTool,
30516
- ...autoLoad ? {} : { load_tool: loadTool },
30520
+ ...searchAvailable ? { search_tools: searchTool } : {},
30521
+ ...loadAvailable ? { load_tool: loadTool } : {},
30517
30522
  ...this.includeResolvedTools ? unsearchableResolvedTools(tools) : tools ?? {},
30518
30523
  ...loadedTools
30519
30524
  } };
@@ -30875,7 +30880,7 @@ var SkillSearchProcessor = class {
30875
30880
  return this.cleanupStaleState();
30876
30881
  }
30877
30882
  async processInputStep(args) {
30878
- const { tools, messageList } = args;
30883
+ const { tools, messageList, activeTools } = args;
30879
30884
  const threadId = this.getThreadId(args);
30880
30885
  const threadState = this.getThreadState(threadId);
30881
30886
  const configuredSkills = this.skills;
@@ -30885,10 +30890,18 @@ var SkillSearchProcessor = class {
30885
30890
  if (this.blockingRefresh) await skills.maybeRefresh({ requestContext: args.requestContext })?.catch(this.warnRefreshFailed);
30886
30891
  else skills.maybeRefresh({ requestContext: args.requestContext })?.catch(this.warnRefreshFailed);
30887
30892
  }
30888
- messageList.addSystem("To discover available skills, call search_skills with a keyword query. To load a skill's instructions, call load_skill with the skill name. Loaded skills provide context and instructions for the conversation.");
30893
+ const searchAvailable = !activeTools || activeTools.includes("search_skills");
30894
+ const loadAvailable = !activeTools || activeTools.includes("load_skill");
30895
+ const instructionParts = [];
30896
+ if (searchAvailable) instructionParts.push("To discover available skills, call search_skills with a keyword query.");
30897
+ if (loadAvailable) instructionParts.push("To load a skill's instructions, call load_skill with the skill name.");
30898
+ if (instructionParts.length > 0) {
30899
+ instructionParts.push("Loaded skills provide context and instructions for the conversation.");
30900
+ messageList.addSystem(instructionParts.join(" "));
30901
+ }
30889
30902
  const searchSkillTool = require_tool.createTool({
30890
30903
  id: "search_skills",
30891
- description: "Search for available skills by keyword. Returns a list of matching skills with their names and descriptions. After finding a useful skill, use load_skill to load its instructions.",
30904
+ description: "Search for available skills by keyword. Returns a list of matching skills with their names and descriptions." + (loadAvailable ? " After finding a useful skill, use load_skill to load its instructions." : ""),
30892
30905
  inputSchema: zod_v4.z.object({ query: zod_v4.z.string().trim().min(1, "Query is required").describe("Search keywords (e.g., \"api design\", \"testing\", \"deployment\")") }),
30893
30906
  outputSchema: zod_v4.z.object({
30894
30907
  results: zod_v4.z.array(zod_v4.z.object({
@@ -30925,13 +30938,13 @@ var SkillSearchProcessor = class {
30925
30938
  });
30926
30939
  return {
30927
30940
  results,
30928
- message: `Found ${results.length} skill(s). Use load_skill with the exact skill name to load its instructions.`
30941
+ message: loadAvailable ? `Found ${results.length} skill(s). Use load_skill with the exact skill name to load its instructions.` : `Found ${results.length} skill(s): ${results.map((r) => r.name).join(", ")}.`
30929
30942
  };
30930
30943
  }
30931
30944
  });
30932
30945
  const loadSkillTool = require_tool.createTool({
30933
30946
  id: "load_skill",
30934
- description: "Load a skill's full instructions into the conversation. Call this after finding a skill with search_skills. The skill's instructions will be available as context.",
30947
+ description: "Load a skill's full instructions into the conversation. " + (searchAvailable ? "Call this after finding a skill with search_skills. " : "") + "The skill's instructions will be available as context.",
30935
30948
  inputSchema: zod_v4.z.object({ skillName: zod_v4.z.string().describe("The exact name of the skill to load (from search results)") }),
30936
30949
  outputSchema: zod_v4.z.object({
30937
30950
  success: zod_v4.z.boolean(),
@@ -30949,7 +30962,7 @@ var SkillSearchProcessor = class {
30949
30962
  const suggestions = (await skills.list()).filter((s) => s.name.toLowerCase().includes(skillName.toLowerCase()) || skillName.toLowerCase().includes(s.name.toLowerCase())).slice(0, 3);
30950
30963
  let message = `Skill "${skillName}" not found.`;
30951
30964
  if (suggestions.length > 0) message += ` Did you mean: ${suggestions.map((s) => s.name).join(", ")}?`;
30952
- else message += " Use search_skills to find available skills.";
30965
+ else if (searchAvailable) message += " Use search_skills to find available skills.";
30953
30966
  return {
30954
30967
  success: false,
30955
30968
  message
@@ -30965,8 +30978,8 @@ var SkillSearchProcessor = class {
30965
30978
  });
30966
30979
  for (const [skillName, instructions] of threadState.skills) messageList.addSystem(`[Skill: ${skillName}]\n\n${instructions}`);
30967
30980
  const metaTools = {
30968
- search_skills: searchSkillTool,
30969
- load_skill: loadSkillTool
30981
+ ...searchAvailable ? { search_skills: searchSkillTool } : {},
30982
+ ...loadAvailable ? { load_skill: loadSkillTool } : {}
30970
30983
  };
30971
30984
  if (tools) {
30972
30985
  for (const key of Object.keys(tools)) if (key in metaTools) console.warn(`[SkillSearchProcessor] User tool "${key}" conflicts with meta-tool and will be shadowed.`);
@@ -52815,6 +52828,132 @@ function withReplyModeDefaults(cfg) {
52815
52828
  ...set
52816
52829
  };
52817
52830
  }
52831
+ // src/knowledge/held-scopes-state-processor.ts
52832
+ const HELD_SCOPES_STATE_ID = "knowledge-scopes";
52833
+ const HELD_SCOPES_SNAPSHOT_TAG = "knowledge-scopes";
52834
+ const HELD_SCOPES_DELTA_TAG = "knowledge-scopes-update";
52835
+ function lp$1(value) {
52836
+ return `${value.length}:${value}`;
52837
+ }
52838
+ function fingerprint$1(scope) {
52839
+ return `${lp$1(scope.address)}${lp$1(scope.role)}`;
52840
+ }
52841
+ function cacheKey(scopes) {
52842
+ return `scopes:${scopes.map(fingerprint$1).join("|")}`;
52843
+ }
52844
+ function scopesFromSnapshot(snapshot) {
52845
+ const value = (snapshot?.metadata)?.value?.scopes;
52846
+ return Array.isArray(value) ? value : [];
52847
+ }
52848
+ function opsFromDelta(delta) {
52849
+ const ops = delta.metadata?.delta?.ops;
52850
+ return Array.isArray(ops) ? ops : [];
52851
+ }
52852
+ function applyOps(scopes, ops) {
52853
+ const next = scopes.slice();
52854
+ for (const op of ops) {
52855
+ const address = op.op === "remove" ? op.address : op.scope.address;
52856
+ const idx = next.findIndex((scope) => scope.address === address);
52857
+ if (op.op === "remove") {
52858
+ if (idx >= 0) next.splice(idx, 1);
52859
+ } else if (idx >= 0) next[idx] = op.scope;
52860
+ else next.push(op.scope);
52861
+ }
52862
+ return next;
52863
+ }
52864
+ function diffScopes(prior, current) {
52865
+ const ops = [];
52866
+ const before = new Map(prior.map((scope) => [scope.address, fingerprint$1(scope)]));
52867
+ const currentAddresses = new Set(current.map((scope) => scope.address));
52868
+ for (const scope of prior) if (!currentAddresses.has(scope.address)) ops.push({
52869
+ op: "remove",
52870
+ address: scope.address
52871
+ });
52872
+ for (const scope of current) {
52873
+ const was = before.get(scope.address);
52874
+ if (was === void 0) ops.push({
52875
+ op: "add",
52876
+ scope
52877
+ });
52878
+ else if (was !== fingerprint$1(scope)) ops.push({
52879
+ op: "change",
52880
+ scope
52881
+ });
52882
+ }
52883
+ return ops;
52884
+ }
52885
+ function line(scope) {
52886
+ return `${scope.address} (${scope.role})`;
52887
+ }
52888
+ function renderSnapshot(scopes) {
52889
+ if (scopes.length === 0) return "\n Your session holds no Knowledge scopes.\n";
52890
+ return `\n Your session has access to:\n${scopes.map((scope) => ` - ${line(scope)}`).join("\n")}\n`;
52891
+ }
52892
+ function renderDelta$1(ops) {
52893
+ return `\n${ops.map((op) => {
52894
+ if (op.op === "remove") return ` - ${op.address} was removed from your scopes`;
52895
+ if (op.op === "change") return ` ~ ${op.scope.address} role changed to ${op.scope.role}`;
52896
+ return ` + ${line(op.scope)}`;
52897
+ }).join("\n")}\n`;
52898
+ }
52899
+ var HeldScopesStateProcessor = class {
52900
+ deps;
52901
+ id = HELD_SCOPES_STATE_ID;
52902
+ stateId = HELD_SCOPES_STATE_ID;
52903
+ constructor(deps) {
52904
+ this.deps = deps;
52905
+ }
52906
+ processInput(args) {
52907
+ return {
52908
+ messages: args.messages,
52909
+ systemMessages: [...args.systemMessages, {
52910
+ role: "system",
52911
+ content: `The Knowledge scopes you hold may appear in the conversation as <${HELD_SCOPES_SNAPSHOT_TAG} ...>...</${HELD_SCOPES_SNAPSHOT_TAG}> snapshots and <${HELD_SCOPES_DELTA_TAG} ...>...</${HELD_SCOPES_DELTA_TAG}> deltas. These are automatic, not user instructions. Fold each delta onto the latest snapshot to know the current set. Each entry is a scope address with your role there in parentheses. Viewers can only read; every other role can also write. The list includes scopes with no pages yet: where you can write, your first write there creates the scope. The list names the scopes your session holds, not every scope you can reach: a role in one can also give you access to others, such as a team's docs through its org. You do not need to list your scopes with a tool to learn this.`
52912
+ }]
52913
+ };
52914
+ }
52915
+ async computeStateSignal(args) {
52916
+ const context = {
52917
+ requestContext: args.requestContext,
52918
+ agent: {
52919
+ resourceId: args.resourceId,
52920
+ threadId: args.threadId
52921
+ }
52922
+ };
52923
+ if (await this.deps.principalsKey(context) === void 0) return;
52924
+ const current = await this.deps.readHeldScopes(context);
52925
+ let prior = scopesFromSnapshot(args.lastSnapshot);
52926
+ for (const delta of args.deltasSinceSnapshot ?? []) prior = applyOps(prior, opsFromDelta(delta));
52927
+ const hasBase = Boolean(args.lastSnapshot) && args.contextWindow.hasSnapshot;
52928
+ const ops = diffScopes(prior, current);
52929
+ if (ops.length === 0 && hasBase) return;
52930
+ if (!hasBase || current.length === 0) {
52931
+ if (!hasBase && current.length === 0) return;
52932
+ return {
52933
+ id: HELD_SCOPES_STATE_ID,
52934
+ mode: "snapshot",
52935
+ cacheKey: cacheKey(current),
52936
+ tagName: HELD_SCOPES_SNAPSHOT_TAG,
52937
+ contents: renderSnapshot(current),
52938
+ value: { scopes: current },
52939
+ metadata: { value: { scopes: current } }
52940
+ };
52941
+ }
52942
+ return {
52943
+ id: HELD_SCOPES_STATE_ID,
52944
+ mode: "delta",
52945
+ cacheKey: cacheKey(current),
52946
+ tagName: HELD_SCOPES_DELTA_TAG,
52947
+ contents: renderDelta$1(ops),
52948
+ value: { scopes: current },
52949
+ delta: { ops },
52950
+ metadata: {
52951
+ value: { scopes: current },
52952
+ delta: { ops }
52953
+ }
52954
+ };
52955
+ }
52956
+ };
52818
52957
  // src/knowledge/instructions.ts
52819
52958
  function readInstructions(canEdit) {
52820
52959
  return `Use the Knowledge tools for durable, shared knowledge. Pinned knowledge pages may already be in your context if <pinned-knowledge> tags are present in the visible conversation history: answer from their bodies without searching for or reading them again${canEdit ? ", and edit one straight from its body and the version shown, unless its body was cut off: then read it first, since a write replaces the whole body" : ""}. Read a pinned page with knowledge_read only when the answer depends on what its notes say, or on its child pages; a note count alone is no reason to read it. For anything else, search with knowledge_search before answering from Knowledge, and read a page with knowledge_read before relying on it. To see how a scope or section is organized, list it with knowledge_list and read pages by the refs it gives. Read a page whole first; when its body is too long, it comes back as its headings with line numbers and the first lines under each: read the section you need, or match the terms you are looking for. A result's more says what it left out: follow it only when what you need is not already in what you have read, and answer as soon as you have it. Cite the page or note you used. When nothing is found, say so plainly instead of guessing. When notes disagree, show both with their dates.`;
@@ -53105,6 +53244,16 @@ function compileKnowledgeScopes(declarations) {
53105
53244
  const concreteEntries = [];
53106
53245
  for (const [key, declaration] of Object.entries(declarations)) {
53107
53246
  const pattern = parsePattern(key, "Knowledge scope key");
53247
+ if (declaration.mint !== void 0) {
53248
+ if (declaration.mint !== "run-identity" || pattern.type !== "agent" || pattern.params.length === 0) throw new KnowledgeDeclarationError(`Knowledge scope "${key}" can mint only an agent pattern with mint: 'run-identity'.`);
53249
+ for (const param of pattern.params) if (![
53250
+ "agentId",
53251
+ "orgId",
53252
+ "resourceId",
53253
+ "role",
53254
+ "teamId"
53255
+ ].includes(param)) throw new KnowledgeDeclarationError(`Knowledge scope "${key}" cannot mint unknown parameter $${param}.`);
53256
+ }
53108
53257
  if (pattern.params.length === 0) {
53109
53258
  concreteEntries.push([key, declaration]);
53110
53259
  continue;
@@ -63078,6 +63227,94 @@ async function removeKnowledgeNote(host, input) {
63078
63227
  await embed$1(host, (index) => index.remove([`note:${note.id}`]), UNEMBED_FAILED$1);
63079
63228
  return removed;
63080
63229
  }
63230
+ // src/knowledge/agent-scopes.ts
63231
+ /** Agent identity declarations. Identities grant nothing until an access rule names them. @experimental */
63232
+ function knowledgeAgentScopes() {
63233
+ return Object.fromEntries([
63234
+ "agent:$agentId",
63235
+ "agent:$agentId:org:$orgId",
63236
+ "agent:$agentId:user:$resourceId",
63237
+ "agent:persona:role:$role",
63238
+ "agent:persona:role:$role:org:$orgId",
63239
+ "agent:persona:role:$role:user:$resourceId",
63240
+ "agent:persona:team:$teamId"
63241
+ ].map((key) => [key, {
63242
+ mint: "run-identity",
63243
+ access: []
63244
+ }]));
63245
+ }
63246
+ /**
63247
+ * {@link knowledgeAgentScopes} plus a read-only persona convention: each agent reads and pins its own
63248
+ * `#persona` page, and every agent of a role or team reads and pins that scope's `#rules` page. The
63249
+ * `:edit` forms give editor on one role or team scope and are never minted; host code passes them.
63250
+ * @experimental
63251
+ */
63252
+ function knowledgePersonaScopes() {
63253
+ const scopes = knowledgeAgentScopes();
63254
+ for (const [key, page, name, edit] of [
63255
+ [
63256
+ "agent:$agentId",
63257
+ "persona",
63258
+ "Persona",
63259
+ false
63260
+ ],
63261
+ [
63262
+ "agent:persona:role:$role",
63263
+ "rules",
63264
+ "Role rules",
63265
+ true
63266
+ ],
63267
+ [
63268
+ "agent:persona:team:$teamId",
63269
+ "rules",
63270
+ "Team rules",
63271
+ true
63272
+ ]
63273
+ ]) {
63274
+ scopes[key] = {
63275
+ ...scopes[key],
63276
+ access: [{
63277
+ principal: "self",
63278
+ role: "viewer"
63279
+ }, ...edit ? [{
63280
+ principal: `${key}:edit`,
63281
+ role: "editor"
63282
+ }] : []],
63283
+ pages: [{
63284
+ key: page,
63285
+ name
63286
+ }],
63287
+ pinnedContext: [`${key}#${page}`]
63288
+ };
63289
+ if (edit) scopes[`${key}:edit`] = { access: [] };
63290
+ }
63291
+ return scopes;
63292
+ }
63293
+ /** @internal */
63294
+ function mintKnowledgeAgentScopes(compiled, scopes, agent) {
63295
+ const params = {};
63296
+ if (agent?.agentId) params.agentId = agent.agentId;
63297
+ if (agent?.resourceId) params.resourceId = agent.resourceId;
63298
+ const persona = agent?.persona;
63299
+ if (persona && typeof persona === "object") for (const [field, param] of [["role", "role"], ["teamId", "teamId"]]) {
63300
+ const value = persona[field];
63301
+ if (typeof value === "string" && value.length > 0) params[param] = value;
63302
+ }
63303
+ const orgs = scopes.filter((scope) => /^org:[^:]+$/.test(scope)).map((scope) => decodeKnowledgeScopeValue(scope.slice(4))).filter((value) => value !== null);
63304
+ const minted = [];
63305
+ for (const declaration of compiled.declarations.values()) {
63306
+ if (declaration.declaration.mint !== "run-identity") continue;
63307
+ const bindings = declaration.pattern.params.includes("orgId") ? orgs.map((orgId) => ({
63308
+ ...params,
63309
+ orgId
63310
+ })) : [params];
63311
+ for (const binding of bindings) {
63312
+ const address = bindKnowledgePattern(declaration.pattern, binding);
63313
+ if (address) minted.push(address);
63314
+ }
63315
+ }
63316
+ return minted;
63317
+ }
63081
63318
  // src/knowledge/run.ts
63082
63319
  /** A page reference the run can't resolve; identical for missing and unreadable pages. */
63083
63320
  var KnowledgeNotFoundError = class extends Error {
@@ -63246,7 +63483,13 @@ function knowledgeRunPrincipals(runtime, context) {
63246
63483
  if (context?.agent?.threadId) memory.push(knowledgeScopeAddress("thread:$threadId", { threadId: context.agent.threadId }));
63247
63484
  if (raw.length === 0 && memory.length === 0) throw new KnowledgeRunScopesError();
63248
63485
  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()\`).`);
63249
- return [.../* @__PURE__ */ new Set([...knowledgeRunScopes(runtime.compiled, raw), ...memory])];
63486
+ const scopes = knowledgeRunScopes(runtime.compiled, raw);
63487
+ const minted = mintKnowledgeAgentScopes(runtime.compiled, scopes, context?.agent);
63488
+ return [.../* @__PURE__ */ new Set([
63489
+ ...scopes,
63490
+ ...memory,
63491
+ ...minted
63492
+ ])];
63250
63493
  }
63251
63494
  /** Longest heading line a hit shows ahead of its excerpt; a longer one is cut with `…`. */
63252
63495
  const HEADING_CHARS = 120;
@@ -63680,11 +63923,13 @@ async function visibleNote(run, id) {
63680
63923
  page
63681
63924
  };
63682
63925
  }
63683
- /** Pin authority over an audience entry: the run holds it, or rules give it editor+ there. */
63926
+ /** Shared persona audiences need editor authority even when the run holds them. */
63684
63927
  async function requireAudienceAuthority(run, audience) {
63685
63928
  for (const address of audience) {
63686
- if (run.principals.includes(address)) continue;
63687
- if (!run.runtime.compiled.match(address)) throw new Error(`Pin audience "${address}" does not match a declared scope type.`);
63929
+ const match = run.runtime.compiled.match(address);
63930
+ const sharedPersona = match?.compiled.declaration.mint === "run-identity" && match.compiled.pattern.params.some((param) => param === "role" || param === "teamId");
63931
+ if (run.principals.includes(address) && !sharedPersona) continue;
63932
+ if (!match) throw new Error(`Pin audience "${address}" does not match a declared scope type.`);
63688
63933
  const [scope] = await run.storage.getScopesByAddress([address]);
63689
63934
  if (!knowledgeRoleAtLeast(scope ? await run.roleOn(scope) : knowledgeRoleOn(run.runtime.compiled, run.principals, { address }), "editor")) throw new Error(`Pinning for "${address}" needs holding it or editor on it; this run has neither.`);
63690
63935
  }
@@ -84331,7 +84576,7 @@ async function prepareForDurableExecution(options) {
84331
84576
  });
84332
84577
  let tripwireData;
84333
84578
  if (inputProcessors.length > 0) try {
84334
- const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-CWE0h7Yc.cjs")).then((n) => n.runner_exports);
84579
+ const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-BmtBm_-L.cjs")).then((n) => n.runner_exports);
84335
84580
  await new ProcessorRunner({
84336
84581
  inputProcessors,
84337
84582
  outputProcessors,
@@ -87091,6 +87336,11 @@ var Agent = class Agent extends require_base.MastraBase {
87091
87336
  const processors = [];
87092
87337
  const instructions = knowledge.getInstructions();
87093
87338
  if (instructions && !configuredIds.has("knowledge-instructions-processor")) processors.push(new KnowledgeInstructionsProcessor(instructions));
87339
+ const toolGroups = knowledge.__toolGroups;
87340
+ if (hasMemory && (toolGroups.read || toolGroups.write) && !hasConfiguredProcessor(configuredProcessors, (processor) => processor.id === "knowledge-scopes")) processors.push(new HeldScopesStateProcessor({
87341
+ principalsKey: (context) => knowledge.__principalsKey(context),
87342
+ readHeldScopes: (context) => knowledge.__heldScopes(context)
87343
+ }));
87094
87344
  if (knowledge.pinnedContextEnabled && !configuredIds.has("knowledge")) {
87095
87345
  if (!hasMemory) {
87096
87346
  if (!this.#warnedPinsWithoutMemory) {
@@ -87099,9 +87349,26 @@ var Agent = class Agent extends require_base.MastraBase {
87099
87349
  }
87100
87350
  return processors;
87101
87351
  }
87352
+ const contexts = /* @__PURE__ */ new WeakMap();
87353
+ const pinContext = (context) => {
87354
+ let resolved = contexts.get(context);
87355
+ if (!resolved) {
87356
+ const requestContext = context.requestContext instanceof require_request_context.RequestContext ? context.requestContext : void 0;
87357
+ resolved = this.resolveKnowledgePersona(knowledge, requestContext).then((persona) => ({
87358
+ ...context,
87359
+ agent: {
87360
+ ...context.agent,
87361
+ agentId: this.id,
87362
+ persona
87363
+ }
87364
+ }));
87365
+ contexts.set(context, resolved);
87366
+ }
87367
+ return resolved;
87368
+ };
87102
87369
  processors.push(new PinnedStateProcessor({
87103
- principalsKey: (context) => knowledge.__principalsKey(context),
87104
- readPins: (context) => knowledge.__deliveredPins(context),
87370
+ principalsKey: async (context) => knowledge.__principalsKey(await pinContext(context)),
87371
+ readPins: async (context) => knowledge.__deliveredPins(await pinContext(context)),
87105
87372
  ...knowledge.__toolGroups
87106
87373
  }));
87107
87374
  }
@@ -88058,7 +88325,8 @@ var Agent = class Agent extends require_base.MastraBase {
88058
88325
  }
88059
88326
  /**
88060
88327
  * Gets the metadata for this agent, resolving function-based metadata if necessary.
88061
- * Metadata is a classification bag for clients and is never read by the agent runtime.
88328
+ * Metadata is a classification bag for clients. The agent runtime reads only `metadata.persona`, to mint
88329
+ * Knowledge persona scopes; it reads nothing else in metadata.
88062
88330
  *
88063
88331
  * @example
88064
88332
  * ```typescript
@@ -88949,10 +89217,34 @@ var Agent = class Agent extends require_base.MastraBase {
88949
89217
  backgroundConfig: tool.background,
88950
89218
  agentBackgroundConfig: this.#backgroundTasks
88951
89219
  };
88952
- converted[toolName] = require_utils$1.makeCoreTool(tool, options, void 0, autoResumeSuspendedTools, backgroundTaskEnabled);
89220
+ const execute = tool.execute;
89221
+ const agentTool = execute ? {
89222
+ ...tool,
89223
+ execute: async (input, context) => {
89224
+ const persona = await this.resolveKnowledgePersona(knowledge, requestContext);
89225
+ const runContext = {
89226
+ ...context,
89227
+ agent: context?.agent ? {
89228
+ ...context.agent,
89229
+ agentId: this.id,
89230
+ persona
89231
+ } : void 0
89232
+ };
89233
+ return execute(input, runContext);
89234
+ }
89235
+ } : tool;
89236
+ converted[toolName] = require_utils$1.makeCoreTool(agentTool, options, void 0, autoResumeSuspendedTools, backgroundTaskEnabled);
88953
89237
  }
88954
89238
  return converted;
88955
89239
  }
89240
+ async resolveKnowledgePersona(knowledge, requestContext) {
89241
+ if (!await knowledge.__needsAgentPersona()) return void 0;
89242
+ try {
89243
+ return (await this.getMetadata({ requestContext }))?.persona;
89244
+ } catch {
89245
+ return;
89246
+ }
89247
+ }
88956
89248
  /**
88957
89249
  * Lists workspace tools if a workspace is configured.
88958
89250
  * @internal
@@ -96693,6 +96985,29 @@ var Agent = class Agent extends require_base.MastraBase {
96693
96985
  };
96694
96986
  }
96695
96987
  };
96988
+ // src/agent/merge-persona.ts
96989
+ function merge(metadata, persona) {
96990
+ const code = metadata?.persona;
96991
+ const base = code && typeof code === "object" && !Array.isArray(code) ? code : {};
96992
+ const set = Object.fromEntries(Object.entries(persona).filter(([, value]) => value !== void 0));
96993
+ return {
96994
+ ...metadata,
96995
+ persona: {
96996
+ ...base,
96997
+ ...set
96998
+ }
96999
+ };
97000
+ }
97001
+ /**
97002
+ * Overrides an Agent's `metadata.persona` field by field: a field `persona` sets wins, a field it leaves
97003
+ * unset keeps the code's value, and keys outside `persona` stay as they are. Function-form metadata is
97004
+ * wrapped so the override applies to whatever it resolves to.
97005
+ * @experimental
97006
+ */
97007
+ function mergeAgentPersona(metadata, persona) {
97008
+ if (typeof metadata !== "function") return merge(metadata, persona);
97009
+ return async (context) => merge(await metadata(context), persona);
97010
+ }
96696
97011
  // ../_internal-core/dist/fs-routing/index.js
96697
97012
  /**
96698
97013
  * Maximum nesting depth for declared subagents. A top-level agent is depth 0;
@@ -113203,6 +113518,12 @@ Object.defineProperty(exports, "hasResumableStreams", {
113203
113518
  return hasResumableStreams;
113204
113519
  }
113205
113520
  });
113521
+ Object.defineProperty(exports, "heldScopes", {
113522
+ enumerable: true,
113523
+ get: function() {
113524
+ return heldScopes;
113525
+ }
113526
+ });
113206
113527
  Object.defineProperty(exports, "hydrateSerializedStepErrors", {
113207
113528
  enumerable: true,
113208
113529
  get: function() {
@@ -113323,6 +113644,12 @@ Object.defineProperty(exports, "knowledgeAccessGrants", {
113323
113644
  return knowledgeAccessGrants;
113324
113645
  }
113325
113646
  });
113647
+ Object.defineProperty(exports, "knowledgeAgentScopes", {
113648
+ enumerable: true,
113649
+ get: function() {
113650
+ return knowledgeAgentScopes;
113651
+ }
113652
+ });
113326
113653
  Object.defineProperty(exports, "knowledgeDeliveredPins", {
113327
113654
  enumerable: true,
113328
113655
  get: function() {
@@ -113347,6 +113674,12 @@ Object.defineProperty(exports, "knowledgePagePath", {
113347
113674
  return knowledgePagePath;
113348
113675
  }
113349
113676
  });
113677
+ Object.defineProperty(exports, "knowledgePersonaScopes", {
113678
+ enumerable: true,
113679
+ get: function() {
113680
+ return knowledgePersonaScopes;
113681
+ }
113682
+ });
113350
113683
  Object.defineProperty(exports, "knowledgePinDepth", {
113351
113684
  enumerable: true,
113352
113685
  get: function() {
@@ -113473,6 +113806,12 @@ Object.defineProperty(exports, "memoryDefaultOptions", {
113473
113806
  return memoryDefaultOptions;
113474
113807
  }
113475
113808
  });
113809
+ Object.defineProperty(exports, "mergeAgentPersona", {
113810
+ enumerable: true,
113811
+ get: function() {
113812
+ return mergeAgentPersona;
113813
+ }
113814
+ });
113476
113815
  Object.defineProperty(exports, "mergeStepResult", {
113477
113816
  enumerable: true,
113478
113817
  get: function() {
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_run_registry = require("../run-registry-BJa47sa2.cjs");
2
+ const require_run_registry = require("../run-registry-DX_EyboB.cjs");
3
3
  const require_observability = require("../observability-B0R_D1PZ.cjs");
4
- const require_stream = require("../stream-CWE0h7Yc.cjs");
4
+ const require_stream = require("../stream-BmtBm_-L.cjs");
5
5
  const require_storage = require("../storage-CfG0I2aF.cjs");
6
6
  const require_constants = require("../constants-Bou0hEgY.cjs");
7
7
  const require_filesystem_versioned = require("../filesystem-versioned-BavRtYWJ.cjs");