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

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 (368) hide show
  1. package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +49 -0
  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/session.d.ts +11 -1
  11. package/dist/{agent-controller--gKWI81G.js → agent-controller-BrRzZy4-.js} +21 -12
  12. package/dist/{agent-controller-BolLBwDm.cjs → agent-controller-DKI-d-np.cjs} +21 -12
  13. package/dist/background-tasks/index.cjs +1 -1
  14. package/dist/background-tasks/index.js +1 -1
  15. package/dist/{background-tasks-CgzXjBfE.js → background-tasks-CDP3Pgeu.js} +1 -1
  16. package/dist/{background-tasks-DYtlijQ1.cjs → background-tasks-CDgdfRmB.cjs} +1 -1
  17. package/dist/browser/index.cjs +1 -1
  18. package/dist/browser/index.js +1 -1
  19. package/dist/{builder-Dz-g-9CZ.cjs → builder-Bs4CtyqT.cjs} +2 -2
  20. package/dist/{builder-emNPaIaC.js → builder-DuT0Iqb5.js} +2 -2
  21. package/dist/capabilities/302ai.json +201 -201
  22. package/dist/capabilities/abliteratedllm.json +38 -38
  23. package/dist/capabilities/abliteration-ai.json +4 -4
  24. package/dist/capabilities/above.json +19 -19
  25. package/dist/capabilities/adaption.json +13 -13
  26. package/dist/capabilities/adzuki.json +30 -30
  27. package/dist/capabilities/agentrouter.json +12 -12
  28. package/dist/capabilities/agnes.json +2 -2
  29. package/dist/capabilities/ai-router.json +4 -4
  30. package/dist/capabilities/aiand.json +23 -23
  31. package/dist/capabilities/aigrow.json +9 -9
  32. package/dist/capabilities/aimlapi.json +153 -153
  33. package/dist/capabilities/aipg.json +2 -2
  34. package/dist/capabilities/aixy.json +22 -22
  35. package/dist/capabilities/aki-io.json +10 -10
  36. package/dist/capabilities/alibaba-cn.json +99 -99
  37. package/dist/capabilities/alibaba-coding-plan-cn.json +6 -6
  38. package/dist/capabilities/alibaba-coding-plan.json +6 -6
  39. package/dist/capabilities/alibaba-token-plan-cn.json +51 -51
  40. package/dist/capabilities/alibaba-token-plan.json +52 -52
  41. package/dist/capabilities/alibaba.json +73 -73
  42. package/dist/capabilities/ambient.json +17 -17
  43. package/dist/capabilities/amd.json +10 -10
  44. package/dist/capabilities/anthropic.json +41 -41
  45. package/dist/capabilities/anyapi.json +47 -47
  46. package/dist/capabilities/apiko.json +4 -4
  47. package/dist/capabilities/arcee.json +11 -11
  48. package/dist/capabilities/augure.json +6 -6
  49. package/dist/capabilities/auriko.json +18 -18
  50. package/dist/capabilities/bailing.json +4 -4
  51. package/dist/capabilities/baseten.json +33 -33
  52. package/dist/capabilities/bee.json +5 -5
  53. package/dist/capabilities/berget.json +6 -6
  54. package/dist/capabilities/bothub.json +10 -10
  55. package/dist/capabilities/boundless.json +34 -34
  56. package/dist/capabilities/bumo.json +43 -43
  57. package/dist/capabilities/byteplus.json +31 -31
  58. package/dist/capabilities/cheapaimodel.json +5 -5
  59. package/dist/capabilities/cheapest-token.json +27 -27
  60. package/dist/capabilities/chutes.json +10 -10
  61. package/dist/capabilities/clarifai.json +2 -2
  62. package/dist/capabilities/cline-pass.json +37 -37
  63. package/dist/capabilities/cloudcode.json +8 -8
  64. package/dist/capabilities/cloudferro-sherlock.json +4 -4
  65. package/dist/capabilities/cloudflare-workers-ai.json +17 -17
  66. package/dist/capabilities/commandcode.json +151 -151
  67. package/dist/capabilities/concentrate.json +277 -269
  68. package/dist/capabilities/cortecs.json +108 -108
  69. package/dist/capabilities/crossmodel.json +172 -172
  70. package/dist/capabilities/crusoe.json +16 -16
  71. package/dist/capabilities/daoxe.json +8 -8
  72. package/dist/capabilities/databricks.json +128 -128
  73. package/dist/capabilities/deepinfra.json +97 -91
  74. package/dist/capabilities/deepseek.json +3 -3
  75. package/dist/capabilities/digitalocean.json +113 -113
  76. package/dist/capabilities/dothoosh.json +23 -23
  77. package/dist/capabilities/doubleword.json +27 -27
  78. package/dist/capabilities/edenai.json +279 -279
  79. package/dist/capabilities/empiriolabs.json +160 -160
  80. package/dist/capabilities/engy.json +20 -20
  81. package/dist/capabilities/entrim.json +8 -8
  82. package/dist/capabilities/evroc.json +18 -18
  83. package/dist/capabilities/ezkielyna.json +11 -11
  84. package/dist/capabilities/fastrouter.json +87 -87
  85. package/dist/capabilities/fireworks-ai.json +83 -83
  86. package/dist/capabilities/freemodel.json +19 -19
  87. package/dist/capabilities/friendli.json +7 -7
  88. package/dist/capabilities/frogbot.json +88 -88
  89. package/dist/capabilities/gisoo.json +18 -18
  90. package/dist/capabilities/gmicloud.json +20 -20
  91. package/dist/capabilities/google.json +55 -55
  92. package/dist/capabilities/graphn.json +6 -6
  93. package/dist/capabilities/greenpt.json +34 -34
  94. package/dist/capabilities/helicone.json +81 -81
  95. package/dist/capabilities/hetzner.json +5 -5
  96. package/dist/capabilities/hopper.json +2 -2
  97. package/dist/capabilities/hostinger-router.json +10 -10
  98. package/dist/capabilities/hpc-ai.json +11 -11
  99. package/dist/capabilities/huawei-maas.json +15 -15
  100. package/dist/capabilities/hubris.json +31 -31
  101. package/dist/capabilities/huggingface.json +93 -85
  102. package/dist/capabilities/humain.json +2 -2
  103. package/dist/capabilities/hyper.json +27 -27
  104. package/dist/capabilities/impossibl.json +165 -165
  105. package/dist/capabilities/inception.json +3 -3
  106. package/dist/capabilities/inceptron.json +8 -8
  107. package/dist/capabilities/inco.json +5 -5
  108. package/dist/capabilities/infer.json +13 -13
  109. package/dist/capabilities/inferall.json +6 -6
  110. package/dist/capabilities/inference-coop.json +15 -15
  111. package/dist/capabilities/inferenceapis.json +20 -20
  112. package/dist/capabilities/inferris.json +3 -3
  113. package/dist/capabilities/infersia.json +8 -8
  114. package/dist/capabilities/infomaniak.json +4 -4
  115. package/dist/capabilities/io-net.json +5 -5
  116. package/dist/capabilities/iteracompute.json +29 -29
  117. package/dist/capabilities/jad-ai.json +3 -3
  118. package/dist/capabilities/jalapeno.json +11 -11
  119. package/dist/capabilities/jiekou.json +61 -61
  120. package/dist/capabilities/joingonka.json +4 -4
  121. package/dist/capabilities/jzstoken.json +57 -57
  122. package/dist/capabilities/keln.json +23 -23
  123. package/dist/capabilities/kenari.json +121 -121
  124. package/dist/capabilities/kilo.json +615 -615
  125. package/dist/capabilities/kimi-code-plan-cn.json +6 -6
  126. package/dist/capabilities/kimi-code-plan-global.json +6 -6
  127. package/dist/capabilities/kitani.json +4 -4
  128. package/dist/capabilities/klavo.json +13 -13
  129. package/dist/capabilities/korouter.json +29 -29
  130. package/dist/capabilities/kunavo.json +2 -2
  131. package/dist/capabilities/liquid.json +10 -10
  132. package/dist/capabilities/lithosai.json +3 -3
  133. package/dist/capabilities/llmgateway-providers.json +926 -926
  134. package/dist/capabilities/llmgateway.json +330 -330
  135. package/dist/capabilities/llmtr.json +26 -26
  136. package/dist/capabilities/logits.json +2 -2
  137. package/dist/capabilities/longcat.json +2 -2
  138. package/dist/capabilities/lowrouter.json +65 -65
  139. package/dist/capabilities/lyceum.json +8 -8
  140. package/dist/capabilities/melious.json +9 -9
  141. package/dist/capabilities/merge-gateway.json +269 -269
  142. package/dist/capabilities/meta.json +8 -8
  143. package/dist/capabilities/mistral.json +19 -19
  144. package/dist/capabilities/mixlayer.json +4 -4
  145. package/dist/capabilities/modal.json +11 -11
  146. package/dist/capabilities/model-oracle-ai.json +24 -24
  147. package/dist/capabilities/modelis.json +23 -23
  148. package/dist/capabilities/modelscope.json +2 -2
  149. package/dist/capabilities/modular.json +13 -13
  150. package/dist/capabilities/moneo.json +8 -8
  151. package/dist/capabilities/moonshotai-cn.json +6 -6
  152. package/dist/capabilities/moonshotai.json +6 -6
  153. package/dist/capabilities/morph.json +15 -15
  154. package/dist/capabilities/munito-eu.json +8 -8
  155. package/dist/capabilities/munito.json +10 -10
  156. package/dist/capabilities/nan.json +28 -28
  157. package/dist/capabilities/nano-gpt.json +578 -578
  158. package/dist/capabilities/nearai.json +106 -106
  159. package/dist/capabilities/nebius.json +32 -32
  160. package/dist/capabilities/neon.json +121 -121
  161. package/dist/capabilities/neuralwatt.json +40 -40
  162. package/dist/capabilities/nokeep.json +4 -4
  163. package/dist/capabilities/novita-ai.json +148 -148
  164. package/dist/capabilities/nvidia.json +44 -44
  165. package/dist/capabilities/oathbreaker.json +5 -5
  166. package/dist/capabilities/obscurify.json +24 -24
  167. package/dist/capabilities/oci.json +6 -6
  168. package/dist/capabilities/ofox.json +349 -349
  169. package/dist/capabilities/ollama-cloud.json +54 -54
  170. package/dist/capabilities/openai.json +59 -59
  171. package/dist/capabilities/opencode-go.json +84 -84
  172. package/dist/capabilities/openrouter.json +538 -539
  173. package/dist/capabilities/opper.json +25 -25
  174. package/dist/capabilities/orcarouter.json +206 -206
  175. package/dist/capabilities/outerlabs.json +28 -28
  176. package/dist/capabilities/ovhcloud.json +19 -19
  177. package/dist/capabilities/pareto.json +5 -5
  178. package/dist/capabilities/pendra.json +4 -4
  179. package/dist/capabilities/perplexity-agent.json +62 -62
  180. package/dist/capabilities/phala.json +20 -20
  181. package/dist/capabilities/pioneer.json +32 -32
  182. package/dist/capabilities/poe.json +131 -131
  183. package/dist/capabilities/poolside.json +2 -2
  184. package/dist/capabilities/powerspring.json +11 -11
  185. package/dist/capabilities/primalabs.json +7 -7
  186. package/dist/capabilities/prime.json +112 -112
  187. package/dist/capabilities/privatemode-ai.json +11 -11
  188. package/dist/capabilities/proxystacks.json +6 -6
  189. package/dist/capabilities/qiniu-ai.json +14 -14
  190. package/dist/capabilities/refuseless.json +10 -10
  191. package/dist/capabilities/regolo-ai.json +5 -5
  192. package/dist/capabilities/requesty.json +259 -200
  193. package/dist/capabilities/ruapi.json +16 -16
  194. package/dist/capabilities/runcrate.json +15 -15
  195. package/dist/capabilities/runinfra.json +19 -19
  196. package/dist/capabilities/sakana.json +7 -7
  197. package/dist/capabilities/sandbase.json +21 -21
  198. package/dist/capabilities/sarvam.json +11 -11
  199. package/dist/capabilities/scaleway.json +16 -16
  200. package/dist/capabilities/scnet-token-plan.json +10 -10
  201. package/dist/capabilities/scx-ai.json +21 -21
  202. package/dist/capabilities/sensenova.json +15 -15
  203. package/dist/capabilities/siliconflow-cn.json +58 -58
  204. package/dist/capabilities/siliconflow.json +61 -61
  205. package/dist/capabilities/snowflake-cortex.json +18 -18
  206. package/dist/capabilities/sokkan.json +5 -5
  207. package/dist/capabilities/sparrowcodes.json +20 -20
  208. package/dist/capabilities/standardcompute.json +95 -95
  209. package/dist/capabilities/steadyrouter.json +33 -33
  210. package/dist/capabilities/stepfun-ai-step-plan.json +4 -4
  211. package/dist/capabilities/stepfun-ai.json +4 -4
  212. package/dist/capabilities/stepfun-step-plan.json +4 -4
  213. package/dist/capabilities/stepfun.json +4 -4
  214. package/dist/capabilities/stepping-stone.json +17 -17
  215. package/dist/capabilities/superbot-gg.json +4 -4
  216. package/dist/capabilities/synthetic.json +11 -11
  217. package/dist/capabilities/synthorai.json +23 -23
  218. package/dist/capabilities/teamorouter.json +22 -22
  219. package/dist/capabilities/teapot-router.json +15 -15
  220. package/dist/capabilities/tencent-token-plan-intl.json +22 -22
  221. package/dist/capabilities/tencent-token-plan.json +43 -43
  222. package/dist/capabilities/tencent-tokenhub.json +47 -47
  223. package/dist/capabilities/tensorx.json +37 -37
  224. package/dist/capabilities/tenstorrent.json +8 -8
  225. package/dist/capabilities/the-grid-ai.json +30 -30
  226. package/dist/capabilities/thinkingmachines.json +78 -78
  227. package/dist/capabilities/tinfoil.json +9 -9
  228. package/dist/capabilities/togetherai.json +55 -55
  229. package/dist/capabilities/tokengo.json +19 -19
  230. package/dist/capabilities/tokenify.json +2 -2
  231. package/dist/capabilities/trustedrouter.json +6 -6
  232. package/dist/capabilities/trustedtokens.json +17 -17
  233. package/dist/capabilities/umans-ai-coding-plan.json +14 -14
  234. package/dist/capabilities/umans-ai.json +10 -10
  235. package/dist/capabilities/uncensuredai.json +4 -4
  236. package/dist/capabilities/unrestricted.json +6 -6
  237. package/dist/capabilities/uplinkswitch.json +21 -21
  238. package/dist/capabilities/upstage.json +6 -6
  239. package/dist/capabilities/vancine.json +16 -16
  240. package/dist/capabilities/vercel.json +578 -578
  241. package/dist/capabilities/vivgrid.json +86 -86
  242. package/dist/capabilities/volcengine-coding-plan.json +26 -26
  243. package/dist/capabilities/volcengine.json +23 -23
  244. package/dist/capabilities/vultr.json +34 -34
  245. package/dist/capabilities/wafer.ai.json +17 -17
  246. package/dist/capabilities/wallaby.json +2 -2
  247. package/dist/capabilities/wally.json +13 -13
  248. package/dist/capabilities/wandb.json +21 -21
  249. package/dist/capabilities/watt.json +26 -26
  250. package/dist/capabilities/xai.json +6 -6
  251. package/dist/capabilities/xiaomi-token-plan-ams.json +2 -2
  252. package/dist/capabilities/xiaomi-token-plan-cn.json +2 -2
  253. package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -2
  254. package/dist/capabilities/xiaomi.json +3 -3
  255. package/dist/capabilities/xpersona.json +12 -12
  256. package/dist/capabilities/xxapi.json +28 -28
  257. package/dist/capabilities/zai-coding-plan.json +18 -18
  258. package/dist/capabilities/zai.json +30 -30
  259. package/dist/capabilities/zenifra.json +31 -31
  260. package/dist/capabilities/zenmux.json +202 -202
  261. package/dist/capabilities/zerogpu.json +8 -8
  262. package/dist/capabilities/zhipuai-coding-plan.json +6 -6
  263. package/dist/capabilities/zhipuai.json +28 -28
  264. package/dist/capabilities/zro.json +4 -4
  265. package/dist/channels/index.cjs +2 -2
  266. package/dist/channels/index.js +2 -2
  267. package/dist/{channels-BVnDIsZS.cjs → channels-Bkd_v8M1.cjs} +1 -1
  268. package/dist/{channels-CndspFXP.js → channels-CkRMEIQ6.js} +1 -1
  269. package/dist/coding-agent/index.cjs +1 -1
  270. package/dist/coding-agent/index.js +1 -1
  271. package/dist/datasets/index.cjs +2 -2
  272. package/dist/datasets/index.js +2 -2
  273. package/dist/docs/SKILL.md +1 -1
  274. package/dist/docs/assets/SOURCE_MAP.json +570 -570
  275. package/dist/docs/references/reference-agent-controller-session.md +29 -1
  276. package/dist/evals/index.cjs +1 -1
  277. package/dist/evals/index.js +1 -1
  278. package/dist/evals/scoreTraces/index.cjs +1 -1
  279. package/dist/evals/scoreTraces/index.js +1 -1
  280. package/dist/harness/index.cjs +1 -1
  281. package/dist/harness/index.js +1 -1
  282. package/dist/index.cjs +1 -1
  283. package/dist/index.js +1 -1
  284. package/dist/knowledge/importers/overlay.d.ts +138 -0
  285. package/dist/knowledge/importers/sink.d.ts +6 -0
  286. package/dist/knowledge/importers/types.d.ts +5 -0
  287. package/dist/knowledge/index.cjs +1412 -139
  288. package/dist/knowledge/index.js +1412 -139
  289. package/dist/knowledge/links.d.ts +27 -0
  290. package/dist/llm/index.cjs +3 -3
  291. package/dist/llm/index.js +3 -3
  292. package/dist/llm/model/provider-types.generated.d.ts +7619 -7605
  293. package/dist/{llm-B1semiTO.cjs → llm-DAw2eouV.cjs} +2 -2
  294. package/dist/{llm-CytL7cpw.js → llm-DFT5EKp4.js} +2 -2
  295. package/dist/loop/index.cjs +2 -2
  296. package/dist/loop/index.js +2 -2
  297. package/dist/{manager-DnTzA9GL.js → manager-DiDnvKLM.js} +2 -2
  298. package/dist/{manager-BwyfS4ha.cjs → manager-hxzEe4U5.cjs} +2 -2
  299. package/dist/mastra/index.cjs +1 -1
  300. package/dist/mastra/index.js +1 -1
  301. package/dist/{mastra-Dj35Lj_J.cjs → mastra-1diaq68N.cjs} +16 -16
  302. package/dist/{mastra-DTkZPpch.js → mastra-BPaPxG5t.js} +16 -16
  303. package/dist/memory/index.cjs +2 -2
  304. package/dist/memory/index.js +2 -2
  305. package/dist/{model-DyQ07rPH.js → model-CUBZjm0T.js} +1 -1
  306. package/dist/{model-eDfetuno.cjs → model-DSMHJM3c.cjs} +1 -1
  307. package/dist/{netlify-BC4v7Ufv.cjs → netlify-C21T9ozJ.cjs} +1 -1
  308. package/dist/{netlify-BUvdxfHe.js → netlify-D1BKjns0.js} +1 -1
  309. package/dist/notifications/index.cjs +1 -1
  310. package/dist/notifications/index.js +1 -1
  311. package/dist/processor-provider/index.cjs +1 -1
  312. package/dist/processor-provider/index.js +1 -1
  313. package/dist/processors/index.cjs +2 -2
  314. package/dist/processors/index.js +2 -2
  315. package/dist/{provider-registry-CP_5SNiw.js → provider-registry-BAlFFX5o.js} +22725 -22697
  316. package/dist/{provider-registry-Bn01gq9y.cjs → provider-registry-ChojUVJa.cjs} +22725 -22697
  317. package/dist/provider-registry.json +22472 -22444
  318. package/dist/{registry-generator-CDPyxbzt.js → registry-generator-BbWSH6W4.js} +1 -1
  319. package/dist/{registry-generator-CNFKGRFQ.cjs → registry-generator-CAUL9Hek.cjs} +1 -1
  320. package/dist/{rehydrate-DExpzlNS.cjs → rehydrate-0xSq47n9.cjs} +2 -2
  321. package/dist/{rehydrate-CnGNY2zq.js → rehydrate-CzUnNFU6.js} +2 -2
  322. package/dist/relevance/index.cjs +2 -2
  323. package/dist/relevance/index.js +2 -2
  324. package/dist/{run-registry-CibQoN6K.cjs → run-registry-CrTsH9iL.cjs} +403 -11
  325. package/dist/{run-registry-BL_kKvFE.js → run-registry-DJT02z_9.js} +380 -12
  326. package/dist/storage/domains/knowledge/base.d.ts +86 -1
  327. package/dist/storage/domains/knowledge/importers-inmemory.d.ts +9 -0
  328. package/dist/storage/domains/knowledge/importers.d.ts +31 -0
  329. package/dist/storage/domains/knowledge/inmemory.d.ts +7 -0
  330. package/dist/storage/domains/knowledge/pages-inmemory.d.ts +31 -1
  331. package/dist/storage/domains/knowledge/pages.d.ts +74 -0
  332. package/dist/storage/index.cjs +2 -2
  333. package/dist/storage/index.js +2 -2
  334. package/dist/storage/types.d.ts +6 -0
  335. package/dist/stream/index.cjs +2 -2
  336. package/dist/stream/index.js +2 -2
  337. package/dist/{stream-1DGoEkG2.js → stream-CG9OooRx.js} +1 -1
  338. package/dist/{stream-D_7tMaJe.cjs → stream-CMKRczs4.cjs} +1 -1
  339. package/dist/test-utils/llm-mock.cjs +1 -1
  340. package/dist/test-utils/llm-mock.js +1 -1
  341. package/dist/tool-loop-agent/index.cjs +1 -1
  342. package/dist/tool-loop-agent/index.js +1 -1
  343. package/dist/{tool-loop-agent-CLB1r3X3.cjs → tool-loop-agent-14o3Z1qo.cjs} +3 -3
  344. package/dist/{tool-loop-agent-BXya_RYj.js → tool-loop-agent-Bi6z_q7o.js} +3 -3
  345. package/dist/{utils-B-KOMA_Q.cjs → utils-DkvbP8EA.cjs} +1 -1
  346. package/dist/{utils-C55ZdVaj.js → utils-Fag7YDBU.js} +1 -1
  347. package/dist/utils.cjs +1 -1
  348. package/dist/utils.js +1 -1
  349. package/dist/{validate-CmZhnsmX.cjs → validate-Bhrlve2E.cjs} +1 -1
  350. package/dist/{validate-BDfYr72F.js → validate-DLER0nlQ.js} +1 -1
  351. package/dist/vector/index.cjs +1 -1
  352. package/dist/vector/index.js +1 -1
  353. package/dist/worker/index.cjs +1 -1
  354. package/dist/worker/index.js +1 -1
  355. package/dist/{worker-D2B-x7Le.cjs → worker-0gczpztM.cjs} +2 -2
  356. package/dist/{worker-BoybIUTI.cjs → worker-BwJyrFQN.cjs} +2 -2
  357. package/dist/{worker-BG1rw_dg.js → worker-D-em3hyS.js} +2 -2
  358. package/dist/{worker-CuK2RaC0.js → worker-leYV1Y91.js} +2 -2
  359. package/dist/{workflow-CTKqeRXU.cjs → workflow-DWdcEcxw.cjs} +3 -3
  360. package/dist/{workflow-Bt09PcH1.js → workflow-FikHVwog.js} +3 -3
  361. package/dist/workflows/builder/index.cjs +1 -1
  362. package/dist/workflows/builder/index.js +1 -1
  363. package/dist/workflows/evented/index.cjs +1 -1
  364. package/dist/workflows/evented/index.js +1 -1
  365. package/dist/workflows/index.cjs +4 -4
  366. package/dist/workflows/index.js +4 -4
  367. package/package.json +8 -8
  368. package/src/llm/model/provider-types.generated.d.ts +7619 -7605
@@ -1,4 +1,4 @@
1
- import { _ as getCapabilityFileName, g as shouldEnableGateway, m as getGatewayId } from "./netlify-BUvdxfHe.js";
1
+ import { _ as getCapabilityFileName, g as shouldEnableGateway, m as getGatewayId } from "./netlify-D1BKjns0.js";
2
2
  import path from "path";
3
3
  import fs from "fs/promises";
4
4
  // src/llm/model/registry-generator.ts
@@ -1,5 +1,5 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-BrhgMLW6.cjs");
2
- const require_netlify = require("./netlify-BC4v7Ufv.cjs");
2
+ const require_netlify = require("./netlify-C21T9ozJ.cjs");
3
3
  let path = require("path");
4
4
  path = require_rolldown_runtime.__toESM(path, 1);
5
5
  let fs_promises = require("fs/promises");
@@ -1,6 +1,6 @@
1
- const require_run_registry = require("./run-registry-CibQoN6K.cjs");
1
+ const require_run_registry = require("./run-registry-CrTsH9iL.cjs");
2
2
  const require_predicate_index = require("./predicate/index.cjs");
3
- const require_validate = require("./validate-CmZhnsmX.cjs");
3
+ const require_validate = require("./validate-Bhrlve2E.cjs");
4
4
  let _mastra_schema_compat_schema = require("@mastra/schema-compat/schema");
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
- import { Ac as predicateToCondition, Bs as cloneWorkflow, Hs as createWorkflow, Qc as createStepFromTool, Vs as createEventedWorkflow, Xc as createStepFromAgent, fl as getSingleStepEntryId, kc as mapVariable } from "./run-registry-BL_kKvFE.js";
1
+ import { Gs as createEventedWorkflow, Ks as createWorkflow, Nc as mapVariable, Pc as predicateToCondition, Ws as cloneWorkflow, el as createStepFromAgent, gl as getSingleStepEntryId, nl as createStepFromTool } from "./run-registry-DJT02z_9.js";
2
2
  import { derivePredicateLabel } from "./predicate/index.js";
3
- import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-BDfYr72F.js";
3
+ import { a as jsonSchemaToZod, l as parseMapConfig } from "./validate-DLER0nlQ.js";
4
4
  import { standardSchemaToJSONSchema, toStandardSchema } from "./schema/index.js";
5
5
  // src/workflows/dynamic/serialize.ts
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_run_registry = require("../run-registry-CibQoN6K.cjs");
3
- const require_stream = require("../stream-D_7tMaJe.cjs");
2
+ const require_run_registry = require("../run-registry-CrTsH9iL.cjs");
3
+ const require_stream = require("../stream-CMKRczs4.cjs");
4
4
  // src/relevance/relevance-score-provider.ts
5
5
  function createSimilarityPrompt(query, text) {
6
6
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -1,5 +1,5 @@
1
- import { F as Agent } from "../run-registry-BL_kKvFE.js";
2
- import { ln as isSupportedLanguageModel } from "../stream-1DGoEkG2.js";
1
+ import { F as Agent } from "../run-registry-DJT02z_9.js";
2
+ import { ln as isSupportedLanguageModel } from "../stream-CG9OooRx.js";
3
3
  // src/relevance/relevance-score-provider.ts
4
4
  function createSimilarityPrompt(query, text) {
5
5
  return `Rate the semantic similarity between the following the query and the text on a scale from 0 to 1 (decimals allowed), where 1 means exactly the same meaning and 0 means completely different:
@@ -4,14 +4,14 @@ const require_base = require("./base-BIzR1D3_.cjs");
4
4
  const require_observability = require("./observability-B0R_D1PZ.cjs");
5
5
  const require_error = require("./error-D90lJ6M7.cjs");
6
6
  const require_error$1 = require("./error-L1V4uUbd.cjs");
7
- const require_stream = require("./stream-D_7tMaJe.cjs");
7
+ const require_stream = require("./stream-CMKRczs4.cjs");
8
8
  const require_request_context = require("./request-context-D9RXYCy8.cjs");
9
9
  const require_output_helpers = require("./output-helpers-DgsH4aTb.cjs");
10
10
  const require_message_list = require("./message-list-vR3uLAHL.cjs");
11
11
  const require_storage = require("./storage-CfG0I2aF.cjs");
12
12
  const require_utils = require("./utils-D-eNsgDM.cjs");
13
13
  const require_error_count = require("./error-count-DeDpeWU2.cjs");
14
- const require_llm = require("./llm-B1semiTO.cjs");
14
+ const require_llm = require("./llm-DAw2eouV.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-ChojUVJa.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-DSMHJM3c.cjs");
30
+ const require_utils$1 = require("./utils-DkvbP8EA.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-CDgdfRmB.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");
@@ -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.
@@ -84576,7 +84944,7 @@ async function prepareForDurableExecution(options) {
84576
84944
  });
84577
84945
  let tripwireData;
84578
84946
  if (inputProcessors.length > 0) try {
84579
- const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-D_7tMaJe.cjs")).then((n) => n.runner_exports);
84947
+ const { ProcessorRunner } = await Promise.resolve().then(() => require("./stream-CMKRczs4.cjs")).then((n) => n.runner_exports);
84580
84948
  await new ProcessorRunner({
84581
84949
  inputProcessors,
84582
84950
  outputProcessors,
@@ -111747,6 +112115,12 @@ Object.defineProperty(exports, "KnowledgeLinkRefreshIncompleteError", {
111747
112115
  return KnowledgeLinkRefreshIncompleteError;
111748
112116
  }
111749
112117
  });
112118
+ Object.defineProperty(exports, "KnowledgeLinkRepairUnsupportedError", {
112119
+ enumerable: true,
112120
+ get: function() {
112121
+ return KnowledgeLinkRepairUnsupportedError;
112122
+ }
112123
+ });
111750
112124
  Object.defineProperty(exports, "KnowledgeMoveTooLargeError", {
111751
112125
  enumerable: true,
111752
112126
  get: function() {
@@ -112719,6 +113093,12 @@ Object.defineProperty(exports, "calculateAccumulatedUsage", {
112719
113093
  return calculateAccumulatedUsage;
112720
113094
  }
112721
113095
  });
113096
+ Object.defineProperty(exports, "canRepairKnowledgeLinksInBatch", {
113097
+ enumerable: true,
113098
+ get: function() {
113099
+ return canRepairKnowledgeLinksInBatch;
113100
+ }
113101
+ });
112722
113102
  Object.defineProperty(exports, "cancelNestedRun", {
112723
113103
  enumerable: true,
112724
113104
  get: function() {
@@ -113673,6 +114053,12 @@ Object.defineProperty(exports, "knowledgeMemoryScopes", {
113673
114053
  return knowledgeMemoryScopes;
113674
114054
  }
113675
114055
  });
114056
+ Object.defineProperty(exports, "knowledgePageKeyProblem", {
114057
+ enumerable: true,
114058
+ get: function() {
114059
+ return knowledgePageKeyProblem;
114060
+ }
114061
+ });
113676
114062
  Object.defineProperty(exports, "knowledgePagePath", {
113677
114063
  enumerable: true,
113678
114064
  get: function() {
@@ -114081,6 +114467,12 @@ Object.defineProperty(exports, "renewWorkflowLease", {
114081
114467
  return renewWorkflowLease;
114082
114468
  }
114083
114469
  });
114470
+ Object.defineProperty(exports, "repairKnowledgeLinks", {
114471
+ enumerable: true,
114472
+ get: function() {
114473
+ return repairKnowledgeLinks;
114474
+ }
114475
+ });
114084
114476
  Object.defineProperty(exports, "repeatAfterSettled", {
114085
114477
  enumerable: true,
114086
114478
  get: function() {