@mastra/core 1.86.0-alpha.8 → 1.86.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (459) hide show
  1. package/dist/_types/@internal_core@0.1.4/dist/knowledge-compat/index.d.ts +363 -0
  2. package/dist/a2a/index.cjs +1 -1
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/agent/agent.d.ts +12 -0
  5. package/dist/agent/durable/index.cjs +1 -13
  6. package/dist/agent/durable/index.js +1 -13
  7. package/dist/agent/durable/preparation.d.ts +2 -0
  8. package/dist/agent/durable/utils/resolve-runtime.d.ts +9 -0
  9. package/dist/agent/durable/workflows/durable-loop-builder.d.ts +4 -0
  10. package/dist/agent/durable/workflows/finalize-run.d.ts +3 -1
  11. package/dist/agent/durable/workflows/steps/llm-execution.d.ts +1 -0
  12. package/dist/agent/index.cjs +3 -3
  13. package/dist/agent/index.js +3 -3
  14. package/dist/agent/message-list/index.cjs +1 -1
  15. package/dist/agent/message-list/index.js +1 -1
  16. package/dist/agent/message-list/message-list.d.ts +11 -0
  17. package/dist/agent/message-list/utils/provider-compat.d.ts +1 -0
  18. package/dist/agent/request-context-snapshot.d.ts +1 -1
  19. package/dist/agent/streams/types.d.ts +10 -0
  20. package/dist/agent/thread-stream-runtime.d.ts +5 -0
  21. package/dist/agent-builder/ee/index.cjs +1 -1
  22. package/dist/agent-builder/ee/index.js +1 -1
  23. package/dist/agent-controller/index.cjs +1 -1
  24. package/dist/agent-controller/index.js +1 -1
  25. package/dist/{agent-controller-DEPayioq.cjs → agent-controller-CrQ9OF80.cjs} +7 -7
  26. package/dist/{agent-controller-B7POPub5.js → agent-controller-SSlKzE6A.js} +7 -7
  27. package/dist/background-tasks/index.cjs +1 -1
  28. package/dist/background-tasks/index.js +1 -1
  29. package/dist/{background-tasks-7iftnRK_.cjs → background-tasks-BDrYBis-.cjs} +5 -3
  30. package/dist/{background-tasks-Cv1ecD6S.js → background-tasks-BnJfNLFo.js} +5 -3
  31. package/dist/browser/index.cjs +2 -2
  32. package/dist/browser/index.js +2 -2
  33. package/dist/{builder-Gg-xnX_E.js → builder-Cl-0BWkh.js} +2 -2
  34. package/dist/{builder-DuJBbQDH.cjs → builder-Cw8u3pPl.cjs} +2 -2
  35. package/dist/capabilities/302ai.json +204 -204
  36. package/dist/capabilities/abliteratedllm.json +30 -30
  37. package/dist/capabilities/above.json +21 -21
  38. package/dist/capabilities/adaption.json +15 -15
  39. package/dist/capabilities/adzuki.json +24 -24
  40. package/dist/capabilities/agentrouter.json +9 -9
  41. package/dist/capabilities/agnes.json +3 -3
  42. package/dist/capabilities/ai-router.json +8 -8
  43. package/dist/capabilities/aiand.json +31 -23
  44. package/dist/capabilities/aigrow.json +14 -14
  45. package/dist/capabilities/aimlapi.json +144 -147
  46. package/dist/capabilities/aipg.json +2 -2
  47. package/dist/capabilities/aixy.json +21 -21
  48. package/dist/capabilities/aki-io.json +10 -10
  49. package/dist/capabilities/alibaba-cn.json +136 -117
  50. package/dist/capabilities/alibaba-coding-plan-cn.json +7 -19
  51. package/dist/capabilities/alibaba-coding-plan.json +7 -19
  52. package/dist/capabilities/alibaba-token-plan-cn.json +49 -67
  53. package/dist/capabilities/alibaba-token-plan.json +50 -68
  54. package/dist/capabilities/alibaba.json +72 -119
  55. package/dist/capabilities/ambient.json +8 -8
  56. package/dist/capabilities/amd.json +10 -10
  57. package/dist/capabilities/anthropic.json +47 -47
  58. package/dist/capabilities/anyapi.json +19 -19
  59. package/dist/capabilities/apiko.json +5 -5
  60. package/dist/capabilities/arcee.json +11 -11
  61. package/dist/capabilities/augure.json +2 -2
  62. package/dist/capabilities/auriko.json +23 -23
  63. package/dist/capabilities/bailing.json +4 -4
  64. package/dist/capabilities/baseten.json +55 -25
  65. package/dist/capabilities/bee.json +4 -4
  66. package/dist/capabilities/berget.json +5 -5
  67. package/dist/capabilities/bothub.json +17 -17
  68. package/dist/capabilities/boundless.json +37 -37
  69. package/dist/capabilities/bumo.json +41 -41
  70. package/dist/capabilities/byteplus.json +26 -26
  71. package/dist/capabilities/cerebras.json +4 -4
  72. package/dist/capabilities/cheapaimodel.json +3 -3
  73. package/dist/capabilities/cheapest-token.json +30 -30
  74. package/dist/capabilities/chutes.json +10 -10
  75. package/dist/capabilities/cline-pass.json +39 -39
  76. package/dist/capabilities/cloudcode.json +9 -9
  77. package/dist/capabilities/cloudferro-sherlock.json +4 -4
  78. package/dist/capabilities/cloudflare-workers-ai.json +33 -33
  79. package/dist/capabilities/commandcode.json +139 -139
  80. package/dist/capabilities/concentrate.json +274 -274
  81. package/dist/capabilities/cortecs.json +108 -108
  82. package/dist/capabilities/crossmodel.json +189 -189
  83. package/dist/capabilities/crusoe.json +10 -10
  84. package/dist/capabilities/daoxe.json +9 -9
  85. package/dist/capabilities/databricks.json +315 -59
  86. package/dist/capabilities/deepinfra.json +90 -155
  87. package/dist/capabilities/deepseek.json +2 -2
  88. package/dist/capabilities/digitalocean.json +114 -114
  89. package/dist/capabilities/dothoosh.json +34 -34
  90. package/dist/capabilities/doubleword.json +28 -28
  91. package/dist/capabilities/edenai.json +433 -433
  92. package/dist/capabilities/empiriolabs.json +176 -176
  93. package/dist/capabilities/engy.json +17 -17
  94. package/dist/capabilities/entrim.json +6 -6
  95. package/dist/capabilities/evroc.json +13 -13
  96. package/dist/capabilities/ezkielyna.json +12 -12
  97. package/dist/capabilities/fastrouter.json +88 -88
  98. package/dist/capabilities/fireworks-ai.json +104 -41
  99. package/dist/capabilities/freemodel.json +20 -20
  100. package/dist/capabilities/friendli.json +9 -9
  101. package/dist/capabilities/frogbot.json +93 -93
  102. package/dist/capabilities/gisoo.json +19 -19
  103. package/dist/capabilities/gmicloud.json +21 -21
  104. package/dist/capabilities/google.json +55 -55
  105. package/dist/capabilities/graphn.json +11 -11
  106. package/dist/capabilities/greenpt.json +36 -36
  107. package/dist/capabilities/groq.json +9 -9
  108. package/dist/capabilities/helicone.json +83 -83
  109. package/dist/capabilities/hostinger-router.json +13 -13
  110. package/dist/capabilities/hpc-ai.json +8 -8
  111. package/dist/capabilities/huawei-maas.json +17 -17
  112. package/dist/capabilities/hubris.json +28 -28
  113. package/dist/capabilities/huggingface.json +200 -53
  114. package/dist/capabilities/humain.json +2 -2
  115. package/dist/capabilities/hyper.json +26 -26
  116. package/dist/capabilities/impossibl.json +127 -127
  117. package/dist/capabilities/inception.json +2 -2
  118. package/dist/capabilities/inceptron.json +8 -8
  119. package/dist/capabilities/inco.json +4 -4
  120. package/dist/capabilities/infer.json +14 -14
  121. package/dist/capabilities/inference-coop.json +15 -15
  122. package/dist/capabilities/inferenceapis.json +22 -22
  123. package/dist/capabilities/inferris.json +3 -3
  124. package/dist/capabilities/infersia.json +9 -9
  125. package/dist/capabilities/inferx.json +3 -3
  126. package/dist/capabilities/infomaniak.json +4 -4
  127. package/dist/capabilities/io-net.json +5 -5
  128. package/dist/capabilities/isoquant.json +4 -4
  129. package/dist/capabilities/iteracompute.json +51 -51
  130. package/dist/capabilities/jalapeno.json +12 -12
  131. package/dist/capabilities/jiekou.json +65 -65
  132. package/dist/capabilities/joingonka.json +4 -4
  133. package/dist/capabilities/jzstoken.json +54 -54
  134. package/dist/capabilities/keln.json +21 -28
  135. package/dist/capabilities/kenari.json +124 -121
  136. package/dist/capabilities/kilo.json +635 -636
  137. package/dist/capabilities/kimi-code-plan-cn.json +6 -6
  138. package/dist/capabilities/kimi-code-plan-global.json +6 -6
  139. package/dist/capabilities/kitani.json +4 -4
  140. package/dist/capabilities/klavo.json +13 -13
  141. package/dist/capabilities/korouter.json +31 -31
  142. package/dist/capabilities/kunavo.json +9 -9
  143. package/dist/capabilities/liquid.json +10 -10
  144. package/dist/capabilities/llmgateway-providers.json +909 -909
  145. package/dist/capabilities/llmgateway.json +333 -333
  146. package/dist/capabilities/llmtr.json +19 -19
  147. package/dist/capabilities/logits.json +2 -2
  148. package/dist/capabilities/longcat.json +1 -6
  149. package/dist/capabilities/lowrouter.json +52 -52
  150. package/dist/capabilities/lyceum.json +7 -7
  151. package/dist/capabilities/melious.json +16 -16
  152. package/dist/capabilities/merge-gateway.json +275 -275
  153. package/dist/capabilities/meta.json +9 -9
  154. package/dist/capabilities/minimax-cn-coding-plan.json +6 -6
  155. package/dist/capabilities/minimax-coding-plan.json +6 -6
  156. package/dist/capabilities/mistral.json +18 -18
  157. package/dist/capabilities/mixlayer.json +5 -5
  158. package/dist/capabilities/modal.json +13 -13
  159. package/dist/capabilities/model-oracle-ai.json +26 -26
  160. package/dist/capabilities/modelis.json +24 -24
  161. package/dist/capabilities/modelscope.json +2 -2
  162. package/dist/capabilities/modular.json +9 -9
  163. package/dist/capabilities/moneo.json +14 -14
  164. package/dist/capabilities/moonshotai-cn.json +6 -6
  165. package/dist/capabilities/moonshotai.json +6 -6
  166. package/dist/capabilities/morph.json +13 -13
  167. package/dist/capabilities/munito-eu.json +6 -6
  168. package/dist/capabilities/munito.json +10 -10
  169. package/dist/capabilities/nan.json +24 -24
  170. package/dist/capabilities/nano-gpt.json +577 -577
  171. package/dist/capabilities/nearai.json +82 -82
  172. package/dist/capabilities/nebius.json +29 -29
  173. package/dist/capabilities/neon.json +134 -134
  174. package/dist/capabilities/neuralwatt.json +43 -43
  175. package/dist/capabilities/nokeep.json +4 -4
  176. package/dist/capabilities/novita-ai.json +135 -135
  177. package/dist/capabilities/nvidia.json +38 -38
  178. package/dist/capabilities/oathbreaker.json +2 -2
  179. package/dist/capabilities/obscurify.json +26 -26
  180. package/dist/capabilities/oci.json +5 -5
  181. package/dist/capabilities/ofox.json +338 -338
  182. package/dist/capabilities/ollama-cloud.json +55 -55
  183. package/dist/capabilities/openai.json +48 -48
  184. package/dist/capabilities/opencode-go.json +81 -81
  185. package/dist/capabilities/openreason.json +5 -5
  186. package/dist/capabilities/openrouter.json +548 -563
  187. package/dist/capabilities/opper.json +23 -23
  188. package/dist/capabilities/orcarouter.json +212 -212
  189. package/dist/capabilities/outerlabs.json +30 -30
  190. package/dist/capabilities/ovhcloud.json +8 -8
  191. package/dist/capabilities/pareto.json +5 -5
  192. package/dist/capabilities/pendra.json +4 -4
  193. package/dist/capabilities/perplexity-agent.json +59 -59
  194. package/dist/capabilities/perplexity.json +2 -2
  195. package/dist/capabilities/phala.json +27 -27
  196. package/dist/capabilities/pioneer.json +24 -24
  197. package/dist/capabilities/poe.json +136 -136
  198. package/dist/capabilities/powerspring.json +14 -14
  199. package/dist/capabilities/primalabs.json +7 -7
  200. package/dist/capabilities/prime.json +108 -108
  201. package/dist/capabilities/privatemode-ai.json +12 -12
  202. package/dist/capabilities/proxystacks.json +6 -6
  203. package/dist/capabilities/qiniu-ai.json +15 -15
  204. package/dist/capabilities/refuseless.json +9 -9
  205. package/dist/capabilities/regolo-ai.json +6 -6
  206. package/dist/capabilities/requesty.json +171 -171
  207. package/dist/capabilities/ruapi.json +20 -20
  208. package/dist/capabilities/runcrate.json +16 -16
  209. package/dist/capabilities/runinfra.json +17 -17
  210. package/dist/capabilities/sakana.json +6 -6
  211. package/dist/capabilities/sambanova.json +6 -6
  212. package/dist/capabilities/sandbase.json +16 -16
  213. package/dist/capabilities/sarvam.json +12 -12
  214. package/dist/capabilities/scaleway.json +17 -17
  215. package/dist/capabilities/scnet-token-plan.json +8 -8
  216. package/dist/capabilities/scx-ai.json +29 -29
  217. package/dist/capabilities/sensenova.json +14 -14
  218. package/dist/capabilities/siliconflow-cn.json +61 -61
  219. package/dist/capabilities/siliconflow.json +57 -57
  220. package/dist/capabilities/snowflake-cortex.json +24 -24
  221. package/dist/capabilities/sokkan.json +10 -10
  222. package/dist/capabilities/sparrowcodes.json +24 -24
  223. package/dist/capabilities/standardcompute.json +89 -89
  224. package/dist/capabilities/steadyrouter.json +38 -38
  225. package/dist/capabilities/stepfun-ai-step-plan.json +7 -7
  226. package/dist/capabilities/stepfun-ai.json +16 -9
  227. package/dist/capabilities/stepfun-step-plan.json +16 -9
  228. package/dist/capabilities/stepfun.json +16 -9
  229. package/dist/capabilities/stepping-stone.json +18 -18
  230. package/dist/capabilities/subconscious.json +2 -2
  231. package/dist/capabilities/synthetic.json +12 -12
  232. package/dist/capabilities/synthorai.json +26 -26
  233. package/dist/capabilities/teamorouter.json +21 -21
  234. package/dist/capabilities/teapot-router.json +9 -9
  235. package/dist/capabilities/tencent-coding-plan.json +1 -23
  236. package/dist/capabilities/tencent-token-plan.json +57 -20
  237. package/dist/capabilities/tencent-tokenhub.json +182 -7
  238. package/dist/capabilities/tensorx.json +36 -36
  239. package/dist/capabilities/the-grid-ai.json +29 -29
  240. package/dist/capabilities/thinkingmachines.json +73 -56
  241. package/dist/capabilities/tinfoil.json +9 -9
  242. package/dist/capabilities/toapis.json +3 -3
  243. package/dist/capabilities/togetherai.json +61 -90
  244. package/dist/capabilities/tokengo.json +21 -21
  245. package/dist/capabilities/tokenify.json +9 -9
  246. package/dist/capabilities/trustedrouter.json +7 -7
  247. package/dist/capabilities/trustedtokens.json +14 -14
  248. package/dist/capabilities/umans-ai-coding-plan.json +13 -13
  249. package/dist/capabilities/umans-ai.json +10 -10
  250. package/dist/capabilities/uncensuredai.json +4 -4
  251. package/dist/capabilities/unrestricted.json +4 -4
  252. package/dist/capabilities/uplinkswitch.json +19 -19
  253. package/dist/capabilities/upstage.json +6 -6
  254. package/dist/capabilities/vancine.json +19 -19
  255. package/dist/capabilities/vercel.json +558 -537
  256. package/dist/capabilities/vivgrid.json +78 -78
  257. package/dist/capabilities/volcengine-coding-plan.json +26 -56
  258. package/dist/capabilities/volcengine.json +57 -62
  259. package/dist/capabilities/vultr.json +28 -28
  260. package/dist/capabilities/wafer.ai.json +18 -18
  261. package/dist/capabilities/wallaby.json +5 -5
  262. package/dist/capabilities/wally.json +14 -14
  263. package/dist/capabilities/wandb.json +20 -20
  264. package/dist/capabilities/watt.json +22 -22
  265. package/dist/capabilities/xai.json +4 -4
  266. package/dist/capabilities/xiaomi-token-plan-ams.json +2 -12
  267. package/dist/capabilities/xiaomi-token-plan-cn.json +2 -12
  268. package/dist/capabilities/xiaomi-token-plan-sgp.json +2 -12
  269. package/dist/capabilities/xiaomi.json +3 -25
  270. package/dist/capabilities/xpersona.json +11 -11
  271. package/dist/capabilities/xxapi.json +27 -27
  272. package/dist/capabilities/zai-coding-plan.json +14 -14
  273. package/dist/capabilities/zai.json +47 -24
  274. package/dist/capabilities/zenifra.json +24 -24
  275. package/dist/capabilities/zenmux.json +185 -185
  276. package/dist/capabilities/zerogpu.json +12 -12
  277. package/dist/capabilities/zhipuai-coding-plan.json +8 -8
  278. package/dist/capabilities/zhipuai.json +35 -20
  279. package/dist/capabilities/zro.json +7 -7
  280. package/dist/channels/index.cjs +2 -2
  281. package/dist/channels/index.js +2 -2
  282. package/dist/{channels-BRVCOutx.js → channels-Cz1y3W6u.js} +1 -1
  283. package/dist/{channels-MjTA9bFp.cjs → channels-DQg4v_gm.cjs} +1 -1
  284. package/dist/coding-agent/index.cjs +2 -2
  285. package/dist/coding-agent/index.js +2 -2
  286. package/dist/datasets/index.cjs +2 -2
  287. package/dist/datasets/index.js +2 -2
  288. package/dist/docs/SKILL.md +3 -2
  289. package/dist/docs/assets/SOURCE_MAP.json +895 -870
  290. package/dist/docs/references/docs-harness-background-tasks.md +4 -1
  291. package/dist/docs/references/docs-knowledge-importers.md +195 -0
  292. package/dist/docs/references/docs-knowledge-load-your-content.md +1 -1
  293. package/dist/docs/references/docs-knowledge-overview.md +1 -1
  294. package/dist/docs/references/docs-sandbox-filesystem.md +1 -1
  295. package/dist/docs/references/docs-signals-thread-streams.md +1 -1
  296. package/dist/docs/references/docs-studio-auth.md +54 -7
  297. package/dist/docs/references/integrations-auth-clerk.md +48 -4
  298. package/dist/docs/references/reference-agents-agent.md +1 -1
  299. package/dist/docs/references/reference-agents-durable-agent.md +10 -4
  300. package/dist/docs/references/reference-auth-clerk.md +21 -1
  301. package/dist/docs/references/reference-knowledge-knowledge-class.md +11 -4
  302. package/dist/docs/references/reference-memory-observational-memory.md +2 -2
  303. package/dist/docs/references/reference-streaming-ChunkType.md +2 -2
  304. package/dist/docs/references/reference-workspace-local-sandbox.md +2 -0
  305. package/dist/error/index.cjs +1 -1
  306. package/dist/error/index.js +1 -1
  307. package/dist/{error-C9d_24w-.js → error-BLwEXqOK.js} +2 -2
  308. package/dist/{error-BRQf2ku0.cjs → error-BdEvO8za.cjs} +2 -2
  309. package/dist/evals/index.cjs +1 -1
  310. package/dist/evals/index.js +1 -1
  311. package/dist/evals/scoreTraces/index.cjs +1 -1
  312. package/dist/evals/scoreTraces/index.js +1 -1
  313. package/dist/features/index.cjs +1 -0
  314. package/dist/features/index.js +1 -0
  315. package/dist/{filesystem-B5X-5G0x.js → filesystem-B8ad6kAW.js} +1 -1
  316. package/dist/{filesystem-BDSpwBke.cjs → filesystem-BB5YWXH-.cjs} +1 -1
  317. package/dist/{filesystem-DzM9pcQ8.js → filesystem-BDHUxbHn.js} +1 -1
  318. package/dist/{filesystem-B0AZrbj8.cjs → filesystem-BP5yz5LG.cjs} +1 -1
  319. package/dist/{filesystem-BsdkC311.js → filesystem-B_afSgYk.js} +1 -1
  320. package/dist/{filesystem-C-cyJfi1.cjs → filesystem-BaOJOc-V.cjs} +1 -1
  321. package/dist/{filesystem-B3s0WRud.js → filesystem-BhYgU8qg.js} +1 -1
  322. package/dist/{filesystem-DzfqVTO_.js → filesystem-CLBVmR5j.js} +1 -1
  323. package/dist/{filesystem-CEbD_77-.cjs → filesystem-Cgxc2a_-.cjs} +1 -1
  324. package/dist/{filesystem-Cv79mHRk.js → filesystem-ClBOBoDc.js} +1 -1
  325. package/dist/{filesystem-DsCQiBl2.cjs → filesystem-DVVecqZt.cjs} +1 -1
  326. package/dist/{filesystem-CUAgLugE.cjs → filesystem-Fpsu7e24.cjs} +1 -1
  327. package/dist/{filesystem-versioned-Bijb_p9l.js → filesystem-versioned-BL1ojJLo.js} +1 -1
  328. package/dist/{filesystem-versioned-DZGyPbNC.cjs → filesystem-versioned-BavRtYWJ.cjs} +1 -1
  329. package/dist/harness/index.cjs +1 -1
  330. package/dist/harness/index.js +1 -1
  331. package/dist/index.cjs +1 -1
  332. package/dist/index.js +1 -1
  333. package/dist/knowledge/config.d.ts +10 -0
  334. package/dist/knowledge/host-writes.d.ts +10 -0
  335. package/dist/knowledge/importers/conformance.d.ts +25 -0
  336. package/dist/knowledge/importers/define.d.ts +204 -0
  337. package/dist/knowledge/importers/host.d.ts +143 -0
  338. package/dist/knowledge/importers/index.d.ts +12 -0
  339. package/dist/knowledge/importers/local-host.d.ts +106 -0
  340. package/dist/knowledge/importers/manifest.d.ts +25 -0
  341. package/dist/knowledge/importers/runner.d.ts +61 -0
  342. package/dist/knowledge/importers/sink.d.ts +105 -0
  343. package/dist/knowledge/importers/types.d.ts +144 -0
  344. package/dist/knowledge/index.cjs +2715 -8
  345. package/dist/knowledge/index.d.ts +54 -4
  346. package/dist/knowledge/index.js +2692 -9
  347. package/dist/knowledge/instructions.d.ts +1 -1
  348. package/dist/knowledge/links.d.ts +8 -0
  349. package/dist/knowledge/pinned-state-processor.d.ts +5 -0
  350. package/dist/knowledge/pinned.d.ts +4 -1
  351. package/dist/knowledge/scope-runtime.d.ts +10 -0
  352. package/dist/llm/index.cjs +3 -3
  353. package/dist/llm/index.js +3 -3
  354. package/dist/llm/model/provider-types.generated.d.ts +7705 -7727
  355. package/dist/{llm-DmUucguC.cjs → llm-8Av3mSjD.cjs} +2 -2
  356. package/dist/{llm-Djd8Qzi0.js → llm-B5A5cwJr.js} +2 -2
  357. package/dist/loop/index.cjs +2 -2
  358. package/dist/loop/index.js +2 -2
  359. package/dist/{manager-CO_Xz2zR.js → manager-DfWQCJUK.js} +2 -2
  360. package/dist/{manager-D27PkIPo.cjs → manager-sv35JY-z.cjs} +2 -2
  361. package/dist/mastra/index.cjs +1 -1
  362. package/dist/mastra/index.js +1 -1
  363. package/dist/mastra/resolve-agent.d.ts +3 -1
  364. package/dist/{mastra-Ch00nEAJ.js → mastra-CigBrT7X.js} +17 -23
  365. package/dist/{mastra-qsVWpOTi.cjs → mastra-D4hvfuxX.cjs} +19 -25
  366. package/dist/memory/index.cjs +3 -3
  367. package/dist/memory/index.js +3 -3
  368. package/dist/{message-list-DPXPXvin.cjs → message-list-Cj0Sq_JP.cjs} +63 -8
  369. package/dist/{message-list-DEuRl82K.js → message-list-KRbg-TnI.js} +63 -8
  370. package/dist/{model-Do6DTJoj.cjs → model-BK93CMtl.cjs} +1 -1
  371. package/dist/{model-CW-mfGYA.js → model-CYtXw861.js} +1 -1
  372. package/dist/{netlify-DU32SDT6.cjs → netlify-BAnn3ouY.cjs} +1 -1
  373. package/dist/{netlify-DZSAbdve.js → netlify-CuI1ZrwR.js} +1 -1
  374. package/dist/notifications/index.cjs +1 -1
  375. package/dist/notifications/index.js +1 -1
  376. package/dist/processor-provider/index.cjs +1 -1
  377. package/dist/processor-provider/index.js +1 -1
  378. package/dist/processors/abort-signal-scope.d.ts +6 -0
  379. package/dist/processors/index.cjs +2 -2
  380. package/dist/processors/index.js +2 -2
  381. package/dist/{provider-registry-zGezZVsL.cjs → provider-registry-BwuI_IpT.cjs} +21696 -21828
  382. package/dist/{provider-registry-deA0x-Gd.js → provider-registry-CmQLzLF_.js} +21696 -21828
  383. package/dist/provider-registry.json +22300 -22417
  384. package/dist/{registry-generator-VvBfOKAD.js → registry-generator-C17V4WfG.js} +1 -1
  385. package/dist/{registry-generator-BkQ1AxZn.cjs → registry-generator-C_0ae7Ce.cjs} +1 -1
  386. package/dist/{rehydrate-DDYFpQsV.cjs → rehydrate-CDQ4dOYj.cjs} +2 -2
  387. package/dist/{rehydrate-BjLV643n.js → rehydrate-PnaVawGX.js} +2 -2
  388. package/dist/relevance/index.cjs +2 -2
  389. package/dist/relevance/index.js +2 -2
  390. package/dist/{run-registry-5Suldxz3.cjs → run-registry-BmckDVBk.cjs} +1156 -403
  391. package/dist/{run-registry-CGRPldLH.js → run-registry-BwEcwYlU.js} +1103 -404
  392. package/dist/{source-DDwx-87N.cjs → source-BVOi8Xhp.cjs} +1 -1
  393. package/dist/{source-Did_2XQc.js → source-fNa6u1kH.js} +1 -1
  394. package/dist/storage/domains/agents/index.cjs +1 -1
  395. package/dist/storage/domains/agents/index.js +1 -1
  396. package/dist/storage/domains/knowledge/base.d.ts +67 -0
  397. package/dist/storage/domains/knowledge/importers-inmemory.d.ts +146 -0
  398. package/dist/storage/domains/knowledge/importers.d.ts +287 -0
  399. package/dist/storage/domains/knowledge/index.d.ts +1 -0
  400. package/dist/storage/domains/knowledge/inmemory.d.ts +11 -0
  401. package/dist/storage/domains/knowledge/pages-inmemory.d.ts +12 -1
  402. package/dist/storage/domains/knowledge/pages.d.ts +1 -0
  403. package/dist/storage/domains/mcp-clients/index.cjs +1 -1
  404. package/dist/storage/domains/mcp-clients/index.js +1 -1
  405. package/dist/storage/domains/mcp-servers/index.cjs +1 -1
  406. package/dist/storage/domains/mcp-servers/index.js +1 -1
  407. package/dist/storage/domains/prompt-blocks/index.cjs +1 -1
  408. package/dist/storage/domains/prompt-blocks/index.js +1 -1
  409. package/dist/storage/domains/scorer-definitions/index.cjs +1 -1
  410. package/dist/storage/domains/scorer-definitions/index.js +1 -1
  411. package/dist/storage/domains/skills/index.cjs +1 -1
  412. package/dist/storage/domains/skills/index.js +1 -1
  413. package/dist/storage/domains/workspaces/index.cjs +1 -1
  414. package/dist/storage/domains/workspaces/index.js +1 -1
  415. package/dist/storage/index.cjs +15 -10
  416. package/dist/storage/index.js +11 -11
  417. package/dist/stream/base/output.d.ts +17 -0
  418. package/dist/stream/index.cjs +2 -2
  419. package/dist/stream/index.js +2 -2
  420. package/dist/stream/types.d.ts +5 -2
  421. package/dist/{stream-Dvy_0o14.cjs → stream-0kdqBOOn.cjs} +64 -9
  422. package/dist/{stream-Dpwx0whf.js → stream-D1y9GzoD.js} +29 -10
  423. package/dist/test-utils/llm-mock.cjs +1 -1
  424. package/dist/test-utils/llm-mock.js +1 -1
  425. package/dist/tool-loop-agent/index.cjs +1 -1
  426. package/dist/tool-loop-agent/index.js +1 -1
  427. package/dist/{tool-loop-agent-PbWrEj1k.js → tool-loop-agent-BdjWGVIb.js} +4 -4
  428. package/dist/{tool-loop-agent-UxOv3FoK.cjs → tool-loop-agent-kWaZAT6Q.cjs} +4 -4
  429. package/dist/{utils-BbMTlyBO.cjs → utils-BKUCaZ12.cjs} +1 -1
  430. package/dist/{utils-BnNi1BYM.js → utils-GHY3hmLx.js} +1 -1
  431. package/dist/utils.cjs +1 -1
  432. package/dist/utils.js +1 -1
  433. package/dist/{validate-HSBcm96b.js → validate-CB-q-R2F.js} +1 -1
  434. package/dist/{validate-Skps-cM3.cjs → validate-De92squ7.cjs} +1 -1
  435. package/dist/vector/index.cjs +2 -2
  436. package/dist/vector/index.js +2 -2
  437. package/dist/worker/index.cjs +1 -1
  438. package/dist/worker/index.js +1 -1
  439. package/dist/{worker-BNS5A3qP.cjs → worker-BbWPQuPR.cjs} +2 -2
  440. package/dist/{worker-DehaD4qD.js → worker-C3u_xzY2.js} +2 -2
  441. package/dist/{worker-BE-0DyKL.cjs → worker-CAKvQj9_.cjs} +2 -2
  442. package/dist/{worker-BKrKHZzU.js → worker-Kwm8EKcj.js} +2 -2
  443. package/dist/{workflow-BjUTwaK9.cjs → workflow-CSjXeNcR.cjs} +3 -3
  444. package/dist/{workflow-Bvw6yDjc.js → workflow-CVmI1Sw-.js} +3 -3
  445. package/dist/workflows/builder/index.cjs +1 -1
  446. package/dist/workflows/builder/index.js +1 -1
  447. package/dist/workflows/evented/index.cjs +1 -1
  448. package/dist/workflows/evented/index.js +1 -1
  449. package/dist/workflows/index.cjs +4 -4
  450. package/dist/workflows/index.js +4 -4
  451. package/dist/workspace/filesystem/filesystem.d.ts +5 -0
  452. package/dist/workspace/index.cjs +1 -1
  453. package/dist/workspace/index.js +1 -1
  454. package/dist/workspace/sandbox/local-sandbox.d.ts +16 -7
  455. package/dist/workspace/sandbox/native-sandbox/types.d.ts +11 -1
  456. package/dist/{workspace-C05xDH60.js → workspace-DY2Nxiyi.js} +75 -27
  457. package/dist/{workspace-D1OzzlLw.cjs → workspace-X2RHJZU9.cjs} +75 -27
  458. package/package.json +3 -3
  459. package/src/llm/model/provider-types.generated.d.ts +7705 -7727
@@ -0,0 +1,143 @@
1
+ import type { KnowledgeImporterFinishRequest, KnowledgeImporterFlush, KnowledgeImporterFlushReceipt, KnowledgeImporterOp, KnowledgeImporterRunReceipt, KnowledgeImporterState } from './types.js';
2
+ /**
3
+ * Run options from the host's trusted caller. A remote host may ignore them: its run ID, fire key
4
+ * and deadline come from the run it dispatched.
5
+ */
6
+ export interface KnowledgeImporterStartRunOptions {
7
+ /** A caller-chosen run ID, e.g. the one a scheduler already recorded. */
8
+ runId?: string;
9
+ /** De-duplicates fires of one schedule tick, e.g. `${bindingId}:${scheduledAt}`. */
10
+ fireKey?: string;
11
+ /** Epoch ms after which the host refuses the run's flushes. */
12
+ deadline?: number;
13
+ }
14
+ export type KnowledgeImporterRunStart = {
15
+ status: 'started';
16
+ runId: string;
17
+ generation: number;
18
+ /** The state the last committed flush left. */
19
+ state: KnowledgeImporterState;
20
+ /** 0 before the first flush. */
21
+ lastSeq: number;
22
+ /**
23
+ * The binding as the host recorded it for this run. A remote host sends it because the app
24
+ * trusts only what the host returns here; the runner picks the importer from it.
25
+ */
26
+ binding?: KnowledgeImporterRunBinding;
27
+ }
28
+ /** Another run of the binding is going; the host recorded this one as skipped. */
29
+ | {
30
+ status: 'skipped';
31
+ runId: string;
32
+ };
33
+ /**
34
+ * A run's binding as a host hands it over. The runner picks the definition by `importer`, checks
35
+ * `settings` with `parseSettings` (failure: `settings_invalid`) and `credentials` with
36
+ * `checkCredentials` (failure: `credential_missing`). Credential values are resolved by the host
37
+ * side in the app's own process; they never come from a remote server.
38
+ */
39
+ export interface KnowledgeImporterRunBinding {
40
+ id: string;
41
+ /** The definition's id. */
42
+ importer: string;
43
+ /** `<scope>#<path>`. */
44
+ target: string;
45
+ settings: unknown;
46
+ credentials: Record<string, string>;
47
+ }
48
+ /**
49
+ * The runner's only way to Knowledge. Core's local host applies flushes to the app's own storage;
50
+ * a remote host (hosted Knowledge) applies them on its server. Both must pass
51
+ * `importerHostConformance`.
52
+ *
53
+ * Rules every host keeps:
54
+ * - `flush` is all or nothing, and its `state` commits with its ops in one transaction.
55
+ * - A flush's seq is exactly the last committed seq + 1. The host recomputes the digest and refuses
56
+ * a mismatch before applying anything.
57
+ * - Flush replay identity is `(runId, generation, seq)`: the same digest returns the stored
58
+ * receipt and applies nothing; a different digest is refused.
59
+ * - `finishRun` needs `lastSeq` equal to the committed seq and is valid once. A replay whose
60
+ * normalized request (`normalizeKnowledgeImporterFinish`) equals the stored one returns the
61
+ * stored receipt; any other is refused, and the stored outcome doesn't change.
62
+ * - After a run ends (finished, canceled or expired) a new seq is refused, while an exact replay
63
+ * of a committed seq still returns its receipt.
64
+ * - Run counts are summed from flush receipts.
65
+ *
66
+ * Refusals throw `KnowledgeImporterHostConflictError`. Any other host failure throws
67
+ * `KnowledgeImporterHostError` with the HTTP status when there is one: the runner resends the same
68
+ * flush (same seq and digest) after a 5xx or a network error, and ends the run on any other.
69
+ *
70
+ * @experimental
71
+ */
72
+ export interface KnowledgeImporterHost {
73
+ startRun(bindingId: string, options?: KnowledgeImporterStartRunOptions): Promise<KnowledgeImporterRunStart>;
74
+ flush(flush: KnowledgeImporterFlush): Promise<KnowledgeImporterFlushReceipt>;
75
+ /**
76
+ * Keeps the run alive; `cancel: true` tells the runner to stop without saving more state. A host
77
+ * that enforces a lease may instead refuse a heartbeat for a run it no longer holds, with
78
+ * `KnowledgeImporterHostConflictError` (`stale_generation` or `run_not_active`). The runner
79
+ * ignores a failed heartbeat; its next flush or finish gets the same refusal and ends the run.
80
+ */
81
+ heartbeat(runId: string, generation: number): Promise<{
82
+ cancel: boolean;
83
+ }>;
84
+ finishRun(request: KnowledgeImporterFinishRequest): Promise<KnowledgeImporterRunReceipt>;
85
+ }
86
+ export type KnowledgeImporterHostConflictCode =
87
+ /** seq isn't the committed seq + 1, or finish's lastSeq isn't the committed seq. */
88
+ 'seq_mismatch'
89
+ /** The digest doesn't match the flush's content, or a committed seq is replayed with other content. */
90
+ | 'digest_mismatch'
91
+ /** The run belongs to an older generation, or the binding's writer moved on. */
92
+ | 'stale_generation'
93
+ /** The run has ended, been canceled, expired or never started. */
94
+ | 'run_not_active'
95
+ /** A finish replay that differs from the recorded finish. */
96
+ | 'finish_mismatch';
97
+ /** A host refused a flush or a finish (409 over HTTP). Retrying the same request won't help. @experimental */
98
+ export declare class KnowledgeImporterHostConflictError extends Error {
99
+ readonly code: KnowledgeImporterHostConflictCode;
100
+ readonly status = 409;
101
+ constructor(code: KnowledgeImporterHostConflictCode, message: string);
102
+ }
103
+ export declare const KNOWLEDGE_IMPORTER_ERROR_CODES: readonly ["source_auth_failed", "source_unreachable", "source_rate_limited", "source_bad_response", "source_not_found", "settings_invalid", "credential_missing", "importer_missing_from_deploy", "importer_error", "stopped", "lease_expired", "deadline_exceeded"];
104
+ export type NormalizedKnowledgeImporterFinish = Omit<KnowledgeImporterRunReceipt, 'runId' | 'counts' | 'chain'>;
105
+ /**
106
+ * The finish request as a host stores and compares it: missing optional fields become null.
107
+ * Throws a TypeError for a request no host should accept.
108
+ */
109
+ export declare function normalizeKnowledgeImporterFinish(request: KnowledgeImporterFinishRequest): NormalizedKnowledgeImporterFinish;
110
+ /**
111
+ * RFC 8785 (JCS) canonical JSON: object members sorted by UTF-16 code units, no whitespace, numbers
112
+ * and strings as ECMAScript serializes them. Members whose value is undefined are left out, as
113
+ * JSON.stringify leaves them out of what goes over the wire; array holes and undefined items are
114
+ * null, as JSON.stringify writes them. Strings with a lone UTF-16 surrogate are refused (RFC 8785
115
+ * §3.2.2.2).
116
+ */
117
+ export declare function canonicalJson(value: unknown): string;
118
+ /**
119
+ * A flush's digest: lowercase hex SHA-256 of the canonical JSON of `{ ops, state }`, with an absent
120
+ * `state` as null. Runners send it; hosts recompute it from the body they received. The body is
121
+ * checked with `parseKnowledgeImporterFlushBody` first, so only payloads that survive a JSON round
122
+ * trip unchanged get a digest.
123
+ */
124
+ export declare function knowledgeImporterFlushDigest(flush: {
125
+ ops: KnowledgeImporterOp[];
126
+ state?: KnowledgeImporterState;
127
+ }): Promise<string>;
128
+ /**
129
+ * Checks a flush body the way every host and runner must before hashing or applying it: known ops
130
+ * and fields only, strings where strings belong, no array holes, no lone surrogates, string-only
131
+ * state. Returns a copy with undefined optional fields left out, so what passes hashes the same
132
+ * before and after a JSON round trip. Throws a TypeError otherwise.
133
+ *
134
+ * @experimental
135
+ */
136
+ export declare function parseKnowledgeImporterFlushBody(body: {
137
+ ops: unknown;
138
+ state?: unknown;
139
+ }): {
140
+ ops: KnowledgeImporterOp[];
141
+ state?: KnowledgeImporterState;
142
+ };
143
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +1,12 @@
1
+ export type * from './types.js';
2
+ export type { KnowledgeImporterManifest } from './manifest.js';
3
+ export type { KnowledgeImporterHost, KnowledgeImporterHostConflictCode, KnowledgeImporterRunBinding, KnowledgeImporterRunStart, KnowledgeImporterStartRunOptions, NormalizedKnowledgeImporterFinish, } from './host.js';
4
+ export { KNOWLEDGE_IMPORTER_ERROR_CODES, KnowledgeImporterHostConflictError, canonicalJson, knowledgeImporterFlushDigest, normalizeKnowledgeImporterFinish, parseKnowledgeImporterFlushBody, } from './host.js';
5
+ export type { KnowledgeImporterBindingInput, KnowledgeImporterClass, KnowledgeImporterContext, KnowledgeImporterCredentialSlot, KnowledgeImporterDefinition, KnowledgeImporterDefinitionInput, KnowledgeImporterItems, KnowledgeImporterStateStore, } from './define.js';
6
+ export { KnowledgeImporter, KnowledgeImporterBase, KnowledgeImporterCredentialsError, KnowledgeImporterDefinitionError, KnowledgeImporterHostError, KnowledgeImporterSettingsError, KnowledgeImporterSourceError, knowledgeImporterRegistry, } from './define.js';
7
+ export type { RunKnowledgeImportOptions, RunKnowledgeImportResult } from './runner.js';
8
+ export { runKnowledgeImport } from './runner.js';
9
+ export { REMOVED_PARENT_BODY as KNOWLEDGE_IMPORT_REMOVED_PARENT_BODY, knowledgeImportKey } from './sink.js';
10
+ export type { KnowledgeImporterHostConformanceCase, KnowledgeImporterHostConformanceFixture } from './conformance.js';
11
+ export { importerHostConformance } from './conformance.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,106 @@
1
+ import type { KnowledgeStorage } from '../../storage/domains/knowledge/base.js';
2
+ import type { KnowledgeImporterRunStatus } from '../../storage/domains/knowledge/importers.js';
3
+ import type { KnowledgeHostWriter } from '../host-writes.js';
4
+ import type { KnowledgeImporterHost, KnowledgeImporterRunBinding, KnowledgeImporterRunStart, KnowledgeImporterStartRunOptions } from './host.js';
5
+ import type { KnowledgeImporterRunReceipt } from './types.js';
6
+ /** @experimental */
7
+ export interface LocalKnowledgeImporterHostOptions {
8
+ /**
9
+ * The bindings this host applies flushes for: a list, or a function read at each run start, so a
10
+ * host that keeps bindings in its own config picks up changes without a new host.
11
+ */
12
+ bindings: readonly KnowledgeImporterRunBinding[] | (() => Promise<readonly KnowledgeImporterRunBinding[]>);
13
+ /** Recorded as the writer of imported pages. Default `importer:<bindingId>`. */
14
+ author?: (binding: KnowledgeImporterRunBinding) => string;
15
+ /**
16
+ * How long one flush may spend in its transaction, from the wait for a connection to the last
17
+ * statement, before it rolls back and the runner resends it. Also capped by the run's deadline.
18
+ * Enforced only on stores with `enforcesTransactionDeadline` (PostgreSQL); COMMIT itself isn't
19
+ * bounded. Default 45 seconds, under the runner's 60-second host-call timeout.
20
+ */
21
+ flushBudgetMs?: number;
22
+ /**
23
+ * A running run whose last heartbeat (or start, before its first) is older than this is taken
24
+ * to have lost its runner: the next start of its binding ends it as `failed` (`stopped`) and
25
+ * starts. A run past its deadline is reclaimed the same way. Default 5 minutes.
26
+ */
27
+ staleRunAfterMs?: number;
28
+ /**
29
+ * Wall-clock budget for one flush's settle slice; it stops before the next node once this has
30
+ * passed. Default 10 seconds, well inside `flushBudgetMs`. Settle work is also capped at 200
31
+ * nodes examined and 50 moves per flush.
32
+ */
33
+ settleBudgetMs?: number;
34
+ /**
35
+ * Strict liveness for a host whose runners live elsewhere (r352 S1). A run is live only while
36
+ * `store.now() < (heartbeatAt ?? startedAt) + leaseMs` and before its deadline, by the store's
37
+ * clock; a heartbeat, a new flush or a finish that finds it otherwise is refused as
38
+ * `run_not_active` and writes nothing, and a lapsed run is never revived. Each flush transaction
39
+ * is cut off at the lease end too. Replaces `staleRunAfterMs`. Unset: the in-process rules
40
+ * (`staleRunAfterMs` reclaim at the next start).
41
+ */
42
+ leaseMs?: number;
43
+ }
44
+ /** Start options of a service host: a claim admitted in the run's start transaction (r352 S4). @experimental */
45
+ export interface KnowledgeImporterServiceStartOptions extends KnowledgeImporterStartRunOptions {
46
+ /**
47
+ * The writer generation the claim was issued for. The start is refused (`stale_generation`)
48
+ * unless it is the current one and the active write path is `'new'`.
49
+ */
50
+ generation?: number;
51
+ /**
52
+ * Called inside the start transaction, under the writer guard and before the scope is
53
+ * materialized and the run row written, with the transaction-bound storage. Throw to refuse the
54
+ * start: everything rolls back, the caller's own writes through `tx` included. A start that
55
+ * finds another run of the binding going rolls back the same way and reports `skipped`.
56
+ */
57
+ admit?: (tx: KnowledgeStorage) => Promise<void>;
58
+ }
59
+ /**
60
+ * A {@link KnowledgeImporterHost} for a service that applies flushes for runners elsewhere: it can
61
+ * also cancel runs and end those whose lease or deadline passed. @experimental
62
+ */
63
+ export interface KnowledgeImporterServiceHost extends KnowledgeImporterHost {
64
+ startRun(bindingId: string, options?: KnowledgeImporterServiceStartOptions): Promise<KnowledgeImporterRunStart>;
65
+ /**
66
+ * Asks a running run to stop: its heartbeat answers `cancel: true` and its new flushes are
67
+ * refused. A finish admitted afterwards is recorded as canceled. No-op on an ended run.
68
+ */
69
+ requestCancel(runId: string): Promise<{
70
+ status: KnowledgeImporterRunStatus;
71
+ } | null>;
72
+ /**
73
+ * Ends every running run past its lease (`leaseMs`, else `staleRunAfterMs`) or deadline, by the
74
+ * store's clock: `canceled` when a cancel was requested, otherwise `failed` with
75
+ * `lease_expired` or `deadline_exceeded`. Safe to call from a schedule and from several workers.
76
+ */
77
+ expireRuns(): Promise<{
78
+ expired: string[];
79
+ }>;
80
+ /**
81
+ * Forgets a binding the app deleted: its tracking, cursor state and runs. Its pages stay where
82
+ * they are as ordinary pages; nothing reserves its target, so any binding can write there next,
83
+ * taking over the pages it finds at its items' paths. A run of it still going is refused at its
84
+ * next flush. No-op for a binding that was never stored.
85
+ */
86
+ retireBinding(bindingId: string): Promise<void>;
87
+ /**
88
+ * A run's status and, once it ended, the receipt its finish stored (the app's, or the host's for a
89
+ * run it ended), with the chaining decision schedulers act on. Null for an unknown run. An ended run
90
+ * with no stored finish reads as `receipt: null`; this host always stores one, so that is for a host
91
+ * that ends runs itself.
92
+ */
93
+ readRun(runId: string): Promise<{
94
+ status: KnowledgeImporterRunStatus;
95
+ receipt: KnowledgeImporterRunReceipt | null;
96
+ } | null>;
97
+ }
98
+ /**
99
+ * A {@link KnowledgeImporterHost} over the app's own Knowledge storage: each flush is one storage
100
+ * transaction holding its page writes, node map, state, run changes and receipt. Embeds run after
101
+ * commit; a failed embed is a warning and never fails the flush.
102
+ *
103
+ * @internal Reached through `Knowledge`; the writer is Knowledge's own.
104
+ */
105
+ export declare function createLocalKnowledgeImporterHost(writer: KnowledgeHostWriter, options: LocalKnowledgeImporterHostOptions): KnowledgeImporterServiceHost;
106
+ //# sourceMappingURL=local-host.d.ts.map
@@ -0,0 +1,25 @@
1
+ import type { JSONSchema7 } from 'json-schema';
2
+ /**
3
+ * What a host shows for an importer class: its form and its credential slots. Plain JSON, so a UI
4
+ * or another process (hosted Knowledge) can render it without the importer's code.
5
+ *
6
+ * @experimental
7
+ */
8
+ export interface KnowledgeImporterManifest {
9
+ id: string;
10
+ label: string;
11
+ description?: string;
12
+ /** An http(s) URL or a `data:image/` URI. */
13
+ iconUrl?: string;
14
+ /** Draft-07 JSON Schema of the settings as a binding supplies them (the schema's input side). */
15
+ settingsSchema: JSONSchema7;
16
+ credentials: Record<string, {
17
+ description: string;
18
+ secret: boolean;
19
+ }>;
20
+ }
21
+ /** The settings schema of an importer with no settings: an empty object. */
22
+ export declare const EMPTY_KNOWLEDGE_IMPORTER_SETTINGS_SCHEMA: JSONSchema7;
23
+ /** Every `$ref` in a schema, so a manifest can refuse ones that point outside the schema. */
24
+ export declare function jsonSchemaRefs(schema: unknown, refs?: string[]): string[];
25
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { KnowledgeImporterBase } from './define.js';
2
+ import type { KnowledgeImporterClass } from './define.js';
3
+ import type { KnowledgeImporterHost, KnowledgeImporterStartRunOptions } from './host.js';
4
+ import type { KnowledgeImporterRunReceipt } from './types.js';
5
+ /** @experimental */
6
+ export interface RunKnowledgeImportOptions {
7
+ /**
8
+ * The app's importers. An instance runs when its binding is the run's binding; a class is
9
+ * constructed from the binding the host returns (a host that keeps bindings itself, as hosted
10
+ * Knowledge does).
11
+ */
12
+ importers: readonly (KnowledgeImporterBase | KnowledgeImporterClass)[];
13
+ host: KnowledgeImporterHost;
14
+ bindingId: string;
15
+ start?: KnowledgeImporterStartRunOptions;
16
+ /** No new pass starts after this. Default 25 minutes. */
17
+ budgetMs?: number;
18
+ /** After the budget, how long a running pass may take before the run is stopped. Default 3 minutes. */
19
+ graceMs?: number;
20
+ /** Most `import` passes in one run. Default 200. */
21
+ maxPasses?: number;
22
+ /** Ops per flush. Default 200. */
23
+ bufferSize?: number;
24
+ /** Default 30 seconds. */
25
+ heartbeatMs?: number;
26
+ /** Resends of one flush or finish after a 5xx or network error. Default 8. */
27
+ maxRetries?: number;
28
+ /**
29
+ * How long one call to the host may take before it counts as a lost ack (retryable: it may have
30
+ * committed). Default 60 seconds.
31
+ */
32
+ hostCallTimeoutMs?: number;
33
+ retryDelayMs?: (attempt: number) => number;
34
+ /** The source fetch handed to the importer. Default the platform fetch. */
35
+ fetch?: (input: string | URL, init?: RequestInit) => Promise<Response>;
36
+ }
37
+ /** @experimental */
38
+ export type RunKnowledgeImportResult = KnowledgeImporterRunReceipt
39
+ /** Another run of the binding was going. */
40
+ | {
41
+ status: 'skipped';
42
+ runId: string;
43
+ }
44
+ /**
45
+ * The host couldn't be reached to record the end. The run stays open on the host until its
46
+ * liveness check ends it; nothing more is written for it.
47
+ */
48
+ | {
49
+ status: 'unfinished';
50
+ runId: string;
51
+ lastSeq: number;
52
+ };
53
+ /**
54
+ * Runs one import: starts a run on the host, calls the importer's `import` in passes, sends its items
55
+ * in numbered flushes, and records how the run ended. Every write goes through `host`; the runner
56
+ * never touches storage. Failures end the run with a fixed code; no exception text leaves the app.
57
+ *
58
+ * @experimental
59
+ */
60
+ export declare function runKnowledgeImport(options: RunKnowledgeImportOptions): Promise<RunKnowledgeImportResult>;
61
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1,105 @@
1
+ import type { KnowledgeStorage } from '../../storage/domains/knowledge/base.js';
2
+ import type { KnowledgeImporterBindingRecord, KnowledgeImporterChangeKind, KnowledgeImportersStorage } from '../../storage/domains/knowledge/importers.js';
3
+ import type { KnowledgePage, KnowledgeProvenance } from '../../storage/domains/knowledge/pages.js';
4
+ import type { KnowledgeImportCounts, KnowledgeImportRefusal, KnowledgeImportRefusalReason, KnowledgeImporterOp } from './types.js';
5
+ /**
6
+ * Applies one flush's ops to pages and the node map, on a transaction view. Pages are found by id
7
+ * through the node map: the binding tracks its anchor (the folder at its target) and the pages its
8
+ * nodes point at. A page already at a new item's path is taken over by that item's node, whoever
9
+ * wrote it, and kept as a stub rather than deleted when the item is removed.
10
+ *
11
+ * @internal
12
+ */
13
+ /** The body a page keeps when its item is gone at the source but pages are still nested under it. */
14
+ export declare const REMOVED_PARENT_BODY = "Removed from the source. Kept because pages are still nested under it.";
15
+ export declare const REMOVED_FOLDER_BODY = "Removed from the source. Kept because another importer writes under it.";
16
+ export declare const REMOVED_ADOPTED_BODY = "Removed from the source. Kept because the page was here before the import.";
17
+ /** Heads the note that keeps the body a page had before an importer took it over. */
18
+ export declare const ORIGINAL_BODY_NOTE = "The body this page had before an importer took it over:\n\n";
19
+ /** Embedding work for after commit. */
20
+ export type KnowledgeImportEmbedJob = {
21
+ kind: 'index';
22
+ pageId: string;
23
+ } | {
24
+ kind: 'remove';
25
+ pageId: string;
26
+ };
27
+ export interface KnowledgeImportChange {
28
+ sourceId: string;
29
+ pageId: string | null;
30
+ change: KnowledgeImporterChangeKind;
31
+ title: string;
32
+ path: string;
33
+ }
34
+ export interface KnowledgeImportSinkResult {
35
+ counts: Omit<KnowledgeImportCounts, 'refused'>;
36
+ refused: KnowledgeImportRefusal[];
37
+ changes: KnowledgeImportChange[];
38
+ embeds: KnowledgeImportEmbedJob[];
39
+ /** Whether any op wrote a page or the node map: an empty or all-refused flush applies nothing. */
40
+ applied: boolean;
41
+ /** Present when the flush ran a settle slice. */
42
+ settle?: KnowledgeImportSettleResult;
43
+ }
44
+ /** Bounds for one settle slice (O3 §C, §C′): a slice never drains everything. */
45
+ export interface KnowledgeImportSettleBudget {
46
+ /** The unsettled node to start after: where the last slice stopped. Null starts a pass. */
47
+ after: string | null;
48
+ /** Unsettled nodes examined at most. */
49
+ candidates: number;
50
+ /** Page moves at most. */
51
+ moves: number;
52
+ /** Epoch ms: the slice stops before the next candidate once this has passed. */
53
+ until: number;
54
+ /** Called as the slice starts, so a host can tell a timeout while settling from one before it. */
55
+ onStart?: () => void;
56
+ }
57
+ export interface KnowledgeImportSettleResult {
58
+ /** The pass isn't through the binding's unsettled nodes: another slice should run. */
59
+ pending: boolean;
60
+ /** Where the next slice starts; null when the pass ended and the next one starts over. */
61
+ cursor: string | null;
62
+ /** Moves and relinks this slice landed. */
63
+ settled: number;
64
+ /** The slice ran from the first unsettled node, so it saw every repair queued before it started. */
65
+ fromStart: boolean;
66
+ }
67
+ /**
68
+ * Host state key another binding's flush sets, to a fresh value, when it queues link repairs on
69
+ * this binding's pages. Those pages may sort before this binding's saved settle cursor, so its next
70
+ * slice starts the pass over when the value differs from {@link KNOWLEDGE_IMPORT_SETTLE_SEEN_KEY}.
71
+ * The binding's own flushes never write this key, so a flush that read the state earlier can't undo it.
72
+ */
73
+ export declare const KNOWLEDGE_IMPORT_SETTLE_RESTART_KEY = "mastra:settle:restart";
74
+ /** The {@link KNOWLEDGE_IMPORT_SETTLE_RESTART_KEY} value the binding's settling last started over for. */
75
+ export declare const KNOWLEDGE_IMPORT_SETTLE_SEEN_KEY = "mastra:settle:seen";
76
+ /** A per-item refusal: its savepoint rolls back and the flush goes on. */
77
+ export declare class KnowledgeImportRefusalError extends Error {
78
+ readonly reason: KnowledgeImportRefusalReason;
79
+ constructor(reason: KnowledgeImportRefusalReason);
80
+ }
81
+ /** Splits `<scope>#<path>`; throws on a target the sink can't own. */
82
+ export declare function parseKnowledgeImportTarget(target: string): {
83
+ scope: string;
84
+ path: string[];
85
+ };
86
+ /**
87
+ * A reversible page key for a source ID: `/`, `#`, `%`, `:` and `~` become `~` and two hex digits,
88
+ * and an empty ID is `~`. As Platform's sink, so imported paths match.
89
+ */
90
+ export declare function knowledgeImportKey(sourceId: string): string;
91
+ export interface KnowledgeImportSinkInput {
92
+ /** A transaction view. */
93
+ storage: KnowledgeStorage;
94
+ importers: KnowledgeImportersStorage;
95
+ binding: KnowledgeImporterBindingRecord;
96
+ /** The scope page of the binding's target, materialized before the flush. */
97
+ scope: KnowledgePage;
98
+ runId: string;
99
+ ops: KnowledgeImporterOp[];
100
+ provenance: KnowledgeProvenance;
101
+ /** Run one settle slice after the ops. */
102
+ settle?: KnowledgeImportSettleBudget;
103
+ }
104
+ export declare function applyKnowledgeImportFlush(input: KnowledgeImportSinkInput): Promise<KnowledgeImportSinkResult>;
105
+ //# sourceMappingURL=sink.d.ts.map
@@ -0,0 +1,144 @@
1
+ /**
2
+ * The importer contract: what an importer writes (items) and what its runner sends a host (flushes).
3
+ * Items name things by `sourceId`, the source's own stable ID. They never name pages or paths;
4
+ * the host's sink decides where an item lands and refuses what the binding doesn't own.
5
+ */
6
+ /** A link from an item to another item of the same binding, resolved through the node map. */
7
+ export interface KnowledgeImportLink {
8
+ sourceId: string;
9
+ rel?: string;
10
+ }
11
+ /** Puts an item in the tree before its body is fetched (search skips it until the body lands). */
12
+ export interface KnowledgeImportDeclaration {
13
+ /** Stable ID at the source, never the title. */
14
+ sourceId: string;
15
+ kind?: string;
16
+ title: string;
17
+ /** The parent's `sourceId`, or null/absent for the binding's target top. */
18
+ parent?: string | null;
19
+ /** Where the item waits while `parent` hasn't arrived: a holding item's `sourceId`. */
20
+ fallbackParent?: string;
21
+ }
22
+ /**
23
+ * One item with its content. A re-upsert whose title, description and body match the page writes
24
+ * nothing; otherwise the item's fields replace the page's, including edits someone made in Knowledge.
25
+ */
26
+ export interface KnowledgeImportItem extends KnowledgeImportDeclaration {
27
+ description?: string;
28
+ body: string;
29
+ links?: KnowledgeImportLink[];
30
+ /** Other refs (URLs, keys) that resolve links to this item. They never change placement. */
31
+ aliases?: string[];
32
+ }
33
+ /** A buffered importer call, as sent in a flush. */
34
+ export type KnowledgeImporterOp = {
35
+ op: 'upsert';
36
+ item: KnowledgeImportItem;
37
+ } | {
38
+ op: 'declare';
39
+ item: KnowledgeImportDeclaration;
40
+ }
41
+ /** Only on a positive signal from the source (archived, trashed); never because an item was missing. */
42
+ | {
43
+ op: 'remove';
44
+ sourceId: string;
45
+ };
46
+ /** Staged `ctx.state.set` values. They commit with the ops of the same flush, or not at all. */
47
+ export type KnowledgeImporterState = Record<string, string>;
48
+ /** Why the sink refused one op. The rest of the flush still commits. */
49
+ export type KnowledgeImportRefusalReason =
50
+ /** Another page took the item's path at the same moment, or the page found there changed before it was locked. */
51
+ 'occupied'
52
+ /** The item's page or the pages on the way to it changed while the flush waited, or Knowledge refused the write (a move too large, for example). */
53
+ | 'conflict'
54
+ /** The op names something the binding can't hold (bad parent, malformed item). */
55
+ | 'invalid';
56
+ export interface KnowledgeImportRefusal {
57
+ sourceId: string;
58
+ reason: KnowledgeImportRefusalReason;
59
+ }
60
+ export interface KnowledgeImportCounts {
61
+ created: number;
62
+ updated: number;
63
+ unchanged: number;
64
+ moved: number;
65
+ removed: number;
66
+ stubbed: number;
67
+ refused: number;
68
+ }
69
+ /** What a host applied for one flush. A replay of the same flush returns the stored receipt. */
70
+ export interface KnowledgeImporterFlushReceipt extends Omit<KnowledgeImportCounts, 'refused'> {
71
+ seq: number;
72
+ refused: KnowledgeImportRefusal[];
73
+ /**
74
+ * The host has settle work left: pages to move under parents that arrived since, or links that
75
+ * now resolve. The runner sends empty flushes (`ops: []`) while this is true and its budget
76
+ * allows; each does one bounded slice. Stored with the receipt, so a replay returns the same value.
77
+ */
78
+ pending?: boolean;
79
+ }
80
+ /** One numbered batch from the runner. All or nothing. */
81
+ export interface KnowledgeImporterFlush {
82
+ runId: string;
83
+ generation: number;
84
+ /** Exactly the host's last committed seq + 1. */
85
+ seq: number;
86
+ /** `knowledgeImporterFlushDigest({ ops, state })`. The host recomputes it and refuses a mismatch. */
87
+ digest: string;
88
+ ops: KnowledgeImporterOp[];
89
+ state?: KnowledgeImporterState;
90
+ }
91
+ export type KnowledgeImporterRunOutcome = 'succeeded' | 'failed' | 'canceled';
92
+ /**
93
+ * Failure codes an importer run can finish with. Fixed codes, no free text: a host may store and
94
+ * show them, so an app's exception text never leaves the app's own logs.
95
+ */
96
+ export type KnowledgeImporterErrorCode = 'source_auth_failed' | 'source_unreachable' | 'source_rate_limited' | 'source_bad_response' | 'source_not_found' | 'settings_invalid' | 'credential_missing' | 'importer_missing_from_deploy' | 'importer_error'
97
+ /** Hard deadline reached; the cursor stays behind what didn't land. */
98
+ | 'stopped'
99
+ /** Recorded by a host that ended the run: its runner stopped renewing the lease. */
100
+ | 'lease_expired'
101
+ /** Recorded by a host that ended the run: the run's deadline passed before it finished. */
102
+ | 'deadline_exceeded';
103
+ export interface KnowledgeImporterRunError {
104
+ code: KnowledgeImporterErrorCode;
105
+ retryable?: boolean;
106
+ /** The source's HTTP status, when the failure was a source response. */
107
+ httpStatus?: number;
108
+ }
109
+ export interface KnowledgeImporterFinishRequest {
110
+ runId: string;
111
+ generation: number;
112
+ outcome: KnowledgeImporterRunOutcome;
113
+ /** Only `succeeded` with backlog is chained into another run. */
114
+ backlog: boolean;
115
+ /** The last seq the runner had a receipt for; must equal the host's committed seq. */
116
+ lastSeq: number;
117
+ error?: KnowledgeImporterRunError;
118
+ }
119
+ /** What a host recorded when a run ended. Counts are summed from flush receipts, never sent by the runner. */
120
+ export interface KnowledgeImporterRunReceipt {
121
+ runId: string;
122
+ outcome: KnowledgeImporterRunOutcome;
123
+ backlog: boolean;
124
+ lastSeq: number;
125
+ error: {
126
+ code: KnowledgeImporterErrorCode;
127
+ retryable: boolean | null;
128
+ httpStatus: number | null;
129
+ } | null;
130
+ counts: KnowledgeImportCounts;
131
+ /**
132
+ * The host's decision to start another run right away: the app's `backlog`, or settle work left
133
+ * after this run's settle flushes made progress. Schedulers chain on this, never on `backlog`.
134
+ * Stored with the finish; a replay returns the same value.
135
+ */
136
+ chain: boolean;
137
+ /**
138
+ * The items the host refused in this run, as the runner received them in flush receipts: the first
139
+ * 100, in order. `counts.refused` has the total. Set by the runner, not stored by the host, so a
140
+ * receipt read back from the host has none.
141
+ */
142
+ refused?: KnowledgeImportRefusal[];
143
+ }
144
+ //# sourceMappingURL=types.d.ts.map