@mastra/core 1.88.0-alpha.0 → 1.88.0-alpha.2

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 (404) hide show
  1. package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +17 -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 +2 -2
  5. package/dist/agent/index.js +2 -2
  6. package/dist/agent-builder/ee/index.cjs +1 -1
  7. package/dist/agent-builder/ee/index.js +1 -1
  8. package/dist/agent-controller/index.cjs +1 -1
  9. package/dist/agent-controller/index.js +1 -1
  10. package/dist/agent-controller/model-catalog-cache.d.ts +9 -5
  11. package/dist/agent-controller/session.d.ts +17 -0
  12. package/dist/{agent-controller-NQKYmY0W.cjs → agent-controller-Bt7DwpZy.cjs} +57 -53
  13. package/dist/{agent-controller-CQDCmsFD.js → agent-controller-CFNkjF3l.js} +57 -53
  14. package/dist/background-tasks/index.cjs +1 -1
  15. package/dist/background-tasks/index.js +1 -1
  16. package/dist/{background-tasks-B7UygDdO.js → background-tasks-DJHuKMQC.js} +1 -1
  17. package/dist/{background-tasks-CeARf1DK.cjs → background-tasks-DbPzYpIZ.cjs} +1 -1
  18. package/dist/browser/index.cjs +1 -1
  19. package/dist/browser/index.js +1 -1
  20. package/dist/{builder-Dmf04g9P.cjs → builder-961mB1xC.cjs} +2 -2
  21. package/dist/{builder-CpAEmMdR.js → builder-BD6HtwKv.js} +2 -2
  22. package/dist/capabilities/302ai.json +200 -200
  23. package/dist/capabilities/abliteratedllm.json +37 -37
  24. package/dist/capabilities/abliteration-ai.json +9 -9
  25. package/dist/capabilities/above.json +22 -22
  26. package/dist/capabilities/adaption.json +13 -13
  27. package/dist/capabilities/adzuki.json +22 -22
  28. package/dist/capabilities/agentrouter.json +10 -10
  29. package/dist/capabilities/agnes.json +3 -3
  30. package/dist/capabilities/ai-router.json +7 -7
  31. package/dist/capabilities/aiand.json +22 -23
  32. package/dist/capabilities/aigrow.json +14 -14
  33. package/dist/capabilities/aimlapi.json +149 -158
  34. package/dist/capabilities/aixy.json +28 -28
  35. package/dist/capabilities/aki-io.json +12 -12
  36. package/dist/capabilities/alibaba-cn.json +99 -99
  37. package/dist/capabilities/alibaba-coding-plan-cn.json +4 -4
  38. package/dist/capabilities/alibaba-coding-plan.json +4 -4
  39. package/dist/capabilities/alibaba-token-plan-cn.json +55 -55
  40. package/dist/capabilities/alibaba-token-plan.json +56 -56
  41. package/dist/capabilities/alibaba.json +77 -77
  42. package/dist/capabilities/ambient.json +7 -7
  43. package/dist/capabilities/amd-tokenlab.json +5 -5
  44. package/dist/capabilities/amd.json +6 -6
  45. package/dist/capabilities/anthropic.json +31 -31
  46. package/dist/capabilities/anyapi.json +47 -47
  47. package/dist/capabilities/apiko.json +5 -5
  48. package/dist/capabilities/arcee.json +4 -4
  49. package/dist/capabilities/augure.json +5 -5
  50. package/dist/capabilities/auriko.json +21 -21
  51. package/dist/capabilities/bailing.json +5 -5
  52. package/dist/capabilities/baseten.json +34 -34
  53. package/dist/capabilities/bee.json +2 -2
  54. package/dist/capabilities/bothub.json +15 -15
  55. package/dist/capabilities/boundless.json +39 -39
  56. package/dist/capabilities/bumo.json +38 -38
  57. package/dist/capabilities/byteplus.json +26 -26
  58. package/dist/capabilities/cheapaimodel.json +7 -7
  59. package/dist/capabilities/cheapest-token.json +32 -32
  60. package/dist/capabilities/chutes.json +33 -33
  61. package/dist/capabilities/cline-pass.json +37 -37
  62. package/dist/capabilities/cloudcode.json +8 -8
  63. package/dist/capabilities/cloudflare-ai-gateway.json +716 -0
  64. package/dist/capabilities/cloudflare-workers-ai.json +12 -12
  65. package/dist/capabilities/cohere.json +67 -0
  66. package/dist/capabilities/commandcode.json +146 -146
  67. package/dist/capabilities/concentrate.json +281 -281
  68. package/dist/capabilities/cortecs.json +103 -103
  69. package/dist/capabilities/crossmodel.json +190 -190
  70. package/dist/capabilities/crusoe.json +11 -11
  71. package/dist/capabilities/daoxe.json +9 -9
  72. package/dist/capabilities/databricks.json +133 -133
  73. package/dist/capabilities/deepinfra.json +96 -96
  74. package/dist/capabilities/deepseek.json +3 -3
  75. package/dist/capabilities/digitalocean.json +115 -115
  76. package/dist/capabilities/dothoosh.json +34 -34
  77. package/dist/capabilities/doubleword.json +30 -30
  78. package/dist/capabilities/edenai.json +288 -279
  79. package/dist/capabilities/empiriolabs.json +187 -178
  80. package/dist/capabilities/engy.json +22 -22
  81. package/dist/capabilities/entrim.json +6 -6
  82. package/dist/capabilities/evroc.json +15 -15
  83. package/dist/capabilities/ezkielyna.json +10 -10
  84. package/dist/capabilities/fastrouter.json +90 -90
  85. package/dist/capabilities/fireworks-ai.json +93 -82
  86. package/dist/capabilities/freemodel.json +8 -8
  87. package/dist/capabilities/friendli.json +8 -8
  88. package/dist/capabilities/frogbot.json +87 -87
  89. package/dist/capabilities/gisoo.json +18 -18
  90. package/dist/capabilities/gmicloud.json +16 -16
  91. package/dist/capabilities/google.json +59 -59
  92. package/dist/capabilities/graphn.json +10 -10
  93. package/dist/capabilities/greenpt.json +32 -32
  94. package/dist/capabilities/helicone.json +80 -80
  95. package/dist/capabilities/hetzner.json +5 -5
  96. package/dist/capabilities/hostinger-router.json +11 -11
  97. package/dist/capabilities/hpc-ai.json +8 -8
  98. package/dist/capabilities/huawei-maas.json +15 -15
  99. package/dist/capabilities/hubris.json +26 -26
  100. package/dist/capabilities/huggingface.json +93 -85
  101. package/dist/capabilities/hyper.json +23 -23
  102. package/dist/capabilities/impossibl.json +153 -153
  103. package/dist/capabilities/inceptron.json +8 -8
  104. package/dist/capabilities/inco.json +3 -3
  105. package/dist/capabilities/infer.json +16 -16
  106. package/dist/capabilities/inferall.json +6 -6
  107. package/dist/capabilities/inference-coop.json +15 -15
  108. package/dist/capabilities/inferenceapis.json +25 -25
  109. package/dist/capabilities/inferris.json +3 -3
  110. package/dist/capabilities/infersia.json +9 -9
  111. package/dist/capabilities/inferx.json +2 -2
  112. package/dist/capabilities/infomaniak.json +2 -2
  113. package/dist/capabilities/iteracompute.json +44 -44
  114. package/dist/capabilities/jalapeno.json +11 -11
  115. package/dist/capabilities/jiekou.json +31 -31
  116. package/dist/capabilities/joingonka.json +4 -4
  117. package/dist/capabilities/jzstoken.json +49 -49
  118. package/dist/capabilities/keln.json +23 -23
  119. package/dist/capabilities/kenari.json +125 -125
  120. package/dist/capabilities/kilo.json +667 -626
  121. package/dist/capabilities/kimchi.json +16 -16
  122. package/dist/capabilities/kimi-code-plan-cn.json +6 -6
  123. package/dist/capabilities/kimi-code-plan-global.json +6 -6
  124. package/dist/capabilities/kitani.json +6 -6
  125. package/dist/capabilities/klavo.json +26 -26
  126. package/dist/capabilities/korouter.json +34 -34
  127. package/dist/capabilities/kunavo.json +6 -6
  128. package/dist/capabilities/liquid.json +11 -11
  129. package/dist/capabilities/lithosai.json +2 -2
  130. package/dist/capabilities/llmgateway-providers.json +933 -931
  131. package/dist/capabilities/llmgateway.json +350 -348
  132. package/dist/capabilities/llmtr.json +20 -20
  133. package/dist/capabilities/lowrouter.json +62 -62
  134. package/dist/capabilities/lyceum.json +13 -13
  135. package/dist/capabilities/melious.json +12 -12
  136. package/dist/capabilities/merge-gateway.json +296 -296
  137. package/dist/capabilities/meta.json +10 -10
  138. package/dist/capabilities/minimax-cn-coding-plan.json +5 -5
  139. package/dist/capabilities/minimax-cn.json +5 -5
  140. package/dist/capabilities/minimax-coding-plan.json +5 -5
  141. package/dist/capabilities/minimax.json +5 -5
  142. package/dist/capabilities/mistral.json +22 -14
  143. package/dist/capabilities/mixlayer.json +5 -5
  144. package/dist/capabilities/modal.json +10 -10
  145. package/dist/capabilities/model-oracle-ai.json +21 -21
  146. package/dist/capabilities/modelis.json +20 -20
  147. package/dist/capabilities/modelscope.json +2 -2
  148. package/dist/capabilities/modular.json +12 -12
  149. package/dist/capabilities/moneo.json +6 -6
  150. package/dist/capabilities/moonshotai-cn.json +7 -7
  151. package/dist/capabilities/moonshotai.json +7 -7
  152. package/dist/capabilities/morph.json +12 -12
  153. package/dist/capabilities/munito-eu.json +6 -6
  154. package/dist/capabilities/munito.json +8 -8
  155. package/dist/capabilities/nan.json +25 -25
  156. package/dist/capabilities/nano-gpt.json +585 -571
  157. package/dist/capabilities/nearai.json +112 -112
  158. package/dist/capabilities/nebius.json +36 -36
  159. package/dist/capabilities/neon.json +123 -123
  160. package/dist/capabilities/neuralwatt.json +41 -41
  161. package/dist/capabilities/nokeep.json +5 -5
  162. package/dist/capabilities/novita-ai.json +127 -127
  163. package/dist/capabilities/nvidia.json +16 -16
  164. package/dist/capabilities/oathbreaker.json +4 -4
  165. package/dist/capabilities/obscurify.json +31 -31
  166. package/dist/capabilities/oci.json +5 -5
  167. package/dist/capabilities/ofox.json +252 -252
  168. package/dist/capabilities/ollama-cloud.json +55 -55
  169. package/dist/capabilities/openai.json +54 -54
  170. package/dist/capabilities/opencode-go.json +109 -93
  171. package/dist/capabilities/openreason.json +4 -4
  172. package/dist/capabilities/openrouter.json +529 -529
  173. package/dist/capabilities/opper.json +27 -27
  174. package/dist/capabilities/orcarouter.json +263 -263
  175. package/dist/capabilities/outerlabs.json +30 -30
  176. package/dist/capabilities/ovhcloud.json +18 -18
  177. package/dist/capabilities/pareto.json +4 -4
  178. package/dist/capabilities/pendra.json +4 -4
  179. package/dist/capabilities/perplexity-agent.json +64 -64
  180. package/dist/capabilities/perplexity.json +2 -2
  181. package/dist/capabilities/phala.json +37 -37
  182. package/dist/capabilities/pioneer.json +2 -2
  183. package/dist/capabilities/poe.json +140 -140
  184. package/dist/capabilities/powerspring.json +11 -11
  185. package/dist/capabilities/primalabs.json +6 -6
  186. package/dist/capabilities/prime.json +119 -119
  187. package/dist/capabilities/privatemode-ai.json +7 -7
  188. package/dist/capabilities/proxystacks.json +3 -3
  189. package/dist/capabilities/qiniu-ai.json +11 -11
  190. package/dist/capabilities/refuseless.json +9 -9
  191. package/dist/capabilities/regolo-ai.json +9 -9
  192. package/dist/capabilities/requesty.json +201 -201
  193. package/dist/capabilities/ruapi.json +25 -25
  194. package/dist/capabilities/runcrate.json +15 -15
  195. package/dist/capabilities/runinfra.json +17 -17
  196. package/dist/capabilities/sakana.json +7 -7
  197. package/dist/capabilities/sambanova.json +5 -5
  198. package/dist/capabilities/sandbase.json +32 -32
  199. package/dist/capabilities/sarvam.json +9 -9
  200. package/dist/capabilities/scaleway.json +14 -14
  201. package/dist/capabilities/scnet-token-plan.json +4 -4
  202. package/dist/capabilities/scx-ai.json +21 -21
  203. package/dist/capabilities/sensenova.json +13 -13
  204. package/dist/capabilities/siliconflow-cn.json +56 -56
  205. package/dist/capabilities/siliconflow.json +63 -63
  206. package/dist/capabilities/snowflake-cortex.json +27 -27
  207. package/dist/capabilities/sokkan.json +2 -2
  208. package/dist/capabilities/sparrowcodes.json +18 -18
  209. package/dist/capabilities/standardcompute.json +83 -83
  210. package/dist/capabilities/steadyrouter.json +46 -46
  211. package/dist/capabilities/stepfun-ai-step-plan.json +8 -8
  212. package/dist/capabilities/stepfun-ai.json +8 -8
  213. package/dist/capabilities/stepfun-step-plan.json +8 -8
  214. package/dist/capabilities/stepfun.json +8 -8
  215. package/dist/capabilities/stepping-stone.json +21 -21
  216. package/dist/capabilities/subconscious.json +2 -2
  217. package/dist/capabilities/synthetic.json +12 -12
  218. package/dist/capabilities/synthorai.json +22 -22
  219. package/dist/capabilities/teamorouter.json +24 -24
  220. package/dist/capabilities/teapot-router.json +8 -8
  221. package/dist/capabilities/tencent-token-plan-intl.json +24 -24
  222. package/dist/capabilities/tencent-token-plan.json +35 -35
  223. package/dist/capabilities/tencent-tokenhub.json +50 -50
  224. package/dist/capabilities/tensorx.json +47 -47
  225. package/dist/capabilities/the-grid-ai.json +26 -26
  226. package/dist/capabilities/thinkingmachines.json +77 -77
  227. package/dist/capabilities/tinfoil.json +13 -13
  228. package/dist/capabilities/toapis.json +3 -3
  229. package/dist/capabilities/togetherai.json +58 -58
  230. package/dist/capabilities/tokengo.json +27 -27
  231. package/dist/capabilities/tokenharbor.json +216 -216
  232. package/dist/capabilities/tokenify.json +9 -9
  233. package/dist/capabilities/trustedrouter.json +7 -7
  234. package/dist/capabilities/trustedtokens.json +13 -13
  235. package/dist/capabilities/umans-ai-coding-plan.json +14 -14
  236. package/dist/capabilities/umans-ai.json +11 -11
  237. package/dist/capabilities/uncensuredai.json +4 -4
  238. package/dist/capabilities/unrestricted.json +4 -4
  239. package/dist/capabilities/uplinkswitch.json +22 -22
  240. package/dist/capabilities/vancine.json +20 -20
  241. package/dist/capabilities/vercel.json +594 -590
  242. package/dist/capabilities/verda.json +4 -4
  243. package/dist/capabilities/vivgrid.json +68 -68
  244. package/dist/capabilities/volcengine-coding-plan.json +29 -29
  245. package/dist/capabilities/volcengine.json +22 -22
  246. package/dist/capabilities/vultr.json +19 -19
  247. package/dist/capabilities/wafer.ai.json +19 -19
  248. package/dist/capabilities/wallaby.json +4 -4
  249. package/dist/capabilities/wally.json +11 -11
  250. package/dist/capabilities/wandb.json +21 -21
  251. package/dist/capabilities/watt.json +25 -25
  252. package/dist/capabilities/xai.json +6 -6
  253. package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
  254. package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
  255. package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
  256. package/dist/capabilities/xiaomi.json +2 -2
  257. package/dist/capabilities/xpersona.json +13 -13
  258. package/dist/capabilities/xxapi.json +28 -28
  259. package/dist/capabilities/zai-coding-plan.json +11 -11
  260. package/dist/capabilities/zai.json +31 -31
  261. package/dist/capabilities/zenifra.json +30 -30
  262. package/dist/capabilities/zenmux.json +175 -175
  263. package/dist/capabilities/zerogpu.json +9 -9
  264. package/dist/capabilities/zhipuai-coding-plan.json +3 -3
  265. package/dist/capabilities/zhipuai.json +33 -33
  266. package/dist/capabilities/zro.json +4 -4
  267. package/dist/channels/index.cjs +2 -2
  268. package/dist/channels/index.js +2 -2
  269. package/dist/{channels-BQ--aLCA.js → channels-Dn6LqqK1.js} +1 -1
  270. package/dist/{channels-CTCBsS5M.cjs → channels-dYHpz7m2.cjs} +1 -1
  271. package/dist/coding-agent/index.cjs +1 -1
  272. package/dist/coding-agent/index.js +1 -1
  273. package/dist/{constants-Dro9fuhk.js → constants-C2Q-ZI5d.js} +6 -0
  274. package/dist/{constants-B2FVV_2e.cjs → constants-DPHwzvan.cjs} +6 -0
  275. package/dist/datasets/index.cjs +2 -2
  276. package/dist/datasets/index.js +2 -2
  277. package/dist/docs/SKILL.md +1 -1
  278. package/dist/docs/assets/SOURCE_MAP.json +1079 -1074
  279. package/dist/docs/references/docs-channels.md +42 -1
  280. package/dist/docs/references/docs-develop.md +2 -0
  281. package/dist/docs/references/docs-evals-experiments.md +2 -0
  282. package/dist/docs/references/docs-guides-build-an-eval-loop.md +5 -1
  283. package/dist/docs/references/docs-guides-overview.md +2 -1
  284. package/dist/docs/references/docs-knowledge-importers.md +11 -1
  285. package/dist/docs/references/docs-knowledge-scopes-and-access.md +26 -0
  286. package/dist/docs/references/docs-mastra-platform-observability-overview.md +60 -0
  287. package/dist/docs/references/docs-memory-message-history.md +24 -16
  288. package/dist/docs/references/docs-memory-overview.md +21 -17
  289. package/dist/docs/references/docs-sandbox-overview.md +12 -10
  290. package/dist/docs/references/docs-workflows-control-flow.md +20 -0
  291. package/dist/docs/references/integrations-observability-arthur.md +1 -1
  292. package/dist/docs/references/reference-agent-controller-agent-controller-class.md +1 -1
  293. package/dist/docs/references/reference-agent-controller-session.md +9 -0
  294. package/dist/docs/references/reference-knowledge-knowledge-class.md +1 -1
  295. package/dist/docs/references/reference-knowledge-knowledge-tools.md +1 -1
  296. package/dist/docs/references/reference-observability-tracing-bridges-datadog.md +12 -11
  297. package/dist/docs/references/reference-processors-processor-interface.md +1 -1
  298. package/dist/docs/references/reference-storage-overview.md +1 -1
  299. package/dist/docs/references/reference-voice-overview.md +0 -27
  300. package/dist/docs/references/reference-workflows-step.md +1 -1
  301. package/dist/docs/references/reference-workspace-workspace-class.md +3 -1
  302. package/dist/evals/index.cjs +2 -2
  303. package/dist/evals/index.js +2 -2
  304. package/dist/evals/scoreTraces/index.cjs +2 -2
  305. package/dist/evals/scoreTraces/index.js +2 -2
  306. package/dist/{execution-fence-C8Q0wWkG.cjs → execution-fence-CHI1L6Gw.cjs} +284 -97
  307. package/dist/{execution-fence-DGFyUV5h.js → execution-fence-P1uj8uB8.js} +273 -98
  308. package/dist/harness/index.cjs +1 -1
  309. package/dist/harness/index.js +1 -1
  310. package/dist/index.cjs +1 -1
  311. package/dist/index.js +1 -1
  312. package/dist/knowledge/importers/local-host.d.ts +2 -1
  313. package/dist/knowledge/importers/sink.d.ts +6 -0
  314. package/dist/knowledge/importers/types.d.ts +5 -0
  315. package/dist/knowledge/index.cjs +105 -20
  316. package/dist/knowledge/index.js +105 -21
  317. package/dist/knowledge/links.d.ts +19 -6
  318. package/dist/llm/index.cjs +3 -3
  319. package/dist/llm/index.js +3 -3
  320. package/dist/llm/model/gateways/mastra.d.ts +19 -0
  321. package/dist/llm/model/gateways/refreshing-cache.d.ts +52 -0
  322. package/dist/llm/model/gateways/url-template.d.ts +3 -1
  323. package/dist/llm/model/provider-types.generated.d.ts +7693 -7570
  324. package/dist/{llm-YNjDFSui.js → llm-D4BaXbwZ.js} +4 -3
  325. package/dist/{llm-RIAYOAtD.cjs → llm-DqcaZBHM.cjs} +4 -3
  326. package/dist/loop/index.cjs +2 -2
  327. package/dist/loop/index.js +2 -2
  328. package/dist/loop/workflows/agentic-execution/background-task-check-step.d.ts +4 -0
  329. package/dist/loop/workflows/agentic-execution/goal-step.d.ts +4 -0
  330. package/dist/loop/workflows/agentic-execution/is-task-complete-step.d.ts +4 -0
  331. package/dist/loop/workflows/agentic-execution/llm-execution-step.d.ts +4 -0
  332. package/dist/loop/workflows/agentic-execution/llm-mapping-step.d.ts +2 -0
  333. package/dist/loop/workflows/schema.d.ts +13 -0
  334. package/dist/{manager-DZhtdV6Q.js → manager-BAs1D8t9.js} +3 -3
  335. package/dist/{manager-Y-jYcS7T.cjs → manager-Do9PPiEw.cjs} +3 -3
  336. package/dist/mastra/index.cjs +1 -1
  337. package/dist/mastra/index.js +1 -1
  338. package/dist/{mastra-BJ54VxOO.js → mastra-CaLISVUE.js} +16 -16
  339. package/dist/{mastra-B2-HBq1-.cjs → mastra-DWCqC_6c.cjs} +16 -16
  340. package/dist/memory/index.cjs +2 -2
  341. package/dist/memory/index.js +2 -2
  342. package/dist/{model-lzZPXaEV.cjs → model-DAcaPIyq.cjs} +1 -1
  343. package/dist/{model-cS3d5rmF.js → model-DafU-uar.js} +1 -1
  344. package/dist/{netlify-1lti1j4Z.cjs → netlify-1Nz6N3ej.cjs} +29 -13
  345. package/dist/{netlify-ClBjc0Xg.js → netlify-CUG0Ko81.js} +29 -13
  346. package/dist/notifications/index.cjs +1 -1
  347. package/dist/notifications/index.js +1 -1
  348. package/dist/processor-provider/index.cjs +1 -1
  349. package/dist/processor-provider/index.js +1 -1
  350. package/dist/processors/index.cjs +2 -2
  351. package/dist/processors/index.js +2 -2
  352. package/dist/{provider-registry-C_XQJvu2.js → provider-registry-BjBiRMhs.js} +22121 -21683
  353. package/dist/{provider-registry-C6jd3Uxi.cjs → provider-registry-D_cE6sCW.cjs} +22132 -21676
  354. package/dist/provider-registry.json +21981 -21714
  355. package/dist/{registry-generator-DBrTbThj.js → registry-generator-VDBSUg0k.js} +1 -1
  356. package/dist/{registry-generator-BYdAlox6.cjs → registry-generator-ji57sjZC.cjs} +1 -1
  357. package/dist/{rehydrate-BtwY0ima.cjs → rehydrate-BOhDMI4r.cjs} +2 -2
  358. package/dist/{rehydrate-4xHubfOY.js → rehydrate-Do67YKWz.js} +2 -2
  359. package/dist/relevance/index.cjs +2 -2
  360. package/dist/relevance/index.js +2 -2
  361. package/dist/storage/constants.cjs +1 -1
  362. package/dist/storage/constants.js +1 -1
  363. package/dist/storage/domains/knowledge/base.d.ts +11 -0
  364. package/dist/storage/domains/knowledge/inmemory.d.ts +1 -0
  365. package/dist/storage/domains/knowledge/pages-inmemory.d.ts +4 -0
  366. package/dist/storage/domains/knowledge/pages.d.ts +1 -1
  367. package/dist/storage/domains/observability/tracing.d.ts +12 -0
  368. package/dist/storage/index.cjs +4 -3
  369. package/dist/storage/index.js +4 -4
  370. package/dist/stream/index.cjs +2 -2
  371. package/dist/stream/index.js +2 -2
  372. package/dist/{stream-H_wVxqdK.js → stream-DlzW_BXE.js} +1 -1
  373. package/dist/{stream-DqKDB3nL.cjs → stream-HM3ei83E.cjs} +1 -1
  374. package/dist/test-utils/llm-mock.cjs +1 -1
  375. package/dist/test-utils/llm-mock.js +1 -1
  376. package/dist/tool-loop-agent/index.cjs +1 -1
  377. package/dist/tool-loop-agent/index.js +1 -1
  378. package/dist/{tool-loop-agent-DvZcOxWe.js → tool-loop-agent-BBlEpcl4.js} +3 -3
  379. package/dist/{tool-loop-agent-D4gSdYuN.cjs → tool-loop-agent-CLyS2mqD.cjs} +3 -3
  380. package/dist/{utils-Dd4m7z13.cjs → utils-CYmtHkJO.cjs} +1 -1
  381. package/dist/{utils-h5k_ChdS.js → utils-DlBS4OO7.js} +1 -1
  382. package/dist/utils.cjs +1 -1
  383. package/dist/utils.js +1 -1
  384. package/dist/{validate-DQB9spZ1.js → validate-C7Ltq3EW.js} +1 -1
  385. package/dist/{validate-u6_TUYSo.cjs → validate-CPda0kNf.cjs} +1 -1
  386. package/dist/vector/index.cjs +1 -1
  387. package/dist/vector/index.js +1 -1
  388. package/dist/worker/index.cjs +1 -1
  389. package/dist/worker/index.js +1 -1
  390. package/dist/{worker-0F7Nukyf.cjs → worker-BTLxhv5x.cjs} +2 -2
  391. package/dist/{worker-DmUkyJY_.js → worker-C75s75rt.js} +2 -2
  392. package/dist/{worker-DWOK2M_5.js → worker-CcLWNaev.js} +2 -2
  393. package/dist/{worker-D-cq8McN.cjs → worker-DkqCjpGQ.cjs} +2 -2
  394. package/dist/{workflow-DXE15e-w.cjs → workflow-BFlBk2d6.cjs} +3 -3
  395. package/dist/{workflow-DamOke3z.js → workflow-Dq4584lm.js} +3 -3
  396. package/dist/workflows/builder/index.cjs +1 -1
  397. package/dist/workflows/builder/index.js +1 -1
  398. package/dist/workflows/evented/index.cjs +1 -1
  399. package/dist/workflows/evented/index.js +1 -1
  400. package/dist/workflows/index.cjs +4 -4
  401. package/dist/workflows/index.js +4 -4
  402. package/dist/workspace/tools/media.d.ts +2 -2
  403. package/package.json +6 -6
  404. package/src/llm/model/provider-types.generated.d.ts +7693 -7570
@@ -4,7 +4,7 @@ const require_base = require("./base-BIzR1D3_.cjs");
4
4
  const require_error = require("./error-D90lJ6M7.cjs");
5
5
  const require_error$1 = require("./error-L1V4uUbd.cjs");
6
6
  const require_output_helpers = require("./output-helpers-D4O_oFne.cjs");
7
- const require_stream = require("./stream-DqKDB3nL.cjs");
7
+ const require_stream = require("./stream-HM3ei83E.cjs");
8
8
  const require_workflows_constants = require("./workflows/constants.cjs");
9
9
  const require_request_context = require("./request-context-D9RXYCy8.cjs");
10
10
  const require_observability = require("./observability-VaoaeadK.cjs");
@@ -12,9 +12,9 @@ const require_storage = require("./storage-CfG0I2aF.cjs");
12
12
  const require_utils = require("./utils-D-eNsgDM.cjs");
13
13
  const require_tool = require("./tool-Dn9WSDVn.cjs");
14
14
  const require_error_count = require("./error-count-DeDpeWU2.cjs");
15
- const require_utils$1 = require("./utils-Dd4m7z13.cjs");
15
+ const require_utils$1 = require("./utils-CYmtHkJO.cjs");
16
16
  const require_ee_iTj2bRDt = require("./ee-iTj2bRDt-D3-QLGDF.cjs");
17
- const require_background_tasks = require("./background-tasks-CeARf1DK.cjs");
17
+ const require_background_tasks = require("./background-tasks-DbPzYpIZ.cjs");
18
18
  const require_toolchecks = require("./toolchecks-DbBsQGHW.cjs");
19
19
  const require_stream$1 = require("./stream-BGbj9jAU.cjs");
20
20
  const require_fetchWithRetry = require("./fetchWithRetry-f5k4p7_1.cjs");
@@ -22,23 +22,23 @@ const require_utils_safe_stringify = require("./utils/safe-stringify.cjs");
22
22
  const require_deep_equal = require("./deep-equal-TMDmByBC.cjs");
23
23
  const require_dynamic_argument = require("./dynamic-argument-CUc1BBOS.cjs");
24
24
  const require_message_list = require("./message-list-C0F2sDNC.cjs");
25
- const require_llm = require("./llm-RIAYOAtD.cjs");
25
+ const require_llm = require("./llm-DqcaZBHM.cjs");
26
26
  const require_payload_transform = require("./payload-transform-CWgnsO9w.cjs");
27
27
  const require_signals = require("./signals-CWxAMEmE.cjs");
28
28
  const require_to_prompt = require("./to-prompt-CG-LyaBY.cjs");
29
29
  const require_dist = require("./dist-P2rjrlmj.cjs");
30
30
  const require_dist$1 = require("./dist-CXeCeeW7.cjs");
31
31
  const require_model = require("./model-jBymoqGa.cjs");
32
- const require_provider_registry = require("./provider-registry-C6jd3Uxi.cjs");
32
+ const require_provider_registry = require("./provider-registry-D_cE6sCW.cjs");
33
33
  const require_inmemory = require("./inmemory-Dc86VWGB.cjs");
34
- const require_model$1 = require("./model-lzZPXaEV.cjs");
34
+ const require_model$1 = require("./model-DAcaPIyq.cjs");
35
35
  const require_predicate_index = require("./predicate/index.cjs");
36
36
  const require_classifier_index = require("./classifier/index.cjs");
37
37
  const require_observability_context_storage = require("./observability/context-storage.cjs");
38
38
  const require_hooks = require("./hooks-D7VDBETj.cjs");
39
39
  const require_schedules = require("./schedules-BZS8McF7.cjs");
40
40
  const require_state_processor = require("./state-processor-DaSmhVUX.cjs");
41
- const require_constants = require("./constants-B2FVV_2e.cjs");
41
+ const require_constants = require("./constants-DPHwzvan.cjs");
42
42
  const require_signal_provider = require("./signal-provider-D9gbevHN.cjs");
43
43
  const require_slugify = require("./slugify-B_WzG9IY.cjs");
44
44
  const require_workspace = require("./workspace-BQD4tcQi.cjs");
@@ -24811,6 +24811,8 @@ const llmIterationOutputSchema = zod_v4.z.object({
24811
24811
  stepResult: llmIterationStepResultSchema,
24812
24812
  processorRetryCount: zod_v4.z.number().optional(),
24813
24813
  fallbackModelIndex: zod_v4.z.number().optional(),
24814
+ fallbackModelId: zod_v4.z.string().optional(),
24815
+ fallbackModelTriesEarlierEntries: zod_v4.z.boolean().optional(),
24814
24816
  skipUnavailableAttachments: zod_v4.z.boolean().optional(),
24815
24817
  processorRetryFeedback: zod_v4.z.string().optional(),
24816
24818
  isTaskCompleteCheckFailed: zod_v4.z.boolean().optional(),
@@ -35147,6 +35149,9 @@ var ObservabilityInMemory = class extends ObservabilityStorage {
35147
35149
  entityType: span.entityType,
35148
35150
  entityId: span.entityId,
35149
35151
  entityName: span.entityName,
35152
+ outcome: span.outcome,
35153
+ stopReason: span.stopReason,
35154
+ stopReasonContext: span.stopReasonContext,
35150
35155
  createdAt: span.createdAt,
35151
35156
  updatedAt: span.updatedAt
35152
35157
  }))
@@ -40310,12 +40315,35 @@ var KnowledgeInvalidCursorError = class extends Error {
40310
40315
  }
40311
40316
  };
40312
40317
  /**
40318
+ * A keyword search the store refuses, such as one with a word over
40319
+ * {@link KNOWLEDGE_SEARCH_MAX_WORD_LENGTH} characters. Recognise it by `name`; adapters bundle their
40320
+ * own copy.
40321
+ * @experimental
40322
+ */
40323
+ var KnowledgeInvalidSearchError = class extends Error {
40324
+ constructor(message) {
40325
+ super(message);
40326
+ this.name = "KnowledgeInvalidSearchError";
40327
+ }
40328
+ };
40329
+ /**
40313
40330
  * Keyword-search words: the query split on whitespace, lowercased, deduplicated, keeping the first
40314
40331
  * {@link KNOWLEDGE_SEARCH_MAX_WORDS}. A hit needs at least one of them (as a case-insensitive
40315
- * substring); an empty list means the search returns nothing.
40332
+ * substring); an empty list means the search returns nothing. Throws
40333
+ * {@link KnowledgeInvalidSearchError} for any word over {@link KNOWLEDGE_SEARCH_MAX_WORD_LENGTH}
40334
+ * characters rather than dropping or cutting it, which would match the wrong pages.
40316
40335
  */
40317
40336
  function knowledgeSearchWords(query) {
40318
- return [...new Set(query.toLowerCase().split(/\s+/).filter(Boolean))].slice(0, 16);
40337
+ const words = [];
40338
+ for (const raw of query.split(/\s+/)) {
40339
+ if (!raw) continue;
40340
+ const length = raw.length > 128 ? [...raw].length : raw.length;
40341
+ if (length > 128) throw new KnowledgeInvalidSearchError(`Knowledge search words can be at most 128 characters; one word has ${length}`);
40342
+ if (words.length === 16) continue;
40343
+ const word = raw.toLowerCase();
40344
+ if (!words.includes(word)) words.push(word);
40345
+ }
40346
+ return words;
40319
40347
  }
40320
40348
  /**
40321
40349
  * Points one matched search word earns on a page, by the best field it appears in: name, then
@@ -41748,6 +41776,13 @@ var InMemoryKnowledgePageStore = class {
41748
41776
  for (const [pageId, links] of this.#bodyLinks) if (links.some((link) => link.toPageId === null ? refs.has(link.ref) : targets.has(link.toPageId))) sources.push(pageId);
41749
41777
  return sources;
41750
41778
  }
41779
+ async listPageBodyLinkSourcesByRef(input) {
41780
+ const refs = new Set(input.refs);
41781
+ const targets = new Set(input.toPageIds);
41782
+ const sources = [];
41783
+ for (const [pageId, links] of this.#bodyLinks) if (links.some((link) => link.toPageId !== null && targets.has(link.toPageId) && refs.has(link.ref))) sources.push(pageId);
41784
+ return sources;
41785
+ }
41751
41786
  /** Every resolved link both of whose ends are live and readable, and not a self-link. */
41752
41787
  #visibleLinks(read, kinds) {
41753
41788
  const wanted = new Set(kinds ?? ["body", "note"]);
@@ -42349,6 +42384,9 @@ var InMemoryKnowledgeStorage = class extends KnowledgeStorage {
42349
42384
  findPagesByNames(input) {
42350
42385
  return this.#pageStore.findPagesByNames(input);
42351
42386
  }
42387
+ listPageBodyLinkSourcesByRef(input) {
42388
+ return this.#pageStore.listPageBodyLinkSourcesByRef(input);
42389
+ }
42352
42390
  findPagesByName(input) {
42353
42391
  return this.#pageStore.findPagesByName(input);
42354
42392
  }
@@ -55582,6 +55620,11 @@ async function knowledgeSubtree(storage, root) {
55582
55620
  */
55583
55621
  const MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES = 99;
55584
55622
  /**
55623
+ * Most linking pages one batched {@link repairKnowledgeLinks} re-resolves by default, in chunks of
55624
+ * {@link MAX_KNOWLEDGE_LINK_REFRESH_SOURCES}; it hands back the rest for the caller to repair later.
55625
+ */
55626
+ const MAX_KNOWLEDGE_LINK_REPAIR_SOURCES = 1e3;
55627
+ /**
55585
55628
  * A link refresh that landed but stopped at {@link MAX_KNOWLEDGE_LINK_REFRESH_SOURCES} linking pages
55586
55629
  * or {@link MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES} namesakes: the rest keep their links until they're
55587
55630
  * next written or `knowledge.reindexLinks()` runs.
@@ -55593,6 +55636,75 @@ var KnowledgeLinkRefreshIncompleteError = class extends Error {
55593
55636
  }
55594
55637
  };
55595
55638
  /**
55639
+ * The pages whose body links may resolve differently now that `affected` answer to what they do:
55640
+ * an unresolved link by a ref one of them answers to, a link resolved to one of them, and a link
55641
+ * resolved to a namesake by one of `names`. A namesake's other linkers name it by id or path, which
55642
+ * a name can't change, so they are left out (an importer re-creating a site's pages would otherwise
55643
+ * re-resolve every page linking to the old copies, on every flush). A store with
55644
+ * `listPageBodyLinkSourcesByRef` tells them apart from its link index; otherwise their bodies are
55645
+ * read once to tell, and a linker with no live page stays in: it keeps no links. `read` holds the
55646
+ * namesake linkers' pages read that way.
55647
+ */
55648
+ async function linkSources(storage, input, maxReads) {
55649
+ const own = new Set(input.affected.map((page) => page.id));
55650
+ const ids = new Set(await storage.listPageBodyLinkSources({
55651
+ refs: [...input.refs],
55652
+ toPageIds: [...own]
55653
+ }));
55654
+ const read = /* @__PURE__ */ new Map();
55655
+ const others = [...input.namesakes].filter((id) => !own.has(id));
55656
+ if (!others.length) return {
55657
+ ids: [...ids],
55658
+ read
55659
+ };
55660
+ const nameKeys = new Set([...input.names].map((name) => knowledgeLinkRefKey(name)));
55661
+ if (storage.listPageBodyLinkSourcesByRef) {
55662
+ if (!nameKeys.size) return {
55663
+ ids: [...ids],
55664
+ read
55665
+ };
55666
+ for (const id of await storage.listPageBodyLinkSourcesByRef({
55667
+ refs: [...nameKeys],
55668
+ toPageIds: others
55669
+ })) ids.add(id);
55670
+ return {
55671
+ ids: [...ids],
55672
+ read
55673
+ };
55674
+ }
55675
+ const candidates = (await storage.listPageBodyLinkSources({ toPageIds: others })).filter((id) => !ids.has(id));
55676
+ if (!candidates.length) return {
55677
+ ids: [...ids],
55678
+ read
55679
+ };
55680
+ if (candidates.length > maxReads - ids.size) {
55681
+ for (const id of candidates) ids.add(id);
55682
+ return {
55683
+ ids: [...ids],
55684
+ read
55685
+ };
55686
+ }
55687
+ for (let i = 0; i < candidates.length; i += 100) for (const page of await storage.getPages({
55688
+ ids: candidates.slice(i, i + 100),
55689
+ read: "all"
55690
+ })) read.set(page.id, page);
55691
+ for (const id of candidates) {
55692
+ const page = read.get(id);
55693
+ if (!page || page.deletedAt) {
55694
+ ids.add(id);
55695
+ continue;
55696
+ }
55697
+ for (const ref of knowledgeBodyLinkRefs(page.body).keys()) if (nameKeys.has(knowledgeLinkRefKey(ref))) {
55698
+ ids.add(id);
55699
+ break;
55700
+ }
55701
+ }
55702
+ return {
55703
+ ids: [...ids],
55704
+ read
55705
+ };
55706
+ }
55707
+ /**
55596
55708
  * Re-resolves the pages whose body links one of `pages` or names a ref one of them answers to now,
55597
55709
  * after they were created, renamed, moved, merged or deleted, in page id order up to
55598
55710
  * {@link MAX_KNOWLEDGE_LINK_REFRESH_SOURCES}. With `withDescendants`, the pages' subtrees count too
@@ -55602,36 +55714,44 @@ var KnowledgeLinkRefreshIncompleteError = class extends Error {
55602
55714
  async function refreshKnowledgeLinksTo(storage, pages, options = {}) {
55603
55715
  const affected = options.withDescendants ? (await Promise.all(pages.map((page) => knowledgeSubtree(storage, page)))).flat() : pages;
55604
55716
  const refs = /* @__PURE__ */ new Set();
55605
- const targets = new Set(affected.map((page) => page.id));
55606
55717
  const names = /* @__PURE__ */ new Set();
55607
55718
  for (const page of affected) {
55608
55719
  for (const key of await pageRefKeys(storage, page)) refs.add(key);
55609
55720
  if (!page.deletedAt) names.add(page.name);
55610
55721
  }
55611
55722
  const crowded = [];
55723
+ const namesakes = /* @__PURE__ */ new Set();
55612
55724
  for (const name of names) {
55613
- const namesakes = await storage.findPagesByName({
55725
+ const found = await storage.findPagesByName({
55614
55726
  name,
55615
55727
  read: "all",
55616
55728
  limit: 100
55617
55729
  });
55618
- if (namesakes.length > MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES) crowded.push(`"${name}"`);
55619
- for (const namesake of namesakes.slice(0, MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES)) targets.add(namesake.id);
55730
+ if (found.length > MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES) crowded.push(`"${name}"`);
55731
+ for (const namesake of found.slice(0, MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES)) namesakes.add(namesake.id);
55620
55732
  }
55621
- const sources = (await storage.listPageBodyLinkSources({
55622
- refs: [...refs],
55623
- toPageIds: [...targets]
55624
- })).sort();
55733
+ const found = await linkSources(storage, {
55734
+ refs,
55735
+ affected,
55736
+ names,
55737
+ namesakes
55738
+ }, 100);
55739
+ const sources = found.ids.sort();
55625
55740
  const crowdedError = () => new KnowledgeLinkRefreshIncompleteError(`More than ${MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES} pages are named ${crowded.join(", ")}; links to the rest were left as they were`);
55626
55741
  if (!sources.length) {
55627
55742
  if (crowded.length) throw crowdedError();
55628
55743
  return;
55629
55744
  }
55630
55745
  const batch = sources.slice(0, 100);
55631
- const live = new Map((await storage.getPages({
55632
- ids: batch,
55746
+ const toRead = batch.filter((id) => !found.read.has(id));
55747
+ const live = new Map(toRead.length ? (await storage.getPages({
55748
+ ids: toRead,
55633
55749
  read: "all"
55634
- })).map((page) => [page.id, page]));
55750
+ })).map((page) => [page.id, page]) : []);
55751
+ for (const id of batch) {
55752
+ const page = found.read.get(id);
55753
+ if (page) live.set(id, page);
55754
+ }
55635
55755
  const resolver = new BodyLinkResolver(storage);
55636
55756
  let done = 0;
55637
55757
  for (const id of batch) {
@@ -55698,8 +55818,8 @@ async function reindexKnowledgeLinks(storage) {
55698
55818
  }
55699
55819
  /**
55700
55820
  * A batched link repair that would stop at a cap the op-by-op refreshes enforce one write at a time
55701
- * (linking pages, namesakes, refs looked up, subtree size): the caller saves op by op instead, so the
55702
- * caps apply exactly as they do there.
55821
+ * (namesakes, subtree size): the caller saves op by op instead, so the caps apply exactly as they do
55822
+ * there.
55703
55823
  */
55704
55824
  var KnowledgeLinkRepairUnsupportedError = class extends Error {
55705
55825
  reason;
@@ -55715,13 +55835,19 @@ function canRepairKnowledgeLinksInBatch(storage) {
55715
55835
  }
55716
55836
  /**
55717
55837
  * Every {@link syncKnowledgePageBodyLinks} and {@link refreshKnowledgeLinksTo} of a flush, run once
55718
- * over the store as the flush left it, in a fixed number of statements: each page's links come out
55719
- * as they do when the calls run one after another after the writes. Throws
55720
- * {@link KnowledgeLinkRepairUnsupportedError}, having written nothing, when a cap could bite.
55721
- */
55722
- async function repairKnowledgeLinks(storage, repair) {
55838
+ * over the store as the flush left it, a few statements per chunk of up to
55839
+ * {@link MAX_KNOWLEDGE_LINK_REFRESH_SOURCES} pages: each page's links come out as they do when the
55840
+ * calls run one after another after the writes. Linking pages past `limit` (default
55841
+ * {@link MAX_KNOWLEDGE_LINK_REPAIR_SOURCES}), in page id order, keep their links and come back in
55842
+ * `deferred`; the synced pages are always written. Throws {@link KnowledgeLinkRepairUnsupportedError},
55843
+ * having written nothing, when a namesake or subtree cap could bite.
55844
+ */
55845
+ async function repairKnowledgeLinks(storage, repair, options = {}) {
55723
55846
  const synced = new Map(repair.synced.map((page) => [page.id, page]));
55724
- if (!synced.size && !repair.refreshed.length) return;
55847
+ if (!synced.size && !repair.refreshed.length) return {
55848
+ rewritten: 0,
55849
+ deferred: []
55850
+ };
55725
55851
  const roots = repair.refreshed.filter((item) => item.withDescendants).map((item) => item.page.id);
55726
55852
  const subtrees = roots.length ? await storage.getPageSubtrees({
55727
55853
  rootIds: [...new Set(roots)],
@@ -55741,40 +55867,51 @@ async function repairKnowledgeLinks(storage, repair) {
55741
55867
  read: "all"
55742
55868
  }) : {};
55743
55869
  const refs = /* @__PURE__ */ new Set();
55744
- const targets = new Set(affected.map((page) => page.id));
55745
55870
  const names = /* @__PURE__ */ new Set();
55746
55871
  for (const page of affected) {
55747
55872
  const parents = !page.isScope && page.key && page.parentId ? chains[page.parentId] ?? [] : [];
55748
55873
  for (const key of refKeysOf(page, parents)) refs.add(key);
55749
55874
  if (!page.deletedAt) names.add(page.name);
55750
55875
  }
55876
+ const namesakes = /* @__PURE__ */ new Set();
55751
55877
  if (names.size) {
55752
- const namesakes = await storage.findPagesByNames({
55878
+ const byName = await storage.findPagesByNames({
55753
55879
  names: [...names],
55754
55880
  read: "all",
55755
55881
  limit: 100
55756
55882
  });
55757
- for (const found of Object.values(namesakes)) {
55883
+ for (const found of Object.values(byName)) {
55758
55884
  if (found.length > MAX_KNOWLEDGE_LINK_REFRESH_NAMESAKES) throw new KnowledgeLinkRepairUnsupportedError("a name past the namesake limit");
55759
- for (const namesake of found) targets.add(namesake.id);
55885
+ for (const namesake of found) namesakes.add(namesake.id);
55760
55886
  }
55761
55887
  }
55762
- const sources = affected.length ? await storage.listPageBodyLinkSources({
55763
- refs: [...refs],
55764
- toPageIds: [...targets]
55765
- }) : [];
55766
- if (sources.length > 100) throw new KnowledgeLinkRepairUnsupportedError("linking pages past the refresh limit");
55767
- const unread = sources.filter((id) => !synced.has(id));
55768
- const live = new Map((unread.length ? await storage.getPages({
55769
- ids: unread,
55888
+ const limit = options.limit ?? 1e3;
55889
+ const found = affected.length ? await linkSources(storage, {
55890
+ refs,
55891
+ affected,
55892
+ names,
55893
+ namesakes
55894
+ }, Math.max(0, limit)) : {
55895
+ ids: [],
55896
+ read: /* @__PURE__ */ new Map()
55897
+ };
55898
+ const unread = found.ids.filter((id) => !synced.has(id)).sort();
55899
+ const now = unread.slice(0, Math.max(0, limit));
55900
+ const deferred = unread.slice(now.length);
55901
+ const toRead = now.filter((id) => !found.read.has(id));
55902
+ const live = /* @__PURE__ */ new Map();
55903
+ for (let i = 0; i < toRead.length; i += 100) for (const page of await storage.getPages({
55904
+ ids: toRead.slice(i, i + 100),
55770
55905
  read: "all"
55771
- }) : []).map((page) => [page.id, page]));
55906
+ })) live.set(page.id, page);
55907
+ for (const id of now) {
55908
+ const page = found.read.get(id);
55909
+ if (page && !page.deletedAt) live.set(id, page);
55910
+ }
55772
55911
  const rewrite = /* @__PURE__ */ new Map();
55773
- for (const id of unread) rewrite.set(id, live.get(id) ?? null);
55774
55912
  for (const [id, page] of synced) rewrite.set(id, page);
55775
- const wanted = /* @__PURE__ */ new Map();
55776
- const lookups = [];
55777
- const refreshing = new Set(sources);
55913
+ for (const id of now) rewrite.set(id, live.get(id) ?? null);
55914
+ const chunks = [[]];
55778
55915
  let looked = 0;
55779
55916
  for (const [id, page] of rewrite) {
55780
55917
  const byKey = /* @__PURE__ */ new Map();
@@ -55789,27 +55926,42 @@ async function repairKnowledgeLinks(storage, repair) {
55789
55926
  });
55790
55927
  }
55791
55928
  const entries = [...byKey];
55792
- wanted.set(id, entries);
55793
- if (page) for (const [, { ref }] of entries) lookups.push({
55794
- ref,
55795
- home: page.scopeId
55796
- });
55797
- if (refreshing.has(id)) looked += new Set(entries.map(([, { ref }]) => ref)).size;
55929
+ let chunk = chunks.at(-1);
55930
+ if (chunk.length && (chunk.length >= 100 || looked + entries.length > 1e3)) {
55931
+ chunks.push(chunk = []);
55932
+ looked = 0;
55933
+ }
55934
+ chunk.push([id, entries]);
55935
+ looked += entries.length;
55798
55936
  }
55799
- if (looked >= 1e3) throw new KnowledgeLinkRepairUnsupportedError("refs looked up past the refresh limit");
55800
- const resolved = await resolveKnowledgeBodyLinks(storage, lookups);
55801
- await storage.applyPageWrites({ writes: [...wanted].map(([pageId, entries]) => {
55802
- const home = rewrite.get(pageId)?.scopeId;
55803
- return {
55804
- op: "replace-links",
55805
- pageId,
55806
- links: entries.map(([key, { ref, count }]) => ({
55807
- ref: key,
55808
- toPageId: home === void 0 ? null : resolved.get(`${home}\u0000${ref}`) ?? null,
55809
- count
55810
- }))
55811
- };
55812
- }) });
55937
+ for (const chunk of chunks) {
55938
+ if (!chunk.length) continue;
55939
+ const lookups = [];
55940
+ for (const [id, entries] of chunk) {
55941
+ const page = rewrite.get(id);
55942
+ if (page) for (const [, { ref }] of entries) lookups.push({
55943
+ ref,
55944
+ home: page.scopeId
55945
+ });
55946
+ }
55947
+ const resolved = await resolveKnowledgeBodyLinks(storage, lookups);
55948
+ await storage.applyPageWrites({ writes: chunk.map(([pageId, entries]) => {
55949
+ const home = rewrite.get(pageId)?.scopeId;
55950
+ return {
55951
+ op: "replace-links",
55952
+ pageId,
55953
+ links: entries.map(([key, { ref, count }]) => ({
55954
+ ref: key,
55955
+ toPageId: home === void 0 ? null : resolved.get(`${home}\u0000${ref}`) ?? null,
55956
+ count
55957
+ }))
55958
+ };
55959
+ }) });
55960
+ }
55961
+ return {
55962
+ rewritten: now.length,
55963
+ deferred
55964
+ };
55813
55965
  }
55814
55966
  /** What {@link BodyLinkResolver} answers for each `(home, ref)`, keyed `home\0ref`, in a fixed number of reads. */
55815
55967
  async function resolveKnowledgeBodyLinks(storage, lookups) {
@@ -85864,7 +86016,7 @@ async function prepareForDurableExecution(options) {
85864
86016
  });
85865
86017
  let tripwireData;
85866
86018
  if (inputProcessors.length > 0) try {
85867
- const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-DqKDB3nL.cjs")).then((n) => n.runner_exports);
86019
+ const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-HM3ei83E.cjs")).then((n) => n.runner_exports);
85868
86020
  await new ProcessorRunner({
85869
86021
  inputProcessors,
85870
86022
  outputProcessors,
@@ -102901,33 +103053,56 @@ async function processOutputStream({ collectedChunks = [], tools, messageId, mes
102901
103053
  toolResultTripwire
102902
103054
  };
102903
103055
  }
102904
- function executeStreamWithFallbackModels(models, logger, startIndex = 0, throwIfInterrupted) {
103056
+ /**
103057
+ * What the next step needs to stay on the model serving this generation. A resumed run
103058
+ * resolves its models again, and the list can come back in another order: the id finds the
103059
+ * model again when the caller named it, the first one included.
103060
+ */
103061
+ function carriedFallbackModel(models, index, triesEarlierEntries) {
103062
+ if (models.length < 2) return {};
103063
+ return {
103064
+ ...index > 0 ? { fallbackModelIndex: index } : {},
103065
+ fallbackModelId: models[index]?.id,
103066
+ ...triesEarlierEntries ? { fallbackModelTriesEarlierEntries: true } : {}
103067
+ };
103068
+ }
103069
+ function carriedFallbackModelIndex(models, carried) {
103070
+ const saved = carried.fallbackModelIndex ?? 0;
103071
+ if (models[saved]?.id === carried.fallbackModelId) return saved;
103072
+ const byId = models.findIndex((candidate) => candidate.id === carried.fallbackModelId);
103073
+ return byId >= 0 ? byId : carried.fallbackModelIndex || 0;
103074
+ }
103075
+ /**
103076
+ * True when a resumed run found its model by id at another position than the one it saved: the
103077
+ * list came back in another order, so the entries now ahead of that model were not tried yet.
103078
+ */
103079
+ function resumedInAnotherOrder(models, carried) {
103080
+ const saved = carried.fallbackModelIndex ?? 0;
103081
+ if (carried.fallbackModelId === void 0 || models[saved]?.id === carried.fallbackModelId) return false;
103082
+ return models.some((candidate) => candidate.id === carried.fallbackModelId);
103083
+ }
103084
+ function executeStreamWithFallbackModels(models, logger, startIndex = 0, throwIfInterrupted, tryEntriesBeforeStart = false) {
102905
103085
  return async (callback) => {
102906
- let index = startIndex;
103086
+ const order = [...models.slice(startIndex), ...tryEntriesBeforeStart ? models.slice(0, startIndex) : []];
102907
103087
  let finalResult;
102908
- let done = false;
102909
103088
  let lastError;
102910
- for (const modelConfig of models.slice(startIndex)) {
102911
- index++;
102912
- if (done) break;
102913
- try {
102914
- finalResult = await callback(modelConfig, index === models.length);
102915
- done = true;
102916
- } catch (err) {
102917
- throwIfInterrupted?.();
102918
- if (err instanceof require_stream.TripWire) throw err;
102919
- if (require_stream.isMastraTimeoutError(err) && err.timeoutType === "total") throw err;
102920
- lastError = err;
102921
- const nextModel = models[index];
102922
- if (nextModel) logger?.warn(`Model ${modelConfig.model.modelId} failed; falling back to ${nextModel.model.modelId}`, {
102923
- error: err,
102924
- modelId: modelConfig.model.modelId,
102925
- nextModelId: nextModel.model.modelId,
102926
- attempt: index,
102927
- totalModels: models.length
102928
- });
102929
- else logger?.error(`Error executing model ${modelConfig.model.modelId}`, err);
102930
- }
103089
+ for (const [attempt, modelConfig] of order.entries()) try {
103090
+ finalResult = await callback(modelConfig, attempt === order.length - 1);
103091
+ break;
103092
+ } catch (err) {
103093
+ throwIfInterrupted?.();
103094
+ if (err instanceof require_stream.TripWire) throw err;
103095
+ if (require_stream.isMastraTimeoutError(err) && err.timeoutType === "total") throw err;
103096
+ lastError = err;
103097
+ const nextModel = order[attempt + 1];
103098
+ if (nextModel) logger?.warn(`Model ${modelConfig.model.modelId} failed; falling back to ${nextModel.model.modelId}`, {
103099
+ error: err,
103100
+ modelId: modelConfig.model.modelId,
103101
+ nextModelId: nextModel.model.modelId,
103102
+ attempt: attempt + 1,
103103
+ totalModels: order.length
103104
+ });
103105
+ else logger?.error(`Error executing model ${modelConfig.model.modelId}`, err);
102931
103106
  }
102932
103107
  if (typeof finalResult === "undefined") {
102933
103108
  const fatalError = lastError ?? /* @__PURE__ */ new Error("Exhausted all fallback models without receiving a result.");
@@ -103194,7 +103369,8 @@ function createLLMExecutionStep({ models, _internal, messageId: messageIdPassed,
103194
103369
  let warnings;
103195
103370
  let request;
103196
103371
  let rawResponse;
103197
- let activeFallbackModelIndex = inputData.fallbackModelIndex || 0;
103372
+ let activeFallbackModelIndex = carriedFallbackModelIndex(models, inputData);
103373
+ const triesEarlierEntries = inputData.fallbackModelTriesEarlierEntries === true || resumedInAnotherOrder(models, inputData);
103198
103374
  let executedStepModel;
103199
103375
  let terminalInputStepFailure;
103200
103376
  let materializeFailedAttempt;
@@ -103206,8 +103382,8 @@ function createLLMExecutionStep({ models, _internal, messageId: messageIdPassed,
103206
103382
  logger
103207
103383
  });
103208
103384
  let settleRequest = () => {};
103209
- const execution = await executeStreamWithFallbackModels(models, logger, activeFallbackModelIndex, throwIfInterrupted)(async (modelConfig, isLastModel) => {
103210
- activeFallbackModelIndex = models.findIndex((candidate) => candidate.id === modelConfig.id);
103385
+ const execution = await executeStreamWithFallbackModels(models, logger, activeFallbackModelIndex, throwIfInterrupted, triesEarlierEntries)(async (modelConfig, isLastModel) => {
103386
+ activeFallbackModelIndex = models.indexOf(modelConfig);
103211
103387
  materializeFailedAttempt = void 0;
103212
103388
  settleRequest();
103213
103389
  settleRequest = require_utils$1.startRunStep(options?.stepOwner ?? options?.abortSignal);
@@ -104081,7 +104257,7 @@ function createLLMExecutionStep({ models, _internal, messageId: messageIdPassed,
104081
104257
  nonUser: []
104082
104258
  },
104083
104259
  processorRetryCount: inputData.processorRetryCount,
104084
- ...activeFallbackModelIndex > 0 ? { fallbackModelIndex: activeFallbackModelIndex } : {},
104260
+ ...carriedFallbackModel(models, activeFallbackModelIndex, triesEarlierEntries),
104085
104261
  ...inputData.skipUnavailableAttachments ? { skipUnavailableAttachments: true } : {}
104086
104262
  };
104087
104263
  if (!aborted) return result;
@@ -104294,7 +104470,7 @@ function createLLMExecutionStep({ models, _internal, messageId: messageIdPassed,
104294
104470
  },
104295
104471
  messages,
104296
104472
  processorRetryCount: nextProcessorRetryCount,
104297
- ...activeFallbackModelIndex > 0 ? { fallbackModelIndex: activeFallbackModelIndex } : {},
104473
+ ...carriedFallbackModel(models, activeFallbackModelIndex, triesEarlierEntries),
104298
104474
  ...skipUnavailableAttachments ? { skipUnavailableAttachments } : {}
104299
104475
  };
104300
104476
  }
@@ -104476,7 +104652,6 @@ function createLLMExecutionStep({ models, _internal, messageId: messageIdPassed,
104476
104652
  nonUser: messageList.get.response.aiV5.model()
104477
104653
  };
104478
104654
  const stepReason = shouldRetry ? "retry" : tripwireTriggered ? "tripwire" : hasErrored ? "error" : finishReason;
104479
- const nextFallbackModelIndex = shouldContinue ? activeFallbackModelIndex : 0;
104480
104655
  cleanupProviderToolSpans(!shouldContinue || shouldRetry);
104481
104656
  const nextProcessorRetryCount = shouldRetry ? currentProcessorRetryCount + 1 : 0;
104482
104657
  return {
@@ -104510,7 +104685,7 @@ function createLLMExecutionStep({ models, _internal, messageId: messageIdPassed,
104510
104685
  messages,
104511
104686
  processorRetryCount: nextProcessorRetryCount,
104512
104687
  processorRetryFeedback: retryFeedbackText,
104513
- ...nextFallbackModelIndex > 0 ? { fallbackModelIndex: nextFallbackModelIndex } : {}
104688
+ ...shouldContinue ? carriedFallbackModel(models, activeFallbackModelIndex, triesEarlierEntries) : {}
104514
104689
  };
104515
104690
  }
104516
104691
  });
@@ -115856,6 +116031,12 @@ Object.defineProperty(exports, "KnowledgeInvalidCursorError", {
115856
116031
  return KnowledgeInvalidCursorError;
115857
116032
  }
115858
116033
  });
116034
+ Object.defineProperty(exports, "KnowledgeInvalidSearchError", {
116035
+ enumerable: true,
116036
+ get: function() {
116037
+ return KnowledgeInvalidSearchError;
116038
+ }
116039
+ });
115859
116040
  Object.defineProperty(exports, "KnowledgeLinkRefreshIncompleteError", {
115860
116041
  enumerable: true,
115861
116042
  get: function() {
@@ -115952,6 +116133,12 @@ Object.defineProperty(exports, "MAX_FS_SUBAGENT_DEPTH", {
115952
116133
  return MAX_FS_SUBAGENT_DEPTH;
115953
116134
  }
115954
116135
  });
116136
+ Object.defineProperty(exports, "MAX_KNOWLEDGE_LINK_REPAIR_SOURCES", {
116137
+ enumerable: true,
116138
+ get: function() {
116139
+ return MAX_KNOWLEDGE_LINK_REPAIR_SOURCES;
116140
+ }
116141
+ });
115955
116142
  Object.defineProperty(exports, "MAX_KNOWLEDGE_MOVE_PAGES", {
115956
116143
  enumerable: true,
115957
116144
  get: function() {