@mastra/server 0.0.0-type-testing-20260120105120 → 0.0.0-unified-workspace-snapshot-20260128233410

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 (328) hide show
  1. package/CHANGELOG.md +302 -3
  2. package/a2a/store.d.ts +1 -0
  3. package/auth.d.ts +1 -0
  4. package/dist/{chunk-3REGEJEN.js → chunk-24SISJRB.js} +6 -6
  5. package/dist/chunk-24SISJRB.js.map +1 -0
  6. package/dist/chunk-2ZLYWOYM.cjs +623 -0
  7. package/dist/chunk-2ZLYWOYM.cjs.map +1 -0
  8. package/dist/{chunk-TMS4LS2J.js → chunk-4G5R2KZI.js} +26 -16
  9. package/dist/chunk-4G5R2KZI.js.map +1 -0
  10. package/dist/{chunk-T4SPG2GP.cjs → chunk-4HFYR562.cjs} +4 -4
  11. package/dist/chunk-4HFYR562.cjs.map +1 -0
  12. package/dist/{chunk-AVRO3FIN.cjs → chunk-4LVJBXI2.cjs} +97 -4
  13. package/dist/chunk-4LVJBXI2.cjs.map +1 -0
  14. package/dist/{chunk-HCVDHEDD.cjs → chunk-5GXOE6RS.cjs} +187 -165
  15. package/dist/chunk-5GXOE6RS.cjs.map +1 -0
  16. package/dist/{chunk-AV3CN5ZR.cjs → chunk-5HVOCRC4.cjs} +34 -16
  17. package/dist/chunk-5HVOCRC4.cjs.map +1 -0
  18. package/dist/{chunk-UK4FZWNW.cjs → chunk-5VXFAF6R.cjs} +48 -41
  19. package/dist/chunk-5VXFAF6R.cjs.map +1 -0
  20. package/dist/{chunk-PNZQCQY4.cjs → chunk-6G2RQWKA.cjs} +15 -15
  21. package/dist/chunk-6G2RQWKA.cjs.map +1 -0
  22. package/dist/{chunk-4EYONQIW.cjs → chunk-7D3UAMQM.cjs} +4 -4
  23. package/dist/chunk-7D3UAMQM.cjs.map +1 -0
  24. package/dist/{chunk-CGIGPJRU.js → chunk-7XHQEMU2.js} +37 -70
  25. package/dist/chunk-7XHQEMU2.js.map +1 -0
  26. package/dist/chunk-AAHPYUEC.cjs +211 -0
  27. package/dist/chunk-AAHPYUEC.cjs.map +1 -0
  28. package/dist/{chunk-2CYGIE3E.js → chunk-AOU2LXZK.js} +197 -82
  29. package/dist/chunk-AOU2LXZK.js.map +1 -0
  30. package/dist/{chunk-WLGJVDH4.js → chunk-BB46GZPA.js} +6 -3
  31. package/dist/chunk-BB46GZPA.js.map +1 -0
  32. package/dist/{chunk-I27H7BEB.js → chunk-CW327NIR.js} +9 -6
  33. package/dist/chunk-CW327NIR.js.map +1 -0
  34. package/dist/{chunk-7S7ALPCY.js → chunk-D5VCL56B.js} +97 -5
  35. package/dist/chunk-D5VCL56B.js.map +1 -0
  36. package/dist/{chunk-GNCALVLC.js → chunk-DEG24CE7.js} +22 -3
  37. package/dist/chunk-DEG24CE7.js.map +1 -0
  38. package/dist/{chunk-H34VRYSF.js → chunk-DH5UZ4DD.js} +22 -15
  39. package/dist/chunk-DH5UZ4DD.js.map +1 -0
  40. package/dist/{chunk-6MP2S6VI.cjs → chunk-EJCBKZET.cjs} +48 -40
  41. package/dist/chunk-EJCBKZET.cjs.map +1 -0
  42. package/dist/{chunk-33CKPQS4.cjs → chunk-ERXWG5L2.cjs} +22 -2
  43. package/dist/chunk-ERXWG5L2.cjs.map +1 -0
  44. package/dist/{chunk-7XPMKW4Y.cjs → chunk-ETCMV326.cjs} +12 -9
  45. package/dist/chunk-ETCMV326.cjs.map +1 -0
  46. package/dist/chunk-ETVLWGEB.js +596 -0
  47. package/dist/chunk-ETVLWGEB.js.map +1 -0
  48. package/dist/{chunk-5VDI75UV.js → chunk-EV5H2JQU.js} +5 -4
  49. package/dist/chunk-EV5H2JQU.js.map +1 -0
  50. package/dist/{chunk-XB27LCKO.js → chunk-FA66XJZJ.js} +15 -9
  51. package/dist/chunk-FA66XJZJ.js.map +1 -0
  52. package/dist/{chunk-FWSKVWS7.cjs → chunk-FRRHYZR6.cjs} +4 -4
  53. package/dist/chunk-FRRHYZR6.cjs.map +1 -0
  54. package/dist/{chunk-GHQZIEPS.js → chunk-G34VLTQC.js} +74 -52
  55. package/dist/{chunk-HCVDHEDD.cjs.map → chunk-G34VLTQC.js.map} +1 -1
  56. package/dist/{chunk-ZQ2G6QKS.cjs → chunk-H2FLPRXD.cjs} +175 -97
  57. package/dist/chunk-H2FLPRXD.cjs.map +1 -0
  58. package/dist/chunk-H66LLFDL.js +1 -1
  59. package/dist/chunk-H66LLFDL.js.map +1 -1
  60. package/dist/{chunk-XCEQ4GQW.cjs → chunk-H6UO5RMT.cjs} +53 -90
  61. package/dist/chunk-H6UO5RMT.cjs.map +1 -0
  62. package/dist/{chunk-QPFYN6B5.cjs → chunk-HDGF45K7.cjs} +17 -14
  63. package/dist/chunk-HDGF45K7.cjs.map +1 -0
  64. package/dist/{chunk-P3H4AZKI.cjs → chunk-HZINLMHL.cjs} +15 -15
  65. package/dist/chunk-HZINLMHL.cjs.map +1 -0
  66. package/dist/{chunk-IVGQTL3T.js → chunk-I4MLE3R3.js} +31 -23
  67. package/dist/chunk-I4MLE3R3.js.map +1 -0
  68. package/dist/{chunk-WJ6DNHLW.cjs → chunk-I7CFYVAL.cjs} +34 -24
  69. package/dist/chunk-I7CFYVAL.cjs.map +1 -0
  70. package/dist/{chunk-DVSCJECS.js → chunk-IS3HHGL4.js} +6 -6
  71. package/dist/chunk-IS3HHGL4.js.map +1 -0
  72. package/dist/chunk-JHSXUNQV.cjs +703 -0
  73. package/dist/chunk-JHSXUNQV.cjs.map +1 -0
  74. package/dist/{chunk-XOUK3IYU.js → chunk-K4HSW5ZF.js} +4 -4
  75. package/dist/chunk-K4HSW5ZF.js.map +1 -0
  76. package/dist/{chunk-YN3FWKVQ.js → chunk-KADBYP7R.js} +6 -4
  77. package/dist/chunk-KADBYP7R.js.map +1 -0
  78. package/dist/chunk-LFTVDHOD.js +200 -0
  79. package/dist/chunk-LFTVDHOD.js.map +1 -0
  80. package/dist/{chunk-G2AMUTU4.js → chunk-OS7SAIRA.js} +6 -6
  81. package/dist/chunk-OS7SAIRA.js.map +1 -0
  82. package/dist/{chunk-YK63KHHB.cjs → chunk-OZGT6GOC.cjs} +507 -161
  83. package/dist/chunk-OZGT6GOC.cjs.map +1 -0
  84. package/dist/{chunk-4R2Z655M.js → chunk-P7IT44NU.js} +145 -67
  85. package/dist/chunk-P7IT44NU.js.map +1 -0
  86. package/dist/{chunk-L2E5RUVT.cjs → chunk-PWXUI3OG.cjs} +15 -15
  87. package/dist/chunk-PWXUI3OG.cjs.map +1 -0
  88. package/dist/chunk-QXDNFBJQ.js +220 -0
  89. package/dist/chunk-QXDNFBJQ.js.map +1 -0
  90. package/dist/{chunk-EUBTCHQC.js → chunk-RIX6WEJ2.js} +4 -4
  91. package/dist/chunk-RIX6WEJ2.js.map +1 -0
  92. package/dist/{chunk-CLAEGIP5.cjs → chunk-RSSBE2Q6.cjs} +10 -8
  93. package/dist/chunk-RSSBE2Q6.cjs.map +1 -0
  94. package/dist/chunk-S4SLHUJ7.cjs +253 -0
  95. package/dist/chunk-S4SLHUJ7.cjs.map +1 -0
  96. package/dist/{chunk-KKY4MSZO.js → chunk-SG3SQGMV.js} +28 -10
  97. package/dist/chunk-SG3SQGMV.js.map +1 -0
  98. package/dist/{chunk-N4EIZSG2.js → chunk-SRQBCSNC.js} +15 -11
  99. package/dist/chunk-SRQBCSNC.js.map +1 -0
  100. package/dist/{chunk-FLLJIPD4.cjs → chunk-T5KH32UA.cjs} +6 -5
  101. package/dist/chunk-T5KH32UA.cjs.map +1 -0
  102. package/dist/{chunk-3FEYUHHJ.js → chunk-TCWPL26W.js} +10 -7
  103. package/dist/chunk-TCWPL26W.js.map +1 -0
  104. package/dist/{chunk-2CLS2PYJ.js → chunk-UNWXKDYP.js} +398 -55
  105. package/dist/chunk-UNWXKDYP.js.map +1 -0
  106. package/dist/chunk-USR6JK77.js +62 -0
  107. package/dist/chunk-USR6JK77.js.map +1 -0
  108. package/dist/{chunk-BRI4GUZ2.cjs → chunk-VL4AR6TK.cjs} +6 -2
  109. package/dist/chunk-VL4AR6TK.cjs.map +1 -0
  110. package/dist/chunk-VX3VN7FN.cjs +1 -1
  111. package/dist/chunk-VX3VN7FN.cjs.map +1 -1
  112. package/dist/{chunk-4DJ7EJRB.cjs → chunk-W6H577VU.cjs} +25 -21
  113. package/dist/chunk-W6H577VU.cjs.map +1 -0
  114. package/dist/{chunk-NUO7HPOV.cjs → chunk-XIRAKXBF.cjs} +220 -105
  115. package/dist/chunk-XIRAKXBF.cjs.map +1 -0
  116. package/dist/{chunk-5NFRDYFN.js → chunk-XKLJYRAA.js} +4 -4
  117. package/dist/chunk-XKLJYRAA.js.map +1 -0
  118. package/dist/chunk-Z45X45WX.js +684 -0
  119. package/dist/chunk-Z45X45WX.js.map +1 -0
  120. package/dist/{chunk-MPUVSOEU.cjs → chunk-ZI4WQHQA.cjs} +21 -15
  121. package/dist/chunk-ZI4WQHQA.cjs.map +1 -0
  122. package/dist/chunk-ZKMVCV4G.cjs +71 -0
  123. package/dist/chunk-ZKMVCV4G.cjs.map +1 -0
  124. package/dist/docs/README.md +1 -1
  125. package/dist/docs/SKILL.md +1 -1
  126. package/dist/docs/SOURCE_MAP.json +1 -1
  127. package/dist/docs/server/01-custom-adapters.md +10 -10
  128. package/dist/docs/server/02-reference.md +22 -8
  129. package/dist/server/auth/helpers.d.ts +8 -1
  130. package/dist/server/auth/helpers.d.ts.map +1 -1
  131. package/dist/server/auth/index.cjs +42 -131
  132. package/dist/server/auth/index.cjs.map +1 -1
  133. package/dist/server/auth/index.js +1 -125
  134. package/dist/server/auth/index.js.map +1 -1
  135. package/dist/server/auth/path-pattern.d.ts +43 -0
  136. package/dist/server/auth/path-pattern.d.ts.map +1 -0
  137. package/dist/server/constants.d.ts +51 -0
  138. package/dist/server/constants.d.ts.map +1 -0
  139. package/dist/server/handlers/a2a.cjs +9 -9
  140. package/dist/server/handlers/a2a.d.ts.map +1 -1
  141. package/dist/server/handlers/a2a.js +1 -1
  142. package/dist/server/handlers/agent-builder.cjs +16 -16
  143. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  144. package/dist/server/handlers/agent-builder.js +1 -1
  145. package/dist/server/handlers/agent-versions.cjs +60 -0
  146. package/dist/server/handlers/agent-versions.cjs.map +1 -0
  147. package/dist/server/handlers/agent-versions.d.ts +479 -0
  148. package/dist/server/handlers/agent-versions.d.ts.map +1 -0
  149. package/dist/server/handlers/agent-versions.js +3 -0
  150. package/dist/server/handlers/agent-versions.js.map +1 -0
  151. package/dist/server/handlers/agents.cjs +40 -28
  152. package/dist/server/handlers/agents.d.ts +58 -5
  153. package/dist/server/handlers/agents.d.ts.map +1 -1
  154. package/dist/server/handlers/agents.js +1 -1
  155. package/dist/server/handlers/logs.cjs +4 -4
  156. package/dist/server/handlers/logs.d.ts.map +1 -1
  157. package/dist/server/handlers/logs.js +1 -1
  158. package/dist/server/handlers/mcp.cjs +9 -9
  159. package/dist/server/handlers/mcp.d.ts +22 -0
  160. package/dist/server/handlers/mcp.d.ts.map +1 -1
  161. package/dist/server/handlers/mcp.js +1 -1
  162. package/dist/server/handlers/memory.cjs +25 -25
  163. package/dist/server/handlers/memory.d.ts +25 -1
  164. package/dist/server/handlers/memory.d.ts.map +1 -1
  165. package/dist/server/handlers/memory.js +1 -1
  166. package/dist/server/handlers/observability.cjs +5 -5
  167. package/dist/server/handlers/observability.d.ts +1 -0
  168. package/dist/server/handlers/observability.d.ts.map +1 -1
  169. package/dist/server/handlers/observability.js +1 -1
  170. package/dist/server/handlers/processors.cjs +4 -4
  171. package/dist/server/handlers/processors.d.ts.map +1 -1
  172. package/dist/server/handlers/processors.js +1 -1
  173. package/dist/server/handlers/scores.cjs +7 -7
  174. package/dist/server/handlers/scores.d.ts.map +1 -1
  175. package/dist/server/handlers/scores.js +1 -1
  176. package/dist/server/handlers/stored-agents.cjs +6 -6
  177. package/dist/server/handlers/stored-agents.d.ts +33 -5
  178. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  179. package/dist/server/handlers/stored-agents.js +1 -1
  180. package/dist/server/handlers/system.cjs +2 -2
  181. package/dist/server/handlers/system.d.ts.map +1 -1
  182. package/dist/server/handlers/system.js +1 -1
  183. package/dist/server/handlers/tools.cjs +6 -6
  184. package/dist/server/handlers/tools.d.ts +3 -3
  185. package/dist/server/handlers/tools.d.ts.map +1 -1
  186. package/dist/server/handlers/tools.js +1 -1
  187. package/dist/server/handlers/utils.cjs +21 -5
  188. package/dist/server/handlers/utils.d.ts +26 -0
  189. package/dist/server/handlers/utils.d.ts.map +1 -1
  190. package/dist/server/handlers/utils.js +1 -1
  191. package/dist/server/handlers/vector.cjs +13 -13
  192. package/dist/server/handlers/vector.d.ts.map +1 -1
  193. package/dist/server/handlers/vector.js +1 -1
  194. package/dist/server/handlers/voice.cjs +8 -8
  195. package/dist/server/handlers/voice.d.ts.map +1 -1
  196. package/dist/server/handlers/voice.js +1 -1
  197. package/dist/server/handlers/workflows.cjs +24 -24
  198. package/dist/server/handlers/workflows.d.ts +2 -0
  199. package/dist/server/handlers/workflows.d.ts.map +1 -1
  200. package/dist/server/handlers/workflows.js +1 -1
  201. package/dist/server/handlers/workspace.cjs +80 -0
  202. package/dist/server/handlers/workspace.cjs.map +1 -0
  203. package/dist/server/handlers/workspace.d.ts +591 -0
  204. package/dist/server/handlers/workspace.d.ts.map +1 -0
  205. package/dist/server/handlers/workspace.js +3 -0
  206. package/dist/server/handlers/workspace.js.map +1 -0
  207. package/dist/server/handlers.cjs +24 -24
  208. package/dist/server/handlers.js +12 -12
  209. package/dist/server/schemas/agent-versions.d.ts +1646 -0
  210. package/dist/server/schemas/agent-versions.d.ts.map +1 -0
  211. package/dist/server/schemas/agents.d.ts +30 -19
  212. package/dist/server/schemas/agents.d.ts.map +1 -1
  213. package/dist/server/schemas/memory.d.ts +83 -31
  214. package/dist/server/schemas/memory.d.ts.map +1 -1
  215. package/dist/server/schemas/stored-agents.d.ts +66 -8
  216. package/dist/server/schemas/stored-agents.d.ts.map +1 -1
  217. package/dist/server/schemas/workspace.d.ts +1107 -0
  218. package/dist/server/schemas/workspace.d.ts.map +1 -0
  219. package/dist/server/server-adapter/index.cjs +298 -160
  220. package/dist/server/server-adapter/index.cjs.map +1 -1
  221. package/dist/server/server-adapter/index.d.ts +56 -2
  222. package/dist/server/server-adapter/index.d.ts.map +1 -1
  223. package/dist/server/server-adapter/index.js +158 -23
  224. package/dist/server/server-adapter/index.js.map +1 -1
  225. package/dist/server/server-adapter/openapi-utils.d.ts +10 -0
  226. package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -1
  227. package/dist/server/server-adapter/routes/agents.d.ts.map +1 -1
  228. package/dist/server/server-adapter/routes/index.d.ts +3 -1
  229. package/dist/server/server-adapter/routes/index.d.ts.map +1 -1
  230. package/dist/server/server-adapter/routes/route-builder.d.ts +2 -1
  231. package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -1
  232. package/dist/server/server-adapter/routes/stored-agents.d.ts +1 -1
  233. package/dist/server/server-adapter/routes/stored-agents.d.ts.map +1 -1
  234. package/dist/server/server-adapter/routes/workspace.d.ts +8 -0
  235. package/dist/server/server-adapter/routes/workspace.d.ts.map +1 -0
  236. package/dist/server/utils.d.ts +13 -0
  237. package/dist/server/utils.d.ts.map +1 -1
  238. package/dist/{token-6GSAFR2W-K2BTU23I-5WBYUIGY.cjs → token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs} +9 -9
  239. package/dist/token-6GSAFR2W-ABXTQD64-MC4IMVOB.cjs.map +1 -0
  240. package/dist/{token-6GSAFR2W-VLY2XUPA-NCSASMWN.js → token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js} +6 -6
  241. package/dist/token-6GSAFR2W-ABXTQD64-Z6U2TA2C.js.map +1 -0
  242. package/dist/{token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs → token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs} +9 -9
  243. package/dist/token-6GSAFR2W-F2L44NEJ-B3QIV63M.cjs.map +1 -0
  244. package/dist/{token-6GSAFR2W-KVDFAJ2M-VW443KIA.js → token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js} +6 -6
  245. package/dist/token-6GSAFR2W-F2L44NEJ-GFZ37A2V.js.map +1 -0
  246. package/dist/{token-6GSAFR2W-VLY2XUPA-RKITWXKR.cjs → token-6GSAFR2W-WGTMOPEU-6HSZQUFZ.cjs} +9 -9
  247. package/dist/token-6GSAFR2W-WGTMOPEU-6HSZQUFZ.cjs.map +1 -0
  248. package/dist/{token-6GSAFR2W-K2BTU23I-NW33N3NU.js → token-6GSAFR2W-WGTMOPEU-JKP67ZX4.js} +6 -6
  249. package/dist/token-6GSAFR2W-WGTMOPEU-JKP67ZX4.js.map +1 -0
  250. package/dist/token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js +8 -0
  251. package/dist/{token-util-NEHG7TUY-TIJ3LMSH-SGVKOKXF.js.map → token-util-NEHG7TUY-4YJ4EPCL-MBTAVIJ3.js.map} +1 -1
  252. package/dist/token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs +10 -0
  253. package/dist/{token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs.map → token-util-NEHG7TUY-4YJ4EPCL-SQ4NADRW.cjs.map} +1 -1
  254. package/dist/token-util-NEHG7TUY-TV2H7N56-GGCGMPDG.js +8 -0
  255. package/dist/{token-util-NEHG7TUY-KSXDO2NO-WH6I3PH3.js.map → token-util-NEHG7TUY-TV2H7N56-GGCGMPDG.js.map} +1 -1
  256. package/dist/token-util-NEHG7TUY-TV2H7N56-R7OENTCJ.cjs +10 -0
  257. package/dist/{token-util-NEHG7TUY-KSXDO2NO-J6DEINGO.cjs.map → token-util-NEHG7TUY-TV2H7N56-R7OENTCJ.cjs.map} +1 -1
  258. package/dist/token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs +10 -0
  259. package/dist/{token-util-NEHG7TUY-TIJ3LMSH-ANFISSXX.cjs.map → token-util-NEHG7TUY-XQP3QSPX-BL5O5N7R.cjs.map} +1 -1
  260. package/dist/token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js +8 -0
  261. package/dist/{token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js.map → token-util-NEHG7TUY-XQP3QSPX-YCJRRNXO.js.map} +1 -1
  262. package/handlers/server/handlers.d.ts +1 -0
  263. package/handlers.d.ts +1 -0
  264. package/package.json +12 -10
  265. package/server-adapter.d.ts +1 -0
  266. package/dist/chunk-2CLS2PYJ.js.map +0 -1
  267. package/dist/chunk-2CYGIE3E.js.map +0 -1
  268. package/dist/chunk-33CKPQS4.cjs.map +0 -1
  269. package/dist/chunk-3FEYUHHJ.js.map +0 -1
  270. package/dist/chunk-3REGEJEN.js.map +0 -1
  271. package/dist/chunk-4DJ7EJRB.cjs.map +0 -1
  272. package/dist/chunk-4EYONQIW.cjs.map +0 -1
  273. package/dist/chunk-4R2Z655M.js.map +0 -1
  274. package/dist/chunk-5NFRDYFN.js.map +0 -1
  275. package/dist/chunk-5VDI75UV.js.map +0 -1
  276. package/dist/chunk-5W4RPVTK.cjs +0 -49
  277. package/dist/chunk-5W4RPVTK.cjs.map +0 -1
  278. package/dist/chunk-6MP2S6VI.cjs.map +0 -1
  279. package/dist/chunk-7S7ALPCY.js.map +0 -1
  280. package/dist/chunk-7XPMKW4Y.cjs.map +0 -1
  281. package/dist/chunk-AV3CN5ZR.cjs.map +0 -1
  282. package/dist/chunk-AVRO3FIN.cjs.map +0 -1
  283. package/dist/chunk-BRI4GUZ2.cjs.map +0 -1
  284. package/dist/chunk-CGIGPJRU.js.map +0 -1
  285. package/dist/chunk-CLAEGIP5.cjs.map +0 -1
  286. package/dist/chunk-DVSCJECS.js.map +0 -1
  287. package/dist/chunk-EUBTCHQC.js.map +0 -1
  288. package/dist/chunk-FLLJIPD4.cjs.map +0 -1
  289. package/dist/chunk-FWSKVWS7.cjs.map +0 -1
  290. package/dist/chunk-G2AMUTU4.js.map +0 -1
  291. package/dist/chunk-GHQZIEPS.js.map +0 -1
  292. package/dist/chunk-GNCALVLC.js.map +0 -1
  293. package/dist/chunk-H34VRYSF.js.map +0 -1
  294. package/dist/chunk-I27H7BEB.js.map +0 -1
  295. package/dist/chunk-IVGQTL3T.js.map +0 -1
  296. package/dist/chunk-KKY4MSZO.js.map +0 -1
  297. package/dist/chunk-L2E5RUVT.cjs.map +0 -1
  298. package/dist/chunk-MPUVSOEU.cjs.map +0 -1
  299. package/dist/chunk-N4EIZSG2.js.map +0 -1
  300. package/dist/chunk-NUO7HPOV.cjs.map +0 -1
  301. package/dist/chunk-P3H4AZKI.cjs.map +0 -1
  302. package/dist/chunk-PNZQCQY4.cjs.map +0 -1
  303. package/dist/chunk-QPFYN6B5.cjs.map +0 -1
  304. package/dist/chunk-T4SPG2GP.cjs.map +0 -1
  305. package/dist/chunk-TMS4LS2J.js.map +0 -1
  306. package/dist/chunk-UK4FZWNW.cjs.map +0 -1
  307. package/dist/chunk-WJ6DNHLW.cjs.map +0 -1
  308. package/dist/chunk-WLGJVDH4.js.map +0 -1
  309. package/dist/chunk-XB27LCKO.js.map +0 -1
  310. package/dist/chunk-XCEQ4GQW.cjs.map +0 -1
  311. package/dist/chunk-XOUK3IYU.js.map +0 -1
  312. package/dist/chunk-XWGAT2DA.js +0 -44
  313. package/dist/chunk-XWGAT2DA.js.map +0 -1
  314. package/dist/chunk-YK63KHHB.cjs.map +0 -1
  315. package/dist/chunk-YN3FWKVQ.js.map +0 -1
  316. package/dist/chunk-ZQ2G6QKS.cjs.map +0 -1
  317. package/dist/token-6GSAFR2W-K2BTU23I-5WBYUIGY.cjs.map +0 -1
  318. package/dist/token-6GSAFR2W-K2BTU23I-NW33N3NU.js.map +0 -1
  319. package/dist/token-6GSAFR2W-KVDFAJ2M-EPLMGMHT.cjs.map +0 -1
  320. package/dist/token-6GSAFR2W-KVDFAJ2M-VW443KIA.js.map +0 -1
  321. package/dist/token-6GSAFR2W-VLY2XUPA-NCSASMWN.js.map +0 -1
  322. package/dist/token-6GSAFR2W-VLY2XUPA-RKITWXKR.cjs.map +0 -1
  323. package/dist/token-util-NEHG7TUY-DJYRKLRD-6TH3ODCN.cjs +0 -10
  324. package/dist/token-util-NEHG7TUY-DJYRKLRD-EACKYD4V.js +0 -8
  325. package/dist/token-util-NEHG7TUY-KSXDO2NO-J6DEINGO.cjs +0 -10
  326. package/dist/token-util-NEHG7TUY-KSXDO2NO-WH6I3PH3.js +0 -8
  327. package/dist/token-util-NEHG7TUY-TIJ3LMSH-ANFISSXX.cjs +0 -10
  328. package/dist/token-util-NEHG7TUY-TIJ3LMSH-SGVKOKXF.js +0 -8
@@ -1,72 +1,20 @@
1
- import { createPagePaginationSchema, paginationInfoSchema } from './chunk-HT4LP3BO.js';
2
- import { createRoute } from './chunk-7S7ALPCY.js';
1
+ import { listStoredAgentsResponseSchema, listStoredAgentsQuerySchema, getStoredAgentResponseSchema, storedAgentIdPathParams, createStoredAgentResponseSchema, createStoredAgentBodySchema, updateStoredAgentResponseSchema, updateStoredAgentBodySchema, handleAutoVersioning, deleteStoredAgentResponseSchema } from './chunk-ETVLWGEB.js';
3
2
  import { handleError } from './chunk-ONN5EA7E.js';
4
3
  import { HTTPException } from './chunk-6QWQZI4Q.js';
5
- import z from 'zod';
6
-
7
- var storedAgentIdPathParams = z.object({
8
- storedAgentId: z.string().describe("Unique identifier for the stored agent")
9
- });
10
- var storageOrderBySchema = z.object({
11
- field: z.enum(["createdAt", "updatedAt"]).optional(),
12
- direction: z.enum(["ASC", "DESC"]).optional()
13
- });
14
- var listStoredAgentsQuerySchema = createPagePaginationSchema(100).extend({
15
- orderBy: storageOrderBySchema.optional()
16
- });
17
- var scorerConfigSchema = z.object({
18
- sampling: z.object({
19
- type: z.enum(["ratio", "count"]),
20
- rate: z.number().optional(),
21
- count: z.number().optional()
22
- }).optional()
23
- });
24
- var storedAgentBaseSchema = z.object({
25
- name: z.string().describe("Name of the agent"),
26
- description: z.string().optional().describe("Description of the agent"),
27
- instructions: z.string().describe("System instructions for the agent"),
28
- model: z.record(z.string(), z.unknown()).describe("Model configuration (provider, name, etc.)"),
29
- tools: z.array(z.string()).optional().describe("Array of tool keys to resolve from Mastra registry"),
30
- defaultOptions: z.record(z.string(), z.unknown()).optional().describe("Default options for generate/stream calls"),
31
- workflows: z.array(z.string()).optional().describe("Array of workflow keys to resolve from Mastra registry"),
32
- agents: z.array(z.string()).optional().describe("Array of agent keys to resolve from Mastra registry"),
33
- inputProcessors: z.array(z.record(z.string(), z.unknown())).optional().describe("Input processor configurations"),
34
- outputProcessors: z.array(z.record(z.string(), z.unknown())).optional().describe("Output processor configurations"),
35
- memory: z.string().optional().describe("Memory key to resolve from Mastra registry"),
36
- scorers: z.record(z.string(), scorerConfigSchema).optional().describe("Scorer keys with optional sampling config"),
37
- metadata: z.record(z.string(), z.unknown()).optional().describe("Additional metadata for the agent")
38
- });
39
- var createStoredAgentBodySchema = storedAgentBaseSchema.extend({
40
- id: z.string().describe("Unique identifier for the agent")
41
- });
42
- var updateStoredAgentBodySchema = storedAgentBaseSchema.partial();
43
- var storedAgentSchema = storedAgentBaseSchema.extend({
44
- id: z.string(),
45
- createdAt: z.date(),
46
- updatedAt: z.date()
47
- });
48
- var listStoredAgentsResponseSchema = paginationInfoSchema.extend({
49
- agents: z.array(storedAgentSchema)
50
- });
51
- var getStoredAgentResponseSchema = storedAgentSchema;
52
- var createStoredAgentResponseSchema = storedAgentSchema;
53
- var updateStoredAgentResponseSchema = storedAgentSchema;
54
- var deleteStoredAgentResponseSchema = z.object({
55
- success: z.boolean(),
56
- message: z.string()
57
- });
4
+ import { createRoute } from './chunk-D5VCL56B.js';
58
5
 
59
6
  // src/server/handlers/stored-agents.ts
60
7
  var LIST_STORED_AGENTS_ROUTE = createRoute({
61
8
  method: "GET",
62
- path: "/api/stored/agents",
9
+ path: "/stored/agents",
63
10
  responseType: "json",
64
11
  queryParamSchema: listStoredAgentsQuerySchema,
65
12
  responseSchema: listStoredAgentsResponseSchema,
66
13
  summary: "List stored agents",
67
14
  description: "Returns a paginated list of all agents stored in the database",
68
15
  tags: ["Stored Agents"],
69
- handler: async ({ mastra, page, perPage, orderBy }) => {
16
+ requiresAuth: true,
17
+ handler: async ({ mastra, page, perPage, orderBy, ownerId, metadata }) => {
70
18
  try {
71
19
  const storage = mastra.getStorage();
72
20
  if (!storage) {
@@ -79,7 +27,9 @@ var LIST_STORED_AGENTS_ROUTE = createRoute({
79
27
  const result = await agentsStore.listAgents({
80
28
  page,
81
29
  perPage,
82
- orderBy
30
+ orderBy,
31
+ ownerId,
32
+ metadata
83
33
  });
84
34
  return result;
85
35
  } catch (error) {
@@ -89,13 +39,14 @@ var LIST_STORED_AGENTS_ROUTE = createRoute({
89
39
  });
90
40
  var GET_STORED_AGENT_ROUTE = createRoute({
91
41
  method: "GET",
92
- path: "/api/stored/agents/:storedAgentId",
42
+ path: "/stored/agents/:storedAgentId",
93
43
  responseType: "json",
94
44
  pathParamSchema: storedAgentIdPathParams,
95
45
  responseSchema: getStoredAgentResponseSchema,
96
46
  summary: "Get stored agent by ID",
97
47
  description: "Returns a specific agent from storage by its unique identifier",
98
48
  tags: ["Stored Agents"],
49
+ requiresAuth: true,
99
50
  handler: async ({ mastra, storedAgentId }) => {
100
51
  try {
101
52
  const storage = mastra.getStorage();
@@ -106,7 +57,7 @@ var GET_STORED_AGENT_ROUTE = createRoute({
106
57
  if (!agentsStore) {
107
58
  throw new HTTPException(500, { message: "Agents storage domain is not available" });
108
59
  }
109
- const agent = await agentsStore.getAgentById({ id: storedAgentId });
60
+ const agent = await agentsStore.getAgentByIdResolved({ id: storedAgentId });
110
61
  if (!agent) {
111
62
  throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });
112
63
  }
@@ -118,13 +69,14 @@ var GET_STORED_AGENT_ROUTE = createRoute({
118
69
  });
119
70
  var CREATE_STORED_AGENT_ROUTE = createRoute({
120
71
  method: "POST",
121
- path: "/api/stored/agents",
72
+ path: "/stored/agents",
122
73
  responseType: "json",
123
74
  bodySchema: createStoredAgentBodySchema,
124
75
  responseSchema: createStoredAgentResponseSchema,
125
76
  summary: "Create stored agent",
126
77
  description: "Creates a new agent in storage with the provided configuration",
127
78
  tags: ["Stored Agents"],
79
+ requiresAuth: true,
128
80
  handler: async ({
129
81
  mastra,
130
82
  id,
@@ -136,11 +88,13 @@ var CREATE_STORED_AGENT_ROUTE = createRoute({
136
88
  defaultOptions,
137
89
  workflows,
138
90
  agents,
91
+ integrationTools,
139
92
  inputProcessors,
140
93
  outputProcessors,
141
94
  memory,
142
95
  scorers,
143
- metadata
96
+ metadata,
97
+ ownerId
144
98
  }) => {
145
99
  try {
146
100
  const storage = mastra.getStorage();
@@ -156,6 +110,7 @@ var CREATE_STORED_AGENT_ROUTE = createRoute({
156
110
  throw new HTTPException(409, { message: `Agent with id ${id} already exists` });
157
111
  }
158
112
  const toolsFromBody = Array.isArray(tools) ? tools : void 0;
113
+ const integrationToolsFromBody = Array.isArray(integrationTools) ? integrationTools : void 0;
159
114
  const agent = await agentsStore.createAgent({
160
115
  agent: {
161
116
  id,
@@ -167,11 +122,13 @@ var CREATE_STORED_AGENT_ROUTE = createRoute({
167
122
  defaultOptions,
168
123
  workflows,
169
124
  agents,
125
+ integrationTools: integrationToolsFromBody,
170
126
  inputProcessors,
171
127
  outputProcessors,
172
128
  memory,
173
129
  scorers,
174
- metadata
130
+ metadata,
131
+ ownerId
175
132
  }
176
133
  });
177
134
  return agent;
@@ -182,7 +139,7 @@ var CREATE_STORED_AGENT_ROUTE = createRoute({
182
139
  });
183
140
  var UPDATE_STORED_AGENT_ROUTE = createRoute({
184
141
  method: "PATCH",
185
- path: "/api/stored/agents/:storedAgentId",
142
+ path: "/stored/agents/:storedAgentId",
186
143
  responseType: "json",
187
144
  pathParamSchema: storedAgentIdPathParams,
188
145
  bodySchema: updateStoredAgentBodySchema,
@@ -190,6 +147,7 @@ var UPDATE_STORED_AGENT_ROUTE = createRoute({
190
147
  summary: "Update stored agent",
191
148
  description: "Updates an existing agent in storage with the provided fields",
192
149
  tags: ["Stored Agents"],
150
+ requiresAuth: true,
193
151
  handler: async ({
194
152
  mastra,
195
153
  storedAgentId,
@@ -201,11 +159,13 @@ var UPDATE_STORED_AGENT_ROUTE = createRoute({
201
159
  defaultOptions,
202
160
  workflows,
203
161
  agents,
162
+ integrationTools,
204
163
  inputProcessors,
205
164
  outputProcessors,
206
165
  memory,
207
166
  scorers,
208
- metadata
167
+ metadata,
168
+ ownerId
209
169
  }) => {
210
170
  try {
211
171
  const storage = mastra.getStorage();
@@ -221,7 +181,8 @@ var UPDATE_STORED_AGENT_ROUTE = createRoute({
221
181
  throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });
222
182
  }
223
183
  const toolsFromBody = Array.isArray(tools) ? tools : void 0;
224
- const agent = await agentsStore.updateAgent({
184
+ const integrationToolsFromBody = Array.isArray(integrationTools) ? integrationTools : void 0;
185
+ const updatedAgent = await agentsStore.updateAgent({
225
186
  id: storedAgentId,
226
187
  name,
227
188
  description,
@@ -231,12 +192,16 @@ var UPDATE_STORED_AGENT_ROUTE = createRoute({
231
192
  defaultOptions,
232
193
  workflows,
233
194
  agents,
195
+ integrationTools: integrationToolsFromBody,
234
196
  inputProcessors,
235
197
  outputProcessors,
236
198
  memory,
237
199
  scorers,
238
- metadata
200
+ metadata,
201
+ ownerId
239
202
  });
203
+ const { agent } = await handleAutoVersioning(agentsStore, storedAgentId, existing, updatedAgent);
204
+ mastra.clearStoredAgentCache(storedAgentId);
240
205
  return agent;
241
206
  } catch (error) {
242
207
  return handleError(error, "Error updating stored agent");
@@ -245,13 +210,14 @@ var UPDATE_STORED_AGENT_ROUTE = createRoute({
245
210
  });
246
211
  var DELETE_STORED_AGENT_ROUTE = createRoute({
247
212
  method: "DELETE",
248
- path: "/api/stored/agents/:storedAgentId",
213
+ path: "/stored/agents/:storedAgentId",
249
214
  responseType: "json",
250
215
  pathParamSchema: storedAgentIdPathParams,
251
216
  responseSchema: deleteStoredAgentResponseSchema,
252
217
  summary: "Delete stored agent",
253
218
  description: "Deletes an agent from storage by its unique identifier",
254
219
  tags: ["Stored Agents"],
220
+ requiresAuth: true,
255
221
  handler: async ({ mastra, storedAgentId }) => {
256
222
  try {
257
223
  const storage = mastra.getStorage();
@@ -267,6 +233,7 @@ var DELETE_STORED_AGENT_ROUTE = createRoute({
267
233
  throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });
268
234
  }
269
235
  await agentsStore.deleteAgent({ id: storedAgentId });
236
+ mastra.clearStoredAgentCache(storedAgentId);
270
237
  return { success: true, message: `Agent ${storedAgentId} deleted successfully` };
271
238
  } catch (error) {
272
239
  return handleError(error, "Error deleting stored agent");
@@ -275,5 +242,5 @@ var DELETE_STORED_AGENT_ROUTE = createRoute({
275
242
  });
276
243
 
277
244
  export { CREATE_STORED_AGENT_ROUTE, DELETE_STORED_AGENT_ROUTE, GET_STORED_AGENT_ROUTE, LIST_STORED_AGENTS_ROUTE, UPDATE_STORED_AGENT_ROUTE };
278
- //# sourceMappingURL=chunk-CGIGPJRU.js.map
279
- //# sourceMappingURL=chunk-CGIGPJRU.js.map
245
+ //# sourceMappingURL=chunk-7XHQEMU2.js.map
246
+ //# sourceMappingURL=chunk-7XHQEMU2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/handlers/stored-agents.ts"],"names":[],"mappings":";;;;;;AAwBO,IAAM,2BAA2B,WAAA,CAAY;AAAA,EAClD,MAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAM,gBAAA;AAAA,EACN,YAAA,EAAc,MAAA;AAAA,EACd,gBAAA,EAAkB,2BAAA;AAAA,EAClB,cAAA,EAAgB,8BAAA;AAAA,EAChB,OAAA,EAAS,oBAAA;AAAA,EACT,WAAA,EAAa,+DAAA;AAAA,EACb,IAAA,EAAM,CAAC,eAAe,CAAA;AAAA,EACtB,YAAA,EAAc,IAAA;AAAA,EACd,OAAA,EAAS,OAAO,EAAE,MAAA,EAAQ,MAAM,OAAA,EAAS,OAAA,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EAAS,qBAAA;AAAA,EACT,WAAA,EAAa,wDAAA;AAAA,EACb,IAAA,EAAM,CAAC,eAAe,CAAA;AAAA,EACtB,YAAA,EAAc,IAAA;AAAA,EACd,OAAA,EAAS,OAAO,EAAE,MAAA,EAAQ,eAAc,KAAM;AAC5C,IAAA,IAAI;AACF,MAAA,MAAM,OAAA,GAAU,OAAO,UAAA,EAAW;AAElC,MAAA,IAAI,CAAC,OAAA,EAAS;AACZ,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,6BAA6B,CAAA;AAAA,MACvE;AAEA,MAAA,MAAM,WAAA,GAAc,MAAM,OAAA,CAAQ,QAAA,CAAS,QAAQ,CAAA;AACnD,MAAA,IAAI,CAAC,WAAA,EAAa;AAChB,QAAA,MAAM,IAAI,aAAA,CAAc,GAAA,EAAK,EAAE,OAAA,EAAS,0CAA0C,CAAA;AAAA,MACpF;AAGA,MAAA,MAAM,WAAW,MAAM,WAAA,CAAY,aAAa,EAAE,EAAA,EAAI,eAAe,CAAA;AACrE,MAAA,IAAI,CAAC,QAAA,EAAU;AACb,QAAA,MAAM,IAAI,cAAc,GAAA,EAAK,EAAE,SAAS,CAAA,qBAAA,EAAwB,aAAa,cAAc,CAAA;AAAA,MAC7F;AAEA,MAAA,MAAM,WAAA,CAAY,WAAA,CAAY,EAAE,EAAA,EAAI,eAAe,CAAA;AAGnD,MAAA,MAAA,CAAO,sBAAsB,aAAa,CAAA;AAE1C,MAAA,OAAO,EAAE,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,CAAA,MAAA,EAAS,aAAa,CAAA,qBAAA,CAAA,EAAwB;AAAA,IACjF,SAAS,KAAA,EAAO;AACd,MAAA,OAAO,WAAA,CAAY,OAAO,6BAA6B,CAAA;AAAA,IACzD;AAAA,EACF;AACF,CAAC","file":"chunk-7XHQEMU2.js","sourcesContent":["import { HTTPException } from '../http-exception';\nimport {\n storedAgentIdPathParams,\n listStoredAgentsQuerySchema,\n createStoredAgentBodySchema,\n updateStoredAgentBodySchema,\n listStoredAgentsResponseSchema,\n getStoredAgentResponseSchema,\n createStoredAgentResponseSchema,\n updateStoredAgentResponseSchema,\n deleteStoredAgentResponseSchema,\n} from '../schemas/stored-agents';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { handleAutoVersioning } from './agent-versions';\nimport { handleError } from './error';\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /stored/agents - List all stored agents\n */\nexport const LIST_STORED_AGENTS_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents',\n responseType: 'json',\n queryParamSchema: listStoredAgentsQuerySchema,\n responseSchema: listStoredAgentsResponseSchema,\n summary: 'List stored agents',\n description: 'Returns a paginated list of all agents stored in the database',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, page, perPage, orderBy, ownerId, metadata }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n const result = await agentsStore.listAgents({\n page,\n perPage,\n orderBy,\n ownerId,\n metadata,\n });\n\n return result;\n } catch (error) {\n return handleError(error, 'Error listing stored agents');\n }\n },\n});\n\n/**\n * GET /stored/agents/:storedAgentId - Get a stored agent by ID\n */\nexport const GET_STORED_AGENT_ROUTE = createRoute({\n method: 'GET',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n responseSchema: getStoredAgentResponseSchema,\n summary: 'Get stored agent by ID',\n description: 'Returns a specific agent from storage by its unique identifier',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, storedAgentId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Use getAgentByIdResolved to automatically resolve from active version\n const agent = await agentsStore.getAgentByIdResolved({ id: storedAgentId });\n\n if (!agent) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n\n return agent;\n } catch (error) {\n return handleError(error, 'Error getting stored agent');\n }\n },\n});\n\n/**\n * POST /stored/agents - Create a new stored agent\n */\nexport const CREATE_STORED_AGENT_ROUTE = createRoute({\n method: 'POST',\n path: '/stored/agents',\n responseType: 'json',\n bodySchema: createStoredAgentBodySchema,\n responseSchema: createStoredAgentResponseSchema,\n summary: 'Create stored agent',\n description: 'Creates a new agent in storage with the provided configuration',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n id,\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n metadata,\n ownerId,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Check if agent with this ID already exists\n const existing = await agentsStore.getAgentById({ id });\n if (existing) {\n throw new HTTPException(409, { message: `Agent with id ${id} already exists` });\n }\n\n // Only include tools if it's actually an array from the body (not {} from adapter)\n const toolsFromBody = Array.isArray(tools) ? tools : undefined;\n const integrationToolsFromBody = Array.isArray(integrationTools) ? integrationTools : undefined;\n\n const agent = await agentsStore.createAgent({\n agent: {\n id,\n name,\n description,\n instructions,\n model,\n tools: toolsFromBody,\n defaultOptions,\n workflows,\n agents,\n integrationTools: integrationToolsFromBody,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n metadata,\n ownerId,\n },\n });\n\n return agent;\n } catch (error) {\n return handleError(error, 'Error creating stored agent');\n }\n },\n});\n\n/**\n * PATCH /stored/agents/:storedAgentId - Update a stored agent\n */\nexport const UPDATE_STORED_AGENT_ROUTE = createRoute({\n method: 'PATCH',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n bodySchema: updateStoredAgentBodySchema,\n responseSchema: updateStoredAgentResponseSchema,\n summary: 'Update stored agent',\n description: 'Updates an existing agent in storage with the provided fields',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({\n mastra,\n storedAgentId,\n name,\n description,\n instructions,\n model,\n tools,\n defaultOptions,\n workflows,\n agents,\n integrationTools,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n metadata,\n ownerId,\n }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Check if agent exists\n const existing = await agentsStore.getAgentById({ id: storedAgentId });\n if (!existing) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n\n // Only include tools/integrationTools if they're actually arrays from the body (not {} from adapter)\n const toolsFromBody = Array.isArray(tools) ? tools : undefined;\n const integrationToolsFromBody = Array.isArray(integrationTools) ? integrationTools : undefined;\n\n const updatedAgent = await agentsStore.updateAgent({\n id: storedAgentId,\n name,\n description,\n instructions,\n model,\n tools: toolsFromBody,\n defaultOptions,\n workflows,\n agents,\n integrationTools: integrationToolsFromBody,\n inputProcessors,\n outputProcessors,\n memory,\n scorers,\n metadata,\n ownerId,\n });\n\n // Handle auto-versioning with retry logic for race conditions\n // This creates a version if there are meaningful changes and updates activeVersionId\n const { agent } = await handleAutoVersioning(agentsStore, storedAgentId, existing, updatedAgent);\n\n // Clear the cached agent instance so the next request gets the updated config\n mastra.clearStoredAgentCache(storedAgentId);\n\n return agent;\n } catch (error) {\n return handleError(error, 'Error updating stored agent');\n }\n },\n});\n\n/**\n * DELETE /stored/agents/:storedAgentId - Delete a stored agent\n */\nexport const DELETE_STORED_AGENT_ROUTE = createRoute({\n method: 'DELETE',\n path: '/stored/agents/:storedAgentId',\n responseType: 'json',\n pathParamSchema: storedAgentIdPathParams,\n responseSchema: deleteStoredAgentResponseSchema,\n summary: 'Delete stored agent',\n description: 'Deletes an agent from storage by its unique identifier',\n tags: ['Stored Agents'],\n requiresAuth: true,\n handler: async ({ mastra, storedAgentId }) => {\n try {\n const storage = mastra.getStorage();\n\n if (!storage) {\n throw new HTTPException(500, { message: 'Storage is not configured' });\n }\n\n const agentsStore = await storage.getStore('agents');\n if (!agentsStore) {\n throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n }\n\n // Check if agent exists\n const existing = await agentsStore.getAgentById({ id: storedAgentId });\n if (!existing) {\n throw new HTTPException(404, { message: `Stored agent with id ${storedAgentId} not found` });\n }\n\n await agentsStore.deleteAgent({ id: storedAgentId });\n\n // Clear the cached agent instance\n mastra.clearStoredAgentCache(storedAgentId);\n\n return { success: true, message: `Agent ${storedAgentId} deleted successfully` };\n } catch (error) {\n return handleError(error, 'Error deleting stored agent');\n }\n },\n});\n"]}
@@ -0,0 +1,211 @@
1
+ 'use strict';
2
+
3
+ // src/server/auth/defaults.ts
4
+ var defaultAuthConfig = {
5
+ protected: ["/api/*"],
6
+ public: ["/api"],
7
+ // Simple rule system
8
+ rules: [
9
+ // Admin users can do anything
10
+ {
11
+ condition: (user) => {
12
+ if (typeof user === "object" && user !== null) {
13
+ if ("isAdmin" in user) {
14
+ return !!user.isAdmin;
15
+ }
16
+ if ("role" in user) {
17
+ return user.role === "admin";
18
+ }
19
+ }
20
+ return false;
21
+ },
22
+ allow: true
23
+ }
24
+ ]
25
+ };
26
+
27
+ // src/server/auth/path-pattern.ts
28
+ function parse(input, loose) {
29
+ if (input instanceof RegExp) return { keys: false, pattern: input };
30
+ let c;
31
+ let o;
32
+ let tmp;
33
+ let ext;
34
+ const keys = [];
35
+ let pattern = "";
36
+ const arr = input.split("/");
37
+ arr[0] || arr.shift();
38
+ while (tmp = arr.shift()) {
39
+ c = tmp[0];
40
+ if (c === "*") {
41
+ keys.push(c);
42
+ pattern += tmp[1] === "?" ? "(?:/(.*))?" : "/(.*)";
43
+ } else if (c === ":") {
44
+ o = tmp.indexOf("?", 1);
45
+ ext = tmp.indexOf(".", 1);
46
+ keys.push(tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length));
47
+ pattern += !!~o && !~ext ? "(?:/([^/]+?))?" : "/([^/]+?)";
48
+ if (!!~ext) pattern += (!!~o ? "?" : "") + "\\" + tmp.substring(ext);
49
+ } else {
50
+ pattern += "/" + tmp;
51
+ }
52
+ }
53
+ return {
54
+ keys,
55
+ pattern: new RegExp("^" + pattern + ("/?$"), "i")
56
+ };
57
+ }
58
+
59
+ // src/server/auth/helpers.ts
60
+ var isProtectedCustomRoute = (path, method, customRouteAuthConfig) => {
61
+ if (!customRouteAuthConfig) {
62
+ return false;
63
+ }
64
+ const exactRouteKey = `${method}:${path}`;
65
+ if (customRouteAuthConfig.has(exactRouteKey)) {
66
+ return customRouteAuthConfig.get(exactRouteKey) === true;
67
+ }
68
+ const allRouteKey = `ALL:${path}`;
69
+ if (customRouteAuthConfig.has(allRouteKey)) {
70
+ return customRouteAuthConfig.get(allRouteKey) === true;
71
+ }
72
+ for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {
73
+ const colonIndex = routeKey.indexOf(":");
74
+ if (colonIndex === -1) {
75
+ continue;
76
+ }
77
+ const routeMethod = routeKey.substring(0, colonIndex);
78
+ const routePattern = routeKey.substring(colonIndex + 1);
79
+ if (routeMethod !== method && routeMethod !== "ALL") {
80
+ continue;
81
+ }
82
+ if (pathMatchesPattern(path, routePattern)) {
83
+ return requiresAuth === true;
84
+ }
85
+ }
86
+ return false;
87
+ };
88
+ var isDevPlaygroundRequest = (path, method, getHeader, authConfig, customRouteAuthConfig) => {
89
+ const protectedAccess = [...defaultAuthConfig.protected || [], ...authConfig.protected || []];
90
+ return process.env.MASTRA_DEV === "true" && // Allow if path doesn't match protected patterns AND is not a protected custom route
91
+ (!isAnyMatch(path, method, protectedAccess) && !isProtectedCustomRoute(path, method, customRouteAuthConfig) || // Or if has playground header
92
+ getHeader("x-mastra-dev-playground") === "true");
93
+ };
94
+ var isCustomRoutePublic = (path, method, customRouteAuthConfig) => {
95
+ if (!customRouteAuthConfig) {
96
+ return false;
97
+ }
98
+ const exactRouteKey = `${method}:${path}`;
99
+ if (customRouteAuthConfig.has(exactRouteKey)) {
100
+ return !customRouteAuthConfig.get(exactRouteKey);
101
+ }
102
+ const allRouteKey = `ALL:${path}`;
103
+ if (customRouteAuthConfig.has(allRouteKey)) {
104
+ return !customRouteAuthConfig.get(allRouteKey);
105
+ }
106
+ for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {
107
+ const colonIndex = routeKey.indexOf(":");
108
+ if (colonIndex === -1) {
109
+ continue;
110
+ }
111
+ const routeMethod = routeKey.substring(0, colonIndex);
112
+ const routePattern = routeKey.substring(colonIndex + 1);
113
+ if (routeMethod !== method && routeMethod !== "ALL") {
114
+ continue;
115
+ }
116
+ if (pathMatchesPattern(path, routePattern)) {
117
+ return !requiresAuth;
118
+ }
119
+ }
120
+ return false;
121
+ };
122
+ var isProtectedPath = (path, method, authConfig, customRouteAuthConfig) => {
123
+ const protectedAccess = [...defaultAuthConfig.protected || [], ...authConfig.protected || []];
124
+ return isAnyMatch(path, method, protectedAccess) || !isCustomRoutePublic(path, method, customRouteAuthConfig);
125
+ };
126
+ var canAccessPublicly = (path, method, authConfig) => {
127
+ const publicAccess = [...defaultAuthConfig.public || [], ...authConfig.public || []];
128
+ return isAnyMatch(path, method, publicAccess);
129
+ };
130
+ var isAnyMatch = (path, method, patterns) => {
131
+ if (!patterns) {
132
+ return false;
133
+ }
134
+ for (const patternPathOrMethod of patterns) {
135
+ if (patternPathOrMethod instanceof RegExp) {
136
+ if (patternPathOrMethod.test(path)) {
137
+ return true;
138
+ }
139
+ }
140
+ if (typeof patternPathOrMethod === "string" && pathMatchesPattern(path, patternPathOrMethod)) {
141
+ return true;
142
+ }
143
+ if (Array.isArray(patternPathOrMethod) && patternPathOrMethod.length === 2) {
144
+ const [pattern, methodOrMethods] = patternPathOrMethod;
145
+ if (pathMatchesPattern(path, pattern) && matchesOrIncludes(methodOrMethods, method)) {
146
+ return true;
147
+ }
148
+ }
149
+ }
150
+ return false;
151
+ };
152
+ var pathMatchesPattern = (path, pattern) => {
153
+ const { pattern: regex } = parse(pattern);
154
+ return regex.test(path);
155
+ };
156
+ var pathMatchesRule = (path, rulePath) => {
157
+ if (!rulePath) return true;
158
+ if (typeof rulePath === "string") {
159
+ return pathMatchesPattern(path, rulePath);
160
+ }
161
+ if (rulePath instanceof RegExp) {
162
+ return rulePath.test(path);
163
+ }
164
+ if (Array.isArray(rulePath)) {
165
+ return rulePath.some((p) => pathMatchesPattern(path, p));
166
+ }
167
+ return false;
168
+ };
169
+ var matchesOrIncludes = (values, value) => {
170
+ if (typeof values === "string") {
171
+ return values === value;
172
+ }
173
+ if (Array.isArray(values)) {
174
+ return values.includes(value);
175
+ }
176
+ return false;
177
+ };
178
+ var checkRules = async (rules, path, method, user) => {
179
+ for (const i in rules || []) {
180
+ const rule = rules?.[i];
181
+ if (!pathMatchesRule(path, rule.path)) {
182
+ continue;
183
+ }
184
+ if (rule.methods && !matchesOrIncludes(rule.methods, method)) {
185
+ continue;
186
+ }
187
+ const condition = rule.condition;
188
+ if (typeof condition === "function") {
189
+ const allowed = await Promise.resolve().then(() => condition(user)).catch(() => false);
190
+ if (allowed) {
191
+ return true;
192
+ }
193
+ } else if (rule.allow) {
194
+ return true;
195
+ }
196
+ }
197
+ return false;
198
+ };
199
+
200
+ exports.canAccessPublicly = canAccessPublicly;
201
+ exports.checkRules = checkRules;
202
+ exports.defaultAuthConfig = defaultAuthConfig;
203
+ exports.isCustomRoutePublic = isCustomRoutePublic;
204
+ exports.isDevPlaygroundRequest = isDevPlaygroundRequest;
205
+ exports.isProtectedCustomRoute = isProtectedCustomRoute;
206
+ exports.isProtectedPath = isProtectedPath;
207
+ exports.matchesOrIncludes = matchesOrIncludes;
208
+ exports.pathMatchesPattern = pathMatchesPattern;
209
+ exports.pathMatchesRule = pathMatchesRule;
210
+ //# sourceMappingURL=chunk-AAHPYUEC.cjs.map
211
+ //# sourceMappingURL=chunk-AAHPYUEC.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/auth/defaults.ts","../src/server/auth/path-pattern.ts","../src/server/auth/helpers.ts"],"names":[],"mappings":";;;AAGO,IAAM,iBAAA,GAAsC;AAAA,EACjD,SAAA,EAAW,CAAC,QAAQ,CAAA;AAAA,EACpB,MAAA,EAAQ,CAAC,MAAM,CAAA;AAAA;AAAA,EAEf,KAAA,EAAO;AAAA;AAAA,IAEL;AAAA,MACE,WAAW,CAAA,IAAA,KAAQ;AACjB,QAAA,IAAI,OAAO,IAAA,KAAS,QAAA,IAAY,IAAA,KAAS,IAAA,EAAM;AAC7C,UAAA,IAAI,aAAa,IAAA,EAAM;AACrB,YAAA,OAAO,CAAC,CAAC,IAAA,CAAK,OAAA;AAAA,UAChB;AAEA,UAAA,IAAI,UAAU,IAAA,EAAM;AAClB,YAAA,OAAO,KAAK,IAAA,KAAS,OAAA;AAAA,UACvB;AAAA,QACF;AACA,QAAA,OAAO,KAAA;AAAA,MACT,CAAA;AAAA,MACA,KAAA,EAAO;AAAA;AACT;AAEJ;;;ACcO,SAAS,KAAA,CAAM,OAAwB,KAAA,EAAgC;AAC5E,EAAA,IAAI,iBAAiB,MAAA,EAAQ,OAAO,EAAE,IAAA,EAAM,KAAA,EAAO,SAAS,KAAA,EAAM;AAElE,EAAA,IAAI,CAAA;AACJ,EAAA,IAAI,CAAA;AACJ,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI,GAAA;AACJ,EAAA,MAAM,OAAiB,EAAC;AACxB,EAAA,IAAI,OAAA,GAAU,EAAA;AACd,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,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,WAAW,QAAA,EAAU;AAC9B,IAAA,OAAO,MAAA,KAAW,KAAA;AAAA,EACpB;AAEA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG;AACzB,IAAA,OAAO,MAAA,CAAO,SAAS,KAAK,CAAA;AAAA,EAC9B;AAEA,EAAA,OAAO,KAAA;AACT;AAGO,IAAM,UAAA,GAAa,OACxB,KAAA,EACA,IAAA,EACA,QACA,IAAA,KACqB;AAErB,EAAA,KAAA,MAAW,CAAA,IAAK,KAAA,IAAS,EAAC,EAAG;AAC3B,IAAA,MAAM,IAAA,GAAO,QAAQ,CAAC,CAAA;AAEtB,IAAA,IAAI,CAAC,eAAA,CAAgB,IAAA,EAAM,IAAA,CAAK,IAAI,CAAA,EAAG;AACrC,MAAA;AAAA,IACF;AAGA,IAAA,IAAI,KAAK,OAAA,IAAW,CAAC,kBAAkB,IAAA,CAAK,OAAA,EAAS,MAAM,CAAA,EAAG;AAC5D,MAAA;AAAA,IACF;AAGA,IAAA,MAAM,YAAY,IAAA,CAAK,SAAA;AACvB,IAAA,IAAI,OAAO,cAAc,UAAA,EAAY;AACnC,MAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,OAAA,EAAQ,CACnC,IAAA,CAAK,MAAM,SAAA,CAAU,IAAI,CAAC,CAAA,CAC1B,KAAA,CAAM,MAAM,KAAK,CAAA;AAEpB,MAAA,IAAI,OAAA,EAAS;AACX,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF,CAAA,MAAA,IAAW,KAAK,KAAA,EAAO;AACrB,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF;AAGA,EAAA,OAAO,KAAA;AACT","file":"chunk-AAHPYUEC.cjs","sourcesContent":["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'],\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 pattern += '/' + tmp;\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 { MastraAuthConfig } from '@mastra/core/server';\n\nimport { defaultAuthConfig } from './defaults';\nimport { parse } from './path-pattern';\n\n/**\n * Check if a route is a registered custom route that requires authentication.\n * Returns true only if the route is explicitly registered with requiresAuth: true.\n * Returns false if the route is not in the config or has requiresAuth: false.\n */\nexport const isProtectedCustomRoute = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig) {\n return false;\n }\n\n // Check exact match first (fast path for static routes)\n const exactRouteKey = `${method}:${path}`;\n if (customRouteAuthConfig.has(exactRouteKey)) {\n return customRouteAuthConfig.get(exactRouteKey) === true;\n }\n\n // Check exact match for ALL method\n const allRouteKey = `ALL:${path}`;\n if (customRouteAuthConfig.has(allRouteKey)) {\n return customRouteAuthConfig.get(allRouteKey) === true;\n }\n\n // Check pattern matches for dynamic routes (e.g., '/users/:id')\n for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {\n const colonIndex = routeKey.indexOf(':');\n if (colonIndex === -1) {\n continue; // Skip malformed keys\n }\n\n const routeMethod = routeKey.substring(0, colonIndex);\n const routePattern = routeKey.substring(colonIndex + 1);\n\n // Check if method matches (exact match or ALL)\n if (routeMethod !== method && routeMethod !== 'ALL') {\n continue;\n }\n\n // Check if path matches the pattern\n if (pathMatchesPattern(path, routePattern)) {\n return requiresAuth === true;\n }\n }\n\n return false; // Not in config = not a protected custom route\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\nexport const isCustomRoutePublic = (\n path: string,\n method: string,\n customRouteAuthConfig?: Map<string, boolean>,\n): boolean => {\n if (!customRouteAuthConfig) {\n return false;\n }\n\n // Check exact match first (fast path for static routes)\n const exactRouteKey = `${method}:${path}`;\n if (customRouteAuthConfig.has(exactRouteKey)) {\n return !customRouteAuthConfig.get(exactRouteKey); // True when route opts out of auth\n }\n\n // Check exact match for ALL method\n const allRouteKey = `ALL:${path}`;\n if (customRouteAuthConfig.has(allRouteKey)) {\n return !customRouteAuthConfig.get(allRouteKey);\n }\n\n // Check pattern matches for dynamic routes (e.g., '/users/:id')\n for (const [routeKey, requiresAuth] of customRouteAuthConfig.entries()) {\n const colonIndex = routeKey.indexOf(':');\n if (colonIndex === -1) {\n continue; // Skip malformed keys\n }\n\n const routeMethod = routeKey.substring(0, colonIndex);\n const routePattern = routeKey.substring(colonIndex + 1);\n\n // Check if method matches (exact match or ALL)\n if (routeMethod !== method && routeMethod !== 'ALL') {\n continue;\n }\n\n // Check if path matches the pattern\n if (pathMatchesPattern(path, routePattern)) {\n return !requiresAuth; // True when route opts out of auth\n }\n }\n\n return false;\n};\n\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) || !isCustomRoutePublic(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// 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, check conditions\n const condition = rule.condition;\n if (typeof condition === 'function') {\n const allowed = await Promise.resolve()\n .then(() => condition(user))\n .catch(() => false);\n\n if (allowed) {\n return true;\n }\n } else if (rule.allow) {\n return true;\n }\n }\n\n // No matching rules, deny by default\n return false;\n};\n"]}