@mastra/core 1.87.0-alpha.10 → 1.87.0-alpha.12

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 (405) hide show
  1. package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +49 -0
  2. package/dist/a2a/index.cjs +1 -1
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/agent/durable/index.cjs +1 -1
  5. package/dist/agent/durable/index.js +1 -1
  6. package/dist/agent/durable/run-registry.d.ts +2 -0
  7. package/dist/agent/durable/types.d.ts +6 -0
  8. package/dist/agent/durable/utils/resolve-runtime.d.ts +5 -0
  9. package/dist/agent/index.cjs +3 -3
  10. package/dist/agent/index.js +3 -3
  11. package/dist/agent/message-list/index.cjs +1 -1
  12. package/dist/agent/message-list/index.js +1 -1
  13. package/dist/agent/message-list/state/MessageStateManager.d.ts +5 -0
  14. package/dist/agent-builder/ee/index.cjs +1 -1
  15. package/dist/agent-builder/ee/index.js +1 -1
  16. package/dist/agent-controller/index.cjs +1 -1
  17. package/dist/agent-controller/index.js +1 -1
  18. package/dist/agent-controller/session.d.ts +11 -1
  19. package/dist/{agent-controller-BolLBwDm.cjs → agent-controller-BcN7r3yI.cjs} +40 -204
  20. package/dist/{agent-controller--gKWI81G.js → agent-controller-DfeTRuBc.js} +40 -204
  21. package/dist/background-tasks/index.cjs +1 -1
  22. package/dist/background-tasks/index.js +1 -1
  23. package/dist/{background-tasks-CgzXjBfE.js → background-tasks-BcU--rXL.js} +1 -1
  24. package/dist/{background-tasks-DYtlijQ1.cjs → background-tasks-DRUHnQOk.cjs} +1 -1
  25. package/dist/browser/index.cjs +15 -6
  26. package/dist/browser/index.js +15 -6
  27. package/dist/browser/processor.d.ts +1 -0
  28. package/dist/{builder-Dz-g-9CZ.cjs → builder-Bufqrcz3.cjs} +2 -2
  29. package/dist/{builder-emNPaIaC.js → builder-TuIc5l7X.js} +2 -2
  30. package/dist/capabilities/302ai.json +201 -201
  31. package/dist/capabilities/abliteratedllm.json +34 -34
  32. package/dist/capabilities/abliteration-ai.json +11 -11
  33. package/dist/capabilities/above.json +22 -22
  34. package/dist/capabilities/adaption.json +13 -13
  35. package/dist/capabilities/adzuki.json +33 -33
  36. package/dist/capabilities/agentrouter.json +7 -7
  37. package/dist/capabilities/agnes.json +4 -4
  38. package/dist/capabilities/ai-router.json +8 -8
  39. package/dist/capabilities/aiand.json +22 -22
  40. package/dist/capabilities/aigrow.json +12 -12
  41. package/dist/capabilities/aimlapi.json +149 -149
  42. package/dist/capabilities/aixy.json +26 -26
  43. package/dist/capabilities/aki-io.json +12 -12
  44. package/dist/capabilities/alibaba-cn.json +93 -93
  45. package/dist/capabilities/alibaba-coding-plan-cn.json +5 -5
  46. package/dist/capabilities/alibaba-coding-plan.json +5 -5
  47. package/dist/capabilities/alibaba-token-plan-cn.json +37 -37
  48. package/dist/capabilities/alibaba-token-plan.json +40 -40
  49. package/dist/capabilities/alibaba.json +66 -66
  50. package/dist/capabilities/ambient.json +13 -13
  51. package/dist/capabilities/amd.json +11 -11
  52. package/dist/capabilities/anthropic.json +42 -42
  53. package/dist/capabilities/anyapi.json +47 -47
  54. package/dist/capabilities/apiko.json +5 -5
  55. package/dist/capabilities/arcee.json +11 -11
  56. package/dist/capabilities/augure.json +7 -7
  57. package/dist/capabilities/auriko.json +21 -21
  58. package/dist/capabilities/bailing.json +5 -5
  59. package/dist/capabilities/baseten.json +33 -33
  60. package/dist/capabilities/bee.json +4 -4
  61. package/dist/capabilities/berget.json +8 -8
  62. package/dist/capabilities/bothub.json +17 -17
  63. package/dist/capabilities/boundless.json +38 -38
  64. package/dist/capabilities/bumo.json +34 -34
  65. package/dist/capabilities/byteplus.json +24 -24
  66. package/dist/capabilities/cerebras.json +4 -4
  67. package/dist/capabilities/cheapaimodel.json +10 -10
  68. package/dist/capabilities/cheapest-token.json +28 -28
  69. package/dist/capabilities/chutes.json +7 -7
  70. package/dist/capabilities/cline-pass.json +35 -35
  71. package/dist/capabilities/cloudcode.json +7 -7
  72. package/dist/capabilities/cloudferro-sherlock.json +4 -4
  73. package/dist/capabilities/cloudflare-workers-ai.json +19 -19
  74. package/dist/capabilities/commandcode.json +149 -149
  75. package/dist/capabilities/concentrate.json +276 -268
  76. package/dist/capabilities/cortecs.json +104 -104
  77. package/dist/capabilities/crossmodel.json +179 -179
  78. package/dist/capabilities/crusoe.json +19 -19
  79. package/dist/capabilities/daoxe.json +6 -6
  80. package/dist/capabilities/databricks.json +124 -124
  81. package/dist/capabilities/deepinfra.json +89 -83
  82. package/dist/capabilities/deepseek.json +4 -4
  83. package/dist/capabilities/digitalocean.json +113 -113
  84. package/dist/capabilities/dothoosh.json +32 -32
  85. package/dist/capabilities/doubleword.json +25 -25
  86. package/dist/capabilities/edenai.json +286 -286
  87. package/dist/capabilities/empiriolabs.json +169 -169
  88. package/dist/capabilities/engy.json +16 -16
  89. package/dist/capabilities/entrim.json +8 -8
  90. package/dist/capabilities/evroc.json +12 -12
  91. package/dist/capabilities/ezkielyna.json +4 -4
  92. package/dist/capabilities/fastrouter.json +83 -83
  93. package/dist/capabilities/fireworks-ai.json +99 -99
  94. package/dist/capabilities/fortytwo.json +4 -4
  95. package/dist/capabilities/freemodel.json +22 -22
  96. package/dist/capabilities/friendli.json +8 -8
  97. package/dist/capabilities/frogbot.json +87 -87
  98. package/dist/capabilities/gisoo.json +17 -17
  99. package/dist/capabilities/gmicloud.json +21 -21
  100. package/dist/capabilities/google.json +58 -58
  101. package/dist/capabilities/graphn.json +8 -8
  102. package/dist/capabilities/greenpt.json +34 -34
  103. package/dist/capabilities/groq.json +9 -9
  104. package/dist/capabilities/helicone.json +87 -87
  105. package/dist/capabilities/hetzner.json +5 -5
  106. package/dist/capabilities/hostinger-router.json +10 -10
  107. package/dist/capabilities/hpc-ai.json +12 -12
  108. package/dist/capabilities/huawei-maas.json +15 -15
  109. package/dist/capabilities/hubris.json +32 -32
  110. package/dist/capabilities/huggingface.json +93 -85
  111. package/dist/capabilities/humain.json +2 -2
  112. package/dist/capabilities/hyper.json +23 -23
  113. package/dist/capabilities/impossibl.json +173 -173
  114. package/dist/capabilities/inceptron.json +8 -8
  115. package/dist/capabilities/inco.json +4 -4
  116. package/dist/capabilities/infer.json +14 -14
  117. package/dist/capabilities/inferall.json +9 -9
  118. package/dist/capabilities/inference-coop.json +9 -9
  119. package/dist/capabilities/inferenceapis.json +13 -13
  120. package/dist/capabilities/inferris.json +4 -4
  121. package/dist/capabilities/infersia.json +8 -8
  122. package/dist/capabilities/inferx.json +3 -3
  123. package/dist/capabilities/infomaniak.json +2 -2
  124. package/dist/capabilities/io-net.json +5 -5
  125. package/dist/capabilities/isoquant.json +4 -4
  126. package/dist/capabilities/iteracompute.json +53 -53
  127. package/dist/capabilities/jad-ai.json +2 -2
  128. package/dist/capabilities/jalapeno.json +12 -12
  129. package/dist/capabilities/jiekou.json +67 -67
  130. package/dist/capabilities/joingonka.json +4 -4
  131. package/dist/capabilities/jzstoken.json +53 -53
  132. package/dist/capabilities/keln.json +21 -21
  133. package/dist/capabilities/kenari.json +132 -124
  134. package/dist/capabilities/kilo.json +604 -604
  135. package/dist/capabilities/kimi-code-plan-cn.json +7 -7
  136. package/dist/capabilities/kimi-code-plan-global.json +7 -7
  137. package/dist/capabilities/kitani.json +6 -6
  138. package/dist/capabilities/klavo.json +21 -21
  139. package/dist/capabilities/korouter.json +30 -30
  140. package/dist/capabilities/kunavo.json +7 -7
  141. package/dist/capabilities/liquid.json +9 -9
  142. package/dist/capabilities/lithosai.json +2 -2
  143. package/dist/capabilities/llmgateway-providers.json +944 -944
  144. package/dist/capabilities/llmgateway.json +340 -340
  145. package/dist/capabilities/llmtr.json +30 -30
  146. package/dist/capabilities/logits.json +2 -2
  147. package/dist/capabilities/longcat.json +2 -2
  148. package/dist/capabilities/lowrouter.json +60 -60
  149. package/dist/capabilities/lyceum.json +12 -12
  150. package/dist/capabilities/melious.json +8 -8
  151. package/dist/capabilities/merge-gateway.json +280 -280
  152. package/dist/capabilities/meta.json +7 -7
  153. package/dist/capabilities/mistral.json +18 -18
  154. package/dist/capabilities/mixlayer.json +5 -5
  155. package/dist/capabilities/modal.json +12 -12
  156. package/dist/capabilities/model-oracle-ai.json +25 -25
  157. package/dist/capabilities/modelis.json +21 -21
  158. package/dist/capabilities/modular.json +13 -13
  159. package/dist/capabilities/moneo.json +18 -18
  160. package/dist/capabilities/moonshotai-cn.json +7 -7
  161. package/dist/capabilities/moonshotai.json +7 -7
  162. package/dist/capabilities/morph.json +16 -16
  163. package/dist/capabilities/munito-eu.json +6 -6
  164. package/dist/capabilities/munito.json +10 -10
  165. package/dist/capabilities/nan.json +28 -28
  166. package/dist/capabilities/nano-gpt.json +566 -565
  167. package/dist/capabilities/nearai.json +96 -96
  168. package/dist/capabilities/nebius.json +32 -32
  169. package/dist/capabilities/neon.json +124 -124
  170. package/dist/capabilities/neuralwatt.json +36 -36
  171. package/dist/capabilities/nokeep.json +5 -5
  172. package/dist/capabilities/novita-ai.json +153 -153
  173. package/dist/capabilities/nvidia.json +35 -35
  174. package/dist/capabilities/oathbreaker.json +3 -3
  175. package/dist/capabilities/obscurify.json +27 -27
  176. package/dist/capabilities/oci.json +10 -10
  177. package/dist/capabilities/ofox.json +381 -381
  178. package/dist/capabilities/ollama-cloud.json +48 -48
  179. package/dist/capabilities/openai.json +59 -59
  180. package/dist/capabilities/opencode-go.json +91 -91
  181. package/dist/capabilities/openreason.json +5 -5
  182. package/dist/capabilities/openrouter.json +526 -527
  183. package/dist/capabilities/opper.json +29 -29
  184. package/dist/capabilities/orcarouter.json +228 -228
  185. package/dist/capabilities/outerlabs.json +30 -30
  186. package/dist/capabilities/ovhcloud.json +19 -19
  187. package/dist/capabilities/pareto.json +5 -5
  188. package/dist/capabilities/pendra.json +4 -4
  189. package/dist/capabilities/perplexity-agent.json +47 -47
  190. package/dist/capabilities/phala.json +30 -30
  191. package/dist/capabilities/pioneer.json +27 -27
  192. package/dist/capabilities/poe.json +133 -133
  193. package/dist/capabilities/poolside.json +2 -2
  194. package/dist/capabilities/powerspring.json +9 -9
  195. package/dist/capabilities/primalabs.json +9 -9
  196. package/dist/capabilities/prime.json +106 -106
  197. package/dist/capabilities/privatemode-ai.json +12 -12
  198. package/dist/capabilities/proxystacks.json +7 -7
  199. package/dist/capabilities/qiniu-ai.json +14 -14
  200. package/dist/capabilities/refuseless.json +8 -8
  201. package/dist/capabilities/regolo-ai.json +2 -2
  202. package/dist/capabilities/requesty.json +258 -199
  203. package/dist/capabilities/ruapi.json +21 -21
  204. package/dist/capabilities/runcrate.json +14 -14
  205. package/dist/capabilities/runinfra.json +18 -18
  206. package/dist/capabilities/sakana.json +6 -6
  207. package/dist/capabilities/sambanova.json +6 -6
  208. package/dist/capabilities/sandbase.json +22 -22
  209. package/dist/capabilities/sarvam.json +14 -14
  210. package/dist/capabilities/scaleway.json +16 -16
  211. package/dist/capabilities/scnet-token-plan.json +10 -10
  212. package/dist/capabilities/scx-ai.json +29 -29
  213. package/dist/capabilities/sensenova.json +12 -12
  214. package/dist/capabilities/siliconflow-cn.json +56 -56
  215. package/dist/capabilities/siliconflow.json +60 -60
  216. package/dist/capabilities/snowflake-cortex.json +20 -20
  217. package/dist/capabilities/sokkan.json +10 -10
  218. package/dist/capabilities/sparrowcodes.json +16 -16
  219. package/dist/capabilities/standardcompute.json +88 -88
  220. package/dist/capabilities/steadyrouter.json +35 -35
  221. package/dist/capabilities/stepfun-ai-step-plan.json +4 -4
  222. package/dist/capabilities/stepfun-ai.json +4 -4
  223. package/dist/capabilities/stepfun-step-plan.json +4 -4
  224. package/dist/capabilities/stepfun.json +4 -4
  225. package/dist/capabilities/stepping-stone.json +21 -21
  226. package/dist/capabilities/subconscious.json +2 -2
  227. package/dist/capabilities/superbot-gg.json +4 -4
  228. package/dist/capabilities/synthetic.json +10 -10
  229. package/dist/capabilities/synthorai.json +19 -19
  230. package/dist/capabilities/teamorouter.json +25 -25
  231. package/dist/capabilities/teapot-router.json +7 -7
  232. package/dist/capabilities/tencent-token-plan-intl.json +24 -24
  233. package/dist/capabilities/tencent-token-plan.json +40 -40
  234. package/dist/capabilities/tencent-tokenhub.json +47 -47
  235. package/dist/capabilities/tensorx.json +48 -48
  236. package/dist/capabilities/tenstorrent.json +8 -8
  237. package/dist/capabilities/the-grid-ai.json +28 -28
  238. package/dist/capabilities/thinkingmachines.json +39 -39
  239. package/dist/capabilities/tinfoil.json +14 -14
  240. package/dist/capabilities/toapis.json +2 -2
  241. package/dist/capabilities/togetherai.json +50 -50
  242. package/dist/capabilities/tokengo.json +19 -19
  243. package/dist/capabilities/tokenify.json +9 -9
  244. package/dist/capabilities/trustedrouter.json +7 -7
  245. package/dist/capabilities/trustedtokens.json +20 -20
  246. package/dist/capabilities/umans-ai-coding-plan.json +18 -18
  247. package/dist/capabilities/umans-ai.json +12 -12
  248. package/dist/capabilities/uncensuredai.json +4 -4
  249. package/dist/capabilities/unrestricted.json +8 -8
  250. package/dist/capabilities/uplinkswitch.json +22 -22
  251. package/dist/capabilities/upstage.json +6 -6
  252. package/dist/capabilities/vancine.json +15 -15
  253. package/dist/capabilities/vercel.json +546 -546
  254. package/dist/capabilities/vivgrid.json +84 -84
  255. package/dist/capabilities/volcengine-coding-plan.json +28 -28
  256. package/dist/capabilities/volcengine.json +29 -29
  257. package/dist/capabilities/vultr.json +31 -31
  258. package/dist/capabilities/wafer.ai.json +15 -15
  259. package/dist/capabilities/wallaby.json +2 -2
  260. package/dist/capabilities/wally.json +9 -9
  261. package/dist/capabilities/wandb.json +16 -16
  262. package/dist/capabilities/watt.json +22 -22
  263. package/dist/capabilities/xai.json +7 -7
  264. package/dist/capabilities/xiaomi.json +3 -3
  265. package/dist/capabilities/xpersona.json +11 -11
  266. package/dist/capabilities/xxapi.json +28 -28
  267. package/dist/capabilities/zai-coding-plan.json +12 -12
  268. package/dist/capabilities/zai.json +31 -31
  269. package/dist/capabilities/zenifra.json +26 -26
  270. package/dist/capabilities/zenmux.json +159 -159
  271. package/dist/capabilities/zerogpu.json +11 -11
  272. package/dist/capabilities/zhipuai-coding-plan.json +8 -8
  273. package/dist/capabilities/zhipuai.json +29 -29
  274. package/dist/capabilities/zro.json +7 -7
  275. package/dist/channels/index.cjs +2 -2
  276. package/dist/channels/index.js +2 -2
  277. package/dist/{channels-CndspFXP.js → channels-Cdsqdajh.js} +1 -1
  278. package/dist/{channels-BVnDIsZS.cjs → channels-MsOnUvU6.cjs} +1 -1
  279. package/dist/coding-agent/index.cjs +2 -2
  280. package/dist/coding-agent/index.js +2 -2
  281. package/dist/datasets/index.cjs +2 -2
  282. package/dist/datasets/index.js +2 -2
  283. package/dist/docs/SKILL.md +1 -1
  284. package/dist/docs/assets/SOURCE_MAP.json +609 -609
  285. package/dist/docs/references/reference-agent-controller-session.md +29 -1
  286. package/dist/docs/references/reference-memory-observational-memory.md +4 -0
  287. package/dist/docs/references/reference.md +1 -0
  288. package/dist/evals/index.cjs +1 -1
  289. package/dist/evals/index.js +1 -1
  290. package/dist/evals/scoreTraces/index.cjs +1 -1
  291. package/dist/evals/scoreTraces/index.js +1 -1
  292. package/dist/harness/index.cjs +1 -1
  293. package/dist/harness/index.js +1 -1
  294. package/dist/index.cjs +1 -1
  295. package/dist/index.js +1 -1
  296. package/dist/knowledge/importers/overlay.d.ts +138 -0
  297. package/dist/knowledge/importers/sink.d.ts +6 -0
  298. package/dist/knowledge/importers/types.d.ts +5 -0
  299. package/dist/knowledge/index.cjs +1412 -139
  300. package/dist/knowledge/index.js +1412 -139
  301. package/dist/knowledge/links.d.ts +27 -0
  302. package/dist/llm/index.cjs +3 -3
  303. package/dist/llm/index.js +3 -3
  304. package/dist/llm/model/provider-types.generated.d.ts +7781 -7766
  305. package/dist/llm/reasoning/anthropic-thinking.d.ts +5 -0
  306. package/dist/llm/reasoning/gemini-thinking.d.ts +24 -0
  307. package/dist/llm/reasoning/index.cjs +389 -0
  308. package/dist/llm/reasoning/index.d.ts +8 -0
  309. package/dist/llm/reasoning/index.js +362 -0
  310. package/dist/llm/reasoning/model-fallback.d.ts +75 -0
  311. package/dist/llm/reasoning/model-ids.d.ts +5 -0
  312. package/dist/llm/reasoning/thinking-provider-options.d.ts +10 -0
  313. package/dist/llm/reasoning/thinking-request.d.ts +14 -0
  314. package/dist/llm/reasoning/thinking.d.ts +37 -0
  315. package/dist/{llm-B1semiTO.cjs → llm-CS6YY_IV.cjs} +2 -2
  316. package/dist/{llm-CytL7cpw.js → llm-zjtMQn7M.js} +2 -2
  317. package/dist/loop/index.cjs +2 -2
  318. package/dist/loop/index.js +2 -2
  319. package/dist/{manager-BwyfS4ha.cjs → manager-BU_lY6kl.cjs} +2 -2
  320. package/dist/{manager-DnTzA9GL.js → manager-Do0MENhH.js} +2 -2
  321. package/dist/mastra/index.cjs +1 -1
  322. package/dist/mastra/index.d.ts +2 -0
  323. package/dist/mastra/index.js +1 -1
  324. package/dist/{mastra-DTkZPpch.js → mastra-C-1zIyS5.js} +22 -16
  325. package/dist/{mastra-Dj35Lj_J.cjs → mastra-DYVjsXTO.cjs} +22 -16
  326. package/dist/memory/index.cjs +3 -3
  327. package/dist/memory/index.js +3 -3
  328. package/dist/memory/om-events/index.cjs +189 -0
  329. package/dist/memory/om-events/index.d.ts +17 -0
  330. package/dist/memory/om-events/index.js +188 -0
  331. package/dist/{message-list-vR3uLAHL.cjs → message-list-C0F2sDNC.cjs} +3 -2
  332. package/dist/{message-list-BGm1DCiG.js → message-list-RgFlLrxG.js} +3 -2
  333. package/dist/{model-eDfetuno.cjs → model-DGFc1hw3.cjs} +1 -1
  334. package/dist/{model-DyQ07rPH.js → model-DIzIjDej.js} +1 -1
  335. package/dist/{netlify-BUvdxfHe.js → netlify-B9mLgxJs.js} +1 -1
  336. package/dist/{netlify-BC4v7Ufv.cjs → netlify-CyL6FNsw.cjs} +1 -1
  337. package/dist/notifications/index.cjs +1 -1
  338. package/dist/notifications/index.js +1 -1
  339. package/dist/processor-provider/index.cjs +1 -1
  340. package/dist/processor-provider/index.js +1 -1
  341. package/dist/processors/index.cjs +2 -2
  342. package/dist/processors/index.js +2 -2
  343. package/dist/{provider-registry-CP_5SNiw.js → provider-registry-DdQoO_jd.js} +22523 -22492
  344. package/dist/{provider-registry-Bn01gq9y.cjs → provider-registry-g9m_fyV8.cjs} +22523 -22492
  345. package/dist/provider-registry.json +22977 -22946
  346. package/dist/{registry-generator-CNFKGRFQ.cjs → registry-generator-At8J4ZOR.cjs} +1 -1
  347. package/dist/{registry-generator-CDPyxbzt.js → registry-generator-CX6Ev697.js} +1 -1
  348. package/dist/{rehydrate-DExpzlNS.cjs → rehydrate-BzD6UX8f.cjs} +2 -2
  349. package/dist/{rehydrate-CnGNY2zq.js → rehydrate-DEDxsr6E.js} +2 -2
  350. package/dist/relevance/index.cjs +2 -2
  351. package/dist/relevance/index.js +2 -2
  352. package/dist/{run-registry-BL_kKvFE.js → run-registry-D22IF5SK.js} +434 -26
  353. package/dist/{run-registry-CibQoN6K.cjs → run-registry-PiQTSx2Y.cjs} +457 -25
  354. package/dist/storage/domains/knowledge/base.d.ts +86 -1
  355. package/dist/storage/domains/knowledge/importers-inmemory.d.ts +9 -0
  356. package/dist/storage/domains/knowledge/importers.d.ts +31 -0
  357. package/dist/storage/domains/knowledge/inmemory.d.ts +7 -0
  358. package/dist/storage/domains/knowledge/pages-inmemory.d.ts +31 -1
  359. package/dist/storage/domains/knowledge/pages.d.ts +74 -0
  360. package/dist/storage/index.cjs +2 -2
  361. package/dist/storage/index.js +2 -2
  362. package/dist/storage/types.d.ts +6 -0
  363. package/dist/stream/base/output.d.ts +7 -0
  364. package/dist/stream/index.cjs +2 -2
  365. package/dist/stream/index.js +2 -2
  366. package/dist/{stream-D_7tMaJe.cjs → stream-BbPZavop.cjs} +36 -4
  367. package/dist/{stream-1DGoEkG2.js → stream-CoQTdzLm.js} +31 -5
  368. package/dist/test-utils/llm-mock.cjs +1 -1
  369. package/dist/test-utils/llm-mock.js +1 -1
  370. package/dist/tool-loop-agent/index.cjs +1 -1
  371. package/dist/tool-loop-agent/index.js +1 -1
  372. package/dist/{tool-loop-agent-CLB1r3X3.cjs → tool-loop-agent-8lyD6O4o.cjs} +4 -4
  373. package/dist/{tool-loop-agent-BXya_RYj.js → tool-loop-agent-DhQkNDaR.js} +4 -4
  374. package/dist/{utils-C55ZdVaj.js → utils-B-3lET9S.js} +1 -1
  375. package/dist/{utils-B-KOMA_Q.cjs → utils-DtmyBuBT.cjs} +1 -1
  376. package/dist/utils.cjs +1 -1
  377. package/dist/utils.js +1 -1
  378. package/dist/{validate-BDfYr72F.js → validate-CO4rWYyH.js} +1 -1
  379. package/dist/{validate-CmZhnsmX.cjs → validate-vucjWXcz.cjs} +1 -1
  380. package/dist/vector/index.cjs +2 -2
  381. package/dist/vector/index.js +2 -2
  382. package/dist/worker/index.cjs +1 -1
  383. package/dist/worker/index.js +1 -1
  384. package/dist/{worker-CuK2RaC0.js → worker-B6CpapAF.js} +2 -2
  385. package/dist/{worker-BoybIUTI.cjs → worker-BgifMkOw.cjs} +2 -2
  386. package/dist/{worker-BG1rw_dg.js → worker-CCpSrXBY.js} +2 -2
  387. package/dist/{worker-D2B-x7Le.cjs → worker-eUT7GgQ9.cjs} +2 -2
  388. package/dist/{workflow-Bt09PcH1.js → workflow-B4Tn58DD.js} +3 -3
  389. package/dist/{workflow-CTKqeRXU.cjs → workflow-BJSrGEEL.cjs} +3 -3
  390. package/dist/workflows/builder/index.cjs +1 -1
  391. package/dist/workflows/builder/index.js +1 -1
  392. package/dist/workflows/evented/index.cjs +1 -1
  393. package/dist/workflows/evented/index.js +1 -1
  394. package/dist/workflows/index.cjs +4 -4
  395. package/dist/workflows/index.js +4 -4
  396. package/dist/workspace/index.cjs +1 -1
  397. package/dist/workspace/index.js +1 -1
  398. package/dist/workspace/sandbox/local-sandbox.d.ts +11 -0
  399. package/dist/workspace/sandbox/sandbox.d.ts +2 -0
  400. package/dist/{workspace-C8Zo5_qK.cjs → workspace-C5lXteRU.cjs} +174 -12
  401. package/dist/{workspace-DOAil8mG.js → workspace-CnmmMou8.js} +174 -12
  402. package/llm/reasoning.d.ts +1 -0
  403. package/memory/om-events.d.ts +1 -0
  404. package/package.json +27 -7
  405. package/src/llm/model/provider-types.generated.d.ts +7781 -7766
@@ -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-D_7tMaJe.cjs");
7
+ const require_stream = require("./stream-BbPZavop.cjs");
8
8
  const require_request_context = require("./request-context-D9RXYCy8.cjs");
9
9
  const require_output_helpers = require("./output-helpers-DgsH4aTb.cjs");
10
- const require_message_list = require("./message-list-vR3uLAHL.cjs");
10
+ const require_message_list = require("./message-list-C0F2sDNC.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-B1semiTO.cjs");
14
+ const require_llm = require("./llm-CS6YY_IV.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-Bn01gq9y.cjs");
26
+ const require_provider_registry = require("./provider-registry-g9m_fyV8.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-eDfetuno.cjs");
30
- const require_utils$1 = require("./utils-B-KOMA_Q.cjs");
29
+ const require_model$1 = require("./model-DGFc1hw3.cjs");
30
+ const require_utils$1 = require("./utils-DtmyBuBT.cjs");
31
31
  const require_ee_iTj2bRDt = require("./ee-iTj2bRDt-D3-QLGDF.cjs");
32
- const require_background_tasks = require("./background-tasks-DYtlijQ1.cjs");
32
+ const require_background_tasks = require("./background-tasks-DRUHnQOk.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,7 +41,7 @@ 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-C8Zo5_qK.cjs");
44
+ const require_workspace = require("./workspace-C5lXteRU.cjs");
45
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");
@@ -39202,6 +39202,29 @@ function knowledgePageKeyProblem(key) {
39202
39202
  if (!key) return "Knowledge page key must not be empty";
39203
39203
  if (/[/#%]/.test(key)) return `Knowledge page key "${key}" must not contain "/", "#" or "%"`;
39204
39204
  }
39205
+ const isRowWrite = (write) => write.op === "create" || write.op === "update" || write.op === "move" || write.op === "delete";
39206
+ /**
39207
+ * Throws unless the batch holds `applyPageWrites`' first rule: at most one create, one move and one
39208
+ * delete per page, no create, update or move of a page the batch deletes, and at most one write
39209
+ * per note (stores apply note removals before additions, so two writes of one note can't keep
39210
+ * input order).
39211
+ */
39212
+ function assertKnowledgePageWritesBatchable(writes) {
39213
+ const rows = /* @__PURE__ */ new Map();
39214
+ const notes = /* @__PURE__ */ new Map();
39215
+ for (const write of writes) {
39216
+ if (isRowWrite(write)) rows.set(write.id, [...rows.get(write.id) ?? [], write.op]);
39217
+ if ((write.op === "add-note" || write.op === "remove-note") && write.id !== void 0) {
39218
+ const seen = notes.get(write.id);
39219
+ if (seen !== void 0) throw new Error(`Knowledge page writes can't apply ${seen}, ${write.op} to note ${write.id} in one batch`);
39220
+ notes.set(write.id, write.op);
39221
+ }
39222
+ }
39223
+ for (const [id, ops] of rows) {
39224
+ const count = (op) => ops.filter((o) => o === op).length;
39225
+ if (count("create") > 1 || count("move") > 1 || count("delete") > 1 || count("delete") === 1 && ops.length > 1) throw new Error(`Knowledge page writes can't apply ${ops.join(", ")} to page ${id} in one batch`);
39226
+ }
39227
+ }
39205
39228
  // src/storage/domains/knowledge/pages.ts
39206
39229
  /**
39207
39230
  * Knowledge storage contract, schema 4: pages, notes, stamps, mentions, body links and pins.
@@ -40039,6 +40062,10 @@ var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage
40039
40062
  const node = [...this.#s.nodes.values()].find((n) => n.pageId === pageId);
40040
40063
  return node ? structuredClone(node) : null;
40041
40064
  }
40065
+ async getNodesByPages(pageIds) {
40066
+ const pages = new Set(pageIds);
40067
+ return [...this.#s.nodes.values()].filter((n) => pages.has(n.pageId)).map((n) => structuredClone(n));
40068
+ }
40042
40069
  async saveNode(node) {
40043
40070
  const owner = [...this.#s.nodes.values()].find((n) => n.pageId === node.pageId);
40044
40071
  if (owner && (owner.bindingId !== node.bindingId || owner.sourceId !== node.sourceId)) throw new Error(`Knowledge page ${node.pageId} is already mapped to another imported node`);
@@ -40050,6 +40077,22 @@ var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage
40050
40077
  async deleteNode(bindingId, sourceId) {
40051
40078
  this.#s.nodes.delete(key(bindingId, sourceId));
40052
40079
  }
40080
+ async writeNodes(input) {
40081
+ const next = new Map(this.#s.nodes);
40082
+ for (const d of input.deletes) next.delete(key(d.bindingId, d.sourceId));
40083
+ const updatedAt = /* @__PURE__ */ new Date();
40084
+ for (const node of input.saves) next.set(key(node.bindingId, node.sourceId), structuredClone({
40085
+ ...node,
40086
+ updatedAt
40087
+ }));
40088
+ const byPage = /* @__PURE__ */ new Map();
40089
+ for (const [k, node] of next) {
40090
+ const other = byPage.get(node.pageId);
40091
+ if (other !== void 0 && other !== k) throw new Error(`Knowledge page ${node.pageId} is already mapped to another imported node`);
40092
+ byPage.set(node.pageId, k);
40093
+ }
40094
+ this.#s.nodes = next;
40095
+ }
40053
40096
  async listNodes(bindingId, options = {}) {
40054
40097
  const limit = options.limit ?? 500;
40055
40098
  const nodes = [...this.#s.nodes.values()].filter((n) => n.bindingId === bindingId && (options.after === void 0 || byteOrder(n.sourceId, options.after) > 0) && (!options.unsettled || n.unsettled)).sort((a, b) => byteOrder(a.sourceId, b.sourceId));
@@ -40102,6 +40145,9 @@ var InMemoryKnowledgeImportersStorage = class extends KnowledgeImportersStorage
40102
40145
  change: structuredClone(change)
40103
40146
  });
40104
40147
  }
40148
+ async recordRunChanges(changes) {
40149
+ for (const change of changes) await this.recordRunChange(change);
40150
+ }
40105
40151
  async listRunChanges(runId, options = {}) {
40106
40152
  const limit = options.limit ?? 500;
40107
40153
  const after = options.after === void 0 ? 0 : Number(options.after);
@@ -40447,10 +40493,53 @@ var InMemoryKnowledgePageStore = class {
40447
40493
  }
40448
40494
  return page && this.#pageReadable(page, input.read) ? clone$1(page) : null;
40449
40495
  }
40496
+ async getPageChains(input) {
40497
+ const ids = [...new Set(input.ids)];
40498
+ const chains = await Promise.all(ids.map((id) => this.getPageParents({
40499
+ parentId: id,
40500
+ read: input.read
40501
+ })));
40502
+ return Object.fromEntries(ids.map((id, i) => [id, chains[i]]));
40503
+ }
40504
+ async getPagesByPaths(input) {
40505
+ return Promise.all(input.paths.map((path) => this.getPageByPath({
40506
+ scopeId: input.scopeId,
40507
+ path,
40508
+ read: input.read
40509
+ })));
40510
+ }
40511
+ async getLastChildPositions(input) {
40512
+ return Object.fromEntries([...new Set(input.parentIds)].map((id) => [id, this.#children(id).sort(byPosition).at(-1)?.position ?? null]));
40513
+ }
40514
+ async getPageSubtrees(input) {
40515
+ const out = Object.fromEntries(input.rootIds.map((id) => [id, null]));
40516
+ for (const rootId of new Set(input.rootIds)) {
40517
+ const pages = [];
40518
+ for (let i = -1; i < pages.length && pages.length <= input.limit; i++) {
40519
+ const parentId = i < 0 ? rootId : pages[i].id;
40520
+ pages.push(...this.#children(parentId).filter((page) => !page.isScope));
40521
+ }
40522
+ out[rootId] = pages.length > input.limit ? null : pages.map(clone$1);
40523
+ }
40524
+ return out;
40525
+ }
40526
+ async listNotesByPages(input) {
40527
+ const notes = Object.fromEntries([...new Set(input.pageIds)].map((id) => [id, []]));
40528
+ for (const note of [...this.#notes.values()].sort(oldestFirst)) if (Object.hasOwn(notes, note.pageId) && !note.deletedAt && this.#noteVisible(note, input.read)) notes[note.pageId].push(clone$1(note));
40529
+ return notes;
40530
+ }
40450
40531
  async findPagesByName(input) {
40451
40532
  const name = canonicalKnowledgeName(input.name);
40452
40533
  return [...this.#pages.values()].filter((page) => !page.deletedAt && canonicalKnowledgeName(page.name) === name && (input.scopeId === void 0 || page.scopeId === input.scopeId) && this.#pageReadable(page, input.read)).sort(newestFirst).slice(0, pageSize(input.limit)).map(clone$1);
40453
40534
  }
40535
+ async findPagesByNames(input) {
40536
+ const names = [...new Set(input.names)];
40537
+ const found = await Promise.all(names.map((name) => this.findPagesByName({
40538
+ ...input,
40539
+ name
40540
+ })));
40541
+ return Object.fromEntries(names.map((name, i) => [name, found[i]]));
40542
+ }
40454
40543
  async listChildPages(input) {
40455
40544
  const { items, nextCursor } = paginate(this.#children(input.parentId).filter((page) => !page.isScope && this.#pageReadable(page, input.read)).sort(byPosition), input.cursor, input.limit);
40456
40545
  return {
@@ -40546,6 +40635,63 @@ var InMemoryKnowledgePageStore = class {
40546
40635
  ...nextCursor ? { nextCursor } : {}
40547
40636
  };
40548
40637
  }
40638
+ /** The single writes, one by one in input order; all undone if one fails. */
40639
+ async applyPageWrites(input) {
40640
+ assertKnowledgePageWritesBatchable(input.writes);
40641
+ const before = this.snapshot();
40642
+ try {
40643
+ for (const write of input.writes) switch (write.op) {
40644
+ case "create": {
40645
+ const { op: _op, scopeId: _scope, depth: _depth, ...create } = write;
40646
+ await this.createPage(create);
40647
+ break;
40648
+ }
40649
+ case "update": {
40650
+ const { op: _op, scopeId: _scope, ...update } = write;
40651
+ await this.updatePage(update);
40652
+ break;
40653
+ }
40654
+ case "move": {
40655
+ const { op: _op, scopeId: _scope, fromScopeId: _from, depth: _depth, ...move } = write;
40656
+ await this.movePage(move);
40657
+ break;
40658
+ }
40659
+ case "delete":
40660
+ await this.deletePage({
40661
+ id: write.id,
40662
+ expectedVersion: write.expectedVersion,
40663
+ deletedBy: write.deletedBy
40664
+ });
40665
+ break;
40666
+ case "add-note": {
40667
+ const { op: _op, scopeId: _scope, ...note } = write;
40668
+ await this.addNote(note);
40669
+ break;
40670
+ }
40671
+ case "remove-note": {
40672
+ const note = await this.getNote({
40673
+ id: write.id,
40674
+ read: "all",
40675
+ includeDeleted: true
40676
+ });
40677
+ if (note && note.pageId !== write.pageId) throw new KnowledgeConflictError(write.id);
40678
+ await this.removeNote({
40679
+ id: write.id,
40680
+ deletedBy: write.deletedBy,
40681
+ provenance: write.provenance
40682
+ });
40683
+ break;
40684
+ }
40685
+ case "replace-links": await this.replacePageBodyLinks({
40686
+ pageId: write.pageId,
40687
+ links: write.links
40688
+ });
40689
+ }
40690
+ } catch (error) {
40691
+ this.restore(before);
40692
+ throw error;
40693
+ }
40694
+ }
40549
40695
  async createPage(input) {
40550
40696
  const parent = this.#livePage(input.parentId);
40551
40697
  const scopeId = parent.isScope ? parent.id : parent.scopeId;
@@ -40944,6 +41090,24 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
40944
41090
  getPageParents(input) {
40945
41091
  return this.#pageStore.getPageParents(input);
40946
41092
  }
41093
+ getPageChains(input) {
41094
+ return this.#pageStore.getPageChains(input);
41095
+ }
41096
+ getPagesByPaths(input) {
41097
+ return this.#pageStore.getPagesByPaths(input);
41098
+ }
41099
+ getLastChildPositions(input) {
41100
+ return this.#pageStore.getLastChildPositions(input);
41101
+ }
41102
+ getPageSubtrees(input) {
41103
+ return this.#pageStore.getPageSubtrees(input);
41104
+ }
41105
+ listNotesByPages(input) {
41106
+ return this.#pageStore.listNotesByPages(input);
41107
+ }
41108
+ applyPageWrites(input) {
41109
+ return this.#pageStore.applyPageWrites(input);
41110
+ }
40947
41111
  listScopeDeclarations() {
40948
41112
  return this.#pageStore.listScopeDeclarations();
40949
41113
  }
@@ -40956,6 +41120,9 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
40956
41120
  getPageByPath(input) {
40957
41121
  return this.#pageStore.getPageByPath(input);
40958
41122
  }
41123
+ findPagesByNames(input) {
41124
+ return this.#pageStore.findPagesByNames(input);
41125
+ }
40959
41126
  findPagesByName(input) {
40960
41127
  return this.#pageStore.findPagesByName(input);
40961
41128
  }
@@ -53717,6 +53884,13 @@ async function syncKnowledgePageBodyLinks(storage, page, resolver = new BodyLink
53717
53884
  }
53718
53885
  /** The ref keys a page answers to now: its id, name, scope address and `scope#key/key` path. */
53719
53886
  async function pageRefKeys(storage, page) {
53887
+ return refKeysOf(page, !page.isScope && page.key && page.parentId ? await storage.getPageParents({
53888
+ parentId: page.parentId,
53889
+ read: "all"
53890
+ }) : []);
53891
+ }
53892
+ /** {@link pageRefKeys} from the page's parents as `getPageParents` gives them. */
53893
+ function refKeysOf(page, parents) {
53720
53894
  const keys = [knowledgeLinkRefKey(page.id), knowledgeLinkRefKey(page.name)];
53721
53895
  if (page.isScope) {
53722
53896
  if (page.address) keys.push(knowledgeLinkRefKey(page.address));
@@ -53724,10 +53898,7 @@ async function pageRefKeys(storage, page) {
53724
53898
  }
53725
53899
  if (!page.key || !page.parentId) return keys;
53726
53900
  const path = [];
53727
- for (const current of [page, ...await storage.getPageParents({
53728
- parentId: page.parentId,
53729
- read: "all"
53730
- })]) {
53901
+ for (const current of [page, ...parents]) {
53731
53902
  if (current.isScope) {
53732
53903
  if (current.address) keys.push(knowledgeLinkRefKey(`${current.address}#${path.join("/")}`));
53733
53904
  return keys;
@@ -53876,6 +54047,203 @@ async function reindexKnowledgeLinks(storage) {
53876
54047
  } while (cursor);
53877
54048
  return count;
53878
54049
  }
54050
+ /**
54051
+ * A batched link repair that would stop at a cap the op-by-op refreshes enforce one write at a time
54052
+ * (linking pages, namesakes, refs looked up, subtree size): the caller saves op by op instead, so the
54053
+ * caps apply exactly as they do there.
54054
+ */
54055
+ var KnowledgeLinkRepairUnsupportedError = class extends Error {
54056
+ reason;
54057
+ constructor(reason) {
54058
+ super(`batched link repair: ${reason}`);
54059
+ this.reason = reason;
54060
+ this.name = "KnowledgeLinkRepairUnsupportedError";
54061
+ }
54062
+ };
54063
+ /** True when the store has every set-based read and write {@link repairKnowledgeLinks} uses. */
54064
+ function canRepairKnowledgeLinksInBatch(storage) {
54065
+ return !!(storage.getPageChains && storage.getPagesByPaths && storage.getPageSubtrees && storage.findPagesByNames && storage.applyPageWrites);
54066
+ }
54067
+ /**
54068
+ * Every {@link syncKnowledgePageBodyLinks} and {@link refreshKnowledgeLinksTo} of a flush, run once
54069
+ * over the store as the flush left it, in a fixed number of statements: each page's links come out
54070
+ * as they do when the calls run one after another after the writes. Throws
54071
+ * {@link KnowledgeLinkRepairUnsupportedError}, having written nothing, when a cap could bite.
54072
+ */
54073
+ async function repairKnowledgeLinks(storage, repair) {
54074
+ const synced = new Map(repair.synced.map((page) => [page.id, page]));
54075
+ if (!synced.size && !repair.refreshed.length) return;
54076
+ const roots = repair.refreshed.filter((item) => item.withDescendants).map((item) => item.page.id);
54077
+ const subtrees = roots.length ? await storage.getPageSubtrees({
54078
+ rootIds: [...new Set(roots)],
54079
+ limit: 500
54080
+ }) : {};
54081
+ const affected = [];
54082
+ for (const { page, withDescendants } of repair.refreshed) {
54083
+ affected.push(page);
54084
+ if (!withDescendants) continue;
54085
+ const under = subtrees[page.id];
54086
+ if (!under) throw new KnowledgeLinkRepairUnsupportedError("a moved subtree past the move limit");
54087
+ affected.push(...under);
54088
+ }
54089
+ const parentIds = affected.flatMap((page) => !page.isScope && page.key && page.parentId ? [page.parentId] : []);
54090
+ const chains = parentIds.length ? await storage.getPageChains({
54091
+ ids: [...new Set(parentIds)],
54092
+ read: "all"
54093
+ }) : {};
54094
+ const refs = /* @__PURE__ */ new Set();
54095
+ const targets = new Set(affected.map((page) => page.id));
54096
+ const names = /* @__PURE__ */ new Set();
54097
+ for (const page of affected) {
54098
+ const parents = !page.isScope && page.key && page.parentId ? chains[page.parentId] ?? [] : [];
54099
+ for (const key of refKeysOf(page, parents)) refs.add(key);
54100
+ if (!page.deletedAt) names.add(page.name);
54101
+ }
54102
+ if (names.size) {
54103
+ const namesakes = await storage.findPagesByNames({
54104
+ names: [...names],
54105
+ read: "all",
54106
+ limit: 100
54107
+ });
54108
+ for (const found of Object.values(namesakes)) {
54109
+ if (found.length > MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES) throw new KnowledgeLinkRepairUnsupportedError("a name past the namesake limit");
54110
+ for (const namesake of found) targets.add(namesake.id);
54111
+ }
54112
+ }
54113
+ const sources = affected.length ? await storage.listPageBodyLinkSources({
54114
+ refs: [...refs],
54115
+ toPageIds: [...targets]
54116
+ }) : [];
54117
+ if (sources.length > 100) throw new KnowledgeLinkRepairUnsupportedError("linking pages past the refresh limit");
54118
+ const unread = sources.filter((id) => !synced.has(id));
54119
+ const live = new Map((unread.length ? await storage.getPages({
54120
+ ids: unread,
54121
+ read: "all"
54122
+ }) : []).map((page) => [page.id, page]));
54123
+ const rewrite = /* @__PURE__ */ new Map();
54124
+ for (const id of unread) rewrite.set(id, live.get(id) ?? null);
54125
+ for (const [id, page] of synced) rewrite.set(id, page);
54126
+ const wanted = /* @__PURE__ */ new Map();
54127
+ const lookups = [];
54128
+ const refreshing = new Set(sources);
54129
+ let looked = 0;
54130
+ for (const [id, page] of rewrite) {
54131
+ const byKey = /* @__PURE__ */ new Map();
54132
+ if (page && !page.deletedAt) for (const [ref, count] of knowledgeBodyLinkRefs(page.body)) {
54133
+ const key = knowledgeLinkRefKey(ref);
54134
+ if (key.length > 512) continue;
54135
+ const entry = byKey.get(key);
54136
+ if (entry) entry.count += count;
54137
+ else byKey.set(key, {
54138
+ ref,
54139
+ count
54140
+ });
54141
+ }
54142
+ const entries = [...byKey];
54143
+ wanted.set(id, entries);
54144
+ if (page) for (const [, { ref }] of entries) lookups.push({
54145
+ ref,
54146
+ home: page.scopeId
54147
+ });
54148
+ if (refreshing.has(id)) looked += new Set(entries.map(([, { ref }]) => ref)).size;
54149
+ }
54150
+ if (looked >= 1e3) throw new KnowledgeLinkRepairUnsupportedError("refs looked up past the refresh limit");
54151
+ const resolved = await resolveKnowledgeBodyLinks(storage, lookups);
54152
+ await storage.applyPageWrites({ writes: [...wanted].map(([pageId, entries]) => {
54153
+ const home = rewrite.get(pageId)?.scopeId;
54154
+ return {
54155
+ op: "replace-links",
54156
+ pageId,
54157
+ links: entries.map(([key, { ref, count }]) => ({
54158
+ ref: key,
54159
+ toPageId: home === void 0 ? null : resolved.get(`${home}\u0000${ref}`) ?? null,
54160
+ count
54161
+ }))
54162
+ };
54163
+ }) });
54164
+ }
54165
+ /** What {@link BodyLinkResolver} answers for each `(home, ref)`, keyed `home\0ref`, in a fixed number of reads. */
54166
+ async function resolveKnowledgeBodyLinks(storage, lookups) {
54167
+ const answers = /* @__PURE__ */ new Map();
54168
+ if (!lookups.length) return answers;
54169
+ const keyOf = (home, ref) => `${home}\u0000${ref}`;
54170
+ const byId = new Set((await storage.getPages({
54171
+ ids: [...new Set(lookups.map((item) => item.ref))],
54172
+ read: "all"
54173
+ })).map((page) => page.id));
54174
+ const remaining = lookups.filter(({ ref, home }) => {
54175
+ if (!byId.has(ref)) return true;
54176
+ answers.set(keyOf(home, ref), ref);
54177
+ return false;
54178
+ });
54179
+ const paths = /* @__PURE__ */ new Map();
54180
+ const addresses = /* @__PURE__ */ new Set();
54181
+ for (const { ref } of remaining) if (ref.indexOf("#") > 0) {
54182
+ const parsed = parseKnowledgePageRef(ref);
54183
+ paths.set(ref, parsed);
54184
+ if (parsed) addresses.add(parsed.scope);
54185
+ } else addresses.add(ref);
54186
+ const scopes = /* @__PURE__ */ new Map();
54187
+ if (addresses.size) {
54188
+ for (const scope of await storage.getScopesByAddress([...addresses])) if (!scope.deletedAt && scope.address) scopes.set(scope.address, scope.id);
54189
+ }
54190
+ const pathsByScope = /* @__PURE__ */ new Map();
54191
+ for (const [ref, parsed] of paths) {
54192
+ const scopeId = parsed && scopes.get(parsed.scope);
54193
+ if (!scopeId) continue;
54194
+ if (!pathsByScope.has(scopeId)) pathsByScope.set(scopeId, /* @__PURE__ */ new Map());
54195
+ pathsByScope.get(scopeId).set(ref, parsed.path);
54196
+ }
54197
+ const pathAnswers = /* @__PURE__ */ new Map();
54198
+ for (const [scopeId, refs] of pathsByScope) {
54199
+ const found = await storage.getPagesByPaths({
54200
+ scopeId,
54201
+ paths: [...refs.values()],
54202
+ read: "all"
54203
+ });
54204
+ [...refs.keys()].forEach((ref, i) => pathAnswers.set(ref, found[i]?.id ?? null));
54205
+ }
54206
+ const namesByHome = /* @__PURE__ */ new Map();
54207
+ for (const { ref, home } of remaining) {
54208
+ if (paths.has(ref)) {
54209
+ answers.set(keyOf(home, ref), pathAnswers.get(ref) ?? null);
54210
+ continue;
54211
+ }
54212
+ const scopeId = scopes.get(ref);
54213
+ if (scopeId) {
54214
+ answers.set(keyOf(home, ref), scopeId);
54215
+ continue;
54216
+ }
54217
+ if (!namesByHome.has(home)) namesByHome.set(home, /* @__PURE__ */ new Set());
54218
+ namesByHome.get(home).add(ref);
54219
+ }
54220
+ const anywhere = /* @__PURE__ */ new Map();
54221
+ for (const [home, names] of namesByHome) {
54222
+ const found = await storage.findPagesByNames({
54223
+ names: [...names],
54224
+ read: "all",
54225
+ scopeId: home,
54226
+ limit: 2
54227
+ });
54228
+ for (const name of names) {
54229
+ const inHome = found[name] ?? [];
54230
+ if (inHome.length) answers.set(keyOf(home, name), inHome.length === 1 ? inHome[0].id : null);
54231
+ else anywhere.set(name, [...anywhere.get(name) ?? [], home]);
54232
+ }
54233
+ }
54234
+ if (anywhere.size) {
54235
+ const found = await storage.findPagesByNames({
54236
+ names: [...anywhere.keys()],
54237
+ read: "all",
54238
+ limit: 2
54239
+ });
54240
+ for (const [name, homes] of anywhere) {
54241
+ const pages = found[name] ?? [];
54242
+ for (const home of homes) answers.set(keyOf(home, name), pages.length === 1 ? pages[0].id : null);
54243
+ }
54244
+ }
54245
+ return answers;
54246
+ }
53879
54247
  // ../_vendored/ai_v7/dist/dist-C-C3A1Ts.js
53880
54248
  /**
53881
54249
  * Symbol used for identifying AI SDK Error instances.
@@ -74095,6 +74463,25 @@ function makeSaveQueueManager(memory, runId, mastra) {
74095
74463
  onSaved: recordRunSavedMessages(runId)
74096
74464
  });
74097
74465
  }
74466
+ /** Rebuild a hydrated entry's starting tools for the caller of the segment now running. */
74467
+ async function rebuildToolsForSegment(mastra, entry, { runId, agentId, input, requestContext }) {
74468
+ const resolved = await resolveRunAgent(mastra, agentId, runId, input.agentVersionId);
74469
+ entry.baseTools = await (isDurableAgentLike(resolved) && resolved.agent !== resolved ? resolved.agent : resolved).getToolsForExecution({
74470
+ runId,
74471
+ threadId: input.state.threadId,
74472
+ resourceId: input.state.resourceId,
74473
+ requestContext,
74474
+ memoryConfig: input.state.memoryConfig,
74475
+ autoResumeSuspendedTools: input.options?.autoResumeSuspendedTools,
74476
+ clientTools: input.options?.clientTools,
74477
+ delegation: entry.delegation,
74478
+ methodType: entry.methodType ?? "stream",
74479
+ backgroundTaskEnabled: Boolean(entry.backgroundTaskManager),
74480
+ backgroundTaskPolicy: input.options?.backgroundTaskPolicy,
74481
+ model: entry.model
74482
+ });
74483
+ return entry.baseTools;
74484
+ }
74098
74485
  /**
74099
74486
  * The run's `requestContextEntries` as handed to scorers (`customContext`), with
74100
74487
  * the signed-in user taken from the live run-level context rather than the
@@ -74234,10 +74621,23 @@ async function resolveRuntimeDependencies(options) {
74234
74621
  let errorProcessors = globalEntry?.errorProcessors;
74235
74622
  let processorStates = globalEntry?.processorStates;
74236
74623
  let rehydratedFromMastra = false;
74624
+ let toolsSegment;
74237
74625
  let rebuiltAgent;
74238
74626
  let backgroundTasks;
74239
- if (hasHydratedEntry) logger?.debug?.(`[DurableAgent:${agentId}] Using model and tools from global registry for run ${runId}`);
74240
- else if (mastra) try {
74627
+ if (hasHydratedEntry) {
74628
+ logger?.debug?.(`[DurableAgent:${agentId}] Using model and tools from global registry for run ${runId}`);
74629
+ const { stepSegment } = options;
74630
+ if (!globalEntry || stepSegment === void 0) {} else if (globalEntry.toolsSegment === void 0) globalEntry.toolsSegment = stepSegment;
74631
+ else if (globalEntry.toolsSegment !== stepSegment && mastra) {
74632
+ tools = await rebuildToolsForSegment(mastra, globalEntry, {
74633
+ runId,
74634
+ agentId,
74635
+ input,
74636
+ requestContext: restoreRequestContext(input.requestContextEntries, options.requestContext)
74637
+ });
74638
+ globalEntry.toolsSegment = stepSegment;
74639
+ }
74640
+ } else if (mastra) try {
74241
74641
  const agent = await resolveRunAgent(mastra, agentId, runId, input.agentVersionId);
74242
74642
  rebuiltAgent = isDurableAgentLike(agent) && agent.agent !== agent ? agent.agent : agent;
74243
74643
  const resolveRequestContext = restoreRequestContext(input.requestContextEntries, options.requestContext);
@@ -74280,6 +74680,7 @@ async function resolveRuntimeDependencies(options) {
74280
74680
  errorProcessors = rebuiltProcessors.errorProcessors;
74281
74681
  processorStates = rebuiltProcessors.processorStates;
74282
74682
  rehydratedFromMastra = true;
74683
+ toolsSegment = options.stepSegment;
74283
74684
  } catch (error) {
74284
74685
  if (error instanceof DurableProcessorRebuildError || error instanceof DurableAgentNotFoundError) throw error;
74285
74686
  if ((input.options?.toolsetToolNames?.length ?? 0) > 0) throw error;
@@ -74296,6 +74697,7 @@ async function resolveRuntimeDependencies(options) {
74296
74697
  const rebuilt = {
74297
74698
  isPlaceholder: false,
74298
74699
  tools,
74700
+ toolsSegment,
74299
74701
  model,
74300
74702
  modelList,
74301
74703
  workspace,
@@ -74988,11 +75390,7 @@ async function runDurableFinishSideEffects({ runId, initData, messageListState,
74988
75390
  });
74989
75391
  const steps = outputResult?.steps;
74990
75392
  const lastStep = steps?.at(-1);
74991
- const responses = messageList.get.response.db();
74992
- const reply = steps && steps.length > 1 && responses.some((msg) => {
74993
- const result = msg.content.metadata?.completionResult;
74994
- return result && typeof result === "object" && "suppressFeedback" in result && result.suppressFeedback === true;
74995
- }) ? require_stream.resolveOutputMessageSkippingCompletionChecks(messageList) : void 0;
75393
+ const reply = require_stream.isFeedbackContinuation(messageList, steps) ? require_stream.resolveOutputMessageSkippingCompletionChecks(messageList) : void 0;
74996
75394
  const parts = reply?.content.parts;
74997
75395
  const offset = parts ? require_stream.findIterationOffsetInParts(parts, lastStep?.text) : void 0;
74998
75396
  const split = reply && offset !== void 0 ? messageList.splitResponseMessageAtPartOffset(reply.id, offset) : void 0;
@@ -77232,6 +77630,7 @@ function createDurableLLMExecutionStep(_options) {
77232
77630
  messageListState: await readMessageListState(params, typedInput)
77233
77631
  },
77234
77632
  requestContext,
77633
+ stepSegment: getStepSegment(runId, params.requestContext),
77235
77634
  logger
77236
77635
  });
77237
77636
  const storeStepTranscript = () => {
@@ -83077,6 +83476,7 @@ var DurableAgenticLoopBuilder = class extends BaseAgenticLoopBuilder {
83077
83476
  }],
83078
83477
  metadata: {
83079
83478
  mode: "stream",
83479
+ iterationFeedback: true,
83080
83480
  completionResult: { suppressFeedback: true }
83081
83481
  },
83082
83482
  format: 2
@@ -84576,7 +84976,7 @@ async function prepareForDurableExecution(options) {
84576
84976
  });
84577
84977
  let tripwireData;
84578
84978
  if (inputProcessors.length > 0) try {
84579
- const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-D_7tMaJe.cjs")).then((n) => n.runner_exports);
84979
+ const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-BbPZavop.cjs")).then((n) => n.runner_exports);
84580
84980
  await new ProcessorRunner({
84581
84981
  inputProcessors,
84582
84982
  outputProcessors,
@@ -95850,8 +96250,7 @@ var Agent = class Agent extends require_base.MastraBase {
95850
96250
  scopes: Array.isArray(snapshotScopes) ? snapshotScopes : void 0
95851
96251
  };
95852
96252
  const carriedEntries = entry.requestContext ? Object.entries(require_request_context.withoutLiveRequestKeys(Object.fromEntries(entry.requestContext.entries()))) : void 0;
95853
- const droppedStartingUser = carriedEntries !== void 0 && carriedEntries.length < entry.requestContext.size();
95854
- let resumeRequestContext = droppedStartingUser ? new require_request_context.RequestContext(carriedEntries) : entry.requestContext;
96253
+ let resumeRequestContext = carriedEntries !== void 0 && carriedEntries.length < entry.requestContext.size() ? new require_request_context.RequestContext(carriedEntries) : entry.requestContext;
95855
96254
  if (options?.requestContext) {
95856
96255
  resumeRequestContext = options.requestContext;
95857
96256
  for (const [key, value] of carriedEntries ?? []) {
@@ -95961,7 +96360,7 @@ var Agent = class Agent extends require_base.MastraBase {
95961
96360
  await executionFence.settle(async () => {});
95962
96361
  throw error;
95963
96362
  }
95964
- if (!coldSnapshot && (options?.requestContext || options?.delegation || options?.hooks || droppedStartingUser)) try {
96363
+ if (!coldSnapshot) try {
95965
96364
  const requestTools = await this.agentForExecution.getToolsForExecution({
95966
96365
  toolsets: resolvedOptions.toolsets,
95967
96366
  clientTools: resolvedOptions.clientTools,
@@ -95986,7 +96385,7 @@ var Agent = class Agent extends require_base.MastraBase {
95986
96385
  for (const reg of /* @__PURE__ */ new Set([entry, getRunRegistryEntry(runId, this.#mastra)])) {
95987
96386
  if (!reg) continue;
95988
96387
  reg.tools = require_utils$1.rebindProcessorTools(refresh(reg.tools ?? {}, reg.requestTools), resumeRequestContext);
95989
- if (reg.baseTools) reg.baseTools = require_utils$1.rebindProcessorTools(refresh(reg.baseTools, reg.requestTools), resumeRequestContext);
96388
+ reg.baseTools = requestTools;
95990
96389
  reg.requestTools = {
95991
96390
  ...reg.requestTools,
95992
96391
  ...requestTools
@@ -95994,13 +96393,16 @@ var Agent = class Agent extends require_base.MastraBase {
95994
96393
  if (options?.delegation) reg.delegation = resolvedOptions.delegation;
95995
96394
  }
95996
96395
  } catch (error) {
95997
- this.#mastra?.getLogger?.()?.warn?.(`[DurableAgent] resume(${runId}) tool resolution failed: ${error}`);
96396
+ this.#mastra?.getLogger?.()?.error?.(`[DurableAgent] resume(${runId}) tool resolution failed: ${error}`);
96397
+ await executionFence.settle(async () => {});
96398
+ throw error;
95998
96399
  }
95999
96400
  setExecutionClaim(resumeRequestContext, runId, executionFence.claim);
96000
96401
  for (const reg of [entry, getRunRegistryEntry(runId, this.#mastra)]) {
96001
96402
  if (!reg) continue;
96002
96403
  reg.executionFence = executionFence;
96003
96404
  reg.resumeToolCallId = resolvedOptions.toolCallId;
96405
+ if (!coldSnapshot) reg.toolsSegment = void 0;
96004
96406
  }
96005
96407
  const { controller: abortController, detach: detachExternalAbort } = createRunAbortController(resolvedOptions.abortSignal);
96006
96408
  if (agentThreadStreamRuntime.isRunAborted(runId, this.getPubSub())) abortController.abort();
@@ -104746,6 +105148,7 @@ var AgenticLoopBuilder = class extends BaseAgenticLoopBuilder {
104746
105148
  }],
104747
105149
  metadata: {
104748
105150
  mode: "stream",
105151
+ iterationFeedback: true,
104749
105152
  completionResult: { suppressFeedback: true }
104750
105153
  },
104751
105154
  format: 2
@@ -110965,6 +111368,11 @@ function getRunRegistryEntry(runId, mastra) {
110965
111368
  * claim (Inngest). The engine stores the same value on the registry entry it seeds for the segment.
110966
111369
  */
110967
111370
  const DURABLE_CONTEXT_SEGMENT_KEY = "__mastra_durableContextSegment";
111371
+ /** The run segment a step belongs to: its Core execution claim, or the engine's segment id. */
111372
+ function getStepSegment(runId, stepContext) {
111373
+ const segment = getExecutionClaim(stepContext, runId)?.executionId ?? stepContext?.get("__mastra_durableContextSegment");
111374
+ return typeof segment === "string" ? segment : void 0;
111375
+ }
110968
111376
  /**
110969
111377
  * The registry's live request context, when it belongs to the execution running this step. Once
110970
111378
  * another process claims the run (for example an approval from another host), the context cached
@@ -111747,6 +112155,12 @@ Object.defineProperty(exports, "KnowledgeLinkRefreshIncompleteError", {
111747
112155
  return KnowledgeLinkRefreshIncompleteError;
111748
112156
  }
111749
112157
  });
112158
+ Object.defineProperty(exports, "KnowledgeLinkRepairUnsupportedError", {
112159
+ enumerable: true,
112160
+ get: function() {
112161
+ return KnowledgeLinkRepairUnsupportedError;
112162
+ }
112163
+ });
111750
112164
  Object.defineProperty(exports, "KnowledgeMoveTooLargeError", {
111751
112165
  enumerable: true,
111752
112166
  get: function() {
@@ -112719,6 +113133,12 @@ Object.defineProperty(exports, "calculateAccumulatedUsage", {
112719
113133
  return calculateAccumulatedUsage;
112720
113134
  }
112721
113135
  });
113136
+ Object.defineProperty(exports, "canRepairKnowledgeLinksInBatch", {
113137
+ enumerable: true,
113138
+ get: function() {
113139
+ return canRepairKnowledgeLinksInBatch;
113140
+ }
113141
+ });
112722
113142
  Object.defineProperty(exports, "cancelNestedRun", {
112723
113143
  enumerable: true,
112724
113144
  get: function() {
@@ -113673,6 +114093,12 @@ Object.defineProperty(exports, "knowledgeMemoryScopes", {
113673
114093
  return knowledgeMemoryScopes;
113674
114094
  }
113675
114095
  });
114096
+ Object.defineProperty(exports, "knowledgePageKeyProblem", {
114097
+ enumerable: true,
114098
+ get: function() {
114099
+ return knowledgePageKeyProblem;
114100
+ }
114101
+ });
113676
114102
  Object.defineProperty(exports, "knowledgePagePath", {
113677
114103
  enumerable: true,
113678
114104
  get: function() {
@@ -114081,6 +114507,12 @@ Object.defineProperty(exports, "renewWorkflowLease", {
114081
114507
  return renewWorkflowLease;
114082
114508
  }
114083
114509
  });
114510
+ Object.defineProperty(exports, "repairKnowledgeLinks", {
114511
+ enumerable: true,
114512
+ get: function() {
114513
+ return repairKnowledgeLinks;
114514
+ }
114515
+ });
114084
114516
  Object.defineProperty(exports, "repeatAfterSettled", {
114085
114517
  enumerable: true,
114086
114518
  get: function() {