@mastra/server 1.86.0-alpha.5 → 1.86.0-alpha.6

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 (742) hide show
  1. package/dist/{a2a-DtYL9fy1.js → a2a-BFN2C8f2.js} +1 -3
  2. package/dist/a2a-BsBYrosr.cjs +0 -2
  3. package/dist/a2a-C3ClP3C2.js +0 -2
  4. package/dist/{a2a-BAjf7XaU.cjs → a2a-DlEIsCZz.cjs} +1 -3
  5. package/dist/{agent-builder-DmGIcMcp.js → agent-builder-Bd6qGrt6.js} +1 -3
  6. package/dist/{agent-builder-NRim1NAX.cjs → agent-builder-Bz1beuPE.cjs} +1 -3
  7. package/dist/agent-builder-CSnA_l6K.js +0 -2
  8. package/dist/agent-builder-DSKjD22s.cjs +0 -2
  9. package/dist/agent-controller-BHJDvCaS.cjs +0 -2
  10. package/dist/agent-controller-NRR6SK66.js +0 -2
  11. package/dist/agent-versions-CwWhEoU5.cjs +0 -2
  12. package/dist/agent-versions-DfcKpYNW.js +0 -2
  13. package/dist/agents-B0OpLdbp.js +0 -2
  14. package/dist/{agents-CSR862WA.js → agents-BMdbohgU.js} +2 -3
  15. package/dist/agents-CH_G37hG.cjs +0 -2
  16. package/dist/{agents-DpvoAW1s.cjs → agents-DiQ_L6BU.cjs} +2 -3
  17. package/dist/{api-schema-manifest-CGcUFUp0.cjs → api-schema-manifest-BuAf53GH.cjs} +1 -3
  18. package/dist/{api-schema-manifest-CejGItC3.js → api-schema-manifest-CsefW4Vv.js} +1 -3
  19. package/dist/auth-CM5AgF9l.cjs +0 -2
  20. package/dist/auth-CjT_a76k.js +0 -2
  21. package/dist/background-tasks-4EZqzWvG.cjs +0 -2
  22. package/dist/background-tasks-xkwOZ9D_.js +0 -2
  23. package/dist/builder-registry-BBI_5CBL.cjs +0 -2
  24. package/dist/builder-registry-WYVRUCgJ.js +0 -2
  25. package/dist/{catalogue-BxyrTkPQ.js → catalogue-BtSLF1p2.js} +5 -7
  26. package/dist/{catalogue-BEEjZ-fW.cjs → catalogue-CAIZ08il.cjs} +5 -7
  27. package/dist/channels-DlsNzITQ.cjs +0 -2
  28. package/dist/channels-bkX-zz9J.js +0 -2
  29. package/dist/common-D5XxSuvu.cjs +0 -2
  30. package/dist/common-J-yUnHk9.js +0 -2
  31. package/dist/constants-C1ASuP4t.js +0 -2
  32. package/dist/constants-CyNbINin.cjs +0 -2
  33. package/dist/{conversations-CCQijwPL.cjs → conversations-6v0VCbif.cjs} +1 -3
  34. package/dist/conversations-BVj0Dk2Q.cjs +0 -2
  35. package/dist/conversations-DHrKTI6x.js +0 -2
  36. package/dist/{conversations-KzKXe3OK.js → conversations-Dzpv_Cgt.js} +1 -3
  37. package/dist/datasets-C1XJLHN8.js +0 -2
  38. package/dist/datasets-hqDd4IUN.cjs +0 -2
  39. package/dist/default-options-DRN81WEQ.cjs +0 -2
  40. package/dist/default-options-Dir6CKnE.js +0 -2
  41. package/dist/dist-36GZrEvk.cjs +0 -2
  42. package/dist/dist-BZGewCGq.cjs +0 -2
  43. package/dist/dist-Bal15xNO.cjs +0 -2
  44. package/dist/{dist-CSKnIYx2.cjs → dist-C0Das1QD.cjs} +1 -1
  45. package/dist/{dist-CLzhYZ2T.cjs → dist-C5rwoPuL.cjs} +235 -44
  46. package/dist/dist-CNjm6d2Q.js +0 -2
  47. package/dist/dist-CVoi_Dov.js +0 -2
  48. package/dist/dist-C_7xKME1.js +1 -0
  49. package/dist/{dist-BFqayW55.js → dist-Czbww9cr.js} +235 -44
  50. package/dist/dist-D02J6PZG.cjs +0 -2
  51. package/dist/dist-DC9qnRcv.js +0 -2
  52. package/dist/dist-Dc0g0QSi.js +0 -2
  53. package/dist/dist-Dwfkbwzg.js +0 -2
  54. package/dist/dist-lG-fYW7-.cjs +0 -2
  55. package/dist/docs/SKILL.md +1 -1
  56. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  57. package/dist/dynamic-workflows-DPgV6qtS.cjs +0 -2
  58. package/dist/dynamic-workflows-DmkCJ4Lp.js +0 -2
  59. package/dist/editor-builder-CXLdplIj.js +0 -2
  60. package/dist/{editor-builder-vasNoMoK.cjs → editor-builder-Cx9ZiHBw.cjs} +1 -3
  61. package/dist/{editor-builder-BOqUsHI9.js → editor-builder-DpNB1W4s.js} +1 -3
  62. package/dist/editor-builder-eF2IetF2.cjs +0 -2
  63. package/dist/favorites-8aieznq3.js +0 -2
  64. package/dist/favorites-D0CoxxQn.cjs +0 -2
  65. package/dist/helpers-Zu5ZVxSl.cjs +0 -2
  66. package/dist/helpers-hFdKABRP.js +0 -2
  67. package/dist/http-exception-Co3MbFUf.cjs +0 -2
  68. package/dist/http-exception-CzaWkxMl.js +0 -2
  69. package/dist/index.cjs +0 -2
  70. package/dist/index.js +0 -2
  71. package/dist/knowledge-DAqUHFK5.js +0 -2
  72. package/dist/knowledge-DL03nbSW.cjs +0 -2
  73. package/dist/logs-B0dcn5iB.cjs +0 -2
  74. package/dist/logs-Ca_q8krO.js +0 -2
  75. package/dist/logs-CqgT7AOV.js +0 -2
  76. package/dist/logs-YisOj8HR.cjs +0 -2
  77. package/dist/mcp-B7Q8qwjn.cjs +0 -2
  78. package/dist/mcp-C060MyHc.cjs +0 -2
  79. package/dist/mcp-CQ_pR-JC.js +0 -2
  80. package/dist/mcp-DXvFogeV.js +0 -2
  81. package/dist/mcp-client-versions-BS99SD4O.cjs +0 -2
  82. package/dist/mcp-client-versions-Rd-ry9Qa.js +0 -2
  83. package/dist/memory--xJDrSwF.cjs +0 -2
  84. package/dist/memory-03B4pe3w.js +0 -2
  85. package/dist/memory-4Izw-l6v.cjs +0 -2
  86. package/dist/memory-CCEjoCF6.js +0 -2
  87. package/dist/message-history-BBVH-ORZ.js +0 -2
  88. package/dist/message-history-CtELj716.cjs +0 -2
  89. package/dist/observability-Cn4P60P4.cjs +0 -2
  90. package/dist/observability-new-endpoints-iRwQxqwY.cjs +0 -2
  91. package/dist/observability-new-endpoints-vj6FaEcm.js +0 -2
  92. package/dist/observability-zr7LDCQG.js +0 -2
  93. package/dist/{plans-CF7WEUSe.js → plans-BoUO4vWD.js} +1 -3
  94. package/dist/{plans-DWm5yfiR.cjs → plans-DYNE2s8s.cjs} +1 -3
  95. package/dist/{probe-image-size-C7QtN5-G.js → probe-image-size-C0BvSeqt.js} +1 -3
  96. package/dist/{probe-image-size-qvUx8Kjc.cjs → probe-image-size-DQsyQSUh.cjs} +1 -3
  97. package/dist/processor-providers-CRrcV9ra.cjs +0 -2
  98. package/dist/processor-providers-WHdDe4aA.js +0 -2
  99. package/dist/processors-BEut-2a-.cjs +0 -2
  100. package/dist/processors-IhyRC0xH.js +0 -2
  101. package/dist/prompt-block-versions-3T-L2loy.js +0 -2
  102. package/dist/prompt-block-versions-BTdrcaLe.cjs +0 -2
  103. package/dist/{responses-vS2YsMlq.cjs → responses-ByDnfqlJ.cjs} +1 -3
  104. package/dist/{responses-C1T0-Hw8.js → responses-CGv4KFQ3.js} +1 -3
  105. package/dist/responses-CTiwnWeF.cjs +0 -2
  106. package/dist/responses-D-fsDRLd.js +0 -2
  107. package/dist/route-builder-DjTBxSZN.cjs +0 -2
  108. package/dist/route-builder-Dz18c3qm.js +0 -2
  109. package/dist/{routes-BGtkFANE.cjs → routes-BLjObOVE.cjs} +11 -13
  110. package/dist/{routes-CIPFz2Tx.js → routes-C0TLNOPH.js} +11 -13
  111. package/dist/rule-group-4pWeG61q.js +0 -2
  112. package/dist/rule-group-CIacr-Zz.cjs +0 -2
  113. package/dist/schedules-0ceTSdBB.cjs +0 -2
  114. package/dist/schedules-D_VfFdAH.js +0 -2
  115. package/dist/schema-TQPB_dl2-CCzMcdDx.js +0 -2
  116. package/dist/schema-TQPB_dl2-CJX1q58F.cjs +0 -2
  117. package/dist/scorer-versions-Bhdvt-cX.cjs +0 -2
  118. package/dist/scorer-versions-DhT7Lj33.js +0 -2
  119. package/dist/scores-BULd4ZBI.js +0 -2
  120. package/dist/scores-CWCaN4jf.cjs +0 -2
  121. package/dist/{scores-qNLVpqlb.js → scores-CqNF-thA.js} +1 -3
  122. package/dist/{scores-Cjq0cSLS.cjs → scores-EVbkxGHy.cjs} +1 -3
  123. package/dist/server/a2a/store.cjs +0 -2
  124. package/dist/server/a2a/store.js +0 -2
  125. package/dist/server/browser-stream/index.cjs +0 -2
  126. package/dist/server/browser-stream/index.js +0 -2
  127. package/dist/server/handlers/a2a.cjs +1 -1
  128. package/dist/server/handlers/a2a.js +1 -1
  129. package/dist/server/handlers/agent-access.cjs +0 -2
  130. package/dist/server/handlers/agent-access.js +0 -2
  131. package/dist/server/handlers/agent-builder.cjs +1 -1
  132. package/dist/server/handlers/agent-builder.js +1 -1
  133. package/dist/server/handlers/agent-versions.cjs +0 -2
  134. package/dist/server/handlers/agent-versions.js +0 -2
  135. package/dist/server/handlers/agents.cjs +1 -1
  136. package/dist/server/handlers/agents.js +1 -1
  137. package/dist/server/handlers/auth.cjs +0 -2
  138. package/dist/server/handlers/auth.js +0 -2
  139. package/dist/server/handlers/author-enrichment.cjs +0 -2
  140. package/dist/server/handlers/author-enrichment.js +0 -2
  141. package/dist/server/handlers/authorship.cjs +0 -2
  142. package/dist/server/handlers/authorship.js +0 -2
  143. package/dist/server/handlers/conversations.cjs +1 -1
  144. package/dist/server/handlers/conversations.js +1 -1
  145. package/dist/server/handlers/datasets.cjs +0 -2
  146. package/dist/server/handlers/datasets.js +0 -2
  147. package/dist/server/handlers/editor-builder.cjs +1 -1
  148. package/dist/server/handlers/editor-builder.js +1 -1
  149. package/dist/server/handlers/error.cjs +0 -2
  150. package/dist/server/handlers/error.js +0 -2
  151. package/dist/server/handlers/favorites-enrichment.cjs +1 -3
  152. package/dist/server/handlers/favorites-enrichment.js +1 -3
  153. package/dist/server/handlers/gateway-memory-client.cjs +0 -2
  154. package/dist/server/handlers/gateway-memory-client.js +0 -2
  155. package/dist/server/handlers/mcp-client-versions.cjs +0 -2
  156. package/dist/server/handlers/mcp-client-versions.js +0 -2
  157. package/dist/server/handlers/observability-export.cjs +0 -2
  158. package/dist/server/handlers/observability-export.js +0 -2
  159. package/dist/server/handlers/observability-list-query-schemas.cjs +0 -2
  160. package/dist/server/handlers/observability-list-query-schemas.js +0 -2
  161. package/dist/server/handlers/observability-shared.cjs +0 -2
  162. package/dist/server/handlers/observability-shared.js +0 -2
  163. package/dist/server/handlers/observability-signal-context.cjs +0 -2
  164. package/dist/server/handlers/observability-signal-context.js +0 -2
  165. package/dist/server/handlers/observability-storage-schemas.cjs +0 -2
  166. package/dist/server/handlers/observability-storage-schemas.js +0 -2
  167. package/dist/server/handlers/plans.cjs +1 -1
  168. package/dist/server/handlers/plans.js +1 -1
  169. package/dist/server/handlers/processor-providers.cjs +0 -2
  170. package/dist/server/handlers/processor-providers.js +0 -2
  171. package/dist/server/handlers/processors.cjs +0 -2
  172. package/dist/server/handlers/processors.js +0 -2
  173. package/dist/server/handlers/prompt-block-versions.cjs +0 -2
  174. package/dist/server/handlers/prompt-block-versions.js +0 -2
  175. package/dist/server/handlers/responses.adapter.cjs +0 -2
  176. package/dist/server/handlers/responses.adapter.js +0 -2
  177. package/dist/server/handlers/responses.cjs +1 -1
  178. package/dist/server/handlers/responses.js +1 -1
  179. package/dist/server/handlers/responses.storage.cjs +0 -2
  180. package/dist/server/handlers/responses.storage.js +0 -2
  181. package/dist/server/handlers/schedules-workflows-shim.cjs +0 -2
  182. package/dist/server/handlers/schedules-workflows-shim.js +0 -2
  183. package/dist/server/handlers/scorer-versions.cjs +0 -2
  184. package/dist/server/handlers/scorer-versions.js +0 -2
  185. package/dist/server/handlers/scores.cjs +1 -1
  186. package/dist/server/handlers/scores.js +1 -1
  187. package/dist/server/handlers/skills-sh-shared.cjs +0 -2
  188. package/dist/server/handlers/skills-sh-shared.js +0 -2
  189. package/dist/server/handlers/stored-agent-favorites.cjs +1 -3
  190. package/dist/server/handlers/stored-agent-favorites.js +1 -3
  191. package/dist/server/handlers/stored-agents.cjs +1 -3
  192. package/dist/server/handlers/stored-agents.js +1 -3
  193. package/dist/server/handlers/stored-mcp-clients.cjs +0 -2
  194. package/dist/server/handlers/stored-mcp-clients.js +0 -2
  195. package/dist/server/handlers/stored-prompt-blocks.cjs +0 -2
  196. package/dist/server/handlers/stored-prompt-blocks.js +0 -2
  197. package/dist/server/handlers/stored-scorers.cjs +0 -2
  198. package/dist/server/handlers/stored-scorers.js +0 -2
  199. package/dist/server/handlers/stored-skill-favorites.cjs +1 -3
  200. package/dist/server/handlers/stored-skill-favorites.js +1 -3
  201. package/dist/server/handlers/stored-skills.cjs +1 -3
  202. package/dist/server/handlers/stored-skills.js +1 -3
  203. package/dist/server/handlers/stored-workspaces.cjs +0 -2
  204. package/dist/server/handlers/stored-workspaces.js +0 -2
  205. package/dist/server/handlers/system.cjs +1 -3
  206. package/dist/server/handlers/system.js +1 -3
  207. package/dist/server/handlers/test-utils.cjs +0 -2
  208. package/dist/server/handlers/test-utils.js +0 -2
  209. package/dist/server/handlers/tool-providers.cjs +0 -2
  210. package/dist/server/handlers/tool-providers.js +0 -2
  211. package/dist/server/handlers/tool-schema-overrides.cjs +0 -2
  212. package/dist/server/handlers/tool-schema-overrides.js +0 -2
  213. package/dist/server/handlers/tools.cjs +1 -1
  214. package/dist/server/handlers/tools.js +1 -1
  215. package/dist/server/handlers/validate-agent-instructions.cjs +0 -2
  216. package/dist/server/handlers/validate-agent-instructions.js +0 -2
  217. package/dist/server/handlers/validate-avatar.cjs +0 -2
  218. package/dist/server/handlers/validate-avatar.js +0 -2
  219. package/dist/server/handlers/version-helpers.cjs +0 -2
  220. package/dist/server/handlers/version-helpers.js +0 -2
  221. package/dist/server/handlers/voice.cjs +1 -1
  222. package/dist/server/handlers/voice.js +1 -1
  223. package/dist/server/handlers.cjs +9 -9
  224. package/dist/server/handlers.js +9 -9
  225. package/dist/server/mcp/catalogue.d.ts +1 -1
  226. package/dist/server/mcp/schema.d.ts +1 -1
  227. package/dist/server/server-adapter/api-schema-manifest.d.ts +1 -1
  228. package/dist/server/server-adapter/index.cjs +2 -2
  229. package/dist/server/server-adapter/index.js +2 -2
  230. package/dist/server/server-adapter/openapi-utils.d.ts +1 -1
  231. package/dist/server/server-adapter/routes/conversations.d.ts +3 -3
  232. package/dist/server/utils/agent-stream-events.d.ts +1 -0
  233. package/dist/{server-adapter-Do1caUp0.cjs → server-adapter-BkAKl970.cjs} +1 -3
  234. package/dist/{server-adapter-DI4I8Pxw.js → server-adapter-CxMHZZAv.js} +1 -3
  235. package/dist/storage-CVkNJ5eB.js +0 -2
  236. package/dist/storage-mEqRYYDg.cjs +0 -2
  237. package/dist/stored-agents-DmN_pIIl.js +0 -2
  238. package/dist/stored-agents-m0Knvv29.cjs +0 -2
  239. package/dist/stored-mcp-clients-D14ULUvS.cjs +0 -2
  240. package/dist/stored-mcp-clients-d_PaPgGc.js +0 -2
  241. package/dist/stored-prompt-blocks-B5yfQnPC.js +0 -2
  242. package/dist/stored-prompt-blocks-CqaOxMZ-.cjs +0 -2
  243. package/dist/stored-scorers-2F2k6XSx.js +0 -2
  244. package/dist/stored-scorers-iM2Qq9Nh.cjs +0 -2
  245. package/dist/stored-skills-GNJMp022.js +0 -2
  246. package/dist/stored-skills-xuecapXy.cjs +0 -2
  247. package/dist/stored-workspaces-Bswuz00o.js +0 -2
  248. package/dist/stored-workspaces-g5-GKY38.cjs +0 -2
  249. package/dist/system-CKTXaHMZ.js +0 -2
  250. package/dist/system-DKCYwd0y.cjs +0 -2
  251. package/dist/tool-providers-BVwRJTtB.cjs +0 -2
  252. package/dist/tool-providers-Cq3vFqgE.js +0 -2
  253. package/dist/{tools-DqgYXmdT.js → tools-CZmeb9MB.js} +1 -3
  254. package/dist/{tools-Cv7TwNHv.cjs → tools-D07qyAT0.cjs} +1 -3
  255. package/dist/utils-C2VRtQjI.js +0 -2
  256. package/dist/utils-CvYihOoy.js +0 -2
  257. package/dist/utils-DQJOBnMo.cjs +0 -2
  258. package/dist/utils-j29NB2ZJ.cjs +0 -2
  259. package/dist/vector-Bz-glead.js +0 -2
  260. package/dist/vector-DIFU_fwU.cjs +0 -2
  261. package/dist/vectors-CPSofSCf.cjs +0 -2
  262. package/dist/vectors-CadLydEJ.js +0 -2
  263. package/dist/version-common-BLTDO88f.js +0 -2
  264. package/dist/version-common-Cc0STXl9.cjs +0 -2
  265. package/dist/{voice-D-iJiiSN.js → voice-BNwHCtxv.js} +1 -3
  266. package/dist/{voice-BUAV_TGD.cjs → voice-DN72TM58.cjs} +1 -3
  267. package/dist/workflow-builder-BET96Cr_.js +0 -2
  268. package/dist/workflow-builder-DpL3Nq6T.cjs +0 -2
  269. package/dist/workflows-CKcjXfXk.cjs +0 -2
  270. package/dist/workflows-D3QrUMfm.js +0 -2
  271. package/dist/workflows-DTxiWG6x.js +0 -2
  272. package/dist/workflows-gIKukZ1O.cjs +0 -2
  273. package/dist/workspace-C5BBUatQ.cjs +0 -2
  274. package/dist/workspace-CgIZRc2P.js +0 -2
  275. package/dist/workspace-D-Exdj2l.cjs +0 -2
  276. package/dist/workspace-DBDA3UQl.js +0 -2
  277. package/package.json +7 -6
  278. package/dist/a2a-BAjf7XaU.cjs.map +0 -1
  279. package/dist/a2a-BsBYrosr.cjs.map +0 -1
  280. package/dist/a2a-C3ClP3C2.js.map +0 -1
  281. package/dist/a2a-DtYL9fy1.js.map +0 -1
  282. package/dist/agent-builder-CSnA_l6K.js.map +0 -1
  283. package/dist/agent-builder-DSKjD22s.cjs.map +0 -1
  284. package/dist/agent-builder-DmGIcMcp.js.map +0 -1
  285. package/dist/agent-builder-NRim1NAX.cjs.map +0 -1
  286. package/dist/agent-controller-BHJDvCaS.cjs.map +0 -1
  287. package/dist/agent-controller-NRR6SK66.js.map +0 -1
  288. package/dist/agent-versions-CwWhEoU5.cjs.map +0 -1
  289. package/dist/agent-versions-DfcKpYNW.js.map +0 -1
  290. package/dist/agents-B0OpLdbp.js.map +0 -1
  291. package/dist/agents-CH_G37hG.cjs.map +0 -1
  292. package/dist/agents-CSR862WA.js.map +0 -1
  293. package/dist/agents-DpvoAW1s.cjs.map +0 -1
  294. package/dist/api-schema-manifest-CGcUFUp0.cjs.map +0 -1
  295. package/dist/api-schema-manifest-CejGItC3.js.map +0 -1
  296. package/dist/auth-CM5AgF9l.cjs.map +0 -1
  297. package/dist/auth-CjT_a76k.js.map +0 -1
  298. package/dist/background-tasks-4EZqzWvG.cjs.map +0 -1
  299. package/dist/background-tasks-xkwOZ9D_.js.map +0 -1
  300. package/dist/builder-registry-BBI_5CBL.cjs.map +0 -1
  301. package/dist/builder-registry-WYVRUCgJ.js.map +0 -1
  302. package/dist/catalogue-BEEjZ-fW.cjs.map +0 -1
  303. package/dist/catalogue-BxyrTkPQ.js.map +0 -1
  304. package/dist/channels-DlsNzITQ.cjs.map +0 -1
  305. package/dist/channels-bkX-zz9J.js.map +0 -1
  306. package/dist/common-D5XxSuvu.cjs.map +0 -1
  307. package/dist/common-J-yUnHk9.js.map +0 -1
  308. package/dist/constants-C1ASuP4t.js.map +0 -1
  309. package/dist/constants-CyNbINin.cjs.map +0 -1
  310. package/dist/conversations-BVj0Dk2Q.cjs.map +0 -1
  311. package/dist/conversations-CCQijwPL.cjs.map +0 -1
  312. package/dist/conversations-DHrKTI6x.js.map +0 -1
  313. package/dist/conversations-KzKXe3OK.js.map +0 -1
  314. package/dist/datasets-C1XJLHN8.js.map +0 -1
  315. package/dist/datasets-hqDd4IUN.cjs.map +0 -1
  316. package/dist/default-options-DRN81WEQ.cjs.map +0 -1
  317. package/dist/default-options-Dir6CKnE.js.map +0 -1
  318. package/dist/dist-36GZrEvk.cjs.map +0 -1
  319. package/dist/dist-BFqayW55.js.map +0 -1
  320. package/dist/dist-BZGewCGq.cjs.map +0 -1
  321. package/dist/dist-Bal15xNO.cjs.map +0 -1
  322. package/dist/dist-CLzhYZ2T.cjs.map +0 -1
  323. package/dist/dist-CNjm6d2Q.js.map +0 -1
  324. package/dist/dist-CRbjxGDp.js +0 -1
  325. package/dist/dist-CVoi_Dov.js.map +0 -1
  326. package/dist/dist-D02J6PZG.cjs.map +0 -1
  327. package/dist/dist-DC9qnRcv.js.map +0 -1
  328. package/dist/dist-Dc0g0QSi.js.map +0 -1
  329. package/dist/dist-Dwfkbwzg.js.map +0 -1
  330. package/dist/dist-lG-fYW7-.cjs.map +0 -1
  331. package/dist/dynamic-workflows-DPgV6qtS.cjs.map +0 -1
  332. package/dist/dynamic-workflows-DmkCJ4Lp.js.map +0 -1
  333. package/dist/editor-builder-BOqUsHI9.js.map +0 -1
  334. package/dist/editor-builder-CXLdplIj.js.map +0 -1
  335. package/dist/editor-builder-eF2IetF2.cjs.map +0 -1
  336. package/dist/editor-builder-vasNoMoK.cjs.map +0 -1
  337. package/dist/favorites-8aieznq3.js.map +0 -1
  338. package/dist/favorites-D0CoxxQn.cjs.map +0 -1
  339. package/dist/helpers-Zu5ZVxSl.cjs.map +0 -1
  340. package/dist/helpers-hFdKABRP.js.map +0 -1
  341. package/dist/http-exception-Co3MbFUf.cjs.map +0 -1
  342. package/dist/http-exception-CzaWkxMl.js.map +0 -1
  343. package/dist/index.cjs.map +0 -1
  344. package/dist/index.d.ts.map +0 -1
  345. package/dist/index.js.map +0 -1
  346. package/dist/knowledge-DAqUHFK5.js.map +0 -1
  347. package/dist/knowledge-DL03nbSW.cjs.map +0 -1
  348. package/dist/logs-B0dcn5iB.cjs.map +0 -1
  349. package/dist/logs-Ca_q8krO.js.map +0 -1
  350. package/dist/logs-CqgT7AOV.js.map +0 -1
  351. package/dist/logs-YisOj8HR.cjs.map +0 -1
  352. package/dist/mcp-B7Q8qwjn.cjs.map +0 -1
  353. package/dist/mcp-C060MyHc.cjs.map +0 -1
  354. package/dist/mcp-CQ_pR-JC.js.map +0 -1
  355. package/dist/mcp-DXvFogeV.js.map +0 -1
  356. package/dist/mcp-client-versions-BS99SD4O.cjs.map +0 -1
  357. package/dist/mcp-client-versions-Rd-ry9Qa.js.map +0 -1
  358. package/dist/memory--xJDrSwF.cjs.map +0 -1
  359. package/dist/memory-03B4pe3w.js.map +0 -1
  360. package/dist/memory-4Izw-l6v.cjs.map +0 -1
  361. package/dist/memory-CCEjoCF6.js.map +0 -1
  362. package/dist/message-history-BBVH-ORZ.js.map +0 -1
  363. package/dist/message-history-CtELj716.cjs.map +0 -1
  364. package/dist/observability-Cn4P60P4.cjs.map +0 -1
  365. package/dist/observability-new-endpoints-iRwQxqwY.cjs.map +0 -1
  366. package/dist/observability-new-endpoints-vj6FaEcm.js.map +0 -1
  367. package/dist/observability-zr7LDCQG.js.map +0 -1
  368. package/dist/plans-CF7WEUSe.js.map +0 -1
  369. package/dist/plans-DWm5yfiR.cjs.map +0 -1
  370. package/dist/probe-image-size-C7QtN5-G.js.map +0 -1
  371. package/dist/probe-image-size-qvUx8Kjc.cjs.map +0 -1
  372. package/dist/processor-providers-CRrcV9ra.cjs.map +0 -1
  373. package/dist/processor-providers-WHdDe4aA.js.map +0 -1
  374. package/dist/processors-BEut-2a-.cjs.map +0 -1
  375. package/dist/processors-IhyRC0xH.js.map +0 -1
  376. package/dist/prompt-block-versions-3T-L2loy.js.map +0 -1
  377. package/dist/prompt-block-versions-BTdrcaLe.cjs.map +0 -1
  378. package/dist/responses-C1T0-Hw8.js.map +0 -1
  379. package/dist/responses-CTiwnWeF.cjs.map +0 -1
  380. package/dist/responses-D-fsDRLd.js.map +0 -1
  381. package/dist/responses-vS2YsMlq.cjs.map +0 -1
  382. package/dist/route-builder-DjTBxSZN.cjs.map +0 -1
  383. package/dist/route-builder-Dz18c3qm.js.map +0 -1
  384. package/dist/routes-BGtkFANE.cjs.map +0 -1
  385. package/dist/routes-CIPFz2Tx.js.map +0 -1
  386. package/dist/rule-group-4pWeG61q.js.map +0 -1
  387. package/dist/rule-group-CIacr-Zz.cjs.map +0 -1
  388. package/dist/schedules-0ceTSdBB.cjs.map +0 -1
  389. package/dist/schedules-D_VfFdAH.js.map +0 -1
  390. package/dist/schema-TQPB_dl2-CCzMcdDx.js.map +0 -1
  391. package/dist/schema-TQPB_dl2-CJX1q58F.cjs.map +0 -1
  392. package/dist/scorer-versions-Bhdvt-cX.cjs.map +0 -1
  393. package/dist/scorer-versions-DhT7Lj33.js.map +0 -1
  394. package/dist/scores-BULd4ZBI.js.map +0 -1
  395. package/dist/scores-CWCaN4jf.cjs.map +0 -1
  396. package/dist/scores-Cjq0cSLS.cjs.map +0 -1
  397. package/dist/scores-qNLVpqlb.js.map +0 -1
  398. package/dist/server/a2a/agent-card-signing.d.ts.map +0 -1
  399. package/dist/server/a2a/agent-card-v1.d.ts.map +0 -1
  400. package/dist/server/a2a/protocol.d.ts.map +0 -1
  401. package/dist/server/a2a/push-notification-sender.d.ts.map +0 -1
  402. package/dist/server/a2a/push-notification-store.d.ts.map +0 -1
  403. package/dist/server/a2a/store.cjs.map +0 -1
  404. package/dist/server/a2a/store.d.ts.map +0 -1
  405. package/dist/server/a2a/store.js.map +0 -1
  406. package/dist/server/a2a/task-state.d.ts.map +0 -1
  407. package/dist/server/a2a/tasks.d.ts.map +0 -1
  408. package/dist/server/auth/custom-route-matcher.d.ts.map +0 -1
  409. package/dist/server/auth/defaults.d.ts.map +0 -1
  410. package/dist/server/auth/helpers.d.ts.map +0 -1
  411. package/dist/server/auth/index.d.ts.map +0 -1
  412. package/dist/server/auth/path-pattern.d.ts.map +0 -1
  413. package/dist/server/browser-stream/index.cjs.map +0 -1
  414. package/dist/server/browser-stream/index.d.ts.map +0 -1
  415. package/dist/server/browser-stream/index.js.map +0 -1
  416. package/dist/server/browser-stream/input-handler.d.ts.map +0 -1
  417. package/dist/server/browser-stream/types.d.ts.map +0 -1
  418. package/dist/server/browser-stream/viewer-registry.d.ts.map +0 -1
  419. package/dist/server/constants.d.ts.map +0 -1
  420. package/dist/server/fga-permissions.d.ts.map +0 -1
  421. package/dist/server/handlers/a2a.d.ts.map +0 -1
  422. package/dist/server/handlers/agent-access.cjs.map +0 -1
  423. package/dist/server/handlers/agent-access.d.ts.map +0 -1
  424. package/dist/server/handlers/agent-access.js.map +0 -1
  425. package/dist/server/handlers/agent-builder.d.ts.map +0 -1
  426. package/dist/server/handlers/agent-controller.d.ts.map +0 -1
  427. package/dist/server/handlers/agent-versions.cjs.map +0 -1
  428. package/dist/server/handlers/agent-versions.d.ts.map +0 -1
  429. package/dist/server/handlers/agent-versions.js.map +0 -1
  430. package/dist/server/handlers/agents.d.ts.map +0 -1
  431. package/dist/server/handlers/auth.cjs.map +0 -1
  432. package/dist/server/handlers/auth.d.ts.map +0 -1
  433. package/dist/server/handlers/auth.js.map +0 -1
  434. package/dist/server/handlers/author-enrichment.cjs.map +0 -1
  435. package/dist/server/handlers/author-enrichment.d.ts.map +0 -1
  436. package/dist/server/handlers/author-enrichment.js.map +0 -1
  437. package/dist/server/handlers/authorship.cjs.map +0 -1
  438. package/dist/server/handlers/authorship.d.ts.map +0 -1
  439. package/dist/server/handlers/authorship.js.map +0 -1
  440. package/dist/server/handlers/background-tasks.d.ts.map +0 -1
  441. package/dist/server/handlers/builder-registry.d.ts.map +0 -1
  442. package/dist/server/handlers/channels.d.ts.map +0 -1
  443. package/dist/server/handlers/conversations.d.ts.map +0 -1
  444. package/dist/server/handlers/datasets.cjs.map +0 -1
  445. package/dist/server/handlers/datasets.d.ts.map +0 -1
  446. package/dist/server/handlers/datasets.js.map +0 -1
  447. package/dist/server/handlers/dynamic-workflows.d.ts.map +0 -1
  448. package/dist/server/handlers/editor-builder.d.ts.map +0 -1
  449. package/dist/server/handlers/error.cjs.map +0 -1
  450. package/dist/server/handlers/error.d.ts.map +0 -1
  451. package/dist/server/handlers/error.js.map +0 -1
  452. package/dist/server/handlers/favorites-enrichment.cjs.map +0 -1
  453. package/dist/server/handlers/favorites-enrichment.d.ts.map +0 -1
  454. package/dist/server/handlers/favorites-enrichment.js.map +0 -1
  455. package/dist/server/handlers/gateway-memory-client.cjs.map +0 -1
  456. package/dist/server/handlers/gateway-memory-client.d.ts.map +0 -1
  457. package/dist/server/handlers/gateway-memory-client.js.map +0 -1
  458. package/dist/server/handlers/knowledge.d.ts.map +0 -1
  459. package/dist/server/handlers/logs.d.ts.map +0 -1
  460. package/dist/server/handlers/mcp-client-versions.cjs.map +0 -1
  461. package/dist/server/handlers/mcp-client-versions.d.ts.map +0 -1
  462. package/dist/server/handlers/mcp-client-versions.js.map +0 -1
  463. package/dist/server/handlers/mcp.d.ts.map +0 -1
  464. package/dist/server/handlers/memory.d.ts.map +0 -1
  465. package/dist/server/handlers/observability-export.cjs.map +0 -1
  466. package/dist/server/handlers/observability-export.d.ts.map +0 -1
  467. package/dist/server/handlers/observability-export.js.map +0 -1
  468. package/dist/server/handlers/observability-list-query-schemas.cjs.map +0 -1
  469. package/dist/server/handlers/observability-list-query-schemas.d.ts.map +0 -1
  470. package/dist/server/handlers/observability-list-query-schemas.js.map +0 -1
  471. package/dist/server/handlers/observability-new-endpoints.d.ts.map +0 -1
  472. package/dist/server/handlers/observability-shared.cjs.map +0 -1
  473. package/dist/server/handlers/observability-shared.d.ts.map +0 -1
  474. package/dist/server/handlers/observability-shared.js.map +0 -1
  475. package/dist/server/handlers/observability-signal-context.cjs.map +0 -1
  476. package/dist/server/handlers/observability-signal-context.d.ts.map +0 -1
  477. package/dist/server/handlers/observability-signal-context.js.map +0 -1
  478. package/dist/server/handlers/observability-storage-schemas.cjs.map +0 -1
  479. package/dist/server/handlers/observability-storage-schemas.d.ts.map +0 -1
  480. package/dist/server/handlers/observability-storage-schemas.js.map +0 -1
  481. package/dist/server/handlers/observability.d.ts.map +0 -1
  482. package/dist/server/handlers/plans.d.ts.map +0 -1
  483. package/dist/server/handlers/processor-providers.cjs.map +0 -1
  484. package/dist/server/handlers/processor-providers.d.ts.map +0 -1
  485. package/dist/server/handlers/processor-providers.js.map +0 -1
  486. package/dist/server/handlers/processors.cjs.map +0 -1
  487. package/dist/server/handlers/processors.d.ts.map +0 -1
  488. package/dist/server/handlers/processors.js.map +0 -1
  489. package/dist/server/handlers/prompt-block-versions.cjs.map +0 -1
  490. package/dist/server/handlers/prompt-block-versions.d.ts.map +0 -1
  491. package/dist/server/handlers/prompt-block-versions.js.map +0 -1
  492. package/dist/server/handlers/responses.adapter.cjs.map +0 -1
  493. package/dist/server/handlers/responses.adapter.d.ts.map +0 -1
  494. package/dist/server/handlers/responses.adapter.js.map +0 -1
  495. package/dist/server/handlers/responses.d.ts.map +0 -1
  496. package/dist/server/handlers/responses.storage.cjs.map +0 -1
  497. package/dist/server/handlers/responses.storage.d.ts.map +0 -1
  498. package/dist/server/handlers/responses.storage.js.map +0 -1
  499. package/dist/server/handlers/schedules-workflows-shim.cjs.map +0 -1
  500. package/dist/server/handlers/schedules-workflows-shim.d.ts.map +0 -1
  501. package/dist/server/handlers/schedules-workflows-shim.js.map +0 -1
  502. package/dist/server/handlers/schedules.d.ts.map +0 -1
  503. package/dist/server/handlers/scorer-versions.cjs.map +0 -1
  504. package/dist/server/handlers/scorer-versions.d.ts.map +0 -1
  505. package/dist/server/handlers/scorer-versions.js.map +0 -1
  506. package/dist/server/handlers/scores.d.ts.map +0 -1
  507. package/dist/server/handlers/skills-sh-shared.cjs.map +0 -1
  508. package/dist/server/handlers/skills-sh-shared.d.ts.map +0 -1
  509. package/dist/server/handlers/skills-sh-shared.js.map +0 -1
  510. package/dist/server/handlers/stored-agent-favorites.cjs.map +0 -1
  511. package/dist/server/handlers/stored-agent-favorites.d.ts.map +0 -1
  512. package/dist/server/handlers/stored-agent-favorites.js.map +0 -1
  513. package/dist/server/handlers/stored-agents.cjs.map +0 -1
  514. package/dist/server/handlers/stored-agents.d.ts.map +0 -1
  515. package/dist/server/handlers/stored-agents.js.map +0 -1
  516. package/dist/server/handlers/stored-mcp-clients.cjs.map +0 -1
  517. package/dist/server/handlers/stored-mcp-clients.d.ts.map +0 -1
  518. package/dist/server/handlers/stored-mcp-clients.js.map +0 -1
  519. package/dist/server/handlers/stored-prompt-blocks.cjs.map +0 -1
  520. package/dist/server/handlers/stored-prompt-blocks.d.ts.map +0 -1
  521. package/dist/server/handlers/stored-prompt-blocks.js.map +0 -1
  522. package/dist/server/handlers/stored-scorers.cjs.map +0 -1
  523. package/dist/server/handlers/stored-scorers.d.ts.map +0 -1
  524. package/dist/server/handlers/stored-scorers.js.map +0 -1
  525. package/dist/server/handlers/stored-skill-favorites.cjs.map +0 -1
  526. package/dist/server/handlers/stored-skill-favorites.d.ts.map +0 -1
  527. package/dist/server/handlers/stored-skill-favorites.js.map +0 -1
  528. package/dist/server/handlers/stored-skills.cjs.map +0 -1
  529. package/dist/server/handlers/stored-skills.d.ts.map +0 -1
  530. package/dist/server/handlers/stored-skills.js.map +0 -1
  531. package/dist/server/handlers/stored-workspaces.cjs.map +0 -1
  532. package/dist/server/handlers/stored-workspaces.d.ts.map +0 -1
  533. package/dist/server/handlers/stored-workspaces.js.map +0 -1
  534. package/dist/server/handlers/system.cjs.map +0 -1
  535. package/dist/server/handlers/system.d.ts.map +0 -1
  536. package/dist/server/handlers/system.js.map +0 -1
  537. package/dist/server/handlers/test-utils.cjs.map +0 -1
  538. package/dist/server/handlers/test-utils.d.ts.map +0 -1
  539. package/dist/server/handlers/test-utils.js.map +0 -1
  540. package/dist/server/handlers/tool-providers.cjs.map +0 -1
  541. package/dist/server/handlers/tool-providers.d.ts.map +0 -1
  542. package/dist/server/handlers/tool-providers.js.map +0 -1
  543. package/dist/server/handlers/tool-schema-overrides.cjs.map +0 -1
  544. package/dist/server/handlers/tool-schema-overrides.d.ts.map +0 -1
  545. package/dist/server/handlers/tool-schema-overrides.js.map +0 -1
  546. package/dist/server/handlers/tools.d.ts.map +0 -1
  547. package/dist/server/handlers/utils.d.ts.map +0 -1
  548. package/dist/server/handlers/validate-agent-instructions.cjs.map +0 -1
  549. package/dist/server/handlers/validate-agent-instructions.d.ts.map +0 -1
  550. package/dist/server/handlers/validate-agent-instructions.js.map +0 -1
  551. package/dist/server/handlers/validate-avatar.cjs.map +0 -1
  552. package/dist/server/handlers/validate-avatar.d.ts.map +0 -1
  553. package/dist/server/handlers/validate-avatar.js.map +0 -1
  554. package/dist/server/handlers/vector.d.ts.map +0 -1
  555. package/dist/server/handlers/version-helpers.cjs.map +0 -1
  556. package/dist/server/handlers/version-helpers.d.ts.map +0 -1
  557. package/dist/server/handlers/version-helpers.js.map +0 -1
  558. package/dist/server/handlers/voice.d.ts.map +0 -1
  559. package/dist/server/handlers/workflow-builder.d.ts.map +0 -1
  560. package/dist/server/handlers/workflows.d.ts.map +0 -1
  561. package/dist/server/handlers/workspace.d.ts.map +0 -1
  562. package/dist/server/handlers.d.ts.map +0 -1
  563. package/dist/server/http-exception.d.ts.map +0 -1
  564. package/dist/server/mcp/capabilities.d.ts.map +0 -1
  565. package/dist/server/mcp/catalogue.d.ts.map +0 -1
  566. package/dist/server/mcp/config.d.ts.map +0 -1
  567. package/dist/server/mcp/descriptor.d.ts.map +0 -1
  568. package/dist/server/mcp/oauth.d.ts.map +0 -1
  569. package/dist/server/mcp/result-size.d.ts.map +0 -1
  570. package/dist/server/mcp/route.d.ts.map +0 -1
  571. package/dist/server/mcp/schema.d.ts.map +0 -1
  572. package/dist/server/mcp/toolsets/memory.d.ts.map +0 -1
  573. package/dist/server/mcp/toolsets/observability-summary.d.ts.map +0 -1
  574. package/dist/server/mcp/toolsets/observability.d.ts.map +0 -1
  575. package/dist/server/mcp/toolsets/stored-agents.d.ts.map +0 -1
  576. package/dist/server/schemas/__tests__/route-contracts.typetest.d.ts.map +0 -1
  577. package/dist/server/schemas/a2a.d.ts.map +0 -1
  578. package/dist/server/schemas/agent-builder.d.ts.map +0 -1
  579. package/dist/server/schemas/agent-versions.d.ts.map +0 -1
  580. package/dist/server/schemas/agents.d.ts.map +0 -1
  581. package/dist/server/schemas/auth.d.ts.map +0 -1
  582. package/dist/server/schemas/background-tasks.d.ts.map +0 -1
  583. package/dist/server/schemas/builder-registry.d.ts.map +0 -1
  584. package/dist/server/schemas/channels.d.ts.map +0 -1
  585. package/dist/server/schemas/common.d.ts.map +0 -1
  586. package/dist/server/schemas/conversations.d.ts.map +0 -1
  587. package/dist/server/schemas/datasets.d.ts.map +0 -1
  588. package/dist/server/schemas/default-options.d.ts.map +0 -1
  589. package/dist/server/schemas/dynamic-workflows.d.ts.map +0 -1
  590. package/dist/server/schemas/editor-builder.d.ts.map +0 -1
  591. package/dist/server/schemas/favorites.d.ts.map +0 -1
  592. package/dist/server/schemas/feedback.d.ts.map +0 -1
  593. package/dist/server/schemas/index.d.ts.map +0 -1
  594. package/dist/server/schemas/knowledge.d.ts.map +0 -1
  595. package/dist/server/schemas/logs.d.ts.map +0 -1
  596. package/dist/server/schemas/mcp-client-versions.d.ts.map +0 -1
  597. package/dist/server/schemas/mcp.d.ts.map +0 -1
  598. package/dist/server/schemas/memory-config.d.ts.map +0 -1
  599. package/dist/server/schemas/memory.d.ts.map +0 -1
  600. package/dist/server/schemas/message-history.d.ts.map +0 -1
  601. package/dist/server/schemas/processor-providers.d.ts.map +0 -1
  602. package/dist/server/schemas/processors.d.ts.map +0 -1
  603. package/dist/server/schemas/prompt-block-versions.d.ts.map +0 -1
  604. package/dist/server/schemas/responses.d.ts.map +0 -1
  605. package/dist/server/schemas/route-contracts.d.ts.map +0 -1
  606. package/dist/server/schemas/rule-group.d.ts.map +0 -1
  607. package/dist/server/schemas/schedules.d.ts.map +0 -1
  608. package/dist/server/schemas/scorer-versions.d.ts.map +0 -1
  609. package/dist/server/schemas/scores.d.ts.map +0 -1
  610. package/dist/server/schemas/stored-agents.d.ts.map +0 -1
  611. package/dist/server/schemas/stored-mcp-clients.d.ts.map +0 -1
  612. package/dist/server/schemas/stored-prompt-blocks.d.ts.map +0 -1
  613. package/dist/server/schemas/stored-scorers.d.ts.map +0 -1
  614. package/dist/server/schemas/stored-skills.d.ts.map +0 -1
  615. package/dist/server/schemas/stored-workspaces.d.ts.map +0 -1
  616. package/dist/server/schemas/system.d.ts.map +0 -1
  617. package/dist/server/schemas/tool-providers.d.ts.map +0 -1
  618. package/dist/server/schemas/vectors.d.ts.map +0 -1
  619. package/dist/server/schemas/version-common.d.ts.map +0 -1
  620. package/dist/server/schemas/workflow-builder.d.ts.map +0 -1
  621. package/dist/server/schemas/workflows.d.ts.map +0 -1
  622. package/dist/server/schemas/workspace.d.ts.map +0 -1
  623. package/dist/server/server-adapter/api-schema-manifest.d.ts.map +0 -1
  624. package/dist/server/server-adapter/index.d.ts.map +0 -1
  625. package/dist/server/server-adapter/mcp-auth.d.ts.map +0 -1
  626. package/dist/server/server-adapter/mcp-disconnect.d.ts.map +0 -1
  627. package/dist/server/server-adapter/openapi-utils.d.ts.map +0 -1
  628. package/dist/server/server-adapter/redact.d.ts.map +0 -1
  629. package/dist/server/server-adapter/routes/a2a.d.ts.map +0 -1
  630. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +0 -1
  631. package/dist/server/server-adapter/routes/agent-controller.d.ts.map +0 -1
  632. package/dist/server/server-adapter/routes/agents.d.ts.map +0 -1
  633. package/dist/server/server-adapter/routes/auth.d.ts.map +0 -1
  634. package/dist/server/server-adapter/routes/background-tasks.d.ts.map +0 -1
  635. package/dist/server/server-adapter/routes/channels.d.ts.map +0 -1
  636. package/dist/server/server-adapter/routes/conversations.d.ts.map +0 -1
  637. package/dist/server/server-adapter/routes/datasets.d.ts.map +0 -1
  638. package/dist/server/server-adapter/routes/dynamic-workflows.d.ts.map +0 -1
  639. package/dist/server/server-adapter/routes/editor-builder.d.ts.map +0 -1
  640. package/dist/server/server-adapter/routes/fga-manifest.d.ts.map +0 -1
  641. package/dist/server/server-adapter/routes/index.d.ts.map +0 -1
  642. package/dist/server/server-adapter/routes/knowledge.d.ts.map +0 -1
  643. package/dist/server/server-adapter/routes/legacy.d.ts.map +0 -1
  644. package/dist/server/server-adapter/routes/logs.d.ts.map +0 -1
  645. package/dist/server/server-adapter/routes/mcp.d.ts.map +0 -1
  646. package/dist/server/server-adapter/routes/memory.d.ts.map +0 -1
  647. package/dist/server/server-adapter/routes/observability.d.ts.map +0 -1
  648. package/dist/server/server-adapter/routes/permissions.d.ts.map +0 -1
  649. package/dist/server/server-adapter/routes/processor-providers.d.ts.map +0 -1
  650. package/dist/server/server-adapter/routes/processors.d.ts.map +0 -1
  651. package/dist/server/server-adapter/routes/responses.d.ts.map +0 -1
  652. package/dist/server/server-adapter/routes/route-builder.d.ts.map +0 -1
  653. package/dist/server/server-adapter/routes/schedules.d.ts.map +0 -1
  654. package/dist/server/server-adapter/routes/scorers.d.ts.map +0 -1
  655. package/dist/server/server-adapter/routes/stored-agents.d.ts.map +0 -1
  656. package/dist/server/server-adapter/routes/stored-mcp-clients.d.ts.map +0 -1
  657. package/dist/server/server-adapter/routes/stored-prompt-blocks.d.ts.map +0 -1
  658. package/dist/server/server-adapter/routes/stored-scorers.d.ts.map +0 -1
  659. package/dist/server/server-adapter/routes/stored-skills.d.ts.map +0 -1
  660. package/dist/server/server-adapter/routes/stored-workspaces.d.ts.map +0 -1
  661. package/dist/server/server-adapter/routes/stream-types.d.ts.map +0 -1
  662. package/dist/server/server-adapter/routes/system.d.ts.map +0 -1
  663. package/dist/server/server-adapter/routes/tool-providers.d.ts.map +0 -1
  664. package/dist/server/server-adapter/routes/tools.d.ts.map +0 -1
  665. package/dist/server/server-adapter/routes/vectors.d.ts.map +0 -1
  666. package/dist/server/server-adapter/routes/workflows.d.ts.map +0 -1
  667. package/dist/server/server-adapter/routes/workspace.d.ts.map +0 -1
  668. package/dist/server/server-adapter/serialize.d.ts.map +0 -1
  669. package/dist/server/server-adapter/stream-disconnect.d.ts.map +0 -1
  670. package/dist/server/types.d.ts.map +0 -1
  671. package/dist/server/utils/agent-stream-events.d.ts.map +0 -1
  672. package/dist/server/utils/resolve-builder-model-policy.d.ts.map +0 -1
  673. package/dist/server/utils.d.ts.map +0 -1
  674. package/dist/server-adapter-DI4I8Pxw.js.map +0 -1
  675. package/dist/server-adapter-Do1caUp0.cjs.map +0 -1
  676. package/dist/storage-CVkNJ5eB.js.map +0 -1
  677. package/dist/storage-mEqRYYDg.cjs.map +0 -1
  678. package/dist/stored-agents-DmN_pIIl.js.map +0 -1
  679. package/dist/stored-agents-m0Knvv29.cjs.map +0 -1
  680. package/dist/stored-mcp-clients-D14ULUvS.cjs.map +0 -1
  681. package/dist/stored-mcp-clients-d_PaPgGc.js.map +0 -1
  682. package/dist/stored-prompt-blocks-B5yfQnPC.js.map +0 -1
  683. package/dist/stored-prompt-blocks-CqaOxMZ-.cjs.map +0 -1
  684. package/dist/stored-scorers-2F2k6XSx.js.map +0 -1
  685. package/dist/stored-scorers-iM2Qq9Nh.cjs.map +0 -1
  686. package/dist/stored-skills-GNJMp022.js.map +0 -1
  687. package/dist/stored-skills-xuecapXy.cjs.map +0 -1
  688. package/dist/stored-workspaces-Bswuz00o.js.map +0 -1
  689. package/dist/stored-workspaces-g5-GKY38.cjs.map +0 -1
  690. package/dist/system-CKTXaHMZ.js.map +0 -1
  691. package/dist/system-DKCYwd0y.cjs.map +0 -1
  692. package/dist/tool-providers-BVwRJTtB.cjs.map +0 -1
  693. package/dist/tool-providers-Cq3vFqgE.js.map +0 -1
  694. package/dist/tools-Cv7TwNHv.cjs.map +0 -1
  695. package/dist/tools-DqgYXmdT.js.map +0 -1
  696. package/dist/utils-C2VRtQjI.js.map +0 -1
  697. package/dist/utils-CvYihOoy.js.map +0 -1
  698. package/dist/utils-DQJOBnMo.cjs.map +0 -1
  699. package/dist/utils-j29NB2ZJ.cjs.map +0 -1
  700. package/dist/vector-Bz-glead.js.map +0 -1
  701. package/dist/vector-DIFU_fwU.cjs.map +0 -1
  702. package/dist/vectors-CPSofSCf.cjs.map +0 -1
  703. package/dist/vectors-CadLydEJ.js.map +0 -1
  704. package/dist/version-common-BLTDO88f.js.map +0 -1
  705. package/dist/version-common-Cc0STXl9.cjs.map +0 -1
  706. package/dist/voice-BUAV_TGD.cjs.map +0 -1
  707. package/dist/voice-D-iJiiSN.js.map +0 -1
  708. package/dist/workflow-builder-BET96Cr_.js.map +0 -1
  709. package/dist/workflow-builder-DpL3Nq6T.cjs.map +0 -1
  710. package/dist/workflows-CKcjXfXk.cjs.map +0 -1
  711. package/dist/workflows-D3QrUMfm.js.map +0 -1
  712. package/dist/workflows-DTxiWG6x.js.map +0 -1
  713. package/dist/workflows-gIKukZ1O.cjs.map +0 -1
  714. package/dist/workspace-C5BBUatQ.cjs.map +0 -1
  715. package/dist/workspace-CgIZRc2P.js.map +0 -1
  716. package/dist/workspace-D-Exdj2l.cjs.map +0 -1
  717. package/dist/workspace-DBDA3UQl.js.map +0 -1
  718. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/_types/@internal_ai-sdk-v4@0.0.98/dist/index.d.ts +0 -0
  719. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/_types/@internal_ai-sdk-v5@0.0.98/dist/index.d.ts +0 -0
  720. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/_types/@internal_ai-v6@0.0.98/dist/index.d.ts +0 -0
  721. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/_types/@standard-schema_spec@1.1.0/dist/index.d.ts +0 -0
  722. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/_types/@types_json-schema@7.0.15/index.d.ts +0 -0
  723. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/index.d.ts +0 -0
  724. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/null-to-undefined.d.ts +0 -0
  725. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/provider-compats/anthropic.d.ts +0 -0
  726. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/provider-compats/deepseek.d.ts +0 -0
  727. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/provider-compats/google.d.ts +0 -0
  728. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/provider-compats/meta.d.ts +0 -0
  729. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/provider-compats/openai-reasoning.d.ts +0 -0
  730. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/provider-compats/openai.d.ts +0 -0
  731. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/schema-compatibility-v3.d.ts +0 -0
  732. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/schema-compatibility-v4.d.ts +0 -0
  733. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/schema-compatibility.d.ts +0 -0
  734. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/schema.d.ts +0 -0
  735. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/schema.types.d.ts +0 -0
  736. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/standard-schema/standard-schema.d.ts +0 -0
  737. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/standard-schema/standard-schema.types.d.ts +0 -0
  738. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/standard-schema-compat.d.ts +0 -0
  739. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/types.d.ts +0 -0
  740. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/utils.d.ts +0 -0
  741. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/dist/zod-to-json.d.ts +0 -0
  742. /package/dist/_types/{@mastra_schema-compat@1.4.0 → @mastra_schema-compat@1.4.1-alpha.0}/package.json +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-builder-CXLdplIj.js","names":[],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsB,EAAE,OAAO;CAC1C,OAAO,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQ,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAAS,EAAE,QAAQ,CAAC,CAAC,SAA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0,0 @@
1
- {"version":3,"file":"editor-builder-eF2IetF2.cjs","names":["z","providerSchema"],"sources":["../src/server/schemas/editor-builder.ts"],"sourcesContent":["import { z } from 'zod/v4';\nimport { providerSchema } from './agents';\n\n/**\n * Agent feature flags for the builder.\n *\n * Wire format: each key is an optional boolean. The server normalizes admin\n * input via `resolveAgentFeatures` (default-on semantics): any omitted key\n * resolves to `true`; admins opt out by setting a key to `false`. The\n * `GET /editor/builder/settings` response always carries a fully-resolved\n * object — clients should still use strict `=== true` checks.\n *\n * Special cases:\n * - `browser`: only resolves to `true` when `configuration.agent.browser` is\n * provided. Omitted with no config ⇒ silently `false` (no warning).\n * Explicit `true` with no config ⇒ warns and downgrades to `false`.\n */\nexport const agentFeaturesSchema = z.object({\n tools: z.boolean().optional(),\n agents: z.boolean().optional(),\n workflows: z.boolean().optional(),\n scorers: z.boolean().optional(),\n skills: z.boolean().optional(),\n memory: z.boolean().optional(),\n variables: z.boolean().optional(),\n favorites: z.boolean().optional(),\n avatarUpload: z.boolean().optional(),\n browser: z.boolean().optional(),\n /**\n * Whether the model picker is visible in the Agent Builder.\n * Omitted ⇒ picker visible (default-on). Explicit `false` ⇒ picker hidden\n * (locked mode); `models.default` is required and applied.\n */\n model: z.boolean().optional(),\n});\n\n/**\n * Allowlist + default-model entries for {@link agentModelsSchema}.\n *\n * Four standalone schemas (known × custom × entry × default) joined with `z.union`.\n * The schema does NOT validate `provider` against the runtime registry — invalid strings\n * surface as warnings during Phase 4 config validation.\n *\n * NOTE: `z.union(...).extend()` does not exist; that's why these are separate schemas.\n */\n// All four schemas are `.strict()` so typos like `modelID` or `Provider` are\n// rejected up-front instead of silently widening the policy.\nconst knownProviderEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst customProviderEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1).optional(),\n })\n .strict();\n\nconst knownDefaultModelEntrySchema = z\n .object({\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\nconst customDefaultModelEntrySchema = z\n .object({\n kind: z.literal('custom'),\n provider: z.string().min(1),\n modelId: z.string().min(1),\n })\n .strict();\n\n// Custom-tagged variants must come first so the discriminator (`kind: 'custom'`)\n// wins over the more permissive known-provider schemas. Otherwise the union\n// silently drops the `kind` field on matching inputs.\nexport const providerModelEntrySchema = z.union([customProviderEntrySchema, knownProviderEntrySchema]);\nexport const defaultModelEntrySchema = z.union([customDefaultModelEntrySchema, knownDefaultModelEntrySchema]);\n\n/**\n * Admin-controlled model allowlist + default for the Agent Builder.\n */\nexport const agentModelsSchema = z.object({\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Admin-controlled allowlist for one of the builder pickers (tools/agents/workflows).\n *\n * Semantics:\n * - omitted ⇒ unrestricted (all registered IDs shown in the picker).\n * - `allowed: []` ⇒ empty picker (explicit lockdown).\n * - `allowed: [...ids]` ⇒ only the listed IDs are shown.\n */\nexport const pickerAllowlistSchema = z\n .object({\n allowed: z.array(z.string()).optional(),\n })\n .strict();\n\n/**\n * Agent configuration (pinned, non-overridable settings).\n *\n * Known structured field: `models` (Phase 1 contracts).\n * Other keys flow through unchanged for forward compatibility.\n */\nexport const agentConfigurationSchema = z\n .object({\n models: agentModelsSchema.optional(),\n tools: pickerAllowlistSchema.optional(),\n agents: pickerAllowlistSchema.optional(),\n workflows: pickerAllowlistSchema.optional(),\n })\n .catchall(z.unknown());\n\n/**\n * Resolved picker visibility returned in `BuilderSettingsResponse`.\n *\n * Per kind:\n * - `null` ⇒ unrestricted (show all registered entries).\n * - `string[]` ⇒ explicit allowlist (may be empty to show none).\n */\nexport const builderPickerSchema = z.object({\n visibleTools: z.array(z.string()).nullable(),\n visibleAgents: z.array(z.string()).nullable(),\n visibleWorkflows: z.array(z.string()).nullable(),\n});\n\n/**\n * Derived `BuilderModelPolicy`. Server-owned shape so the playground hook is a\n * thin selector and the UI never re-derives policy from `features` / `configuration`.\n *\n * Mirrors `BuilderModelPolicy` from `@mastra/core/agent-builder/ee`:\n * - `active: false` ⇒ all other fields ignored.\n * - `active: true` + `pickerVisible: false` (locked) ⇒ `default` set in valid configs.\n * - `allowed`/`default` are passed through verbatim when present.\n */\nexport const builderModelPolicySchema = z.object({\n active: z.boolean(),\n pickerVisible: z.boolean().optional(),\n allowed: z.array(providerModelEntrySchema).optional(),\n default: defaultModelEntrySchema.optional(),\n});\n\n/**\n * Response schema for GET /editor/builder/settings\n */\nexport const builderSettingsResponseSchema = z.object({\n enabled: z.boolean(),\n features: z\n .object({\n agent: agentFeaturesSchema.optional(),\n })\n .optional(),\n configuration: z\n .object({\n agent: agentConfigurationSchema.optional(),\n })\n .optional(),\n modelPolicy: builderModelPolicySchema.optional(),\n /**\n * Resolved picker visibility for tools/agents/workflows. Always present when\n * the builder is enabled. Omitted when the builder is disabled.\n */\n picker: builderPickerSchema.optional(),\n /**\n * Non-fatal warnings produced by `EditorAgentBuilder`'s constructor-time\n * validation (e.g. allowlist entries with unknown provider strings, or\n * picker allowlist entries that don't match a registered ID). UI surfaces\n * these as a banner in the Builder admin view.\n */\n modelPolicyWarnings: z.array(z.string()).optional(),\n});\n\n/**\n * Infrastructure status response for Agent Builder admin diagnostics.\n *\n * Reports the Agent Builder-specific primitive configuration plus lightweight\n * runtime resolution state where useful.\n */\nexport const infrastructureStatusResponseSchema = z.object({\n channels: z.object({\n providers: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n isConfigured: z.boolean(),\n routeCount: z.number(),\n }),\n ),\n }),\n browser: z.object({\n type: z.string().nullable(),\n provider: z.string().nullable(),\n env: z.string().nullable(),\n registered: z.boolean(),\n availableProviders: z.array(z.string()),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n workspace: z.object({\n type: z.string().nullable(),\n workspaceId: z.string().nullable(),\n name: z.string().nullable(),\n source: z.string().nullable(),\n registered: z.boolean(),\n hasFilesystem: z.boolean(),\n hasSandbox: z.boolean(),\n filesystemProvider: z.string().nullable(),\n sandboxProvider: z.string().nullable(),\n config: z.array(z.object({ key: z.string(), value: z.string() })),\n }),\n registries: z.object({\n skillsSh: z.object({\n enabled: z.boolean(),\n }),\n }),\n});\n\n/**\n * Response schema for GET /editor/builder/models/available.\n *\n * Same provider shape as GET /agents/providers, but each provider's `models`\n * list is already filtered by the active builder model policy (server applies\n * the EE allowlist). Providers with no allowed models are omitted entirely so\n * the Studio model picker can render the response verbatim.\n */\nexport const builderAvailableModelsResponseSchema = z.object({\n providers: z.array(providerSchema),\n});\n\nexport type BuilderAvailableModelsResponse = z.infer<typeof builderAvailableModelsResponseSchema>;\n\nexport type InfrastructureStatus = z.infer<typeof infrastructureStatusResponseSchema>;\n\nexport type AgentFeatures = z.infer<typeof agentFeaturesSchema>;\nexport type AgentConfiguration = z.infer<typeof agentConfigurationSchema>;\nexport type BuilderSettingsResponse = z.infer<typeof builderSettingsResponseSchema>;\nexport type ProviderModelEntrySchema = z.infer<typeof providerModelEntrySchema>;\nexport type DefaultModelEntrySchema = z.infer<typeof defaultModelEntrySchema>;\nexport type AgentModelsSchema = z.infer<typeof agentModelsSchema>;\nexport type BuilderModelPolicySchema = z.infer<typeof builderModelPolicySchema>;\nexport type PickerAllowlistSchema = z.infer<typeof pickerAllowlistSchema>;\nexport type BuilderPickerSchema = z.infer<typeof builderPickerSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,sBAAsBA,OAAAA,EAAE,OAAO;CAC1C,OAAOA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC5B,QAAQA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,WAAWA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAChC,SAASA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC9B,QAAQA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS;CAC7B,QAAQA,OAAAA,EAAE,QA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AC,SAAS;EAC5B,YAAYA,OAAAA,EAAE,QAAQ;EACtB,eAAeA,OAAAA,EAAE,QAAQ;EACzB,YAAYA,OAAAA,EAAE,QAAQ;EACtB,oBAAoBA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;EACxC,iBAAiBA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS;EACrC,QAAQA,OAAAA,EAAE,MAAMA,OAAAA,EAAE,OAAO;GAAE,KAAKA,OAAAA,EAAE,OAAO;GAAG,OAAOA,OAAAA,EAAE,OAAO;EAAE,CAAC,CAAC;CAClE,CAAC;CACD,YAAYA,OAAAA,EAAE,OAAO,EACnB,UAAUA,OAAAA,EAAE,OAAO,EACjB,SAASA,OAAAA,EAAE,QAAQ,EACrB,CAAC,EACH,CAAC;AACH,CAAC;;;;;;;;;AAUD,MAAa,uCAAuCA,OAAAA,EAAE,OAAO,EAC3D,WAAWA,OAAAA,EAAE,MAAMC,eAAAA,cAAc,EACnC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"editor-builder-vasNoMoK.cjs","names":["agentFeaturesSchema","HTTPException","createRoute","builderSettingsResponseSchema","handleError","builderAvailableModelsResponseSchema","buildProvidersList","infrastructureStatusResponseSchema"],"sources":["../src/server/utils/resolve-builder-model-policy.ts","../src/server/handlers/editor-builder.ts"],"sourcesContent":["import type { BuilderModelPolicy } from '@mastra/core/agent-builder/ee';\nimport type { IMastraEditor } from '@mastra/core/editor';\n\n/**\n * Server-side wrapper around `builderToModelPolicy`.\n *\n * Handles the optional `IMastraEditor` builder API surface (older / OSS editors\n * may not implement `hasEnabledBuilderConfig` / `resolveBuilder`) and returns\n * a uniform `BuilderModelPolicy` to every call site.\n *\n * Returns `{ active: false }` whenever:\n * - no editor is configured,\n * - the editor doesn't expose builder methods,\n * - the builder config is disabled, or\n * - resolving the builder fails / yields nothing.\n *\n * The `@mastra/core/agent-builder/ee` subpath is loaded lazily so this module\n * remains importable on `@mastra/core` versions that pre-date the subpath\n * (the subpath was added in core 1.34.0). The dynamic import is only reached\n * once an editor is actually configured, by which point a compatible core is\n * guaranteed.\n */\nexport async function resolveBuilderModelPolicy(editor: IMastraEditor | undefined): Promise<BuilderModelPolicy> {\n if (!editor) return { active: false };\n if (typeof editor.resolveBuilder !== 'function') return { active: false };\n if (typeof editor.hasEnabledBuilderConfig === 'function' && !editor.hasEnabledBuilderConfig()) {\n return { active: false };\n }\n\n // Degrade to inactive on builder-resolution failure rather than letting the\n // rejection escape: agent execution routes seed this on every request, so a\n // transient failure must not 500 the entire route.\n try {\n const builder = await editor.resolveBuilder();\n const { builderToModelPolicy } = await import('@mastra/core/agent-builder/ee');\n return builderToModelPolicy(builder);\n } catch {\n return { active: false };\n }\n}\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\n\nimport { HTTPException } from '../http-exception';\nimport {\n agentFeaturesSchema,\n builderAvailableModelsResponseSchema,\n builderSettingsResponseSchema,\n infrastructureStatusResponseSchema,\n} from '../schemas/editor-builder';\nimport type { AgentFeatures, InfrastructureStatus } from '../schemas/editor-builder';\nimport { createRoute } from '../server-adapter/routes/route-builder';\nimport { resolveBuilderModelPolicy } from '../utils/resolve-builder-model-policy';\nimport { buildProvidersList } from './agents';\nimport { handleError } from './error';\n\n/**\n * Resolve the active builder feature flags. Returns `null` when the editor is\n * absent, the builder is disabled, or no features are configured.\n */\nasync function resolveBuilderFeatures(mastra: Mastra): Promise<AgentFeatures | null> {\n const editor = mastra.getEditor();\n if (!editor || typeof editor.resolveBuilder !== 'function') return null;\n if (!editor.hasEnabledBuilderConfig?.()) return null;\n const builder = await editor.resolveBuilder();\n if (!builder || !builder.enabled) return null;\n const features = builder.getFeatures?.()?.agent;\n if (!features) return null;\n // Validate the shape so unknown keys cannot smuggle through.\n const parsed = agentFeaturesSchema.safeParse(features);\n return parsed.success ? parsed.data : null;\n}\n\n/**\n * Returns whether a given agent-builder feature is enabled. Used by list /\n * get-by-id handlers to soft-gate response enrichment (omit fields, ignore\n * favoritedOnly / pinFavoritedFor params) when the feature is off.\n */\nexport async function isBuilderFeatureEnabled(mastra: Mastra, feature: keyof AgentFeatures): Promise<boolean> {\n const features = await resolveBuilderFeatures(mastra);\n return features?.[feature] === true;\n}\n\n/**\n * Hard-gate helper for mutation routes that must not exist when the feature\n * is off. Throws `HTTPException(404)` so we don't leak the existence of the\n * feature surface (matches behavior of unregistered routes).\n */\nexport async function requireBuilderFeature(mastra: Mastra, feature: keyof AgentFeatures): Promise<void> {\n if (!(await isBuilderFeatureEnabled(mastra, feature))) {\n throw new HTTPException(404, { message: 'Not Found' });\n }\n}\n\n/**\n * GET /editor/builder/settings\n *\n * Returns the agent builder settings configured by the admin.\n * Used by frontend to determine which features to display.\n */\nexport const GET_EDITOR_BUILDER_SETTINGS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/settings',\n responseType: 'json',\n responseSchema: builderSettingsResponseSchema,\n summary: 'Get agent builder settings',\n description: 'Returns the agent builder feature flags and configuration for UI gating',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'stored-agents:read',\n handler: async ({ mastra }) => {\n try {\n const editor = mastra.getEditor();\n\n // No editor configured\n if (!editor) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Editor doesn't support builder (older version or OSS)\n if (typeof editor.resolveBuilder !== 'function') {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Check if builder is enabled in config\n if (!editor.hasEnabledBuilderConfig?.()) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n // Resolve the builder instance\n const builder = await editor.resolveBuilder();\n if (!builder || !builder.enabled) {\n return { enabled: false, modelPolicy: { active: false } };\n }\n\n const baseWarnings = builder.getModelPolicyWarnings?.() ?? [];\n const configuration = builder.getConfiguration();\n\n // Picker allowlists are written against entity `.id` (what users see in\n // the UI, URLs, traces). The client filters list responses by their\n // response keys, which are not always `.id`:\n // - GET /agents keys by `agent.id`\n // - GET /tools keys by registration key (values include `id`)\n // - GET /workflows keys by registration key (values omit `id`)\n // To keep the client filter simple, we accept `.id` (fallback to\n // registration key) for matching, but emit visible IDs as response keys\n // so `Object.keys(data)` lines up.\n type AliasPair = { id: string; key: string };\n const collectAliases = (registry: Record<string, unknown>): AliasPair[] =>\n Object.entries(registry).map(([key, entity]) => ({\n id: (entity as { id?: string }).id || key,\n key,\n }));\n\n const toolAliases = collectAliases(mastra.listTools() ?? {});\n const agentAliases = collectAliases(mastra.listAgents() ?? {});\n const workflowAliases = collectAliases(mastra.listWorkflows() ?? {});\n\n // Tools/workflows responses are keyed by registration key. Agents\n // response is keyed by `.id`.\n const toResponseKey = (aliases: AliasPair[], byId: 'id' | 'key') => {\n const map = new Map<string, string>();\n for (const a of aliases) {\n map.set(a.id, byId === 'id' ? a.id : a.key);\n map.set(a.key, byId === 'id' ? a.id : a.key);\n }\n return map;\n };\n const toolKeyMap = toResponseKey(toolAliases, 'key');\n const agentKeyMap = toResponseKey(agentAliases, 'id');\n const workflowKeyMap = toResponseKey(workflowAliases, 'key');\n\n // Lazy-load the EE subpath so this module remains importable on\n // `@mastra/core` versions that pre-date it (added in core 1.34.0).\n // We only reach here after `builder.enabled` is true, which guarantees\n // a compatible core.\n const { builderToModelPolicy, resolvePickerVisibility } = await import('@mastra/core/agent-builder/ee');\n\n const picker = resolvePickerVisibility({\n config: configuration?.agent,\n registeredToolIds: toolAliases.flatMap(a => [a.id, a.key]),\n registeredAgentIds: agentAliases.flatMap(a => [a.id, a.key]),\n registeredWorkflowIds: workflowAliases.flatMap(a => [a.id, a.key]),\n });\n\n const normalize = (visible: string[] | null, map: Map<string, string>): string[] | null => {\n if (visible === null) return null;\n const out: string[] = [];\n const seen = new Set<string>();\n for (const id of visible) {\n const mapped = map.get(id);\n if (mapped && !seen.has(mapped)) {\n seen.add(mapped);\n out.push(mapped);\n }\n }\n return out;\n };\n\n const modelPolicyWarnings = [...baseWarnings, ...picker.warnings];\n\n return {\n enabled: true,\n features: builder.getFeatures(),\n configuration,\n modelPolicy: builderToModelPolicy(builder),\n picker: {\n visibleTools: normalize(picker.visibleTools, toolKeyMap),\n visibleAgents: normalize(picker.visibleAgents, agentKeyMap),\n visibleWorkflows: normalize(picker.visibleWorkflows, workflowKeyMap),\n },\n ...(modelPolicyWarnings.length > 0 ? { modelPolicyWarnings } : {}),\n };\n } catch (error) {\n return handleError(error, 'Error getting builder settings');\n }\n },\n});\n\n/**\n * GET /editor/builder/models/available\n *\n * Returns the configured AI providers/models the agent builder may use. The\n * server is the single authority: it scopes the list to providers with a\n * configured API key (`connected`) and applies the active builder model\n * policy via `isModelAllowed`, so the Studio surfaces can render the response\n * verbatim without importing any EE matcher into the browser.\n *\n * - Providers without a configured API key are always omitted — the builder\n * decides the agent's model from this list, so an unconnected provider would\n * produce an agent that can never run.\n * - Policy inactive (or no allowlist) ⇒ all connected providers are returned.\n * - Policy active with an allowlist ⇒ each connected provider's models are\n * filtered, and providers left with no allowed models are omitted entirely.\n */\nexport const GET_EDITOR_BUILDER_AVAILABLE_MODELS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/models/available',\n mcp: {\n toolset: 'stored_agents',\n name: 'list_available_models',\n description:\n 'List the models you can give an agent (providers with an API key, filtered by the agent-builder model policy).',\n requires: capabilities => capabilities.storedAgents,\n },\n responseType: 'json',\n responseSchema: builderAvailableModelsResponseSchema,\n summary: 'List builder-available AI models',\n description: 'Returns AI providers/models filtered by the active agent-builder model policy.',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'stored-agents:read',\n handler: async ({ mastra }) => {\n try {\n // Only surface providers whose API key is configured (`connected`). The\n // agent builder decides the agent's model from this list, so including\n // providers without a key lets it pick a model that can never run. We\n // scope to connected providers so every choice is actually usable.\n const providers = (await buildProvidersList(mastra)).filter(provider => provider.connected);\n const policy = await resolveBuilderModelPolicy(mastra.getEditor());\n\n // Inactive policy (or no allowlist) ⇒ no allowlist filtering to apply.\n if (!policy.active || !policy.allowed || policy.allowed.length === 0) {\n return { providers };\n }\n\n // Lazy-load the EE matcher (server-only); mirrors the convention used by\n // resolve-builder-model-policy and the settings handler.\n const { isModelAllowed } = await import('@mastra/core/agent-builder/ee');\n\n const filtered = providers\n .map(provider => ({\n ...provider,\n models: provider.models.filter(modelId => isModelAllowed(policy.allowed, { provider: provider.id, modelId })),\n }))\n .filter(provider => provider.models.length > 0);\n\n return { providers: filtered };\n } catch (error) {\n return handleError(error, 'Error fetching available models');\n }\n },\n});\n\n/**\n * GET /editor/builder/infrastructure\n *\n * Returns the runtime status of Mastra-opinionated primitives (channels,\n * browser providers, workspaces). Admin-only; surfaced in Studio Settings so\n * admins can sanity-check what's wired up to the running server.\n */\nexport const GET_INFRASTRUCTURE_STATUS_ROUTE = createRoute({\n method: 'GET',\n path: '/editor/builder/infrastructure',\n responseType: 'json',\n responseSchema: infrastructureStatusResponseSchema,\n summary: 'Get infrastructure status',\n description: 'Agent Builder infrastructure configuration and lightweight runtime status.',\n tags: ['Editor'],\n requiresAuth: true,\n requiresPermission: 'infrastructure:read',\n handler: async ({ mastra }) => {\n try {\n const formatConfigValue = (value: unknown): string => {\n if (value === null || value === undefined) return 'not set';\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return String(value);\n if (Array.isArray(value)) return `${value.length} item${value.length === 1 ? '' : 's'}`;\n return value.constructor?.name && value.constructor.name !== 'Object' ? value.constructor.name : 'configured';\n };\n\n const getProviderName = (value: unknown): string | null => {\n if (!value) return null;\n if (typeof value === 'object' && 'provider' in value && typeof value.provider === 'string')\n return value.provider;\n if (typeof value === 'object' && 'constructor' in value) {\n const name = (value as { constructor?: { name?: string } }).constructor?.name;\n return name && name !== 'Object' ? name : 'configured';\n }\n return null;\n };\n\n const getConfigEntries = (config: Record<string, unknown>, omittedKeys: string[] = []) =>\n Object.entries(config)\n .filter(([key, value]) => !omittedKeys.includes(key) && value !== undefined && value !== null)\n .map(([key, value]) => ({ key, value: formatConfigValue(value) }));\n\n // Prefer resolveChannels() so a live channels resolver (e.g. @mastra/connect's\n // channels()) reports connections added after boot; older cores lack the method.\n const mastraWithResolver = mastra as typeof mastra & {\n resolveChannels?: () => Promise<Record<string, ChannelProvider>>;\n };\n const channelProviders =\n typeof mastraWithResolver.resolveChannels === 'function'\n ? await mastraWithResolver.resolveChannels()\n : (mastra.getChannelProviders() ?? {});\n const channels: InfrastructureStatus['channels'] = {\n providers: Object.entries(channelProviders)\n .map(([id, provider]) => {\n const info = provider.getInfo?.();\n const routes = provider.getRoutes?.() ?? [];\n return {\n id: info?.id ?? id,\n name: info?.name ?? id,\n isConfigured: info?.isConfigured ?? false,\n routeCount: routes.length,\n };\n })\n .filter(provider => provider.isConfigured),\n };\n\n const editor = mastra.getEditor();\n let browser: InfrastructureStatus['browser'] = {\n type: null,\n provider: null,\n env: null,\n registered: false,\n availableProviders: [],\n config: [],\n };\n let workspace: InfrastructureStatus['workspace'] = {\n type: null,\n workspaceId: null,\n name: null,\n source: null,\n registered: false,\n hasFilesystem: false,\n hasSandbox: false,\n filesystemProvider: null,\n sandboxProvider: null,\n config: [],\n };\n let registries: InfrastructureStatus['registries'] = {\n skillsSh: { enabled: false },\n };\n\n if (editor?.resolveBuilder) {\n const browsers = (editor as unknown as { __browsers?: Map<string, unknown> }).__browsers;\n const builder = await editor.resolveBuilder();\n const builderRegistries = builder?.getRegistries?.();\n registries = {\n skillsSh: { enabled: builderRegistries?.skillsSh?.enabled === true },\n };\n const configuration = builder?.getConfiguration?.()?.agent as\n | {\n browser?: { type?: string; config?: { provider?: string; env?: string } };\n workspace?: {\n type?: string;\n workspaceId?: string;\n config?: { name?: string; filesystem?: unknown; sandbox?: unknown };\n };\n }\n | undefined;\n\n const browserRef = configuration?.browser;\n const browserConfig = browserRef?.config ?? {};\n const providerId = browserConfig.provider ?? null;\n browser = {\n type: browserRef?.type ?? null,\n provider: providerId,\n env: browserConfig.env ?? null,\n registered: providerId ? !!browsers?.has(providerId) : false,\n availableProviders: browsers ? Array.from(browsers.keys()) : [],\n config: getConfigEntries(browserConfig, ['provider', 'env']),\n };\n\n const workspaceRef = configuration?.workspace;\n const workspaceConfig = workspaceRef?.config ?? {};\n const registeredWorkspaces = mastra.listWorkspaces();\n const registeredWorkspace = workspaceRef?.workspaceId\n ? registeredWorkspaces[workspaceRef.workspaceId]\n : undefined;\n const filesystem = registeredWorkspace?.workspace.filesystem ?? workspaceConfig.filesystem;\n const sandbox = registeredWorkspace?.workspace.sandbox ?? workspaceConfig.sandbox;\n const filesystemConfig =\n typeof workspaceConfig.filesystem === 'object' &&\n workspaceConfig.filesystem &&\n 'config' in workspaceConfig.filesystem\n ? (workspaceConfig.filesystem.config as Record<string, unknown>)\n : {};\n const sandboxConfig =\n typeof workspaceConfig.sandbox === 'object' && workspaceConfig.sandbox && 'config' in workspaceConfig.sandbox\n ? (workspaceConfig.sandbox.config as Record<string, unknown>)\n : {};\n workspace = {\n type: workspaceRef?.type ?? null,\n workspaceId: workspaceRef?.workspaceId ?? null,\n name: workspaceConfig.name ?? registeredWorkspace?.workspace.name ?? null,\n source: registeredWorkspace?.source ?? null,\n registered: !!registeredWorkspace,\n hasFilesystem: !!filesystem,\n hasSandbox: !!sandbox,\n filesystemProvider: getProviderName(filesystem),\n sandboxProvider: getProviderName(sandbox),\n config: [\n ...getConfigEntries(filesystemConfig).map(entry => ({ ...entry, key: `filesystem.${entry.key}` })),\n ...getConfigEntries(sandboxConfig).map(entry => ({ ...entry, key: `sandbox.${entry.key}` })),\n ],\n };\n }\n\n return { channels, browser, workspace, registries };\n } catch (error) {\n return handleError(error, 'Error getting infrastructure status');\n }\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,eAAsB,0BAA0B,QAAgE;CAC9G,IAAI,CAAC,QAAQ,OAAO,EAAE,QAAQ,MAAM;CACpC,IAAI,OAAO,OAAO,mBAAmB,YAAY,OAAO,EAAE,QAAQ,MAAM;CACxE,IAAI,OAAO,OAAO,4BAA4B,cAAc,CAAC,OAAO,wBAAwB,GAC1F,OAAO,EAAE,QAAQ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WAAU;MAAE,GAAG;MAAO,KAAK,cAAc,MAAM;KAAM,EAAE,GACjG,GAAG,iBAAiB,aAAa,CAAC,CAAC,KAAI,WAAU;MAAE,GAAG;MAAO,KAAK,WAAW,MAAM;KAAM,EAAE,CAC7F;IACF;GACF;GAEA,OAAO;IAAE;IAAU;IAAS;IAAW;GAAW;EACpD,SAAS,OAAO;GACd,OAAOH,8BAAAA,YAAY,OAAO,qCAAqC;EACjE;CACF;AACF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"favorites-8aieznq3.js","names":[],"sources":["../src/server/schemas/favorites.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n/**\n * Response body for `PUT|DELETE /stored/{type}/:id/favorite` routes.\n */\nexport const favoriteToggleResponseSchema = z.object({\n favorited: z.boolean().describe('Whether the entity is currently favorited by the caller'),\n favoriteCount: z.number().int().nonnegative().describe('Total number of users who have favorited this entity'),\n});\n"],"mappings":";;;;;AAKA,MAAa,+BAA+B,EAAE,OAAO;CACnD,WAAW,EAAE,QAAQ,CAAC,CAAC,SAAS,yDAAyD;CACzF,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,sDAAsD;AAC/G,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"favorites-D0CoxxQn.cjs","names":["z"],"sources":["../src/server/schemas/favorites.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n/**\n * Response body for `PUT|DELETE /stored/{type}/:id/favorite` routes.\n */\nexport const favoriteToggleResponseSchema = z.object({\n favorited: z.boolean().describe('Whether the entity is currently favorited by the caller'),\n favoriteCount: z.number().int().nonnegative().describe('Total number of users who have favorited this entity'),\n});\n"],"mappings":";;;;;AAKA,MAAa,+BAA+BA,OAAAA,EAAE,OAAO;CACnD,WAAWA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS,yDAAyD;CACzF,eAAeA,OAAAA,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,sDAAsD;AAC/G,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers-Zu5ZVxSl.cjs","names":["Hono","HonoRequest","HTTPException","MASTRA_USER_KEY","normalizeMastraUser","MASTRA_NORMALIZED_USER_KEY","MASTRA_AUTH_TOKEN_KEY","CompositeAuth","MASTRA_RESOURCE_ID_KEY","MASTRA_AUTH_MODE_KEY","MASTRA_USER_PERMISSIONS_KEY","MASTRA_USER_ROLES_KEY"],"sources":["../src/server/auth/custom-route-matcher.ts","../src/server/auth/defaults.ts","../src/server/auth/path-pattern.ts","../src/server/auth/helpers.ts"],"sourcesContent":["import { Hono } from 'hono';\nimport { HonoRequest } from 'hono/request';\n\n/** A custom route as the internal custom-route Hono app registers it. */\nexport interface CustomRouteMatcherEntry {\n method: string;\n path: string;\n /**\n * How many handlers (route middleware + handler) the route registers. Hono stores\n * each one as its own router entry, so mirror the count to build the same router.\n */\n handlerCount?: number;\n}\n\nexport interface CustomRouteMatch<T> {\n entry: T;\n index: number;\n params: Record<string, string>;\n}\n\ntype Marker = (...args: unknown[]) => undefined;\n\nconst noopMiddleware: Marker = () => undefined;\nconst paramRequest = new Request('http://localhost/');\n\n/**\n * Answers \"which custom route will run for this request?\" using the same Hono router\n * the custom-route bridge dispatches with (`buildCustomRouteHandler`), registered in\n * the same order with the same paths and methods. Auth decisions use this instead\n * of a separate pattern matcher, so they can't disagree with dispatch on precedence,\n * case, trailing slashes, percent-decoding or HEAD handling.\n */\nexport class CustomRouteMatcher<T extends CustomRouteMatcherEntry> {\n readonly #app = new Hono();\n readonly #indexByHandler = new Map<unknown, number>();\n readonly #entries: readonly T[];\n\n constructor(entries: readonly T[]) {\n this.#entries = entries;\n // Same global middleware as the custom-route app, so the router sees the same table.\n this.#app.use('*', noopMiddleware as never);\n entries.forEach((entry, index) => {\n const marker: Marker = () => undefined;\n this.#indexByHandler.set(marker, index);\n const handlers = Array.from({ length: Math.max(1, entry.handlerCount ?? 1) }, () => marker as never);\n if (entry.method === 'ALL') {\n this.#app.all(entry.path, handlers[0]!, ...handlers.slice(1));\n } else {\n this.#app.on(entry.method, entry.path, handlers[0]!, ...handlers.slice(1));\n }\n });\n }\n\n /**\n * Match a path the way Hono dispatches it, i.e. `path` is already in the form\n * `getPath()` returns (no query string, percent-decoded once).\n * Throws if Hono can't build a router for the registered paths.\n */\n matchPath(path: string, method: string): CustomRouteMatch<T> | undefined {\n const upper = method.toUpperCase();\n // Hono serves HEAD with the GET handler.\n const dispatchMethod = upper === 'HEAD' ? 'GET' : upper;\n const result = this.#app.router.match(dispatchMethod, path);\n const handlers = result[0];\n for (let i = 0; i < handlers.length; i++) {\n const index = this.#indexByHandler.get(handlers[i]![0][0]);\n if (index === undefined) continue; // the global middleware\n const request = new HonoRequest(paramRequest, path, result as never);\n request.routeIndex = i;\n return { entry: this.#entries[index]!, index, params: request.param() as Record<string, string> };\n }\n return undefined;\n }\n\n /**\n * Match the full URL handed to the custom-route app. Parses it the same way\n * (`new Request(url)` then Hono's `getPath`), so dot segments, encoded characters\n * and the query string are handled exactly as dispatch handles them.\n * Throws if the URL can't be parsed.\n */\n matchUrl(url: string, method: string): CustomRouteMatch<T> | undefined {\n const path = this.#app.getPath(new Request(url));\n return this.matchPath(path, method);\n }\n\n /**\n * Converts a raw request path (as Express/Koa/Fastify see it, not yet decoded) to\n * the path Hono would dispatch when the bridge forwards it. Throws on an\n * unparseable path.\n */\n dispatchPathForRawPath(rawPath: string): string {\n return this.#app.getPath(new Request(`http://localhost${rawPath}`));\n }\n}\n\nconst MAX_CACHED_MATCHERS = 32;\nconst matcherCache = new Map<string, CustomRouteMatcher<CustomRouteMatcherEntry & { key: string }>>();\n\n/**\n * Builds (and caches) a matcher from `customRouteAuthConfig` keys. Keys are\n * `METHOD:path` in registration order, which is the order the server registers\n * custom routes with the custom-route app.\n */\nexport function getCustomRouteAuthConfigMatcher(\n keys: readonly string[],\n): CustomRouteMatcher<CustomRouteMatcherEntry & { key: string }> {\n const signature = JSON.stringify(keys);\n const cached = matcherCache.get(signature);\n if (cached) {\n matcherCache.delete(signature);\n matcherCache.set(signature, cached);\n return cached;\n }\n\n const entries: Array<CustomRouteMatcherEntry & { key: string }> = [];\n for (const key of keys) {\n const colonIndex = key.indexOf(':');\n if (colonIndex === -1) continue; // malformed key\n entries.push({ key, method: key.substring(0, colonIndex).toUpperCase(), path: key.substring(colonIndex + 1) });\n }\n\n const matcher = new CustomRouteMatcher(entries);\n matcherCache.set(signature, matcher);\n if (matcherCache.size > MAX_CACHED_MATCHERS) {\n matcherCache.delete(matcherCache.keys().next().value!);\n }\n return matcher;\n}\n","import type { MastraAuthConfig } from '@mastra/core/server';\n\n// Default configuration that can be extended by clients\nexport const defaultAuthConfig: MastraAuthConfig = {\n protected: ['/api/*'],\n public: ['/api', '/api/auth/*'],\n // Simple rule system\n rules: [\n // Admin users can do anything\n {\n condition: user => {\n if (typeof user === 'object' && user !== null) {\n if ('isAdmin' in user) {\n return !!user.isAdmin;\n }\n\n if ('role' in user) {\n return user.role === 'admin';\n }\n }\n return false;\n },\n allow: true,\n },\n ],\n};\n","/**\n * Path pattern matching utility\n * Inlined from regexparam v3.0.0 (MIT License)\n * https://github.com/lukeed/regexparam\n *\n * Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport interface ParsedPattern {\n keys: string[] | false;\n pattern: RegExp;\n}\n\n/**\n * Parse a route pattern into a RegExp\n * Supports:\n * - Named parameters: /users/:id\n * - Optional parameters: /users/:id?\n * - Wildcards: /files/*\n * - Mixed patterns: /api/:version/users/:id\n */\nexport function parse(input: string | RegExp, loose?: boolean): ParsedPattern {\n if (input instanceof RegExp) return { keys: false, pattern: input };\n\n let c: string;\n let o: number;\n let tmp: string | undefined;\n let ext: number;\n const keys: string[] = [];\n let pattern = '';\n const arr = input.split('/');\n\n arr[0] || arr.shift();\n\n while ((tmp = arr.shift())) {\n c = tmp[0]!;\n if (c === '*') {\n keys.push(c);\n pattern += tmp[1] === '?' ? '(?:/(.*))?' : '/(.*)';\n } else if (c === ':') {\n o = tmp.indexOf('?', 1);\n ext = tmp.indexOf('.', 1);\n keys.push(tmp.substring(1, ~o ? o : ~ext ? ext : tmp.length));\n pattern += !!~o && !~ext ? '(?:/([^/]+?))?' : '/([^/]+?)';\n if (~ext) pattern += (~o ? '?' : '') + '\\\\' + tmp.substring(ext);\n } else {\n // Escape regex metacharacters so static segments stay literal. Without this,\n // a public route like '/a.b' would also match '/axb' and could skip auth for\n // a later protected route the framework dispatches instead.\n pattern += '/' + tmp.replace(/([.+*?^${}()|[\\]\\\\])/g, '\\\\$1');\n }\n }\n\n return {\n keys: keys,\n pattern: new RegExp('^' + pattern + (loose ? '(?=$|/)' : '/?$'), 'i'),\n };\n}\n\n/**\n * Test if a path matches a pattern\n */\nexport function matchPath(path: string, pattern: string | RegExp): boolean {\n const { pattern: regex } = parse(pattern);\n return regex.test(path);\n}\n","import type { ISessionProvider, MastraUser } from '@mastra/core/auth';\nimport type { IRBACProvider, EEUser } from '@mastra/core/auth/ee';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { CompositeAuth, normalizeMastraUser } from '@mastra/core/server';\nimport type { ApiRoute, IMastraAuthProvider, MastraAuthConfig, MastraAuthRequest } from '@mastra/core/server';\n\nimport {\n MASTRA_RESOURCE_ID_KEY,\n MASTRA_USER_KEY,\n MASTRA_NORMALIZED_USER_KEY,\n MASTRA_USER_PERMISSIONS_KEY,\n MASTRA_USER_ROLES_KEY,\n MASTRA_AUTH_TOKEN_KEY,\n MASTRA_AUTH_MODE_KEY,\n} from '../constants';\nimport { HTTPException } from '../http-exception';\nimport { CustomRouteMatcher, getCustomRouteAuthConfigMatcher } from './custom-route-matcher';\nimport { defaultAuthConfig } from './defaults';\nimport { parse } from './path-pattern';\n\n// Re-export request-context key constants so custom middleware can read namespaced\n// auth state without importing internal paths.\nexport {\n MASTRA_USER_KEY,\n MASTRA_NORMALIZED_USER_KEY,\n MASTRA_USER_PERMISSIONS_KEY,\n MASTRA_USER_ROLES_KEY,\n} from '../constants';\n\ntype CustomRouteAuthDecision = 'protected' | 'public' | 'none';\n\n/**\n * Decide auth for a request from the custom route the custom-route app will dispatch\n * it to (see `CustomRouteMatcher`), not from whichever pattern happens to match.\n *\n * Fails closed:\n * - an exact `METHOD:path` (or `ALL:path`) entry that requires auth always wins, so a\n * path registered as protected is never served without auth;\n * - `path` may be a raw request path (Express, Koa, Fastify) or one Hono already\n * decoded, so it's resolved both ways and is only public if every reading lands on\n * a public route, and protected if any reading lands on a protected one;\n * - if the routes or the path can't be parsed, the request is treated as protected.\n */\nconst resolveCustomRouteAuth = (\n path: string,\n method: string,\n customRouteAuthConfig: Map<string, boolean>,\n): CustomRouteAuthDecision => {\n const upperMethod = method.toUpperCase();\n const methods = upperMethod === 'HEAD' ? ['HEAD', 'GET'] : [upperMethod];\n for (const m of methods) {\n if (customRouteAuthConfig.get(`${m}:${path}`) === true || customRouteAuthConfig.get(`ALL:${path}`) === true) {\n return 'protected';\n }\n }\n\n // Adapters pin the current request by appending `METHOD:path` to a copy of the map.\n // As the last entry it only decides when no earlier route matches, so resolve the\n // rest with a cached matcher and fall back to it, instead of building a new router\n // for every request path.\n const keys = [...customRouteAuthConfig.keys()];\n const lastKey = keys[keys.length - 1];\n const pinnedKey =\n lastKey !== undefined && methods.some(m => lastKey === `${m}:${path}` || lastKey === `ALL:${path}`)\n ? lastKey\n : undefined;\n\n let matcher: ReturnType<typeof getCustomRouteAuthConfigMatcher>;\n const candidates = new Set<string>([path]);\n try {\n matcher = getCustomRouteAuthConfigMatcher(pinnedKey ? keys.slice(0, -1) : keys);\n candidates.add(matcher.dispatchPathForRawPath(path));\n } catch {\n return 'protected';\n }\n\n let matchedPublic = false;\n let unmatched = false;\n for (const candidate of candidates) {\n let key: string | undefined;\n try {\n key = matcher.matchPath(candidate, upperMethod)?.entry.key;\n } catch {\n return 'protected';\n }\n if (key === undefined && pinnedKey && candidate === path) {\n key = pinnedKey;\n }\n if (key === undefined) {\n unmatched = true;\n continue;\n }\n if (customRouteAuthConfig.get(key) !== false) {\n return 'protected';\n }\n matchedPublic = true;\n }\n\n return matchedPublic && !unmatched ? 'public' : 'none';\n};\n\n/**\n * Check if a request will be handled by a registered custom route that requires\n * authentication. The route that decides is the one the custom-route app dispatches\n * to (first registered match), using Hono's own matching. Returns false when no\n * custom route handles the request.\n */\nexport const isProtectedCustomRoute = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig || customRouteAuthConfig.size === 0) {\n return false;\n }\n return resolveCustomRouteAuth(path, method, customRouteAuthConfig) === 'protected';\n};\n\nconst apiRouteMatchers = new WeakMap<\n readonly ApiRoute[],\n { signature: string; matcher: CustomRouteMatcher<ApiRoute> }\n>();\n\n/**\n * Find the custom API route Hono dispatches `path` to, with its decoded path params.\n * `path` is in the form Hono's `c.req.path` returns (no query string, decoded once).\n * Matching follows Hono: first registered match wins, case-sensitive, strict\n * trailing slash, and HEAD is served by GET routes.\n */\nexport const findMatchingCustomRoute = (\n path: string,\n method: string,\n apiRoutes?: ApiRoute[],\n): { route: ApiRoute; params: Record<string, string> } | undefined => {\n if (!apiRoutes || apiRoutes.length === 0) return undefined;\n\n const signature = JSON.stringify(apiRoutes.map(route => `${route.method}:${route.path}`));\n let cached = apiRouteMatchers.get(apiRoutes);\n if (!cached || cached.signature !== signature) {\n cached = { signature, matcher: new CustomRouteMatcher(apiRoutes) };\n apiRouteMatchers.set(apiRoutes, cached);\n }\n\n try {\n const match = cached.matcher.matchPath(path, method);\n return match ? { route: match.entry, params: match.params } : undefined;\n } catch {\n // Hono can't route these paths either, so no custom route handles the request.\n return undefined;\n }\n};\n\n/**\n * Check if request is from dev playground\n * @param getHeader - Function to get header value from request\n * @param customRouteAuthConfig - Map of custom route auth configurations\n */\nexport const isDevPlaygroundRequest = (\n path: string,\n method: string,\n getHeader: (name: string) => string | undefined,\n authConfig: MastraAuthConfig,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n const protectedAccess = [...(defaultAuthConfig.protected || []), ...(authConfig.protected || [])];\n return (\n process.env.MASTRA_DEV === 'true' &&\n // Allow if path doesn't match protected patterns AND is not a protected custom route\n ((!isAnyMatch(path, method, protectedAccess) && !isProtectedCustomRoute(path, method, customRouteAuthConfig)) ||\n // Or if has playground header\n getHeader('x-mastra-dev-playground') === 'true')\n );\n};\n\n/**\n * Check if a request will be handled by a custom route registered as public\n * (`requiresAuth: false`). Uses the same dispatch-order resolution as\n * `isProtectedCustomRoute`, and returns false (not public) when no custom route\n * handles the request or the answer is ambiguous.\n */\nexport const isCustomRoutePublic = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig || customRouteAuthConfig.size === 0) {\n return false;\n }\n return resolveCustomRouteAuth(path, method, customRouteAuthConfig) === 'public';\n};\n\n// NOTE: This uses isProtectedCustomRoute (default-allow for unknown paths) rather than\n// !isCustomRoutePublic (default-deny). This is intentional — all registered server and\n// custom routes are auth-checked via registerRoute/checkRouteAuth regardless of this\n// function. The '/api/*' protected pattern exists as a user-facing override mechanism.\n// The old default-deny logic incorrectly blocked non-API paths (e.g. '/', '/agents')\n// which prevented the studio login page from loading in production.\nexport const isProtectedPath = (\n path: string,\n method: string,\n authConfig: MastraAuthConfig,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n const protectedAccess = [...(defaultAuthConfig.protected || []), ...(authConfig.protected || [])];\n return isAnyMatch(path, method, protectedAccess) || isProtectedCustomRoute(path, method, customRouteAuthConfig);\n};\n\nexport const canAccessPublicly = (path: string, method: string, authConfig: MastraAuthConfig): boolean => {\n // Check if this path+method combination is publicly accessible\n const publicAccess = [...(defaultAuthConfig.public || []), ...(authConfig.public || [])];\n\n return isAnyMatch(path, method, publicAccess);\n};\n\nconst isAnyMatch = (\n path: string,\n method: string,\n patterns: MastraAuthConfig['protected'] | MastraAuthConfig['public'],\n): boolean => {\n if (!patterns) {\n return false;\n }\n\n for (const patternPathOrMethod of patterns) {\n if (patternPathOrMethod instanceof RegExp) {\n if (patternPathOrMethod.test(path)) {\n return true;\n }\n }\n\n if (typeof patternPathOrMethod === 'string' && pathMatchesPattern(path, patternPathOrMethod)) {\n return true;\n }\n\n if (Array.isArray(patternPathOrMethod) && patternPathOrMethod.length === 2) {\n const [pattern, methodOrMethods] = patternPathOrMethod;\n if (pathMatchesPattern(path, pattern) && matchesOrIncludes(methodOrMethods, method)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\nexport const pathMatchesPattern = (path: string, pattern: string): boolean => {\n // Use regexparam for battle-tested path matching\n // Supports:\n // - Exact paths: '/api/users'\n // - Wildcards: '/api/agents/*' matches '/api/agents/123'\n // - Path parameters: '/users/:id' matches '/users/123'\n // - Optional parameters: '/users/:id?' matches '/users' and '/users/123'\n // - Mixed patterns: '/api/:version/users/:id/profile'\n const { pattern: regex } = parse(pattern);\n return regex.test(path);\n};\n\nexport const pathMatchesRule = (path: string, rulePath: string | RegExp | string[] | undefined): boolean => {\n if (!rulePath) return true; // No path specified means all paths\n\n if (typeof rulePath === 'string') {\n return pathMatchesPattern(path, rulePath);\n }\n\n if (rulePath instanceof RegExp) {\n return rulePath.test(path);\n }\n\n if (Array.isArray(rulePath)) {\n return rulePath.some(p => pathMatchesPattern(path, p));\n }\n\n return false;\n};\n\nexport const matchesOrIncludes = (values: string | string[], value: string): boolean => {\n if (typeof values === 'string') {\n return values === value;\n }\n\n if (Array.isArray(values)) {\n return values.includes(value);\n }\n\n return false;\n};\n\n// ── Core auth middleware ──\n// Framework-agnostic auth logic extracted from adapter middlewares.\n// Each adapter builds an AuthMiddlewareContext and delegates to coreAuthMiddleware.\n\nexport interface AuthMiddlewareContext {\n path: string;\n method: string;\n getHeader: (name: string) => string | undefined;\n mastra: Mastra;\n authConfig: MastraAuthConfig;\n customRouteAuthConfig?: Map<string, boolean>;\n requestContext: { get: (key: string) => unknown; set: (key: string, value: unknown) => void };\n rawRequest: MastraAuthRequest;\n token: string | null;\n buildAuthorizeContext: () => unknown;\n /** When true, force authentication even if the path matches a public pattern. */\n requiresAuth?: boolean;\n}\n\nexport type AuthResult =\n | { action: 'next'; headers?: Record<string, string> }\n | { action: 'error'; status: number; body: Record<string, unknown>; headers?: Record<string, string> };\n\nconst pass: AuthResult = { action: 'next' };\n\n/**\n * Lets an app's `authorize(path, method, user, context)` read `context.get('requestContext')` and\n * `context.get('mastra')` on every adapter, as it can on Hono, so per-caller values (the Knowledge scope) bind\n * the same way everywhere. Hono and NestJS contexts already answer `get`; Express, Fastify and Koa pass a web\n * Request, Elysia its own context, and adapters with no builder pass nothing.\n */\nconst withAuthorizeVariables = (\n base: unknown,\n ctx: Pick<AuthMiddlewareContext, 'mastra' | 'requestContext' | 'customRouteAuthConfig' | 'rawRequest'>,\n): unknown => {\n const variables: Record<string, unknown> = {\n mastra: ctx.mastra,\n requestContext: ctx.requestContext,\n customRouteAuthConfig: ctx.customRouteAuthConfig,\n };\n const get = (key: string) => variables[key];\n if (base === null || base === undefined) {\n return { get, req: ctx.rawRequest };\n }\n if (typeof base === 'object' && typeof (base as { get?: unknown }).get !== 'function') {\n Object.defineProperty(base, 'get', { value: get, configurable: true });\n }\n return base;\n};\n\nconst adaptToMastraAuthRequest = (request: MastraAuthRequest): MastraAuthRequest => {\n if (!(request instanceof Request)) {\n return request;\n }\n\n return {\n raw: request,\n headers: request.headers,\n header: name => request.headers.get(name) ?? undefined,\n };\n};\n\nexport interface GetAuthenticatedUserOptions {\n mastra: Mastra;\n token: string;\n request: MastraAuthRequest;\n}\n\nexport const getAuthenticatedUser = async <TUser = unknown>({\n mastra,\n token,\n request,\n}: GetAuthenticatedUserOptions): Promise<TUser | null> => {\n const normalizedToken = token.replace(/^Bearer\\s+/i, '').trim();\n if (!normalizedToken) {\n return null;\n }\n\n const authConfig = mastra.getServer()?.auth;\n if (!authConfig || typeof authConfig.authenticateToken !== 'function') {\n return null;\n }\n\n return (await authConfig.authenticateToken(normalizedToken, request)) as TUser | null;\n};\n\n/**\n * Check if an auth config object supports transparent session refresh.\n * Returns true if the auth provider implements the necessary ISessionProvider methods.\n */\nexport function supportsSessionRefresh(\n authConfig: MastraAuthConfig | IMastraAuthProvider,\n): authConfig is (MastraAuthConfig | IMastraAuthProvider) &\n Pick<ISessionProvider, 'refreshSession' | 'getSessionIdFromRequest' | 'getSessionHeaders'> {\n return (\n typeof (authConfig as any).getSessionIdFromRequest === 'function' &&\n typeof (authConfig as any).refreshSession === 'function' &&\n typeof (authConfig as any).getSessionHeaders === 'function'\n );\n}\n\n/**\n * Whether auth is bypassed for this path/method: the dev playground (only when no auth\n * provider is configured), paths that are not protected, and public paths (unless the\n * route forces auth with `requiresAuth: true`).\n */\nexport const isAuthBypassed = ({\n path,\n method,\n getHeader,\n authConfig,\n customRouteAuthConfig,\n requiresAuth,\n}: Pick<\n AuthMiddlewareContext,\n 'path' | 'method' | 'getHeader' | 'authConfig' | 'customRouteAuthConfig' | 'requiresAuth'\n>): boolean => {\n // Only bypass auth for dev playground when no real auth provider is configured.\n // When auth IS configured (has authenticateToken), we need the full auth flow\n // so user/roles/permissions are set in requestContext.\n const hasAuthProvider = typeof authConfig.authenticateToken === 'function';\n if (!hasAuthProvider && isDevPlaygroundRequest(path, method, getHeader, authConfig, customRouteAuthConfig)) {\n return true;\n }\n\n if (!isProtectedPath(path, method, authConfig, customRouteAuthConfig)) {\n return true;\n }\n\n // When a route explicitly requires auth (requiresAuth: true), skip the\n // public-path bypass so the user is still authenticated and permissions\n // are injected into the request context.\n return (\n !requiresAuth &&\n (canAccessPublicly(path, method, authConfig) || isCustomRoutePublic(path, method, customRouteAuthConfig))\n );\n};\n\n/**\n * Single auth middleware: authenticate → authorize.\n * Skip checks (dev playground, unprotected path, public path) are evaluated once.\n */\nexport const coreAuthMiddleware = async (ctx: AuthMiddlewareContext): Promise<AuthResult> => {\n const { path, method, mastra, authConfig, customRouteAuthConfig, requestContext, rawRequest, token } = ctx;\n\n // ── Skip checks (evaluated once) ──\n\n if (isAuthBypassed(ctx)) {\n return pass;\n }\n\n // ── Authentication ──\n\n let user: unknown;\n let refreshHeaders: Record<string, string> | undefined;\n const authRequest = adaptToMastraAuthRequest(rawRequest);\n\n type ConsumePendingResponseHeadersFn = (request: typeof authRequest) => Record<string, string> | undefined;\n const mergePendingProviderHeaders = (request: typeof authRequest = authRequest) => {\n const consume = (authConfig as { consumePendingResponseHeaders?: ConsumePendingResponseHeadersFn })\n .consumePendingResponseHeaders;\n if (typeof consume !== 'function') return;\n let pending: Record<string, string> | undefined;\n try {\n pending = consume.call(authConfig, request);\n } catch {\n // Forwarding a rotated cookie is best-effort; never fail auth over it.\n return;\n }\n if (!pending) return;\n refreshHeaders = { ...(refreshHeaders ?? {}), ...pending };\n };\n\n try {\n if (typeof authConfig.authenticateToken === 'function') {\n user = await authConfig.authenticateToken(token ?? '', authRequest);\n mergePendingProviderHeaders();\n } else {\n throw new Error('No token verification method configured');\n }\n\n // If authentication failed, attempt transparent session refresh before returning 401.\n // This handles expired access tokens without requiring client-side refresh logic.\n if (!user && supportsSessionRefresh(authConfig) && rawRequest instanceof Request) {\n let retryHttpError: HTTPException | undefined;\n try {\n const sessionId = authConfig.getSessionIdFromRequest(rawRequest);\n if (sessionId) {\n const newSession = await authConfig.refreshSession(sessionId);\n if (newSession) {\n // Refresh succeeded — build updated session headers and re-authenticate.\n // We create a synthetic request with the new session cookie so\n // authenticateToken (which reads cookies from the request) picks up\n // the refreshed session instead of the expired one.\n refreshHeaders = authConfig.getSessionHeaders(newSession);\n const refreshedCookie = Object.entries(refreshHeaders)\n .filter(([k]) => k.toLowerCase() === 'set-cookie')\n .map(([, v]) => v.split(';')[0]) // Extract name=value before attributes\n .join('; ');\n if (refreshedCookie) {\n const refreshedRequest = new Request(rawRequest.url, {\n method: rawRequest.method,\n headers: new Headers(rawRequest.headers),\n });\n refreshedRequest.headers.set('Cookie', refreshedCookie);\n // Pass the refreshed cookie value as the token so authenticateToken\n // picks up the new session instead of the stale original.\n // Auth providers typically read cookies from the request object, but\n // some may also inspect the token parameter directly.\n const cookieValue = refreshedCookie.includes('=')\n ? refreshedCookie.split('=').slice(1).join('=')\n : refreshedCookie;\n try {\n const retryAuthRequest = adaptToMastraAuthRequest(refreshedRequest);\n user = await authConfig.authenticateToken(cookieValue, retryAuthRequest);\n mergePendingProviderHeaders(retryAuthRequest);\n } catch (retryErr) {\n retryHttpError = retryErr instanceof HTTPException ? retryErr : undefined;\n throw retryErr;\n }\n }\n if (!user) {\n refreshHeaders = undefined;\n }\n }\n }\n } catch (refreshErr) {\n refreshHeaders = undefined;\n // An explicit HTTP error from the retried authenticateToken goes to the outer handler.\n if (retryHttpError === refreshErr) throw refreshErr;\n mastra.getLogger()?.debug('Session refresh failed, falling back to 401', {\n error: refreshErr instanceof Error ? { message: refreshErr.message } : refreshErr,\n });\n }\n }\n\n if (!user) {\n return { action: 'error', status: 401, body: { error: 'Invalid or expired token' }, headers: refreshHeaders };\n }\n\n requestContext.set(MASTRA_USER_KEY, user);\n // Backward-compat: also write the legacy `'user'` key so existing\n // middleware and integrations that read `requestContext.get('user')`\n // (including built-in FGA route enforcement, memory handlers, and the\n // documented public surface) keep working. New code should prefer\n // `MASTRA_USER_KEY` to avoid collisions with caller-supplied keys.\n requestContext.set('user', user);\n\n // Normalize the authenticated user to the stable MastraUser shape consumed\n // by DynamicArgument callbacks. Must run before mapUserToResourceId:\n // CompositeAuth's resource-id mapping consumes its authenticated-provider\n // bookkeeping while toMastraUser only peeks at it. Best-effort — a user\n // shape the default normalization can't handle leaves the key unset\n // (callbacks see `user: undefined`) instead of failing the request.\n try {\n const toMastraUser =\n 'toMastraUser' in authConfig && typeof authConfig.toMastraUser === 'function'\n ? (authConfig.toMastraUser as (user: unknown) => MastraUser)\n : normalizeMastraUser;\n const normalizedUser = toMastraUser.call(authConfig, user);\n if (normalizedUser && typeof normalizedUser.id === 'string' && normalizedUser.id.trim()) {\n requestContext.set(MASTRA_NORMALIZED_USER_KEY, normalizedUser);\n }\n } catch (normalizeError) {\n mastra\n .getLogger()\n ?.warn('Failed to normalize authenticated user to MastraUser; callbacks will see user: undefined', {\n error: normalizeError instanceof Error ? { message: normalizeError.message } : normalizeError,\n });\n }\n\n // Store the raw auth token so downstream code (e.g., editor MCP client\n // resolution) can forward it when connecting to auth-protected MCP servers.\n // The token may arrive via Authorization header, apiKey query param, or\n // cookie (SimpleAuth sets `mastra-token`). Check all sources so the\n // forwarded value is available regardless of how the user authenticated.\n let effectiveToken = token;\n if (!effectiveToken && rawRequest instanceof Request) {\n const cookieHeader = rawRequest.headers.get('cookie');\n if (cookieHeader) {\n const match = cookieHeader.match(/mastra-token=([^;]+)/);\n if (match?.[1]) effectiveToken = match[1];\n }\n }\n if (effectiveToken) {\n requestContext.set(MASTRA_AUTH_TOKEN_KEY, effectiveToken);\n }\n\n if (typeof authConfig.mapUserToResourceId === 'function') {\n try {\n const resourceId = authConfig.mapUserToResourceId(user);\n // CompositeAuth validates the authenticating provider's mapper. It can\n // return undefined when that provider never configured a mapper.\n if (resourceId !== undefined || !(authConfig instanceof CompositeAuth)) {\n if (typeof resourceId !== 'string' || !resourceId.trim()) {\n throw new Error('mapUserToResourceId must return a non-empty string for the authenticated user');\n }\n requestContext.set(MASTRA_RESOURCE_ID_KEY, resourceId);\n }\n } catch (mapError) {\n mastra.getLogger()?.error('mapUserToResourceId failed', {\n error: mapError instanceof Error ? { message: mapError.message, stack: mapError.stack } : mapError,\n });\n return {\n action: 'error',\n status: 500,\n body: { error: 'Failed to map authenticated user to a resource ID' },\n headers: refreshHeaders,\n };\n }\n }\n\n try {\n // Determine which RBAC provider to use based on auth mode\n const authMode = requestContext.get(MASTRA_AUTH_MODE_KEY);\n const serverConfig = mastra.getServer();\n const studioConfig = mastra.getStudio?.();\n // Use studio RBAC if this is a studio request, otherwise use server RBAC\n const rbacProvider = (authMode === 'studio' ? (studioConfig?.rbac ?? serverConfig?.rbac) : serverConfig?.rbac) as\n | IRBACProvider<EEUser>\n | undefined;\n\n if (rbacProvider) {\n if (!user || typeof user !== 'object' || !('id' in user)) {\n mastra.getLogger()?.warn('RBAC: authenticated user missing required \"id\" field, skipping permission loading');\n } else {\n const permissions = await rbacProvider.getPermissions(user as EEUser);\n requestContext.set(MASTRA_USER_PERMISSIONS_KEY, permissions);\n // Backward-compat alias for callers reading the legacy key.\n requestContext.set('userPermissions', permissions);\n\n const roles = await rbacProvider.getRoles(user as EEUser);\n requestContext.set(MASTRA_USER_ROLES_KEY, roles);\n // Backward-compat alias for callers reading the legacy key.\n requestContext.set('userRoles', roles);\n\n // Populate the normalized user's role from RBAC when the auth\n // provider's user carried none: primary role = first RBAC role.\n const normalizedUser = requestContext.get(MASTRA_NORMALIZED_USER_KEY) as MastraUser | undefined;\n if (normalizedUser && !normalizedUser.role && Array.isArray(roles) && typeof roles[0] === 'string') {\n requestContext.set(MASTRA_NORMALIZED_USER_KEY, { ...normalizedUser, role: roles[0] });\n }\n }\n }\n } catch (rbacError) {\n mastra.getLogger()?.error('RBAC: failed to load user permissions/roles', {\n error: rbacError instanceof Error ? { message: rbacError.message, stack: rbacError.stack } : rbacError,\n });\n }\n } catch (err) {\n mastra.getLogger()?.error('Authentication error', {\n error: err instanceof Error ? { message: err.message, stack: err.stack } : err,\n });\n // Explicit HTTP errors from auth callbacks keep their status/message; anything else is redacted.\n // The HTTPException message is sent to the client, so callers must keep it safe (no internal details).\n if (err instanceof HTTPException && err.status >= 400 && err.status <= 599) {\n return { action: 'error', status: err.status, body: { error: err.message }, headers: refreshHeaders };\n }\n return { action: 'error', status: 401, body: { error: 'Invalid or expired token' }, headers: refreshHeaders };\n }\n\n // ── Authorization ──\n\n const authorizationError = await authorizeAuthenticatedUser({\n path,\n method,\n user,\n mastra,\n authConfig,\n customRouteAuthConfig,\n requestContext,\n rawRequest,\n buildAuthorizeContext: ctx.buildAuthorizeContext,\n });\n if (authorizationError) {\n return { action: 'error', ...authorizationError, headers: refreshHeaders };\n }\n\n return refreshHeaders ? { action: 'next', headers: refreshHeaders } : pass;\n};\n\nexport interface AuthorizeAuthenticatedUserContext {\n path: string;\n method: string;\n user: unknown;\n mastra: Mastra;\n authConfig: MastraAuthConfig;\n customRouteAuthConfig?: Map<string, boolean>;\n requestContext: AuthMiddlewareContext['requestContext'];\n rawRequest: MastraAuthRequest;\n buildAuthorizeContext: () => unknown;\n}\n\n/**\n * The authorization step of server auth for an already authenticated user:\n * `authorizeUser`, `authorize(path, method, user)`, `rules`, or the RBAC default rules.\n * Returns null when the user may access `method path`.\n */\nexport const authorizeAuthenticatedUser = async (\n ctx: AuthorizeAuthenticatedUserContext,\n): Promise<{ status: number; body: Record<string, unknown> } | null> => {\n const { path, method, user, mastra, authConfig, requestContext, rawRequest } = ctx;\n const denied = { status: 403, body: { error: 'Access denied' } };\n\n if ('authorizeUser' in authConfig && typeof authConfig.authorizeUser === 'function') {\n try {\n const isAuthorized = await authConfig.authorizeUser(user, adaptToMastraAuthRequest(rawRequest));\n return isAuthorized ? null : denied;\n } catch (err) {\n mastra.getLogger()?.error('Authorization error in authorizeUser', {\n error: err instanceof Error ? { message: err.message, stack: err.stack } : err,\n });\n return { status: 500, body: { error: 'Authorization error' } };\n }\n }\n\n if ('authorize' in authConfig && typeof authConfig.authorize === 'function') {\n try {\n const authorizeCtx = withAuthorizeVariables(ctx.buildAuthorizeContext(), {\n mastra,\n requestContext,\n customRouteAuthConfig: ctx.customRouteAuthConfig,\n rawRequest,\n });\n const isAuthorized = await authConfig.authorize(path, method, user, authorizeCtx as any);\n return isAuthorized ? null : denied;\n } catch (err) {\n mastra.getLogger()?.error('Authorization error in authorize', {\n error: err instanceof Error ? { message: err.message, stack: err.stack } : err,\n path,\n method,\n });\n return { status: 500, body: { error: 'Authorization error' } };\n }\n }\n\n if ('rules' in authConfig && authConfig.rules && authConfig.rules.length > 0) {\n return (await checkRules(authConfig.rules, path, method, user)) ? null : denied;\n }\n\n // No explicit authorization configured (authorizeUser, authorize, or rules)\n // Check if RBAC is configured - if not, allow authenticated users through\n // (auth-only mode = authenticated users get full access)\n const rbacProvider =\n requestContext.get(MASTRA_AUTH_MODE_KEY) === 'studio'\n ? (mastra.getStudio?.()?.rbac ?? mastra.getServer()?.rbac)\n : mastra.getServer()?.rbac;\n if (rbacProvider) {\n if (defaultAuthConfig.rules && defaultAuthConfig.rules.length > 0) {\n return (await checkRules(defaultAuthConfig.rules, path, method, user)) ? null : denied;\n }\n return denied;\n }\n\n return null;\n};\n\n// Check authorization rules\nexport const checkRules = async (\n rules: MastraAuthConfig['rules'],\n path: string,\n method: string,\n user: unknown,\n): Promise<boolean> => {\n // Go through rules in order (first match wins)\n for (const i in rules || []) {\n const rule = rules?.[i]!;\n // Check if rule applies to this path\n if (!pathMatchesRule(path, rule.path)) {\n continue;\n }\n\n // Check if rule applies to this method\n if (rule.methods && !matchesOrIncludes(rule.methods, method)) {\n continue;\n }\n\n // Rule matches, so it decides. A failed condition denies instead of\n // falling through to a broader rule further down the list.\n const condition = rule.condition;\n if (typeof condition === 'function') {\n return await Promise.resolve()\n .then(() => condition(user))\n .then(result => !!result)\n .catch(() => false);\n }\n return !!rule.allow;\n }\n\n // No matching rules, deny by default\n return false;\n};\n"],"mappings":";;;;;;AAsBA,MAAM,uBAA+B,KAAA;AACrC,MAAM,eAAe,IAAI,QAAQ,mBAAmB;;;;;;;;AASpD,IAAa,qBAAb,MAAmE;CACjE,OAAgB,IAAIA,KAAAA,KAAK;CACzB,kCAA2B,IAAI,IAAqB;CACpD;CAEA,YAAY,SAAuB;EACjC,KAAK,WAAW;EAEhB,KAAK,KAAK,IAAI,KAAK,cAAuB;EAC1C,QAAQ,SAAS,OAAO,UAAU;GAChC,MAAM,eAAuB,KAAA;GAC7B,KAAK,gBAAgB,IAAI,QAAQ,KAAK;GACtC,MAAM,WAAW,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,gBAAgB,CAAC,EAAE,SAAS,MAAe;GACnG,IAAI,MAAM,WAAW,OACnB,KAAK,KAAK,IAAI,MAAM,MAAM,SAAS,IAAK,GAAG,SAAS,MAAM,CAAC,CAAC;QAE5D,KAAK,KAAK,GAAG,MAAM,QAAQ,MAAM,MAAM,SAAS,IAAK,GAAG,SAAS,MAAM,CAAC,CAAC;EAE7E,CAAC;CACH;;;;;;CAOA,UAAU,MAAc,QAAiD;EACvE,MAAM,QAAQ,OAAO,YAAY;EAEjC,MAAM,iBAAiB,UAAU,SAAS,QAAQ;EAClD,MAAM,SAAS,KAAK,KAAK,OAAO,MAAM,gBAAgB,IAAI;EAC1D,MAAM,WAAW,OAAO;EACxB,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;GACxC,MAAM,QAAQ,KAAK,gBAAgB,IAAI,SAAS,EAAE,CAAE,EAAE,CAAC,EAAE;GACzD,IAAI,UAAU,KAAA,GAAW;GACzB,MAAM,UAAU,IAAIC,aAAAA,YAAY,cAAc,MAAM,MAAe;GACnE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YACvB,OAAO,MAAM,QAAQ,QAAQ,CAAC,CAC3B,WAAW,UAAU,IAAI,CAAC,CAAC,CAC3B,MAAK,WAAU,CAAC,CAAC,MAAM,CAAC,CACxB,YAAY,KAAK;EAEtB,OAAO,CAAC,CAAC,KAAK;CAChB;CAGA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers-hFdKABRP.js","names":[],"sources":["../src/server/auth/custom-route-matcher.ts","../src/server/auth/defaults.ts","../src/server/auth/path-pattern.ts","../src/server/auth/helpers.ts"],"sourcesContent":["import { Hono } from 'hono';\nimport { HonoRequest } from 'hono/request';\n\n/** A custom route as the internal custom-route Hono app registers it. */\nexport interface CustomRouteMatcherEntry {\n method: string;\n path: string;\n /**\n * How many handlers (route middleware + handler) the route registers. Hono stores\n * each one as its own router entry, so mirror the count to build the same router.\n */\n handlerCount?: number;\n}\n\nexport interface CustomRouteMatch<T> {\n entry: T;\n index: number;\n params: Record<string, string>;\n}\n\ntype Marker = (...args: unknown[]) => undefined;\n\nconst noopMiddleware: Marker = () => undefined;\nconst paramRequest = new Request('http://localhost/');\n\n/**\n * Answers \"which custom route will run for this request?\" using the same Hono router\n * the custom-route bridge dispatches with (`buildCustomRouteHandler`), registered in\n * the same order with the same paths and methods. Auth decisions use this instead\n * of a separate pattern matcher, so they can't disagree with dispatch on precedence,\n * case, trailing slashes, percent-decoding or HEAD handling.\n */\nexport class CustomRouteMatcher<T extends CustomRouteMatcherEntry> {\n readonly #app = new Hono();\n readonly #indexByHandler = new Map<unknown, number>();\n readonly #entries: readonly T[];\n\n constructor(entries: readonly T[]) {\n this.#entries = entries;\n // Same global middleware as the custom-route app, so the router sees the same table.\n this.#app.use('*', noopMiddleware as never);\n entries.forEach((entry, index) => {\n const marker: Marker = () => undefined;\n this.#indexByHandler.set(marker, index);\n const handlers = Array.from({ length: Math.max(1, entry.handlerCount ?? 1) }, () => marker as never);\n if (entry.method === 'ALL') {\n this.#app.all(entry.path, handlers[0]!, ...handlers.slice(1));\n } else {\n this.#app.on(entry.method, entry.path, handlers[0]!, ...handlers.slice(1));\n }\n });\n }\n\n /**\n * Match a path the way Hono dispatches it, i.e. `path` is already in the form\n * `getPath()` returns (no query string, percent-decoded once).\n * Throws if Hono can't build a router for the registered paths.\n */\n matchPath(path: string, method: string): CustomRouteMatch<T> | undefined {\n const upper = method.toUpperCase();\n // Hono serves HEAD with the GET handler.\n const dispatchMethod = upper === 'HEAD' ? 'GET' : upper;\n const result = this.#app.router.match(dispatchMethod, path);\n const handlers = result[0];\n for (let i = 0; i < handlers.length; i++) {\n const index = this.#indexByHandler.get(handlers[i]![0][0]);\n if (index === undefined) continue; // the global middleware\n const request = new HonoRequest(paramRequest, path, result as never);\n request.routeIndex = i;\n return { entry: this.#entries[index]!, index, params: request.param() as Record<string, string> };\n }\n return undefined;\n }\n\n /**\n * Match the full URL handed to the custom-route app. Parses it the same way\n * (`new Request(url)` then Hono's `getPath`), so dot segments, encoded characters\n * and the query string are handled exactly as dispatch handles them.\n * Throws if the URL can't be parsed.\n */\n matchUrl(url: string, method: string): CustomRouteMatch<T> | undefined {\n const path = this.#app.getPath(new Request(url));\n return this.matchPath(path, method);\n }\n\n /**\n * Converts a raw request path (as Express/Koa/Fastify see it, not yet decoded) to\n * the path Hono would dispatch when the bridge forwards it. Throws on an\n * unparseable path.\n */\n dispatchPathForRawPath(rawPath: string): string {\n return this.#app.getPath(new Request(`http://localhost${rawPath}`));\n }\n}\n\nconst MAX_CACHED_MATCHERS = 32;\nconst matcherCache = new Map<string, CustomRouteMatcher<CustomRouteMatcherEntry & { key: string }>>();\n\n/**\n * Builds (and caches) a matcher from `customRouteAuthConfig` keys. Keys are\n * `METHOD:path` in registration order, which is the order the server registers\n * custom routes with the custom-route app.\n */\nexport function getCustomRouteAuthConfigMatcher(\n keys: readonly string[],\n): CustomRouteMatcher<CustomRouteMatcherEntry & { key: string }> {\n const signature = JSON.stringify(keys);\n const cached = matcherCache.get(signature);\n if (cached) {\n matcherCache.delete(signature);\n matcherCache.set(signature, cached);\n return cached;\n }\n\n const entries: Array<CustomRouteMatcherEntry & { key: string }> = [];\n for (const key of keys) {\n const colonIndex = key.indexOf(':');\n if (colonIndex === -1) continue; // malformed key\n entries.push({ key, method: key.substring(0, colonIndex).toUpperCase(), path: key.substring(colonIndex + 1) });\n }\n\n const matcher = new CustomRouteMatcher(entries);\n matcherCache.set(signature, matcher);\n if (matcherCache.size > MAX_CACHED_MATCHERS) {\n matcherCache.delete(matcherCache.keys().next().value!);\n }\n return matcher;\n}\n","import type { MastraAuthConfig } from '@mastra/core/server';\n\n// Default configuration that can be extended by clients\nexport const defaultAuthConfig: MastraAuthConfig = {\n protected: ['/api/*'],\n public: ['/api', '/api/auth/*'],\n // Simple rule system\n rules: [\n // Admin users can do anything\n {\n condition: user => {\n if (typeof user === 'object' && user !== null) {\n if ('isAdmin' in user) {\n return !!user.isAdmin;\n }\n\n if ('role' in user) {\n return user.role === 'admin';\n }\n }\n return false;\n },\n allow: true,\n },\n ],\n};\n","/**\n * Path pattern matching utility\n * Inlined from regexparam v3.0.0 (MIT License)\n * https://github.com/lukeed/regexparam\n *\n * Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport interface ParsedPattern {\n keys: string[] | false;\n pattern: RegExp;\n}\n\n/**\n * Parse a route pattern into a RegExp\n * Supports:\n * - Named parameters: /users/:id\n * - Optional parameters: /users/:id?\n * - Wildcards: /files/*\n * - Mixed patterns: /api/:version/users/:id\n */\nexport function parse(input: string | RegExp, loose?: boolean): ParsedPattern {\n if (input instanceof RegExp) return { keys: false, pattern: input };\n\n let c: string;\n let o: number;\n let tmp: string | undefined;\n let ext: number;\n const keys: string[] = [];\n let pattern = '';\n const arr = input.split('/');\n\n arr[0] || arr.shift();\n\n while ((tmp = arr.shift())) {\n c = tmp[0]!;\n if (c === '*') {\n keys.push(c);\n pattern += tmp[1] === '?' ? '(?:/(.*))?' : '/(.*)';\n } else if (c === ':') {\n o = tmp.indexOf('?', 1);\n ext = tmp.indexOf('.', 1);\n keys.push(tmp.substring(1, ~o ? o : ~ext ? ext : tmp.length));\n pattern += !!~o && !~ext ? '(?:/([^/]+?))?' : '/([^/]+?)';\n if (~ext) pattern += (~o ? '?' : '') + '\\\\' + tmp.substring(ext);\n } else {\n // Escape regex metacharacters so static segments stay literal. Without this,\n // a public route like '/a.b' would also match '/axb' and could skip auth for\n // a later protected route the framework dispatches instead.\n pattern += '/' + tmp.replace(/([.+*?^${}()|[\\]\\\\])/g, '\\\\$1');\n }\n }\n\n return {\n keys: keys,\n pattern: new RegExp('^' + pattern + (loose ? '(?=$|/)' : '/?$'), 'i'),\n };\n}\n\n/**\n * Test if a path matches a pattern\n */\nexport function matchPath(path: string, pattern: string | RegExp): boolean {\n const { pattern: regex } = parse(pattern);\n return regex.test(path);\n}\n","import type { ISessionProvider, MastraUser } from '@mastra/core/auth';\nimport type { IRBACProvider, EEUser } from '@mastra/core/auth/ee';\nimport type { Mastra } from '@mastra/core/mastra';\nimport { CompositeAuth, normalizeMastraUser } from '@mastra/core/server';\nimport type { ApiRoute, IMastraAuthProvider, MastraAuthConfig, MastraAuthRequest } from '@mastra/core/server';\n\nimport {\n MASTRA_RESOURCE_ID_KEY,\n MASTRA_USER_KEY,\n MASTRA_NORMALIZED_USER_KEY,\n MASTRA_USER_PERMISSIONS_KEY,\n MASTRA_USER_ROLES_KEY,\n MASTRA_AUTH_TOKEN_KEY,\n MASTRA_AUTH_MODE_KEY,\n} from '../constants';\nimport { HTTPException } from '../http-exception';\nimport { CustomRouteMatcher, getCustomRouteAuthConfigMatcher } from './custom-route-matcher';\nimport { defaultAuthConfig } from './defaults';\nimport { parse } from './path-pattern';\n\n// Re-export request-context key constants so custom middleware can read namespaced\n// auth state without importing internal paths.\nexport {\n MASTRA_USER_KEY,\n MASTRA_NORMALIZED_USER_KEY,\n MASTRA_USER_PERMISSIONS_KEY,\n MASTRA_USER_ROLES_KEY,\n} from '../constants';\n\ntype CustomRouteAuthDecision = 'protected' | 'public' | 'none';\n\n/**\n * Decide auth for a request from the custom route the custom-route app will dispatch\n * it to (see `CustomRouteMatcher`), not from whichever pattern happens to match.\n *\n * Fails closed:\n * - an exact `METHOD:path` (or `ALL:path`) entry that requires auth always wins, so a\n * path registered as protected is never served without auth;\n * - `path` may be a raw request path (Express, Koa, Fastify) or one Hono already\n * decoded, so it's resolved both ways and is only public if every reading lands on\n * a public route, and protected if any reading lands on a protected one;\n * - if the routes or the path can't be parsed, the request is treated as protected.\n */\nconst resolveCustomRouteAuth = (\n path: string,\n method: string,\n customRouteAuthConfig: Map<string, boolean>,\n): CustomRouteAuthDecision => {\n const upperMethod = method.toUpperCase();\n const methods = upperMethod === 'HEAD' ? ['HEAD', 'GET'] : [upperMethod];\n for (const m of methods) {\n if (customRouteAuthConfig.get(`${m}:${path}`) === true || customRouteAuthConfig.get(`ALL:${path}`) === true) {\n return 'protected';\n }\n }\n\n // Adapters pin the current request by appending `METHOD:path` to a copy of the map.\n // As the last entry it only decides when no earlier route matches, so resolve the\n // rest with a cached matcher and fall back to it, instead of building a new router\n // for every request path.\n const keys = [...customRouteAuthConfig.keys()];\n const lastKey = keys[keys.length - 1];\n const pinnedKey =\n lastKey !== undefined && methods.some(m => lastKey === `${m}:${path}` || lastKey === `ALL:${path}`)\n ? lastKey\n : undefined;\n\n let matcher: ReturnType<typeof getCustomRouteAuthConfigMatcher>;\n const candidates = new Set<string>([path]);\n try {\n matcher = getCustomRouteAuthConfigMatcher(pinnedKey ? keys.slice(0, -1) : keys);\n candidates.add(matcher.dispatchPathForRawPath(path));\n } catch {\n return 'protected';\n }\n\n let matchedPublic = false;\n let unmatched = false;\n for (const candidate of candidates) {\n let key: string | undefined;\n try {\n key = matcher.matchPath(candidate, upperMethod)?.entry.key;\n } catch {\n return 'protected';\n }\n if (key === undefined && pinnedKey && candidate === path) {\n key = pinnedKey;\n }\n if (key === undefined) {\n unmatched = true;\n continue;\n }\n if (customRouteAuthConfig.get(key) !== false) {\n return 'protected';\n }\n matchedPublic = true;\n }\n\n return matchedPublic && !unmatched ? 'public' : 'none';\n};\n\n/**\n * Check if a request will be handled by a registered custom route that requires\n * authentication. The route that decides is the one the custom-route app dispatches\n * to (first registered match), using Hono's own matching. Returns false when no\n * custom route handles the request.\n */\nexport const isProtectedCustomRoute = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig || customRouteAuthConfig.size === 0) {\n return false;\n }\n return resolveCustomRouteAuth(path, method, customRouteAuthConfig) === 'protected';\n};\n\nconst apiRouteMatchers = new WeakMap<\n readonly ApiRoute[],\n { signature: string; matcher: CustomRouteMatcher<ApiRoute> }\n>();\n\n/**\n * Find the custom API route Hono dispatches `path` to, with its decoded path params.\n * `path` is in the form Hono's `c.req.path` returns (no query string, decoded once).\n * Matching follows Hono: first registered match wins, case-sensitive, strict\n * trailing slash, and HEAD is served by GET routes.\n */\nexport const findMatchingCustomRoute = (\n path: string,\n method: string,\n apiRoutes?: ApiRoute[],\n): { route: ApiRoute; params: Record<string, string> } | undefined => {\n if (!apiRoutes || apiRoutes.length === 0) return undefined;\n\n const signature = JSON.stringify(apiRoutes.map(route => `${route.method}:${route.path}`));\n let cached = apiRouteMatchers.get(apiRoutes);\n if (!cached || cached.signature !== signature) {\n cached = { signature, matcher: new CustomRouteMatcher(apiRoutes) };\n apiRouteMatchers.set(apiRoutes, cached);\n }\n\n try {\n const match = cached.matcher.matchPath(path, method);\n return match ? { route: match.entry, params: match.params } : undefined;\n } catch {\n // Hono can't route these paths either, so no custom route handles the request.\n return undefined;\n }\n};\n\n/**\n * Check if request is from dev playground\n * @param getHeader - Function to get header value from request\n * @param customRouteAuthConfig - Map of custom route auth configurations\n */\nexport const isDevPlaygroundRequest = (\n path: string,\n method: string,\n getHeader: (name: string) => string | undefined,\n authConfig: MastraAuthConfig,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n const protectedAccess = [...(defaultAuthConfig.protected || []), ...(authConfig.protected || [])];\n return (\n process.env.MASTRA_DEV === 'true' &&\n // Allow if path doesn't match protected patterns AND is not a protected custom route\n ((!isAnyMatch(path, method, protectedAccess) && !isProtectedCustomRoute(path, method, customRouteAuthConfig)) ||\n // Or if has playground header\n getHeader('x-mastra-dev-playground') === 'true')\n );\n};\n\n/**\n * Check if a request will be handled by a custom route registered as public\n * (`requiresAuth: false`). Uses the same dispatch-order resolution as\n * `isProtectedCustomRoute`, and returns false (not public) when no custom route\n * handles the request or the answer is ambiguous.\n */\nexport const isCustomRoutePublic = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig || customRouteAuthConfig.size === 0) {\n return false;\n }\n return resolveCustomRouteAuth(path, method, customRouteAuthConfig) === 'public';\n};\n\n// NOTE: This uses isProtectedCustomRoute (default-allow for unknown paths) rather than\n// !isCustomRoutePublic (default-deny). This is intentional — all registered server and\n// custom routes are auth-checked via registerRoute/checkRouteAuth regardless of this\n// function. The '/api/*' protected pattern exists as a user-facing override mechanism.\n// The old default-deny logic incorrectly blocked non-API paths (e.g. '/', '/agents')\n// which prevented the studio login page from loading in production.\nexport const isProtectedPath = (\n path: string,\n method: string,\n authConfig: MastraAuthConfig,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n const protectedAccess = [...(defaultAuthConfig.protected || []), ...(authConfig.protected || [])];\n return isAnyMatch(path, method, protectedAccess) || isProtectedCustomRoute(path, method, customRouteAuthConfig);\n};\n\nexport const canAccessPublicly = (path: string, method: string, authConfig: MastraAuthConfig): boolean => {\n // Check if this path+method combination is publicly accessible\n const publicAccess = [...(defaultAuthConfig.public || []), ...(authConfig.public || [])];\n\n return isAnyMatch(path, method, publicAccess);\n};\n\nconst isAnyMatch = (\n path: string,\n method: string,\n patterns: MastraAuthConfig['protected'] | MastraAuthConfig['public'],\n): boolean => {\n if (!patterns) {\n return false;\n }\n\n for (const patternPathOrMethod of patterns) {\n if (patternPathOrMethod instanceof RegExp) {\n if (patternPathOrMethod.test(path)) {\n return true;\n }\n }\n\n if (typeof patternPathOrMethod === 'string' && pathMatchesPattern(path, patternPathOrMethod)) {\n return true;\n }\n\n if (Array.isArray(patternPathOrMethod) && patternPathOrMethod.length === 2) {\n const [pattern, methodOrMethods] = patternPathOrMethod;\n if (pathMatchesPattern(path, pattern) && matchesOrIncludes(methodOrMethods, method)) {\n return true;\n }\n }\n }\n\n return false;\n};\n\nexport const pathMatchesPattern = (path: string, pattern: string): boolean => {\n // Use regexparam for battle-tested path matching\n // Supports:\n // - Exact paths: '/api/users'\n // - Wildcards: '/api/agents/*' matches '/api/agents/123'\n // - Path parameters: '/users/:id' matches '/users/123'\n // - Optional parameters: '/users/:id?' matches '/users' and '/users/123'\n // - Mixed patterns: '/api/:version/users/:id/profile'\n const { pattern: regex } = parse(pattern);\n return regex.test(path);\n};\n\nexport const pathMatchesRule = (path: string, rulePath: string | RegExp | string[] | undefined): boolean => {\n if (!rulePath) return true; // No path specified means all paths\n\n if (typeof rulePath === 'string') {\n return pathMatchesPattern(path, rulePath);\n }\n\n if (rulePath instanceof RegExp) {\n return rulePath.test(path);\n }\n\n if (Array.isArray(rulePath)) {\n return rulePath.some(p => pathMatchesPattern(path, p));\n }\n\n return false;\n};\n\nexport const matchesOrIncludes = (values: string | string[], value: string): boolean => {\n if (typeof values === 'string') {\n return values === value;\n }\n\n if (Array.isArray(values)) {\n return values.includes(value);\n }\n\n return false;\n};\n\n// ── Core auth middleware ──\n// Framework-agnostic auth logic extracted from adapter middlewares.\n// Each adapter builds an AuthMiddlewareContext and delegates to coreAuthMiddleware.\n\nexport interface AuthMiddlewareContext {\n path: string;\n method: string;\n getHeader: (name: string) => string | undefined;\n mastra: Mastra;\n authConfig: MastraAuthConfig;\n customRouteAuthConfig?: Map<string, boolean>;\n requestContext: { get: (key: string) => unknown; set: (key: string, value: unknown) => void };\n rawRequest: MastraAuthRequest;\n token: string | null;\n buildAuthorizeContext: () => unknown;\n /** When true, force authentication even if the path matches a public pattern. */\n requiresAuth?: boolean;\n}\n\nexport type AuthResult =\n | { action: 'next'; headers?: Record<string, string> }\n | { action: 'error'; status: number; body: Record<string, unknown>; headers?: Record<string, string> };\n\nconst pass: AuthResult = { action: 'next' };\n\n/**\n * Lets an app's `authorize(path, method, user, context)` read `context.get('requestContext')` and\n * `context.get('mastra')` on every adapter, as it can on Hono, so per-caller values (the Knowledge scope) bind\n * the same way everywhere. Hono and NestJS contexts already answer `get`; Express, Fastify and Koa pass a web\n * Request, Elysia its own context, and adapters with no builder pass nothing.\n */\nconst withAuthorizeVariables = (\n base: unknown,\n ctx: Pick<AuthMiddlewareContext, 'mastra' | 'requestContext' | 'customRouteAuthConfig' | 'rawRequest'>,\n): unknown => {\n const variables: Record<string, unknown> = {\n mastra: ctx.mastra,\n requestContext: ctx.requestContext,\n customRouteAuthConfig: ctx.customRouteAuthConfig,\n };\n const get = (key: string) => variables[key];\n if (base === null || base === undefined) {\n return { get, req: ctx.rawRequest };\n }\n if (typeof base === 'object' && typeof (base as { get?: unknown }).get !== 'function') {\n Object.defineProperty(base, 'get', { value: get, configurable: true });\n }\n return base;\n};\n\nconst adaptToMastraAuthRequest = (request: MastraAuthRequest): MastraAuthRequest => {\n if (!(request instanceof Request)) {\n return request;\n }\n\n return {\n raw: request,\n headers: request.headers,\n header: name => request.headers.get(name) ?? undefined,\n };\n};\n\nexport interface GetAuthenticatedUserOptions {\n mastra: Mastra;\n token: string;\n request: MastraAuthRequest;\n}\n\nexport const getAuthenticatedUser = async <TUser = unknown>({\n mastra,\n token,\n request,\n}: GetAuthenticatedUserOptions): Promise<TUser | null> => {\n const normalizedToken = token.replace(/^Bearer\\s+/i, '').trim();\n if (!normalizedToken) {\n return null;\n }\n\n const authConfig = mastra.getServer()?.auth;\n if (!authConfig || typeof authConfig.authenticateToken !== 'function') {\n return null;\n }\n\n return (await authConfig.authenticateToken(normalizedToken, request)) as TUser | null;\n};\n\n/**\n * Check if an auth config object supports transparent session refresh.\n * Returns true if the auth provider implements the necessary ISessionProvider methods.\n */\nexport function supportsSessionRefresh(\n authConfig: MastraAuthConfig | IMastraAuthProvider,\n): authConfig is (MastraAuthConfig | IMastraAuthProvider) &\n Pick<ISessionProvider, 'refreshSession' | 'getSessionIdFromRequest' | 'getSessionHeaders'> {\n return (\n typeof (authConfig as any).getSessionIdFromRequest === 'function' &&\n typeof (authConfig as any).refreshSession === 'function' &&\n typeof (authConfig as any).getSessionHeaders === 'function'\n );\n}\n\n/**\n * Whether auth is bypassed for this path/method: the dev playground (only when no auth\n * provider is configured), paths that are not protected, and public paths (unless the\n * route forces auth with `requiresAuth: true`).\n */\nexport const isAuthBypassed = ({\n path,\n method,\n getHeader,\n authConfig,\n customRouteAuthConfig,\n requiresAuth,\n}: Pick<\n AuthMiddlewareContext,\n 'path' | 'method' | 'getHeader' | 'authConfig' | 'customRouteAuthConfig' | 'requiresAuth'\n>): boolean => {\n // Only bypass auth for dev playground when no real auth provider is configured.\n // When auth IS configured (has authenticateToken), we need the full auth flow\n // so user/roles/permissions are set in requestContext.\n const hasAuthProvider = typeof authConfig.authenticateToken === 'function';\n if (!hasAuthProvider && isDevPlaygroundRequest(path, method, getHeader, authConfig, customRouteAuthConfig)) {\n return true;\n }\n\n if (!isProtectedPath(path, method, authConfig, customRouteAuthConfig)) {\n return true;\n }\n\n // When a route explicitly requires auth (requiresAuth: true), skip the\n // public-path bypass so the user is still authenticated and permissions\n // are injected into the request context.\n return (\n !requiresAuth &&\n (canAccessPublicly(path, method, authConfig) || isCustomRoutePublic(path, method, customRouteAuthConfig))\n );\n};\n\n/**\n * Single auth middleware: authenticate → authorize.\n * Skip checks (dev playground, unprotected path, public path) are evaluated once.\n */\nexport const coreAuthMiddleware = async (ctx: AuthMiddlewareContext): Promise<AuthResult> => {\n const { path, method, mastra, authConfig, customRouteAuthConfig, requestContext, rawRequest, token } = ctx;\n\n // ── Skip checks (evaluated once) ──\n\n if (isAuthBypassed(ctx)) {\n return pass;\n }\n\n // ── Authentication ──\n\n let user: unknown;\n let refreshHeaders: Record<string, string> | undefined;\n const authRequest = adaptToMastraAuthRequest(rawRequest);\n\n type ConsumePendingResponseHeadersFn = (request: typeof authRequest) => Record<string, string> | undefined;\n const mergePendingProviderHeaders = (request: typeof authRequest = authRequest) => {\n const consume = (authConfig as { consumePendingResponseHeaders?: ConsumePendingResponseHeadersFn })\n .consumePendingResponseHeaders;\n if (typeof consume !== 'function') return;\n let pending: Record<string, string> | undefined;\n try {\n pending = consume.call(authConfig, request);\n } catch {\n // Forwarding a rotated cookie is best-effort; never fail auth over it.\n return;\n }\n if (!pending) return;\n refreshHeaders = { ...(refreshHeaders ?? {}), ...pending };\n };\n\n try {\n if (typeof authConfig.authenticateToken === 'function') {\n user = await authConfig.authenticateToken(token ?? '', authRequest);\n mergePendingProviderHeaders();\n } else {\n throw new Error('No token verification method configured');\n }\n\n // If authentication failed, attempt transparent session refresh before returning 401.\n // This handles expired access tokens without requiring client-side refresh logic.\n if (!user && supportsSessionRefresh(authConfig) && rawRequest instanceof Request) {\n let retryHttpError: HTTPException | undefined;\n try {\n const sessionId = authConfig.getSessionIdFromRequest(rawRequest);\n if (sessionId) {\n const newSession = await authConfig.refreshSession(sessionId);\n if (newSession) {\n // Refresh succeeded — build updated session headers and re-authenticate.\n // We create a synthetic request with the new session cookie so\n // authenticateToken (which reads cookies from the request) picks up\n // the refreshed session instead of the expired one.\n refreshHeaders = authConfig.getSessionHeaders(newSession);\n const refreshedCookie = Object.entries(refreshHeaders)\n .filter(([k]) => k.toLowerCase() === 'set-cookie')\n .map(([, v]) => v.split(';')[0]) // Extract name=value before attributes\n .join('; ');\n if (refreshedCookie) {\n const refreshedRequest = new Request(rawRequest.url, {\n method: rawRequest.method,\n headers: new Headers(rawRequest.headers),\n });\n refreshedRequest.headers.set('Cookie', refreshedCookie);\n // Pass the refreshed cookie value as the token so authenticateToken\n // picks up the new session instead of the stale original.\n // Auth providers typically read cookies from the request object, but\n // some may also inspect the token parameter directly.\n const cookieValue = refreshedCookie.includes('=')\n ? refreshedCookie.split('=').slice(1).join('=')\n : refreshedCookie;\n try {\n const retryAuthRequest = adaptToMastraAuthRequest(refreshedRequest);\n user = await authConfig.authenticateToken(cookieValue, retryAuthRequest);\n mergePendingProviderHeaders(retryAuthRequest);\n } catch (retryErr) {\n retryHttpError = retryErr instanceof HTTPException ? retryErr : undefined;\n throw retryErr;\n }\n }\n if (!user) {\n refreshHeaders = undefined;\n }\n }\n }\n } catch (refreshErr) {\n refreshHeaders = undefined;\n // An explicit HTTP error from the retried authenticateToken goes to the outer handler.\n if (retryHttpError === refreshErr) throw refreshErr;\n mastra.getLogger()?.debug('Session refresh failed, falling back to 401', {\n error: refreshErr instanceof Error ? { message: refreshErr.message } : refreshErr,\n });\n }\n }\n\n if (!user) {\n return { action: 'error', status: 401, body: { error: 'Invalid or expired token' }, headers: refreshHeaders };\n }\n\n requestContext.set(MASTRA_USER_KEY, user);\n // Backward-compat: also write the legacy `'user'` key so existing\n // middleware and integrations that read `requestContext.get('user')`\n // (including built-in FGA route enforcement, memory handlers, and the\n // documented public surface) keep working. New code should prefer\n // `MASTRA_USER_KEY` to avoid collisions with caller-supplied keys.\n requestContext.set('user', user);\n\n // Normalize the authenticated user to the stable MastraUser shape consumed\n // by DynamicArgument callbacks. Must run before mapUserToResourceId:\n // CompositeAuth's resource-id mapping consumes its authenticated-provider\n // bookkeeping while toMastraUser only peeks at it. Best-effort — a user\n // shape the default normalization can't handle leaves the key unset\n // (callbacks see `user: undefined`) instead of failing the request.\n try {\n const toMastraUser =\n 'toMastraUser' in authConfig && typeof authConfig.toMastraUser === 'function'\n ? (authConfig.toMastraUser as (user: unknown) => MastraUser)\n : normalizeMastraUser;\n const normalizedUser = toMastraUser.call(authConfig, user);\n if (normalizedUser && typeof normalizedUser.id === 'string' && normalizedUser.id.trim()) {\n requestContext.set(MASTRA_NORMALIZED_USER_KEY, normalizedUser);\n }\n } catch (normalizeError) {\n mastra\n .getLogger()\n ?.warn('Failed to normalize authenticated user to MastraUser; callbacks will see user: undefined', {\n error: normalizeError instanceof Error ? { message: normalizeError.message } : normalizeError,\n });\n }\n\n // Store the raw auth token so downstream code (e.g., editor MCP client\n // resolution) can forward it when connecting to auth-protected MCP servers.\n // The token may arrive via Authorization header, apiKey query param, or\n // cookie (SimpleAuth sets `mastra-token`). Check all sources so the\n // forwarded value is available regardless of how the user authenticated.\n let effectiveToken = token;\n if (!effectiveToken && rawRequest instanceof Request) {\n const cookieHeader = rawRequest.headers.get('cookie');\n if (cookieHeader) {\n const match = cookieHeader.match(/mastra-token=([^;]+)/);\n if (match?.[1]) effectiveToken = match[1];\n }\n }\n if (effectiveToken) {\n requestContext.set(MASTRA_AUTH_TOKEN_KEY, effectiveToken);\n }\n\n if (typeof authConfig.mapUserToResourceId === 'function') {\n try {\n const resourceId = authConfig.mapUserToResourceId(user);\n // CompositeAuth validates the authenticating provider's mapper. It can\n // return undefined when that provider never configured a mapper.\n if (resourceId !== undefined || !(authConfig instanceof CompositeAuth)) {\n if (typeof resourceId !== 'string' || !resourceId.trim()) {\n throw new Error('mapUserToResourceId must return a non-empty string for the authenticated user');\n }\n requestContext.set(MASTRA_RESOURCE_ID_KEY, resourceId);\n }\n } catch (mapError) {\n mastra.getLogger()?.error('mapUserToResourceId failed', {\n error: mapError instanceof Error ? { message: mapError.message, stack: mapError.stack } : mapError,\n });\n return {\n action: 'error',\n status: 500,\n body: { error: 'Failed to map authenticated user to a resource ID' },\n headers: refreshHeaders,\n };\n }\n }\n\n try {\n // Determine which RBAC provider to use based on auth mode\n const authMode = requestContext.get(MASTRA_AUTH_MODE_KEY);\n const serverConfig = mastra.getServer();\n const studioConfig = mastra.getStudio?.();\n // Use studio RBAC if this is a studio request, otherwise use server RBAC\n const rbacProvider = (authMode === 'studio' ? (studioConfig?.rbac ?? serverConfig?.rbac) : serverConfig?.rbac) as\n | IRBACProvider<EEUser>\n | undefined;\n\n if (rbacProvider) {\n if (!user || typeof user !== 'object' || !('id' in user)) {\n mastra.getLogger()?.warn('RBAC: authenticated user missing required \"id\" field, skipping permission loading');\n } else {\n const permissions = await rbacProvider.getPermissions(user as EEUser);\n requestContext.set(MASTRA_USER_PERMISSIONS_KEY, permissions);\n // Backward-compat alias for callers reading the legacy key.\n requestContext.set('userPermissions', permissions);\n\n const roles = await rbacProvider.getRoles(user as EEUser);\n requestContext.set(MASTRA_USER_ROLES_KEY, roles);\n // Backward-compat alias for callers reading the legacy key.\n requestContext.set('userRoles', roles);\n\n // Populate the normalized user's role from RBAC when the auth\n // provider's user carried none: primary role = first RBAC role.\n const normalizedUser = requestContext.get(MASTRA_NORMALIZED_USER_KEY) as MastraUser | undefined;\n if (normalizedUser && !normalizedUser.role && Array.isArray(roles) && typeof roles[0] === 'string') {\n requestContext.set(MASTRA_NORMALIZED_USER_KEY, { ...normalizedUser, role: roles[0] });\n }\n }\n }\n } catch (rbacError) {\n mastra.getLogger()?.error('RBAC: failed to load user permissions/roles', {\n error: rbacError instanceof Error ? { message: rbacError.message, stack: rbacError.stack } : rbacError,\n });\n }\n } catch (err) {\n mastra.getLogger()?.error('Authentication error', {\n error: err instanceof Error ? { message: err.message, stack: err.stack } : err,\n });\n // Explicit HTTP errors from auth callbacks keep their status/message; anything else is redacted.\n // The HTTPException message is sent to the client, so callers must keep it safe (no internal details).\n if (err instanceof HTTPException && err.status >= 400 && err.status <= 599) {\n return { action: 'error', status: err.status, body: { error: err.message }, headers: refreshHeaders };\n }\n return { action: 'error', status: 401, body: { error: 'Invalid or expired token' }, headers: refreshHeaders };\n }\n\n // ── Authorization ──\n\n const authorizationError = await authorizeAuthenticatedUser({\n path,\n method,\n user,\n mastra,\n authConfig,\n customRouteAuthConfig,\n requestContext,\n rawRequest,\n buildAuthorizeContext: ctx.buildAuthorizeContext,\n });\n if (authorizationError) {\n return { action: 'error', ...authorizationError, headers: refreshHeaders };\n }\n\n return refreshHeaders ? { action: 'next', headers: refreshHeaders } : pass;\n};\n\nexport interface AuthorizeAuthenticatedUserContext {\n path: string;\n method: string;\n user: unknown;\n mastra: Mastra;\n authConfig: MastraAuthConfig;\n customRouteAuthConfig?: Map<string, boolean>;\n requestContext: AuthMiddlewareContext['requestContext'];\n rawRequest: MastraAuthRequest;\n buildAuthorizeContext: () => unknown;\n}\n\n/**\n * The authorization step of server auth for an already authenticated user:\n * `authorizeUser`, `authorize(path, method, user)`, `rules`, or the RBAC default rules.\n * Returns null when the user may access `method path`.\n */\nexport const authorizeAuthenticatedUser = async (\n ctx: AuthorizeAuthenticatedUserContext,\n): Promise<{ status: number; body: Record<string, unknown> } | null> => {\n const { path, method, user, mastra, authConfig, requestContext, rawRequest } = ctx;\n const denied = { status: 403, body: { error: 'Access denied' } };\n\n if ('authorizeUser' in authConfig && typeof authConfig.authorizeUser === 'function') {\n try {\n const isAuthorized = await authConfig.authorizeUser(user, adaptToMastraAuthRequest(rawRequest));\n return isAuthorized ? null : denied;\n } catch (err) {\n mastra.getLogger()?.error('Authorization error in authorizeUser', {\n error: err instanceof Error ? { message: err.message, stack: err.stack } : err,\n });\n return { status: 500, body: { error: 'Authorization error' } };\n }\n }\n\n if ('authorize' in authConfig && typeof authConfig.authorize === 'function') {\n try {\n const authorizeCtx = withAuthorizeVariables(ctx.buildAuthorizeContext(), {\n mastra,\n requestContext,\n customRouteAuthConfig: ctx.customRouteAuthConfig,\n rawRequest,\n });\n const isAuthorized = await authConfig.authorize(path, method, user, authorizeCtx as any);\n return isAuthorized ? null : denied;\n } catch (err) {\n mastra.getLogger()?.error('Authorization error in authorize', {\n error: err instanceof Error ? { message: err.message, stack: err.stack } : err,\n path,\n method,\n });\n return { status: 500, body: { error: 'Authorization error' } };\n }\n }\n\n if ('rules' in authConfig && authConfig.rules && authConfig.rules.length > 0) {\n return (await checkRules(authConfig.rules, path, method, user)) ? null : denied;\n }\n\n // No explicit authorization configured (authorizeUser, authorize, or rules)\n // Check if RBAC is configured - if not, allow authenticated users through\n // (auth-only mode = authenticated users get full access)\n const rbacProvider =\n requestContext.get(MASTRA_AUTH_MODE_KEY) === 'studio'\n ? (mastra.getStudio?.()?.rbac ?? mastra.getServer()?.rbac)\n : mastra.getServer()?.rbac;\n if (rbacProvider) {\n if (defaultAuthConfig.rules && defaultAuthConfig.rules.length > 0) {\n return (await checkRules(defaultAuthConfig.rules, path, method, user)) ? null : denied;\n }\n return denied;\n }\n\n return null;\n};\n\n// Check authorization rules\nexport const checkRules = async (\n rules: MastraAuthConfig['rules'],\n path: string,\n method: string,\n user: unknown,\n): Promise<boolean> => {\n // Go through rules in order (first match wins)\n for (const i in rules || []) {\n const rule = rules?.[i]!;\n // Check if rule applies to this path\n if (!pathMatchesRule(path, rule.path)) {\n continue;\n }\n\n // Check if rule applies to this method\n if (rule.methods && !matchesOrIncludes(rule.methods, method)) {\n continue;\n }\n\n // Rule matches, so it decides. A failed condition denies instead of\n // falling through to a broader rule further down the list.\n const condition = rule.condition;\n if (typeof condition === 'function') {\n return await Promise.resolve()\n .then(() => condition(user))\n .then(result => !!result)\n .catch(() => false);\n }\n return !!rule.allow;\n }\n\n // No matching rules, deny by default\n return false;\n};\n"],"mappings":";;;;;;AAsBA,MAAM,uBAA+B,KAAA;AACrC,MAAM,eAAe,IAAI,QAAQ,mBAAmB;;;;;;;;AASpD,IAAa,qBAAb,MAAmE;CACjE,OAAgB,IAAI,KAAK;CACzB,kCAA2B,IAAI,IAAqB;CACpD;CAEA,YAAY,SAAuB;EACjC,KAAK,WAAW;EAEhB,KAAK,KAAK,IAAI,KAAK,cAAuB;EAC1C,QAAQ,SAAS,OAAO,UAAU;GAChC,MAAM,eAAuB,KAAA;GAC7B,KAAK,gBAAgB,IAAI,QAAQ,KAAK;GACtC,MAAM,WAAW,MAAM,KAAK,EAAE,QAAQ,KAAK,IAAI,GAAG,MAAM,gBAAgB,CAAC,EAAE,SAAS,MAAe;GACnG,IAAI,MAAM,WAAW,OACnB,KAAK,KAAK,IAAI,MAAM,MAAM,SAAS,IAAK,GAAG,SAAS,MAAM,CAAC,CAAC;QAE5D,KAAK,KAAK,GAAG,MAAM,QAAQ,MAAM,MAAM,SAAS,IAAK,GAAG,SAAS,MAAM,CAAC,CAAC;EAE7E,CAAC;CACH;;;;;;CAOA,UAAU,MAAc,QAAiD;EACvE,MAAM,QAAQ,OAAO,YAAY;EAEjC,MAAM,iBAAiB,UAAU,SAAS,QAAQ;EAClD,MAAM,SAAS,KAAK,KAAK,OAAO,MAAM,gBAAgB,IAAI;EAC1D,MAAM,WAAW,OAAO;EACxB,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KAAK;GACxC,MAAM,QAAQ,KAAK,gBAAgB,IAAI,SAAS,EAAE,CAAE,EAAE,CAAC,EAAE;GACzD,IAAI,UAAU,KAAA,GAAW;GACzB,MAAM,UAAU,IAAI,YAAY,cAAc,MAAM,MAAe;GACnE,QAAQ,aAAa;GACrB,OAAO;IAAE,OAAO,KAAK,SAAS;IAAS;IAAO,QAAQ,QAAQ,MAAM;GA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1
- {"version":3,"file":"http-exception-Co3MbFUf.cjs","names":[],"sources":["../src/server/http-exception.ts"],"sourcesContent":["// Copied from https://github.com/honojs/hono/blob/main/packages/hono/src/http-exception.ts\n\n/**\n * @module\n * This module provides the `HTTPException` class.\n */\n\ntype InfoStatusCode = 100 | 101 | 102 | 103;\ntype SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;\ntype DeprecatedStatusCode = 305 | 306;\ntype RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;\ntype ClientErrorStatusCode =\n | 400\n | 401\n | 402\n | 403\n | 404\n | 405\n | 406\n | 407\n | 408\n | 409\n | 410\n | 411\n | 412\n | 413\n | 414\n | 415\n | 416\n | 417\n | 418\n | 421\n | 422\n | 423\n | 424\n | 425\n | 426\n | 428\n | 429\n | 431\n | 451;\ntype ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;\n\n/**\n * `UnofficialStatusCode` can be used to specify an unofficial status code.\n * @example\n *\n * ```ts\n * app.get('/unknown', (c) => {\n * return c.text(\"Unknown Error\", 520 as UnofficialStatusCode)\n * })\n * ```\n */\nexport type UnofficialStatusCode = -1;\n\n/**\n * If you want to use an unofficial status, use `UnofficialStatusCode`.\n */\nexport type StatusCode =\n | InfoStatusCode\n | SuccessStatusCode\n | RedirectStatusCode\n | ClientErrorStatusCode\n | ServerErrorStatusCode\n | UnofficialStatusCode;\n\n/**\n * Options for creating an `HTTPException`.\n * @property res - Optional response object to use.\n * @property message - Optional custom error message.\n * @property cause - Optional cause of the error.\n * @property stack - Optional stack trace for the error.\n */\ntype HTTPExceptionOptions = {\n res?: Response;\n message?: string;\n cause?: unknown;\n stack?: string;\n};\n\n/**\n * `HTTPException` must be used when a fatal error such as authentication failure occurs.\n *\n * @see {@link https://hono.dev/docs/api/exception}\n *\n * @param {StatusCode} status - status code of HTTPException\n * @param {HTTPExceptionOptions} options - options of HTTPException\n * @param {HTTPExceptionOptions[\"res\"]} options.res - response of options of HTTPException\n * @param {HTTPExceptionOptions[\"message\"]} options.message - message of options of HTTPException\n * @param {HTTPExceptionOptions[\"cause\"]} options.cause - cause of options of HTTPException\n *\n * @example\n * ```ts\n * import { HTTPException } from 'hono/http-exception'\n *\n * // ...\n *\n * app.post('/auth', async (c, next) => {\n * // authentication\n * if (authorized === false) {\n * throw new HTTPException(401, { message: 'Custom error message' })\n * }\n * await next()\n * })\n * ```\n */\nexport class HTTPException extends Error {\n readonly res?: Response;\n readonly status: StatusCode;\n\n /**\n * Creates an instance of `HTTPException`.\n * @param status - HTTP status code for the exception. Defaults to 500.\n * @param options - Additional options for the exception.\n */\n constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n this.stack = options?.stack || this.stack;\n }\n\n /**\n * Returns the response object associated with the exception.\n * If a response object is not provided, a new response is created with the error message and status code.\n * @returns The response object.\n */\n getResponse(): Response {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers,\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GA,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA;;;;;;CAOA,YAAY,SAAqB,KAAK,SAAgC;EACpE,MAAM,SAAS,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;EACjD,KAAK,MAAM,SAAS;EACpB,KAAK,SAAS;EACd,KAAK,QAAQ,SAAS,SAAS,KAAK;CACtC;;;;;;CAOA,cAAwB;EACtB,IAAI,KAAK,KAKP,OAAO,IAJiB,SAAS,KAAK,IAAI,MAAM;GAC9C,QAAQ,KAAK;GACb,SAAS,KAAK,IAAI;EACpB,CACiB;EAEnB,OAAO,IAAI,SAAS,KAAK,SAAS,EAChC,QAAQ,KAAK,OACf,CAAC;CACH;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"http-exception-CzaWkxMl.js","names":[],"sources":["../src/server/http-exception.ts"],"sourcesContent":["// Copied from https://github.com/honojs/hono/blob/main/packages/hono/src/http-exception.ts\n\n/**\n * @module\n * This module provides the `HTTPException` class.\n */\n\ntype InfoStatusCode = 100 | 101 | 102 | 103;\ntype SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;\ntype DeprecatedStatusCode = 305 | 306;\ntype RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;\ntype ClientErrorStatusCode =\n | 400\n | 401\n | 402\n | 403\n | 404\n | 405\n | 406\n | 407\n | 408\n | 409\n | 410\n | 411\n | 412\n | 413\n | 414\n | 415\n | 416\n | 417\n | 418\n | 421\n | 422\n | 423\n | 424\n | 425\n | 426\n | 428\n | 429\n | 431\n | 451;\ntype ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;\n\n/**\n * `UnofficialStatusCode` can be used to specify an unofficial status code.\n * @example\n *\n * ```ts\n * app.get('/unknown', (c) => {\n * return c.text(\"Unknown Error\", 520 as UnofficialStatusCode)\n * })\n * ```\n */\nexport type UnofficialStatusCode = -1;\n\n/**\n * If you want to use an unofficial status, use `UnofficialStatusCode`.\n */\nexport type StatusCode =\n | InfoStatusCode\n | SuccessStatusCode\n | RedirectStatusCode\n | ClientErrorStatusCode\n | ServerErrorStatusCode\n | UnofficialStatusCode;\n\n/**\n * Options for creating an `HTTPException`.\n * @property res - Optional response object to use.\n * @property message - Optional custom error message.\n * @property cause - Optional cause of the error.\n * @property stack - Optional stack trace for the error.\n */\ntype HTTPExceptionOptions = {\n res?: Response;\n message?: string;\n cause?: unknown;\n stack?: string;\n};\n\n/**\n * `HTTPException` must be used when a fatal error such as authentication failure occurs.\n *\n * @see {@link https://hono.dev/docs/api/exception}\n *\n * @param {StatusCode} status - status code of HTTPException\n * @param {HTTPExceptionOptions} options - options of HTTPException\n * @param {HTTPExceptionOptions[\"res\"]} options.res - response of options of HTTPException\n * @param {HTTPExceptionOptions[\"message\"]} options.message - message of options of HTTPException\n * @param {HTTPExceptionOptions[\"cause\"]} options.cause - cause of options of HTTPException\n *\n * @example\n * ```ts\n * import { HTTPException } from 'hono/http-exception'\n *\n * // ...\n *\n * app.post('/auth', async (c, next) => {\n * // authentication\n * if (authorized === false) {\n * throw new HTTPException(401, { message: 'Custom error message' })\n * }\n * await next()\n * })\n * ```\n */\nexport class HTTPException extends Error {\n readonly res?: Response;\n readonly status: StatusCode;\n\n /**\n * Creates an instance of `HTTPException`.\n * @param status - HTTP status code for the exception. Defaults to 500.\n * @param options - Additional options for the exception.\n */\n constructor(status: StatusCode = 500, options?: HTTPExceptionOptions) {\n super(options?.message, { cause: options?.cause });\n this.res = options?.res;\n this.status = status;\n this.stack = options?.stack || this.stack;\n }\n\n /**\n * Returns the response object associated with the exception.\n * If a response object is not provided, a new response is created with the error message and status code.\n * @returns The response object.\n */\n getResponse(): Response {\n if (this.res) {\n const newResponse = new Response(this.res.body, {\n status: this.status,\n headers: this.res.headers,\n });\n return newResponse;\n }\n return new Response(this.message, {\n status: this.status,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GA,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA;;;;;;CAOA,YAAY,SAAqB,KAAK,SAAgC;EACpE,MAAM,SAAS,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;EACjD,KAAK,MAAM,SAAS;EACpB,KAAK,SAAS;EACd,KAAK,QAAQ,SAAS,SAAS,KAAK;CACtC;;;;;;CAOA,cAAwB;EACtB,IAAI,KAAK,KAKP,OAAO,IAJiB,SAAS,KAAK,IAAI,MAAM;GAC9C,QAAQ,KAAK;GACb,SAAS,KAAK,IAAI;EACpB,CACiB;EAEnB,OAAO,IAAI,SAAS,KAAK,SAAS,EAChC,QAAQ,KAAK,OACf,CAAC;CACH;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["throw new Error(`No exports are available from the top-level \"@mastra/server\" package.\n\nUse specific subpath imports instead, e.g. \"@mastra/server/handlers\" or \"@mastra/server/handlers/tools\".`);\n"],"mappings":";;AAAA,MAAM,IAAI,MAAM;;yGAEyF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["throw new Error(`No exports are available from the top-level \"@mastra/server\" package.\n\nUse specific subpath imports instead, e.g. \"@mastra/server/handlers\" or \"@mastra/server/handlers/tools\".`);\n"],"mappings":";AAAA,MAAM,IAAI,MAAM;;yGAEyF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"knowledge-DAqUHFK5.js","names":[],"sources":["../src/server/schemas/knowledge.ts","../src/server/handlers/knowledge.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\nexport const knowledgePathParams = z.object({\n knowledgeKey: z.string().describe('Application key the Knowledge instance is registered under'),\n});\n\nexport const knowledgePagePathParams = knowledgePathParams.extend({\n pageId: z.string().min(1).max(512).describe('Knowledge page id'),\n});\n\nconst pageId = z.string().min(1).max(512);\nconst limit = z.coerce.number().int().min(1).max(100).optional();\n\nexport const knowledgeTreeQuerySchema = z.object({\n parentId: pageId.optional().describe('Page whose children to list; omit for the root scopes'),\n cursor: z.string().optional(),\n limit,\n});\n\nexport const knowledgePageQuerySchema = z.object({\n noteCursor: z.string().optional(),\n noteLimit: limit,\n});\n\nexport const knowledgeGraphQuerySchema = z.object({\n rootId: pageId.optional().describe('Page to walk from; omit to walk every root scope'),\n maxPages: z.coerce.number().int().min(1).max(500).optional(),\n});\n\n// A repeated param (`?scopeId=a&scopeId=b`) arrives as an array, a lone one as a string.\nconst scopeIds = z\n .union([z.string(), z.array(z.string())])\n .transform(value => (Array.isArray(value) ? value : [value]))\n .pipe(z.array(pageId).max(20));\n\nexport const knowledgeSearchQuerySchema = z.object({\n q: z.string().min(1).max(200).describe('Text to match in page names, synopses, bodies and notes'),\n scopeId: scopeIds.optional().describe('Only pages within these scopes'),\n limit,\n});\n\nconst pageIds = z\n .union([z.string(), z.array(z.string())])\n .transform(value => (Array.isArray(value) ? value : [value]))\n .pipe(z.array(pageId).min(1).max(200));\n\nexport const knowledgeLinkCountsQuerySchema = z.object({\n pageId: pageIds.describe('Pages to count links for; repeat the param for each, at most 200'),\n});\n\nexport const knowledgePageLinksQuerySchema = z.object({\n direction: z.enum(['in', 'out', 'both']).optional().describe('Links into the page, out of it, or both (default)'),\n});\n\nexport const knowledgeActivityQuerySchema = z.object({\n scopeId: pageId.optional(),\n pageId: pageId.optional(),\n cursor: z.string().optional(),\n limit,\n});\n\n// Payloads come from the @mastra/core/knowledge page readers; the UI package owns their TypeScript shapes.\nconst payload = z.record(z.string(), z.unknown());\n\nexport const listKnowledgeResponseSchema = z.object({\n instances: z.array(z.object({ key: z.string(), id: z.string() })),\n});\nexport const knowledgeTreeResponseSchema = payload;\nexport const knowledgePageResponseSchema = payload;\nexport const knowledgeGraphResponseSchema = payload;\nexport const knowledgeSearchResponseSchema = z.object({ results: z.array(payload) });\nexport const knowledgeLinkCountsResponseSchema = z.object({\n counts: z.record(z.string(), z.object({ in: z.number(), out: z.number() })),\n});\nexport const knowledgePageLinksResponseSchema = z.object({\n edges: z.array(\n z.object({ fromPageId: z.string(), toPageId: z.string(), kind: z.enum(['body', 'note']), count: z.number() }),\n ),\n pages: z.array(payload),\n truncated: z.boolean(),\n});\nexport const knowledgeActivityResponseSchema = payload;\nexport const knowledgeEventsResponseSchema = z.object({\n kind: z.enum(['scope', 'page', 'note', 'pin']),\n op: z.string(),\n pageId: z.string().optional(),\n scopeId: z.string().optional(),\n at: z.string(),\n});\n","import * as coreKnowledge from '@mastra/core/knowledge';\nimport type { Knowledge, KnowledgeChangeEvent } from '@mastra/core/knowledge';\nimport type { Mastra } from '@mastra/core/mastra';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport type { KnowledgeReadScope, KnowledgeStorage } from '@mastra/core/storage';\nimport { MASTRA_KNOWLEDGE_PRINCIPALS_KEY } from '../constants';\nimport { MastraFGAPermissions } from '../fga-permissions';\nimport { HTTPException } from '../http-exception';\nimport {\n knowledgeActivityQuerySchema,\n knowledgeActivityResponseSchema,\n knowledgeEventsResponseSchema,\n knowledgeGraphQuerySchema,\n knowledgeGraphResponseSchema,\n knowledgePagePathParams,\n knowledgePageQuerySchema,\n knowledgePageResponseSchema,\n knowledgePathParams,\n knowledgeSearchQuerySchema,\n knowledgeSearchResponseSchema,\n knowledgeLinkCountsQuerySchema,\n knowledgeLinkCountsResponseSchema,\n knowledgePageLinksQuerySchema,\n knowledgePageLinksResponseSchema,\n knowledgeTreeQuerySchema,\n knowledgeTreeResponseSchema,\n listKnowledgeResponseSchema,\n} from '../schemas/knowledge';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { handleError } from './error';\nimport { getHandlerFGAProvider } from './utils';\n\n/**\n * Read-only browsing of Knowledge instances registered on Mastra, for Studio. Nothing here writes.\n *\n * What a caller reads depends on whether the app has auth configured (`server.auth` or `studio.auth`):\n * - No auth: probably a local or test project, so the routes read as the instance owner (`'all'`).\n * - Auth: reads are narrowed to what the signed-in caller can read. The app maps the user to Knowledge\n * principals by setting MASTRA_KNOWLEDGE_PRINCIPALS_KEY in `auth.authorize` (a `string[]`, or `'all'`\n * for an admin); the instance turns them into a read scope with `readScopeFor`. A caller with no\n * mapping is refused with 403.\n *\n * On top of that the path derives `knowledge:read` (`GET /knowledge/...`), and with FGA configured each\n * instance is filtered and gated by `knowledge:read` on that instance. The routes are opt-in\n * (KNOWLEDGE_ROUTES); hosts with their own scoping (Factory) do not mount them.\n */\n\nfunction hasAuth(mastra: Mastra): boolean {\n return Boolean(mastra.getServer?.()?.auth || (mastra as any).getStudio?.()?.auth);\n}\n\nasync function callerReadScope(\n mastra: Mastra,\n requestContext: RequestContext | undefined,\n instance: Knowledge,\n): Promise<KnowledgeReadScope> {\n if (!hasAuth(mastra)) return 'all';\n\n const principals = requestContext?.get(MASTRA_KNOWLEDGE_PRINCIPALS_KEY);\n if (principals === undefined || principals === null) {\n throw new HTTPException(403, {\n message: `Knowledge access is not mapped for this caller. Set request context key \"${MASTRA_KNOWLEDGE_PRINCIPALS_KEY}\" in auth.authorize.`,\n });\n }\n if (principals === 'all') return 'all';\n // The value comes from the app's own authorize code, so a bad one is a host misconfiguration, not a denial.\n if (!Array.isArray(principals) || principals.some(principal => typeof principal !== 'string')) {\n throw new HTTPException(500, {\n message: `Request context key \"${MASTRA_KNOWLEDGE_PRINCIPALS_KEY}\" must be a string array or 'all'.`,\n });\n }\n try {\n return await instance.readScopeFor(principals);\n } catch (error) {\n // A principal that matches no declared scope type: the app's mapping disagrees with its declarations.\n if (error instanceof Error && error.name === 'KnowledgeDeclarationError') {\n throw new HTTPException(500, { message: error.message, cause: error });\n }\n throw error;\n }\n}\n\nasync function accessibleInstances(\n mastra: Mastra,\n requestContext: RequestContext | undefined,\n entries: Array<{ id: string; key: string }>,\n): Promise<Set<string>> {\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n if (!fgaProvider || !user || typeof user !== 'object' || entries.length === 0) {\n return new Set(entries.map(entry => entry.key));\n }\n // FGA names a Knowledge instance by its registered key, as the route metadata does (`:knowledgeKey`).\n const accessible: Array<{ id: string; key: string }> = await fgaProvider.filterAccessible(\n user,\n entries.map(entry => ({ ...entry, id: entry.key })),\n 'knowledge',\n MastraFGAPermissions.KNOWLEDGE_READ,\n );\n return new Set(accessible.map(entry => entry.key));\n}\n\ntype KnowledgePageReaders = Pick<\n typeof coreKnowledge,\n | 'listKnowledgeTreeChildren'\n | 'readKnowledgePage'\n | 'readKnowledgePageActivity'\n | 'readKnowledgePageGraph'\n | 'searchKnowledgeExplorerPages'\n>;\n\n// The page readers first ship in @mastra/core 1.81.0, above this package's peer floor. A named import\n// of an export an older core lacks fails at ESM link time and takes the whole server down, so they are\n// read off the namespace (as in schedules-workflows-shim.ts) and the routes answer 501 without them.\nconst pageReaders: Partial<KnowledgePageReaders> = coreKnowledge;\n\nfunction requirePageReaders(): KnowledgePageReaders {\n const {\n listKnowledgeTreeChildren,\n readKnowledgePage,\n readKnowledgePageActivity,\n readKnowledgePageGraph,\n searchKnowledgeExplorerPages,\n } = pageReaders;\n if (\n !listKnowledgeTreeChildren ||\n !readKnowledgePage ||\n !readKnowledgePageActivity ||\n !readKnowledgePageGraph ||\n !searchKnowledgeExplorerPages\n ) {\n throw new HTTPException(501, { message: 'Knowledge browsing needs @mastra/core 1.81.0 or later.' });\n }\n return {\n listKnowledgeTreeChildren,\n readKnowledgePage,\n readKnowledgePageActivity,\n readKnowledgePageGraph,\n searchKnowledgeExplorerPages,\n };\n}\n\n/**\n * The declared grants between the graph's scopes, each with its principal's display label. Grants are\n * newer than the page readers, so a core without them sends none and the graph still loads.\n */\nasync function graphGrants(\n instance: Knowledge,\n store: KnowledgeStorage,\n pages: readonly coreKnowledge.KnowledgePage[],\n read: KnowledgeReadScope,\n): Promise<Array<coreKnowledge.KnowledgeGraphScopeGrant & { principalLabel?: string }> | undefined> {\n const readGrants = (coreKnowledge as Partial<typeof coreKnowledge>).readKnowledgeScopeGrants;\n const scopeGrants = (instance as Partial<Knowledge>).scopeGrants?.bind(instance);\n if (!readGrants || !scopeGrants) return undefined;\n const grants = await readGrants(store, { pages, read, grantsFor: scopeGrants });\n return grants.map(grant => {\n const principalLabel = instance.scopeLabel?.(grant.principal);\n return principalLabel ? { ...grant, principalLabel } : grant;\n });\n}\n\nasync function resolveStore(\n mastra: Mastra,\n requestContext: RequestContext | undefined,\n knowledgeKey: string | undefined,\n): Promise<{ instance: Knowledge; store: KnowledgeStorage; read: KnowledgeReadScope; readers: KnowledgePageReaders }> {\n const instances = mastra.listKnowledge();\n // Own keys only: `constructor` or `__proto__` must not resolve to an Object.prototype member.\n const instance = knowledgeKey && Object.hasOwn(instances, knowledgeKey) ? instances[knowledgeKey] : undefined;\n if (!knowledgeKey || !instance)\n throw new HTTPException(404, { message: `Knowledge ${knowledgeKey ?? ''} not found` });\n\n // An instance the caller may not read looks the same as one that does not exist.\n const fgaProvider = getHandlerFGAProvider(mastra, requestContext);\n const user = requestContext?.get('user');\n if (fgaProvider && user && typeof user === 'object') {\n const allowed = await fgaProvider.check(user, {\n resource: { type: 'knowledge', id: knowledgeKey },\n permission: MastraFGAPermissions.KNOWLEDGE_READ,\n });\n if (!allowed) throw new HTTPException(404, { message: `Knowledge ${knowledgeKey} not found` });\n }\n const readers = requirePageReaders();\n const read = await callerReadScope(mastra, requestContext, instance);\n return { instance, store: await instance.getStorage(), read, readers };\n}\n\n/**\n * Adds each scope page's declared `displayLabel` with its address's `$params` filled in (`'$orgId policy'`\n * → `'acme policy'`), so the explorer can caption scopes. Scope declarations live in config, not\n * storage, so the readers can't supply it. Older cores without `scopeLabel` send no label.\n */\nfunction withDisplayLabel<T extends { isScope: boolean; address?: string }>(\n instance: Knowledge,\n page: T,\n): T & { displayLabel?: string } {\n if (!page.isScope || !page.address) return page;\n const displayLabel = instance.scopeLabel?.(page.address);\n return displayLabel ? { ...page, displayLabel } : page;\n}\n\nexport const LIST_KNOWLEDGE_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge',\n responseType: 'json',\n responseSchema: listKnowledgeResponseSchema,\n summary: 'List Knowledge instances',\n description:\n \"Returns the Knowledge instances registered on this Mastra instance, by application key. Without app auth the other Knowledge routes read the whole instance; with auth they read only what the caller's Knowledge principals (MASTRA_KNOWLEDGE_PRINCIPALS_KEY, set in auth.authorize) can read, and refuse an unmapped caller with 403.\",\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext }) => {\n try {\n const all = Object.entries(mastra.listKnowledge()).map(([key, instance]) => ({ key, id: instance.id }));\n const allowed = await accessibleInstances(mastra, requestContext, all);\n return { instances: all.filter(entry => allowed.has(entry.key)) };\n } catch (error) {\n return handleError(error, 'Error listing Knowledge instances');\n }\n },\n});\n\nexport const GET_KNOWLEDGE_TREE_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/tree',\n responseType: 'json',\n pathParamSchema: knowledgePathParams,\n queryParamSchema: knowledgeTreeQuerySchema,\n responseSchema: knowledgeTreeResponseSchema,\n summary: 'List one level of the Knowledge page tree',\n description:\n 'Without parentId, returns the root scopes. With parentId, returns its child scopes (first page only) then its child pages in order, paged with cursor.',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, parentId, cursor, limit }) => {\n try {\n const { instance, store, read, readers } = await resolveStore(mastra, requestContext, knowledgeKey);\n const level = await readers.listKnowledgeTreeChildren(store, {\n parentId: parentId ?? null,\n read,\n // An empty `?cursor=` means no cursor, so root scopes are still listed.\n cursor: cursor || undefined,\n limit,\n });\n return { ...level, pages: level.pages.map(page => withDisplayLabel(instance, page)) };\n } catch (error) {\n return handleError(error, 'Error reading Knowledge tree');\n }\n },\n});\n\nexport const GET_KNOWLEDGE_PAGE_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/pages/:pageId',\n responseType: 'json',\n pathParamSchema: knowledgePagePathParams,\n queryParamSchema: knowledgePageQuerySchema,\n responseSchema: knowledgePageResponseSchema,\n summary: 'Get a Knowledge page',\n description:\n 'Returns one page with its ancestors, a page of its notes, its pin, the pages its notes reference and notes elsewhere that mention it; 404 when it does not exist',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, pageId, noteCursor, noteLimit }) => {\n try {\n const { instance, store, read, readers } = await resolveStore(mastra, requestContext, knowledgeKey);\n const view = await readers.readKnowledgePage(store, { pageId, read, noteCursor, noteLimit });\n if (!view) throw new HTTPException(404, { message: 'Knowledge page not found' });\n const label = <T extends { isScope: boolean; declaration?: string }>(page: T) => withDisplayLabel(instance, page);\n return {\n ...view,\n page: label(view.page),\n ancestors: view.ancestors.map(label),\n related: view.related.map(label),\n };\n } catch (error) {\n return handleError(error, 'Error reading Knowledge page');\n }\n },\n});\n\n/**\n * The link readers are newer than the page readers, so a core without them answers these routes with 501\n * and the explorer falls back to counting the pages it has loaded.\n */\nfunction requireLinkReaders() {\n const { readKnowledgePageLinkCounts, readKnowledgePageLinks } = coreKnowledge as Partial<typeof coreKnowledge>;\n if (!readKnowledgePageLinkCounts || !readKnowledgePageLinks) {\n throw new HTTPException(501, { message: 'Knowledge link counts need a newer @mastra/core.' });\n }\n return { readKnowledgePageLinkCounts, readKnowledgePageLinks };\n}\n\nexport const GET_KNOWLEDGE_LINK_COUNTS_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/link-counts',\n responseType: 'json',\n pathParamSchema: knowledgePathParams,\n queryParamSchema: knowledgeLinkCountsQuerySchema,\n responseSchema: knowledgeLinkCountsResponseSchema,\n summary: 'Count the links into and out of pages',\n description:\n 'Returns, for each page id, how many distinct other pages link to it and it links to, by body [[ref]] or note mention, counted over the whole store and not only pages the caller has loaded. A page the caller cannot read counts as no links, the same as one that does not exist. 501 when the store has no link index.',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, pageId }) => {\n try {\n const { store, read } = await resolveStore(mastra, requestContext, knowledgeKey);\n const counts = await requireLinkReaders().readKnowledgePageLinkCounts(store, { pageIds: pageId, read });\n if (!counts) throw new HTTPException(501, { message: 'This Knowledge store has no link index.' });\n return { counts };\n } catch (error) {\n return handleError(error, 'Error counting Knowledge page links');\n }\n },\n});\n\nexport const GET_KNOWLEDGE_PAGE_LINKS_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/pages/:pageId/links',\n responseType: 'json',\n pathParamSchema: knowledgePagePathParams,\n queryParamSchema: knowledgePageLinksQuerySchema,\n responseSchema: knowledgePageLinksResponseSchema,\n summary: \"List a Knowledge page's links\",\n description:\n 'Returns the links into and out of one page, bounded, with the readable pages at their other ends. A page the caller cannot read has none. 501 when the store has no link index.',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, pageId, direction }) => {\n try {\n const { instance, store, read } = await resolveStore(mastra, requestContext, knowledgeKey);\n const links = await requireLinkReaders().readKnowledgePageLinks(store, { pageId, read, direction });\n if (!links) throw new HTTPException(501, { message: 'This Knowledge store has no link index.' });\n return { ...links, pages: links.pages.map(page => ({ ...withDisplayLabel(instance, page) })) };\n } catch (error) {\n return handleError(error, 'Error reading Knowledge page links');\n }\n },\n});\n\nexport const GET_KNOWLEDGE_GRAPH_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/graph',\n responseType: 'json',\n pathParamSchema: knowledgePathParams,\n queryParamSchema: knowledgeGraphQuerySchema,\n responseSchema: knowledgeGraphResponseSchema,\n summary: 'Get a bounded Knowledge page graph',\n description:\n 'Returns pages under rootId (or every root scope) breadth-first with parent and mention edges, bounded; truncated is true when a limit stopped it. grants lists the declared access grants onto the scopes shown, from principal scopes the caller can read. 404 when rootId does not exist.',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, rootId, maxPages }) => {\n try {\n const { instance, store, read, readers } = await resolveStore(mastra, requestContext, knowledgeKey);\n const graph = await readers.readKnowledgePageGraph(store, {\n read,\n rootId: rootId ?? null,\n ...(maxPages ? { limits: { maxPages } } : {}),\n });\n if (!graph) throw new HTTPException(404, { message: 'Knowledge page not found' });\n const grants = await graphGrants(instance, store, graph.pages, read);\n return {\n ...graph,\n pages: graph.pages.map(page => withDisplayLabel(instance, page)),\n ...(grants ? { grants } : {}),\n };\n } catch (error) {\n return handleError(error, 'Error reading Knowledge graph');\n }\n },\n});\n\nexport const SEARCH_KNOWLEDGE_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/search',\n responseType: 'json',\n pathParamSchema: knowledgePathParams,\n queryParamSchema: knowledgeSearchQuerySchema,\n responseSchema: knowledgeSearchResponseSchema,\n summary: 'Search Knowledge pages and notes',\n description: 'Returns pages whose name, synopsis or body, and notes whose text, match the query',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, q, scopeId, limit }) => {\n try {\n const { instance, store, read, readers } = await resolveStore(mastra, requestContext, knowledgeKey);\n const results = await readers.searchKnowledgeExplorerPages(store, {\n query: q,\n read,\n ...(scopeId?.length ? { scopeIds: scopeId } : {}),\n limit,\n });\n return { results: results.map(hit => ({ ...hit, page: withDisplayLabel(instance, hit.page) })) };\n } catch (error) {\n return handleError(error, 'Error searching Knowledge');\n }\n },\n});\n\nexport const GET_KNOWLEDGE_ACTIVITY_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/activity',\n responseType: 'json',\n pathParamSchema: knowledgePathParams,\n queryParamSchema: knowledgeActivityQuerySchema,\n responseSchema: knowledgeActivityResponseSchema,\n summary: 'List recent Knowledge activity',\n description: 'Returns a newest-first page of activity, optionally for one scope or one page',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, scopeId, pageId, cursor, limit }) => {\n try {\n const { store, read, readers } = await resolveStore(mastra, requestContext, knowledgeKey);\n return { ...(await readers.readKnowledgePageActivity(store, { read, scopeId, pageId, cursor, limit })) };\n } catch (error) {\n return handleError(error, 'Error reading Knowledge activity');\n }\n },\n});\n\nconst KEEPALIVE_MS = 25_000;\n/**\n * The read scope is resolved when the stream opens. Ending it after this long makes the client reconnect,\n * which resolves the caller's read scope again, so a revoked grant stops receiving changes.\n */\nconst STREAM_MAX_AGE_MS = 5 * 60_000;\n\n/**\n * What a viewer may learn about one change: the ids in it they can read, or nothing when they can read\n * none. A page they can read now, or the scope it is (or was, before a move or merge) in, counts; a\n * deleted page is matched by its scope.\n */\nasync function visibleChange(store: KnowledgeStorage, read: KnowledgeReadScope, event: KnowledgeChangeEvent) {\n const readable = async (id: string | undefined) =>\n id !== undefined && (read === 'all' || (await store.getPage({ id, read })) !== null);\n const scopeId = 'scopeId' in event ? event.scopeId : undefined;\n const fromScopeId = 'fromScopeId' in event ? event.fromScopeId : undefined;\n const [page, scope, fromScope] = await Promise.all([\n readable(event.pageId),\n readable(scopeId),\n readable(fromScopeId),\n ]);\n if (!page && !scope && !fromScope) return null;\n return {\n kind: event.kind,\n op: event.op,\n ...(page ? { pageId: event.pageId } : {}),\n ...(scope ? { scopeId } : {}),\n at: event.at.toISOString(),\n };\n}\n\nexport const STREAM_KNOWLEDGE_EVENTS_ROUTE = createRoute({\n method: 'GET',\n path: '/knowledge/:knowledgeKey/events',\n responseType: 'stream',\n streamFormat: 'sse',\n sseFlushOnConnect: true,\n pathParamSchema: knowledgePathParams,\n responseSchema: knowledgeEventsResponseSchema,\n summary: 'Stream Knowledge changes',\n description:\n 'Server-Sent Events, one per committed write the caller can read: { kind, op, pageId?, scopeId?, at }. Ids the caller cannot read are left out, and changes they cannot read at all are not sent. Re-read what changed with the other Knowledge routes.',\n tags: ['Knowledge'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, knowledgeKey, abortSignal }) => {\n try {\n const { instance, store, read } = await resolveStore(mastra, requestContext, knowledgeKey);\n if (typeof instance.onChange !== 'function') {\n throw new HTTPException(501, { message: 'Knowledge change events need @mastra/core 1.81.0 or later.' });\n }\n const logger = mastra.getLogger();\n let stop = () => {};\n return new ReadableStream({\n start(controller) {\n let open = true;\n // Writes are filtered in order so a viewer never sees a later change before an earlier one.\n let queue = Promise.resolve();\n const unsubscribe = instance.onChange(event => {\n queue = queue.then(async () => {\n const change = await visibleChange(store, read, event).catch(error => {\n logger?.error('Error filtering a Knowledge change', { error });\n return null;\n });\n if (open && change) controller.enqueue(change);\n });\n });\n const keepalive = setInterval(() => open && controller.enqueue(': keepalive\\n\\n'), KEEPALIVE_MS);\n const expire = setTimeout(() => stop(), STREAM_MAX_AGE_MS);\n stop = () => {\n if (!open) return;\n open = false;\n clearInterval(keepalive);\n clearTimeout(expire);\n unsubscribe();\n try {\n controller.close();\n } catch {\n // Already closed\n }\n };\n if (abortSignal?.aborted) stop();\n else abortSignal?.addEventListener('abort', stop, { once: true });\n },\n cancel() {\n stop();\n },\n });\n } catch (error) {\n return handleError(error, 'Error streaming Knowledge changes');\n }\n },\n});\n"],"mappings":";;;;;;;;AAEA,MAAa,sBAAsB,EAAE,OAAO,EAC1C,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS,4DAA4D,EAChG,CAAC;AAED,MAAa,0BAA0B,oBAAoB,OAAO,EAChE,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS,mBAAmB,EACjE,CAAC;AAED,MAAM,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;AACxC,MAAM,QAAQ,EAAE,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS;AAE/D,MAAa,2BAA2B,EAAE,OAAO;CAC/C,UAAU,OAAO,SAAS,CAAC,CAAC,SAAS,uDAAuD;CAC5F,QAAQ,EAAE,OAAO,CAAC,CAAC,SAAS;CAC5B;AACF,CAAC;AAED,MAAa,2BAA2B,EAAE,OAAO;CAC/C,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;CAChC,WAAW;AACb,CAAC;AAED,MAAa,4BAA4B,EAAE,OAAO;CAChD,QAAQ,OAAO,SAAS,CAAC,CAAC,SAAS,kDAAkD;CACrF,UAAU,EAAE,OAAO,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS;AAC7D,CAAC;AAGD,MAAM,WAAW,EACd,MAAM,CAAC,EAAE,OAAO,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC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