@mastra/server 1.58.0-alpha.12 → 1.58.0-alpha.14

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 (283) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/{a2a-B9X-RdWt.js → a2a-CUkzkdTZ.js} +2 -2
  3. package/dist/{a2a-B9X-RdWt.js.map → a2a-CUkzkdTZ.js.map} +1 -1
  4. package/dist/{a2a-D1t2fS2L.cjs → a2a-DzZHH3OH.cjs} +2 -2
  5. package/dist/{a2a-D1t2fS2L.cjs.map → a2a-DzZHH3OH.cjs.map} +1 -1
  6. package/dist/{api-schema-manifest-CFLB0MBA.cjs → api-schema-manifest-BPk3u4B-.cjs} +3 -3
  7. package/dist/{api-schema-manifest-CFLB0MBA.cjs.map → api-schema-manifest-BPk3u4B-.cjs.map} +1 -1
  8. package/dist/{api-schema-manifest-BLv_Z-sd.js → api-schema-manifest-DSelT9XK.js} +3 -3
  9. package/dist/{api-schema-manifest-BLv_Z-sd.js.map → api-schema-manifest-DSelT9XK.js.map} +1 -1
  10. package/dist/{background-tasks-Bzl2tNJq.js → background-tasks-BtWM0sZs.js} +2 -2
  11. package/dist/{background-tasks-Bzl2tNJq.js.map → background-tasks-BtWM0sZs.js.map} +1 -1
  12. package/dist/{background-tasks-DXns62Go.cjs → background-tasks-C5G2jJax.cjs} +2 -2
  13. package/dist/{background-tasks-DXns62Go.cjs.map → background-tasks-C5G2jJax.cjs.map} +1 -1
  14. package/dist/{builder-registry-QAeqpQKB.js → builder-registry-B8KyPAOP.js} +2 -2
  15. package/dist/{builder-registry-QAeqpQKB.js.map → builder-registry-B8KyPAOP.js.map} +1 -1
  16. package/dist/{builder-registry-CTQyg5l5.cjs → builder-registry-Dcou-kzd.cjs} +2 -2
  17. package/dist/{builder-registry-CTQyg5l5.cjs.map → builder-registry-Dcou-kzd.cjs.map} +1 -1
  18. package/dist/{channels-CPTIswT2.js → channels-B9yt3a2P.js} +2 -2
  19. package/dist/{channels-CPTIswT2.js.map → channels-B9yt3a2P.js.map} +1 -1
  20. package/dist/{channels-FoIf30Hv.cjs → channels-BRoq3VKR.cjs} +2 -2
  21. package/dist/{channels-FoIf30Hv.cjs.map → channels-BRoq3VKR.cjs.map} +1 -1
  22. package/dist/{dist-CzzxT_L5.js → dist-7r8jzEWH.js} +11 -11
  23. package/dist/dist-7r8jzEWH.js.map +1 -0
  24. package/dist/{dist-TkFPtpuy.cjs → dist-DEgLyP8h.cjs} +11 -11
  25. package/dist/dist-DEgLyP8h.cjs.map +1 -0
  26. package/dist/docs/SKILL.md +2 -1
  27. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  28. package/dist/docs/references/docs-server-custom-api-routes.md +375 -0
  29. package/dist/docs/references/reference-server-create-route.md +27 -1
  30. package/dist/{dynamic-workflows-CQs6_anZ.js → dynamic-workflows-B0TE8mjA.js} +2 -2
  31. package/dist/{dynamic-workflows-CQs6_anZ.js.map → dynamic-workflows-B0TE8mjA.js.map} +1 -1
  32. package/dist/{dynamic-workflows-CrvwGZj8.cjs → dynamic-workflows-C-6vmau5.cjs} +2 -2
  33. package/dist/{dynamic-workflows-CrvwGZj8.cjs.map → dynamic-workflows-C-6vmau5.cjs.map} +1 -1
  34. package/dist/{editor-builder-D5lhXbvj.js → editor-builder-Byg6wbi6.js} +2 -2
  35. package/dist/{editor-builder-D5lhXbvj.js.map → editor-builder-Byg6wbi6.js.map} +1 -1
  36. package/dist/{editor-builder-DG5-7x6V.cjs → editor-builder-DT7ypWfa.cjs} +2 -2
  37. package/dist/{editor-builder-DG5-7x6V.cjs.map → editor-builder-DT7ypWfa.cjs.map} +1 -1
  38. package/dist/{observability-new-endpoints-D4AWoyDe.cjs → observability-new-endpoints-BC-dasRY.cjs} +2 -2
  39. package/dist/{observability-new-endpoints-D4AWoyDe.cjs.map → observability-new-endpoints-BC-dasRY.cjs.map} +1 -1
  40. package/dist/{observability-new-endpoints-6HLxLS-H.js → observability-new-endpoints-Drx0C8uc.js} +2 -2
  41. package/dist/{observability-new-endpoints-6HLxLS-H.js.map → observability-new-endpoints-Drx0C8uc.js.map} +1 -1
  42. package/dist/{route-builder-BBovb2TE.cjs → route-builder-BAAedfru.cjs} +10 -1
  43. package/dist/{route-builder-BBovb2TE.cjs.map → route-builder-BAAedfru.cjs.map} +1 -1
  44. package/dist/{route-builder-CQkb7tQY.js → route-builder-YQ_gLIvW.js} +10 -1
  45. package/dist/{route-builder-CQkb7tQY.js.map → route-builder-YQ_gLIvW.js.map} +1 -1
  46. package/dist/{routes-CzvDlbRt.cjs → routes-0BEh3stO.cjs} +10 -10
  47. package/dist/{routes-CzvDlbRt.cjs.map → routes-0BEh3stO.cjs.map} +1 -1
  48. package/dist/{routes-D_-O6SS5.js → routes-BsMPy5bu.js} +10 -10
  49. package/dist/{routes-D_-O6SS5.js.map → routes-BsMPy5bu.js.map} +1 -1
  50. package/dist/{schedules-CfNABln2.cjs → schedules-DOK225ZZ.cjs} +2 -2
  51. package/dist/{schedules-CfNABln2.cjs.map → schedules-DOK225ZZ.cjs.map} +1 -1
  52. package/dist/{schedules-DSkYO_Nl.js → schedules-RjPcNOmY.js} +2 -2
  53. package/dist/{schedules-DSkYO_Nl.js.map → schedules-RjPcNOmY.js.map} +1 -1
  54. package/dist/server/handlers/a2a.cjs +1 -1
  55. package/dist/server/handlers/a2a.d.ts +545 -505
  56. package/dist/server/handlers/a2a.d.ts.map +1 -1
  57. package/dist/server/handlers/a2a.js +1 -1
  58. package/dist/server/handlers/agent-builder.cjs +2 -2
  59. package/dist/server/handlers/agent-builder.d.ts +1069 -764
  60. package/dist/server/handlers/agent-builder.d.ts.map +1 -1
  61. package/dist/server/handlers/agent-builder.js +2 -2
  62. package/dist/server/handlers/agent-controller.cjs +1 -1
  63. package/dist/server/handlers/agent-controller.d.ts +1547 -893
  64. package/dist/server/handlers/agent-controller.d.ts.map +1 -1
  65. package/dist/server/handlers/agent-controller.js +1 -1
  66. package/dist/server/handlers/agent-versions.cjs +1 -1
  67. package/dist/server/handlers/agent-versions.d.ts +8476 -8356
  68. package/dist/server/handlers/agent-versions.d.ts.map +1 -1
  69. package/dist/server/handlers/agent-versions.js +1 -1
  70. package/dist/server/handlers/agents.cjs +1 -1
  71. package/dist/server/handlers/agents.d.ts +9502 -9386
  72. package/dist/server/handlers/agents.d.ts.map +1 -1
  73. package/dist/server/handlers/agents.js +1 -1
  74. package/dist/server/handlers/auth.cjs +1 -1
  75. package/dist/server/handlers/auth.d.ts +693 -297
  76. package/dist/server/handlers/auth.d.ts.map +1 -1
  77. package/dist/server/handlers/auth.js +1 -1
  78. package/dist/server/handlers/background-tasks.cjs +1 -1
  79. package/dist/server/handlers/background-tasks.d.ts +190 -130
  80. package/dist/server/handlers/background-tasks.d.ts.map +1 -1
  81. package/dist/server/handlers/background-tasks.js +1 -1
  82. package/dist/server/handlers/builder-registry.cjs +1 -1
  83. package/dist/server/handlers/builder-registry.d.ts +218 -121
  84. package/dist/server/handlers/builder-registry.d.ts.map +1 -1
  85. package/dist/server/handlers/builder-registry.js +1 -1
  86. package/dist/server/handlers/channels.cjs +1 -1
  87. package/dist/server/handlers/channels.d.ts +157 -77
  88. package/dist/server/handlers/channels.d.ts.map +1 -1
  89. package/dist/server/handlers/channels.js +1 -1
  90. package/dist/server/handlers/conversations.cjs +1 -1
  91. package/dist/server/handlers/conversations.d.ts +221 -141
  92. package/dist/server/handlers/conversations.d.ts.map +1 -1
  93. package/dist/server/handlers/conversations.js +1 -1
  94. package/dist/server/handlers/datasets.cjs +1 -1
  95. package/dist/server/handlers/datasets.d.ts +2669 -2234
  96. package/dist/server/handlers/datasets.d.ts.map +1 -1
  97. package/dist/server/handlers/datasets.js +1 -1
  98. package/dist/server/handlers/dynamic-workflows.cjs +1 -1
  99. package/dist/server/handlers/dynamic-workflows.d.ts +506 -426
  100. package/dist/server/handlers/dynamic-workflows.d.ts.map +1 -1
  101. package/dist/server/handlers/dynamic-workflows.js +1 -1
  102. package/dist/server/handlers/editor-builder.cjs +1 -1
  103. package/dist/server/handlers/editor-builder.d.ts +305 -245
  104. package/dist/server/handlers/editor-builder.d.ts.map +1 -1
  105. package/dist/server/handlers/editor-builder.js +1 -1
  106. package/dist/server/handlers/favorites-enrichment.cjs +1 -1
  107. package/dist/server/handlers/favorites-enrichment.js +1 -1
  108. package/dist/server/handlers/logs.cjs +1 -1
  109. package/dist/server/handlers/logs.d.ts +245 -185
  110. package/dist/server/handlers/logs.d.ts.map +1 -1
  111. package/dist/server/handlers/logs.js +1 -1
  112. package/dist/server/handlers/mcp-client-versions.cjs +1 -1
  113. package/dist/server/handlers/mcp-client-versions.d.ts +447 -307
  114. package/dist/server/handlers/mcp-client-versions.d.ts.map +1 -1
  115. package/dist/server/handlers/mcp-client-versions.js +1 -1
  116. package/dist/server/handlers/mcp.cjs +1 -1
  117. package/dist/server/handlers/mcp.d.ts +357 -156
  118. package/dist/server/handlers/mcp.d.ts.map +1 -1
  119. package/dist/server/handlers/mcp.js +1 -1
  120. package/dist/server/handlers/memory.cjs +1 -1
  121. package/dist/server/handlers/memory.d.ts +1723 -1223
  122. package/dist/server/handlers/memory.d.ts.map +1 -1
  123. package/dist/server/handlers/memory.js +1 -1
  124. package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
  125. package/dist/server/handlers/observability-new-endpoints.d.ts +3239 -2158
  126. package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
  127. package/dist/server/handlers/observability-new-endpoints.js +1 -1
  128. package/dist/server/handlers/observability-shared.cjs +1 -1
  129. package/dist/server/handlers/observability-shared.js +1 -1
  130. package/dist/server/handlers/observability.cjs +2 -2
  131. package/dist/server/handlers/observability.d.ts +267 -149
  132. package/dist/server/handlers/observability.d.ts.map +1 -1
  133. package/dist/server/handlers/observability.js +2 -2
  134. package/dist/server/handlers/processor-providers.cjs +1 -1
  135. package/dist/server/handlers/processor-providers.d.ts +74 -34
  136. package/dist/server/handlers/processor-providers.d.ts.map +1 -1
  137. package/dist/server/handlers/processor-providers.js +1 -1
  138. package/dist/server/handlers/processors.cjs +1 -1
  139. package/dist/server/handlers/processors.d.ts +222 -173
  140. package/dist/server/handlers/processors.d.ts.map +1 -1
  141. package/dist/server/handlers/processors.js +1 -1
  142. package/dist/server/handlers/prompt-block-versions.cjs +1 -1
  143. package/dist/server/handlers/prompt-block-versions.d.ts +646 -506
  144. package/dist/server/handlers/prompt-block-versions.d.ts.map +1 -1
  145. package/dist/server/handlers/prompt-block-versions.js +1 -1
  146. package/dist/server/handlers/responses.cjs +1 -1
  147. package/dist/server/handlers/responses.d.ts +352 -362
  148. package/dist/server/handlers/responses.d.ts.map +1 -1
  149. package/dist/server/handlers/responses.js +1 -1
  150. package/dist/server/handlers/schedules.cjs +1 -1
  151. package/dist/server/handlers/schedules.d.ts +1190 -1028
  152. package/dist/server/handlers/schedules.d.ts.map +1 -1
  153. package/dist/server/handlers/schedules.js +1 -1
  154. package/dist/server/handlers/scorer-versions.cjs +1 -1
  155. package/dist/server/handlers/scorer-versions.d.ts +551 -411
  156. package/dist/server/handlers/scorer-versions.d.ts.map +1 -1
  157. package/dist/server/handlers/scorer-versions.js +1 -1
  158. package/dist/server/handlers/scores.cjs +1 -1
  159. package/dist/server/handlers/scores.d.ts +287 -167
  160. package/dist/server/handlers/scores.d.ts.map +1 -1
  161. package/dist/server/handlers/scores.js +1 -1
  162. package/dist/server/handlers/stored-agent-favorites.cjs +2 -2
  163. package/dist/server/handlers/stored-agent-favorites.d.ts +62 -22
  164. package/dist/server/handlers/stored-agent-favorites.d.ts.map +1 -1
  165. package/dist/server/handlers/stored-agent-favorites.js +2 -2
  166. package/dist/server/handlers/stored-agents.cjs +2 -2
  167. package/dist/server/handlers/stored-agents.d.ts +12248 -16428
  168. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  169. package/dist/server/handlers/stored-agents.js +2 -2
  170. package/dist/server/handlers/stored-mcp-clients.cjs +1 -1
  171. package/dist/server/handlers/stored-mcp-clients.d.ts +417 -324
  172. package/dist/server/handlers/stored-mcp-clients.d.ts.map +1 -1
  173. package/dist/server/handlers/stored-mcp-clients.js +1 -1
  174. package/dist/server/handlers/stored-prompt-blocks.cjs +1 -1
  175. package/dist/server/handlers/stored-prompt-blocks.d.ts +603 -555
  176. package/dist/server/handlers/stored-prompt-blocks.d.ts.map +1 -1
  177. package/dist/server/handlers/stored-prompt-blocks.js +1 -1
  178. package/dist/server/handlers/stored-scorers.cjs +1 -1
  179. package/dist/server/handlers/stored-scorers.d.ts +556 -472
  180. package/dist/server/handlers/stored-scorers.d.ts.map +1 -1
  181. package/dist/server/handlers/stored-scorers.js +1 -1
  182. package/dist/server/handlers/stored-skill-favorites.cjs +2 -2
  183. package/dist/server/handlers/stored-skill-favorites.d.ts +62 -22
  184. package/dist/server/handlers/stored-skill-favorites.d.ts.map +1 -1
  185. package/dist/server/handlers/stored-skill-favorites.js +2 -2
  186. package/dist/server/handlers/stored-skills.cjs +2 -2
  187. package/dist/server/handlers/stored-skills.d.ts +632 -515
  188. package/dist/server/handlers/stored-skills.d.ts.map +1 -1
  189. package/dist/server/handlers/stored-skills.js +2 -2
  190. package/dist/server/handlers/stored-workspaces.cjs +1 -1
  191. package/dist/server/handlers/stored-workspaces.d.ts +646 -546
  192. package/dist/server/handlers/stored-workspaces.d.ts.map +1 -1
  193. package/dist/server/handlers/stored-workspaces.js +1 -1
  194. package/dist/server/handlers/system.cjs +2 -2
  195. package/dist/server/handlers/system.d.ts +146 -106
  196. package/dist/server/handlers/system.d.ts.map +1 -1
  197. package/dist/server/handlers/system.js +2 -2
  198. package/dist/server/handlers/tool-providers.cjs +1 -1
  199. package/dist/server/handlers/tool-providers.d.ts +580 -331
  200. package/dist/server/handlers/tool-providers.d.ts.map +1 -1
  201. package/dist/server/handlers/tool-providers.js +1 -1
  202. package/dist/server/handlers/tools.cjs +1 -1
  203. package/dist/server/handlers/tools.d.ts +177 -77
  204. package/dist/server/handlers/tools.d.ts.map +1 -1
  205. package/dist/server/handlers/tools.js +1 -1
  206. package/dist/server/handlers/vector.cjs +1 -1
  207. package/dist/server/handlers/vector.d.ts +282 -126
  208. package/dist/server/handlers/vector.d.ts.map +1 -1
  209. package/dist/server/handlers/vector.js +1 -1
  210. package/dist/server/handlers/workflows.cjs +1 -1
  211. package/dist/server/handlers/workflows.d.ts +1703 -1181
  212. package/dist/server/handlers/workflows.d.ts.map +1 -1
  213. package/dist/server/handlers/workflows.js +1 -1
  214. package/dist/server/handlers/workspace.cjs +1 -1
  215. package/dist/server/handlers/workspace.d.ts +1936 -1150
  216. package/dist/server/handlers/workspace.d.ts.map +1 -1
  217. package/dist/server/handlers/workspace.js +1 -1
  218. package/dist/server/handlers.cjs +2 -2
  219. package/dist/server/handlers.js +2 -2
  220. package/dist/server/server-adapter/index.cjs +27 -6
  221. package/dist/server/server-adapter/index.cjs.map +1 -1
  222. package/dist/server/server-adapter/index.d.ts +14 -1
  223. package/dist/server/server-adapter/index.d.ts.map +1 -1
  224. package/dist/server/server-adapter/index.js +27 -6
  225. package/dist/server/server-adapter/index.js.map +1 -1
  226. package/dist/server/server-adapter/openapi-utils.d.ts.map +1 -1
  227. package/dist/server/server-adapter/routes/a2a.d.ts +544 -504
  228. package/dist/server/server-adapter/routes/a2a.d.ts.map +1 -1
  229. package/dist/server/server-adapter/routes/agent-builder.d.ts +1054 -749
  230. package/dist/server/server-adapter/routes/agent-builder.d.ts.map +1 -1
  231. package/dist/server/server-adapter/routes/channels.d.ts +153 -73
  232. package/dist/server/server-adapter/routes/channels.d.ts.map +1 -1
  233. package/dist/server/server-adapter/routes/conversations.d.ts +218 -138
  234. package/dist/server/server-adapter/routes/conversations.d.ts.map +1 -1
  235. package/dist/server/server-adapter/routes/datasets.d.ts +2312 -1877
  236. package/dist/server/server-adapter/routes/datasets.d.ts.map +1 -1
  237. package/dist/server/server-adapter/routes/editor-builder.d.ts +506 -349
  238. package/dist/server/server-adapter/routes/editor-builder.d.ts.map +1 -1
  239. package/dist/server/server-adapter/routes/legacy.d.ts +615 -629
  240. package/dist/server/server-adapter/routes/legacy.d.ts.map +1 -1
  241. package/dist/server/server-adapter/routes/logs.d.ts +243 -183
  242. package/dist/server/server-adapter/routes/logs.d.ts.map +1 -1
  243. package/dist/server/server-adapter/routes/mcp.d.ts +347 -147
  244. package/dist/server/server-adapter/routes/mcp.d.ts.map +1 -1
  245. package/dist/server/server-adapter/routes/memory.d.ts +1699 -1199
  246. package/dist/server/server-adapter/routes/memory.d.ts.map +1 -1
  247. package/dist/server/server-adapter/routes/observability.d.ts +2761 -2103
  248. package/dist/server/server-adapter/routes/observability.d.ts.map +1 -1
  249. package/dist/server/server-adapter/routes/processor-providers.d.ts +70 -30
  250. package/dist/server/server-adapter/routes/processor-providers.d.ts.map +1 -1
  251. package/dist/server/server-adapter/routes/processors.d.ts +220 -171
  252. package/dist/server/server-adapter/routes/processors.d.ts.map +1 -1
  253. package/dist/server/server-adapter/routes/responses.d.ts +350 -360
  254. package/dist/server/server-adapter/routes/responses.d.ts.map +1 -1
  255. package/dist/server/server-adapter/routes/route-builder.d.ts +6 -2
  256. package/dist/server/server-adapter/routes/route-builder.d.ts.map +1 -1
  257. package/dist/server/server-adapter/routes/scorers.d.ts +282 -162
  258. package/dist/server/server-adapter/routes/scorers.d.ts.map +1 -1
  259. package/dist/server/server-adapter/routes/stored-mcp-clients.d.ts +821 -588
  260. package/dist/server/server-adapter/routes/stored-mcp-clients.d.ts.map +1 -1
  261. package/dist/server/server-adapter/routes/stored-prompt-blocks.d.ts +1252 -1064
  262. package/dist/server/server-adapter/routes/stored-prompt-blocks.d.ts.map +1 -1
  263. package/dist/server/server-adapter/routes/stored-scorers.d.ts +1046 -822
  264. package/dist/server/server-adapter/routes/stored-scorers.d.ts.map +1 -1
  265. package/dist/server/server-adapter/routes/stored-skills.d.ts +683 -526
  266. package/dist/server/server-adapter/routes/stored-skills.d.ts.map +1 -1
  267. package/dist/server/server-adapter/routes/stored-workspaces.d.ts +637 -537
  268. package/dist/server/server-adapter/routes/stored-workspaces.d.ts.map +1 -1
  269. package/dist/server/server-adapter/routes/system.d.ts +145 -105
  270. package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
  271. package/dist/server/server-adapter/routes/tool-providers.d.ts +566 -317
  272. package/dist/server/server-adapter/routes/tool-providers.d.ts.map +1 -1
  273. package/dist/server/server-adapter/routes/tools.d.ts +103 -43
  274. package/dist/server/server-adapter/routes/tools.d.ts.map +1 -1
  275. package/dist/server/server-adapter/routes/vectors.d.ts +275 -119
  276. package/dist/server/server-adapter/routes/vectors.d.ts.map +1 -1
  277. package/dist/server/server-adapter/routes/workflows.d.ts +1586 -1104
  278. package/dist/server/server-adapter/routes/workflows.d.ts.map +1 -1
  279. package/dist/server/server-adapter/routes/workspace.d.ts +1026 -613
  280. package/dist/server/server-adapter/routes/workspace.d.ts.map +1 -1
  281. package/package.json +6 -6
  282. package/dist/dist-CzzxT_L5.js.map +0 -1
  283. package/dist/dist-TkFPtpuy.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"channels-CPTIswT2.js","names":[],"sources":["../src/server/schemas/channels.ts","../src/server/handlers/channels.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const channelPlatformPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n});\n\nexport const channelAgentPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n agentId: z.string().describe('Agent identifier'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nexport const connectChannelBodySchema = z.object({\n agentId: z.string().describe('Agent identifier to connect'),\n options: z.record(z.string(), z.unknown()).optional().describe('Platform-specific connection options'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nconst channelPlatformInfoSchema = z.object({\n id: z.string().describe('Platform identifier'),\n name: z.string().describe('Human-readable platform name'),\n isConfigured: z.boolean().describe('Whether the platform is ready to connect agents'),\n connectOptionsSchema: z.record(z.string(), z.unknown()).optional().describe('JSON Schema for connect options'),\n});\n\nconst channelInstallationInfoSchema = z.object({\n id: z.string().describe('Installation identifier'),\n platform: z.string().describe('Platform identifier'),\n agentId: z.string().describe('Connected agent identifier'),\n status: z.enum(['active', 'pending']).describe('Installation status'),\n displayName: z.string().optional().describe('Platform-specific display name'),\n installedAt: z.coerce.date().optional().describe('Installation timestamp'),\n});\n\nconst channelConnectOAuthSchema = z.object({\n type: z.literal('oauth').describe('OAuth-based connection requiring browser redirect'),\n authorizationUrl: z.string().describe('OAuth authorization URL for user redirect'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectDeepLinkSchema = z.object({\n type: z.literal('deep_link').describe('Deep-link connection requiring native app interaction'),\n url: z.string().describe('Deep link URL to open in platform app'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectImmediateSchema = z.object({\n type: z.literal('immediate').describe('Immediate connection with no user interaction needed'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectResultSchema = z.discriminatedUnion('type', [\n channelConnectOAuthSchema,\n channelConnectDeepLinkSchema,\n channelConnectImmediateSchema,\n]);\n\nexport const listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);\n\nexport const listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);\n\nexport const connectChannelResponseSchema = channelConnectResultSchema;\n\nexport const disconnectChannelResponseSchema = z.object({\n success: z.boolean(),\n});\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\nimport type { RequestContext } from '@mastra/core/di';\nimport { coreFeatures } from '@mastra/core/features';\n\nimport { MASTRA_USER_KEY } from '../constants';\nimport { HTTPException } from '../http-exception';\nimport {\n channelPlatformPathParams,\n channelAgentPathParams,\n connectChannelBodySchema,\n listChannelPlatformsResponseSchema,\n listChannelInstallationsResponseSchema,\n connectChannelResponseSchema,\n disconnectChannelResponseSchema,\n} from '../schemas/channels';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { assertWriteAccess, getCallerAuthorId, hasAdminBypass, hasScopedPermission } from './authorship';\nimport { handleError } from './error';\n\n// ============================================================================\n// Feature gate + helpers\n// ============================================================================\n\nfunction assertChannelsAvailable(): void {\n if (!coreFeatures.has('channels')) {\n throw new HTTPException(501, { message: 'Channels require a newer version of @mastra/core' });\n }\n}\n\nfunction getChannelOrThrow(mastra: Mastra, platform: string): ChannelProvider {\n const channels = Object.values(mastra.channels ?? {});\n const channel = channels.find(c => c.id === platform);\n if (!channel) {\n const available = channels.map(c => c.id).join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\n/**\n * Unified connect/disconnect authorization.\n *\n * - Stored agent exists → same write access as editing the agent record.\n * - Code-defined agent (no stored record) → route's `requiresAuth` is the gate.\n * - Agent doesn't exist anywhere:\n * - connect → 404 (can't connect a channel to a non-existent agent)\n * - disconnect → orphan cleanup, gated on `channels:write`\n */\nasync function assertChannelAgentWriteAccess(\n mastra: Mastra,\n requestContext: RequestContext,\n agentId: string,\n action: 'connect' | 'disconnect',\n): Promise<void> {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : null;\n const stored = agentsStore ? await agentsStore.getById(agentId) : null;\n\n if (stored) {\n assertWriteAccess({\n requestContext,\n resource: 'agents',\n resourceId: agentId,\n action: 'edit',\n record: stored,\n });\n return;\n }\n\n // Not in stored-agents (or storage doesn't support it). Check the runtime\n // registry for a code-defined agent.\n const codeDefined = mastra.getAgentById(agentId);\n if (codeDefined) {\n // Code-defined agents have no owner/ACL — route's requiresAuth /\n // requiresPermission is the gate. Pass-through.\n return;\n }\n\n if (action === 'connect') {\n throw new HTTPException(404, { message: `Agent \"${agentId}\" not found` });\n }\n\n // Disconnect against an unknown agentId = orphan cleanup (stored agent was\n // deleted but the channel installation row is still around). Allow it, but\n // gate on channels:write so this isn't an \"any authenticated user\" backdoor.\n // Follow the same no-auth-configured pass-through as assertWriteAccess.\n const callerAuthorId = getCallerAuthorId(requestContext);\n if (!callerAuthorId && !requestContext.get(MASTRA_USER_KEY)) return;\n if (hasAdminBypass(requestContext, 'channels')) return;\n if (hasScopedPermission({ requestContext, resource: 'channels', action: 'write' })) return;\n\n throw new HTTPException(404, { message: 'Not found' });\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /channels/platforms - List available channel platforms\n */\nexport const LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/platforms',\n responseType: 'json',\n responseSchema: listChannelPlatformsResponseSchema,\n summary: 'List channel platforms',\n description: 'Returns available channel platforms and their configuration status',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n assertChannelsAvailable();\n try {\n const channels = Object.values(mastra.channels ?? {});\n return channels.map(channel => {\n if (channel.getInfo) {\n return channel.getInfo();\n }\n return {\n id: channel.id,\n name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),\n isConfigured: true,\n };\n });\n } catch (error) {\n return handleError(error, 'Error listing channel platforms');\n }\n },\n});\n\n/**\n * GET /channels/:platform/installations - List installations for a platform\n */\nexport const LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/:platform/installations',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n responseSchema: listChannelInstallationsResponseSchema,\n summary: 'List channel installations',\n description: 'Returns all active and pending installations for a channel platform',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, platform }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.listInstallations) {\n return [];\n }\n\n return await channel.listInstallations();\n } catch (error) {\n return handleError(error, 'Error listing channel installations');\n }\n },\n});\n\n/**\n * POST /channels/:platform/connect - Connect an agent to a platform\n */\nexport const CONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/connect',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n bodySchema: connectChannelBodySchema,\n responseSchema: connectChannelResponseSchema,\n summary: 'Connect agent to channel',\n description: 'Creates a platform app for the agent and returns an OAuth authorization URL',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.connect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic connection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n return await channel.connect(agentId, options);\n } catch (error) {\n return handleError(error, 'Error connecting agent to channel');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/disconnect',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: disconnectChannelResponseSchema,\n summary: 'Disconnect agent from channel',\n description: 'Deletes the platform app and cleans up the installation',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.disconnect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic disconnection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');\n\n await channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error disconnecting agent from channel');\n }\n },\n});\n"],"mappings":";;;;;;;;AAMA,MAAa,4BAA4B,EAAE,OAAO,EAChD,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C,EAC7E,CAAC;AAED,MAAa,yBAAyB,EAAE,OAAO;CAC7C,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C;CAC3E,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,kBAAkB;AACjD,CAAC;AAMD,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../src/server/handlers/channels.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const channelPlatformPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n});\n\nexport const channelAgentPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n agentId: z.string().describe('Agent identifier'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nexport const connectChannelBodySchema = z.object({\n agentId: z.string().describe('Agent identifier to connect'),\n options: z.record(z.string(), z.unknown()).optional().describe('Platform-specific connection options'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nconst channelPlatformInfoSchema = z.object({\n id: z.string().describe('Platform identifier'),\n name: z.string().describe('Human-readable platform name'),\n isConfigured: z.boolean().describe('Whether the platform is ready to connect agents'),\n connectOptionsSchema: z.record(z.string(), z.unknown()).optional().describe('JSON Schema for connect options'),\n});\n\nconst channelInstallationInfoSchema = z.object({\n id: z.string().describe('Installation identifier'),\n platform: z.string().describe('Platform identifier'),\n agentId: z.string().describe('Connected agent identifier'),\n status: z.enum(['active', 'pending']).describe('Installation status'),\n displayName: z.string().optional().describe('Platform-specific display name'),\n installedAt: z.coerce.date().optional().describe('Installation timestamp'),\n});\n\nconst channelConnectOAuthSchema = z.object({\n type: z.literal('oauth').describe('OAuth-based connection requiring browser redirect'),\n authorizationUrl: z.string().describe('OAuth authorization URL for user redirect'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectDeepLinkSchema = z.object({\n type: z.literal('deep_link').describe('Deep-link connection requiring native app interaction'),\n url: z.string().describe('Deep link URL to open in platform app'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectImmediateSchema = z.object({\n type: z.literal('immediate').describe('Immediate connection with no user interaction needed'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectResultSchema = z.discriminatedUnion('type', [\n channelConnectOAuthSchema,\n channelConnectDeepLinkSchema,\n channelConnectImmediateSchema,\n]);\n\nexport const listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);\n\nexport const listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);\n\nexport const connectChannelResponseSchema = channelConnectResultSchema;\n\nexport const disconnectChannelResponseSchema = z.object({\n success: z.boolean(),\n});\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\nimport type { RequestContext } from '@mastra/core/di';\nimport { coreFeatures } from '@mastra/core/features';\n\nimport { MASTRA_USER_KEY } from '../constants';\nimport { HTTPException } from '../http-exception';\nimport {\n channelPlatformPathParams,\n channelAgentPathParams,\n connectChannelBodySchema,\n listChannelPlatformsResponseSchema,\n listChannelInstallationsResponseSchema,\n connectChannelResponseSchema,\n disconnectChannelResponseSchema,\n} from '../schemas/channels';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { assertWriteAccess, getCallerAuthorId, hasAdminBypass, hasScopedPermission } from './authorship';\nimport { handleError } from './error';\n\n// ============================================================================\n// Feature gate + helpers\n// ============================================================================\n\nfunction assertChannelsAvailable(): void {\n if (!coreFeatures.has('channels')) {\n throw new HTTPException(501, { message: 'Channels require a newer version of @mastra/core' });\n }\n}\n\nfunction getChannelOrThrow(mastra: Mastra, platform: string): ChannelProvider {\n const channels = Object.values(mastra.channels ?? {});\n const channel = channels.find(c => c.id === platform);\n if (!channel) {\n const available = channels.map(c => c.id).join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\n/**\n * Unified connect/disconnect authorization.\n *\n * - Stored agent exists → same write access as editing the agent record.\n * - Code-defined agent (no stored record) → route's `requiresAuth` is the gate.\n * - Agent doesn't exist anywhere:\n * - connect → 404 (can't connect a channel to a non-existent agent)\n * - disconnect → orphan cleanup, gated on `channels:write`\n */\nasync function assertChannelAgentWriteAccess(\n mastra: Mastra,\n requestContext: RequestContext,\n agentId: string,\n action: 'connect' | 'disconnect',\n): Promise<void> {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : null;\n const stored = agentsStore ? await agentsStore.getById(agentId) : null;\n\n if (stored) {\n assertWriteAccess({\n requestContext,\n resource: 'agents',\n resourceId: agentId,\n action: 'edit',\n record: stored,\n });\n return;\n }\n\n // Not in stored-agents (or storage doesn't support it). Check the runtime\n // registry for a code-defined agent.\n const codeDefined = mastra.getAgentById(agentId);\n if (codeDefined) {\n // Code-defined agents have no owner/ACL — route's requiresAuth /\n // requiresPermission is the gate. Pass-through.\n return;\n }\n\n if (action === 'connect') {\n throw new HTTPException(404, { message: `Agent \"${agentId}\" not found` });\n }\n\n // Disconnect against an unknown agentId = orphan cleanup (stored agent was\n // deleted but the channel installation row is still around). Allow it, but\n // gate on channels:write so this isn't an \"any authenticated user\" backdoor.\n // Follow the same no-auth-configured pass-through as assertWriteAccess.\n const callerAuthorId = getCallerAuthorId(requestContext);\n if (!callerAuthorId && !requestContext.get(MASTRA_USER_KEY)) return;\n if (hasAdminBypass(requestContext, 'channels')) return;\n if (hasScopedPermission({ requestContext, resource: 'channels', action: 'write' })) return;\n\n throw new HTTPException(404, { message: 'Not found' });\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /channels/platforms - List available channel platforms\n */\nexport const LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/platforms',\n responseType: 'json',\n responseSchema: listChannelPlatformsResponseSchema,\n summary: 'List channel platforms',\n description: 'Returns available channel platforms and their configuration status',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n assertChannelsAvailable();\n try {\n const channels = Object.values(mastra.channels ?? {});\n return channels.map(channel => {\n if (channel.getInfo) {\n return channel.getInfo();\n }\n return {\n id: channel.id,\n name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),\n isConfigured: true,\n };\n });\n } catch (error) {\n return handleError(error, 'Error listing channel platforms');\n }\n },\n});\n\n/**\n * GET /channels/:platform/installations - List installations for a platform\n */\nexport const LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/:platform/installations',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n responseSchema: listChannelInstallationsResponseSchema,\n summary: 'List channel installations',\n description: 'Returns all active and pending installations for a channel platform',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, platform }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.listInstallations) {\n return [];\n }\n\n return await channel.listInstallations();\n } catch (error) {\n return handleError(error, 'Error listing channel installations');\n }\n },\n});\n\n/**\n * POST /channels/:platform/connect - Connect an agent to a platform\n */\nexport const CONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/connect',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n bodySchema: connectChannelBodySchema,\n responseSchema: connectChannelResponseSchema,\n summary: 'Connect agent to channel',\n description: 'Creates a platform app for the agent and returns an OAuth authorization URL',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.connect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic connection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n return await channel.connect(agentId, options);\n } catch (error) {\n return handleError(error, 'Error connecting agent to channel');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/disconnect',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: disconnectChannelResponseSchema,\n summary: 'Disconnect agent from channel',\n description: 'Deletes the platform app and cleans up the installation',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.disconnect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic disconnection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');\n\n await channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error disconnecting agent from channel');\n }\n },\n});\n"],"mappings":";;;;;;;;AAMA,MAAa,4BAA4B,EAAE,OAAO,EAChD,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C,EAC7E,CAAC;AAED,MAAa,yBAAyB,EAAE,OAAO;CAC7C,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C;CAC3E,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,kBAAkB;AACjD,CAAC;AAMD,MAAa,2BAA2B,EAAE,OAAO;CAC/C,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,6BAA6B;CAC1D,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,sCAAsC;AACvG,CAAC;AAMD,MAAM,4BAA4B,EAAE,OAAO;CACzC,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,qBAAqB;CAC7C,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,8BAA8B;CACxD,cAAc,EAAE,QAAQ,CAAC,CAAC,SAAS,iDAAiD;CACpF,sBAAsB,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,iCAAiC;AAC/G,CAAC;AAED,MAAM,gCAAgC,EAAE,OAAO;CAC7C,IAAI,EAAE,OAAO,CAAC,CAAC,SAAS,yBAAyB;CACjD,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,qBAAqB;CACnD,SAAS,EAAE,OAAO,CAAC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;CACR,MAAM;CACN,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,UAAU;CACjB,cAAc;CACd,SAAS,OAAO,EAAE,QAAQ,gBAAgB,UAAU,cAAc;EAChE,wBAAwB;EACxB,IAAI;GACF,MAAM,UAAU,kBAAkB,QAAQ,QAAQ;GAElD,IAAI,CAAC,QAAQ,YACX,MAAM,IAAI,cAAc,KAAK,EAC3B,SAAS,YAAY,SAAS,+CAChC,CAAC;GAGH,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,YAAY;GAEjF,MAAM,QAAQ,WAAW,OAAO;GAChC,OAAO,EAAE,SAAS,KAAK;EACzB,SAAS,OAAO;GACd,OAAO,YAAY,OAAO,wCAAwC;EACpE;CACF;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  const require_http_exception = require("./http-exception-CKDHupKw.cjs");
2
- const require_route_builder = require("./route-builder-BBovb2TE.cjs");
2
+ const require_route_builder = require("./route-builder-BAAedfru.cjs");
3
3
  require("./constants-ChBaIptn.cjs");
4
4
  const require_server_handlers_error = require("./server/handlers/error.cjs");
5
5
  const require_server_handlers_authorship = require("./server/handlers/authorship.cjs");
@@ -227,4 +227,4 @@ Object.defineProperty(exports, "LIST_CHANNEL_PLATFORMS_ROUTE", {
227
227
  }
228
228
  });
229
229
 
230
- //# sourceMappingURL=channels-FoIf30Hv.cjs.map
230
+ //# sourceMappingURL=channels-BRoq3VKR.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"channels-FoIf30Hv.cjs","names":["z","coreFeatures","HTTPException","getCallerAuthorId","hasAdminBypass","hasScopedPermission","createRoute","handleError"],"sources":["../src/server/schemas/channels.ts","../src/server/handlers/channels.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const channelPlatformPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n});\n\nexport const channelAgentPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n agentId: z.string().describe('Agent identifier'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nexport const connectChannelBodySchema = z.object({\n agentId: z.string().describe('Agent identifier to connect'),\n options: z.record(z.string(), z.unknown()).optional().describe('Platform-specific connection options'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nconst channelPlatformInfoSchema = z.object({\n id: z.string().describe('Platform identifier'),\n name: z.string().describe('Human-readable platform name'),\n isConfigured: z.boolean().describe('Whether the platform is ready to connect agents'),\n connectOptionsSchema: z.record(z.string(), z.unknown()).optional().describe('JSON Schema for connect options'),\n});\n\nconst channelInstallationInfoSchema = z.object({\n id: z.string().describe('Installation identifier'),\n platform: z.string().describe('Platform identifier'),\n agentId: z.string().describe('Connected agent identifier'),\n status: z.enum(['active', 'pending']).describe('Installation status'),\n displayName: z.string().optional().describe('Platform-specific display name'),\n installedAt: z.coerce.date().optional().describe('Installation timestamp'),\n});\n\nconst channelConnectOAuthSchema = z.object({\n type: z.literal('oauth').describe('OAuth-based connection requiring browser redirect'),\n authorizationUrl: z.string().describe('OAuth authorization URL for user redirect'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectDeepLinkSchema = z.object({\n type: z.literal('deep_link').describe('Deep-link connection requiring native app interaction'),\n url: z.string().describe('Deep link URL to open in platform app'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectImmediateSchema = z.object({\n type: z.literal('immediate').describe('Immediate connection with no user interaction needed'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectResultSchema = z.discriminatedUnion('type', [\n channelConnectOAuthSchema,\n channelConnectDeepLinkSchema,\n channelConnectImmediateSchema,\n]);\n\nexport const listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);\n\nexport const listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);\n\nexport const connectChannelResponseSchema = channelConnectResultSchema;\n\nexport const disconnectChannelResponseSchema = z.object({\n success: z.boolean(),\n});\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\nimport type { RequestContext } from '@mastra/core/di';\nimport { coreFeatures } from '@mastra/core/features';\n\nimport { MASTRA_USER_KEY } from '../constants';\nimport { HTTPException } from '../http-exception';\nimport {\n channelPlatformPathParams,\n channelAgentPathParams,\n connectChannelBodySchema,\n listChannelPlatformsResponseSchema,\n listChannelInstallationsResponseSchema,\n connectChannelResponseSchema,\n disconnectChannelResponseSchema,\n} from '../schemas/channels';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { assertWriteAccess, getCallerAuthorId, hasAdminBypass, hasScopedPermission } from './authorship';\nimport { handleError } from './error';\n\n// ============================================================================\n// Feature gate + helpers\n// ============================================================================\n\nfunction assertChannelsAvailable(): void {\n if (!coreFeatures.has('channels')) {\n throw new HTTPException(501, { message: 'Channels require a newer version of @mastra/core' });\n }\n}\n\nfunction getChannelOrThrow(mastra: Mastra, platform: string): ChannelProvider {\n const channels = Object.values(mastra.channels ?? {});\n const channel = channels.find(c => c.id === platform);\n if (!channel) {\n const available = channels.map(c => c.id).join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\n/**\n * Unified connect/disconnect authorization.\n *\n * - Stored agent exists → same write access as editing the agent record.\n * - Code-defined agent (no stored record) → route's `requiresAuth` is the gate.\n * - Agent doesn't exist anywhere:\n * - connect → 404 (can't connect a channel to a non-existent agent)\n * - disconnect → orphan cleanup, gated on `channels:write`\n */\nasync function assertChannelAgentWriteAccess(\n mastra: Mastra,\n requestContext: RequestContext,\n agentId: string,\n action: 'connect' | 'disconnect',\n): Promise<void> {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : null;\n const stored = agentsStore ? await agentsStore.getById(agentId) : null;\n\n if (stored) {\n assertWriteAccess({\n requestContext,\n resource: 'agents',\n resourceId: agentId,\n action: 'edit',\n record: stored,\n });\n return;\n }\n\n // Not in stored-agents (or storage doesn't support it). Check the runtime\n // registry for a code-defined agent.\n const codeDefined = mastra.getAgentById(agentId);\n if (codeDefined) {\n // Code-defined agents have no owner/ACL — route's requiresAuth /\n // requiresPermission is the gate. Pass-through.\n return;\n }\n\n if (action === 'connect') {\n throw new HTTPException(404, { message: `Agent \"${agentId}\" not found` });\n }\n\n // Disconnect against an unknown agentId = orphan cleanup (stored agent was\n // deleted but the channel installation row is still around). Allow it, but\n // gate on channels:write so this isn't an \"any authenticated user\" backdoor.\n // Follow the same no-auth-configured pass-through as assertWriteAccess.\n const callerAuthorId = getCallerAuthorId(requestContext);\n if (!callerAuthorId && !requestContext.get(MASTRA_USER_KEY)) return;\n if (hasAdminBypass(requestContext, 'channels')) return;\n if (hasScopedPermission({ requestContext, resource: 'channels', action: 'write' })) return;\n\n throw new HTTPException(404, { message: 'Not found' });\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /channels/platforms - List available channel platforms\n */\nexport const LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/platforms',\n responseType: 'json',\n responseSchema: listChannelPlatformsResponseSchema,\n summary: 'List channel platforms',\n description: 'Returns available channel platforms and their configuration status',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n assertChannelsAvailable();\n try {\n const channels = Object.values(mastra.channels ?? {});\n return channels.map(channel => {\n if (channel.getInfo) {\n return channel.getInfo();\n }\n return {\n id: channel.id,\n name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),\n isConfigured: true,\n };\n });\n } catch (error) {\n return handleError(error, 'Error listing channel platforms');\n }\n },\n});\n\n/**\n * GET /channels/:platform/installations - List installations for a platform\n */\nexport const LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/:platform/installations',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n responseSchema: listChannelInstallationsResponseSchema,\n summary: 'List channel installations',\n description: 'Returns all active and pending installations for a channel platform',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, platform }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.listInstallations) {\n return [];\n }\n\n return await channel.listInstallations();\n } catch (error) {\n return handleError(error, 'Error listing channel installations');\n }\n },\n});\n\n/**\n * POST /channels/:platform/connect - Connect an agent to a platform\n */\nexport const CONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/connect',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n bodySchema: connectChannelBodySchema,\n responseSchema: connectChannelResponseSchema,\n summary: 'Connect agent to channel',\n description: 'Creates a platform app for the agent and returns an OAuth authorization URL',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.connect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic connection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n return await channel.connect(agentId, options);\n } catch (error) {\n return handleError(error, 'Error connecting agent to channel');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/disconnect',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: disconnectChannelResponseSchema,\n summary: 'Disconnect agent from channel',\n description: 'Deletes the platform app and cleans up the installation',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.disconnect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic disconnection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');\n\n await channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(error, 'Error disconnecting agent from channel');\n }\n },\n});\n"],"mappings":";;;;;;;;AAMA,MAAa,4BAA4BA,OAAAA,EAAE,OAAO,EAChD,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C,EAC7E,CAAC;AAED,MAAa,yBAAyBA,OAAAA,EAAE,OAAO;CAC7C,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,+CAA6C;CAC3E,SAASA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,kBAAkB;AACjD,CAAC;AAMD,MAAa,2BAA2BA,OAAAA,EAAE,OAAO;CAC/C,SAASA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,6BAA6B;CAC1D,SAASA,OAAAA,EAAE,OAAOA,OAAAA,EAAE,OAAO,GAAGA,OAAAA,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,sCAAsC;AACvG,CAAC;AAMD,MAAM,4BAA4BA,OAAAA,EAAE,OAAO;CACzC,IAAIA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,qBAAqB;CAC7C,MAAMA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,8BAA8B;CACxD,cAAcA,OAAAA,EAAE,QAAQ,CAAC,CAAC,SAAS,iDAAiD;CACpF,sBAAsBA,OAAAA,EAAE,OAAOA,OAAAA,EAAE,OAAO,GAAGA,OAAAA,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,iCAAiC;AAC/G,CAAC;AAED,MAAM,gCAAgCA,OAAAA,EAAE,OAAO;CAC7C,IAAIA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,yBAAyB;CACjD,UAAUA,OAAAA,EAAE,OAAO,CAAC,CAAC,SAAS,qBAAqB;CACnD,SAASA,OAAAA,EAAE,OAAO,CAAC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AAC,QAAQ,SACX,MAAM,IAAIJ,uBAAAA,cAAc,KAAK,EAC3B,SAAS,YAAY,SAAS,4CAChC,CAAC;GAGH,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,SAAS;GAE9E,OAAO,MAAM,QAAQ,QAAQ,SAAS,OAAO;EAC/C,SAAS,OAAO;GACd,OAAOK,8BAAAA,YAAY,OAAO,mCAAmC;EAC/D;CACF;AACF,CAAC;;;;AAKD,MAAa,2BAA2BD,sBAAAA,YAAY;CAClD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,UAAU;CACjB,cAAc;CACd,SAAS,OAAO,EAAE,QAAQ,gBAAgB,UAAU,cAAc;EAChE,wBAAwB;EACxB,IAAI;GACF,MAAM,UAAU,kBAAkB,QAAQ,QAAQ;GAElD,IAAI,CAAC,QAAQ,YACX,MAAM,IAAIJ,uBAAAA,cAAc,KAAK,EAC3B,SAAS,YAAY,SAAS,+CAChC,CAAC;GAGH,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,YAAY;GAEjF,MAAM,QAAQ,WAAW,OAAO;GAChC,OAAO,EAAE,SAAS,KAAK;EACzB,SAAS,OAAO;GACd,OAAOK,8BAAAA,YAAY,OAAO,wCAAwC;EACpE;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"channels-BRoq3VKR.cjs","names":["z","coreFeatures","HTTPException","getCallerAuthorId","hasAdminBypass","hasScopedPermission","createRoute","handleError"],"sources":["../src/server/schemas/channels.ts","../src/server/handlers/channels.ts"],"sourcesContent":["import { z } from 'zod/v4';\n\n// ============================================================================\n// Path Parameter Schemas\n// ============================================================================\n\nexport const channelPlatformPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n});\n\nexport const channelAgentPathParams = z.object({\n platform: z.string().describe('Channel platform identifier (e.g., \"slack\")'),\n agentId: z.string().describe('Agent identifier'),\n});\n\n// ============================================================================\n// Body Parameter Schemas\n// ============================================================================\n\nexport const connectChannelBodySchema = z.object({\n agentId: z.string().describe('Agent identifier to connect'),\n options: z.record(z.string(), z.unknown()).optional().describe('Platform-specific connection options'),\n});\n\n// ============================================================================\n// Response Schemas\n// ============================================================================\n\nconst channelPlatformInfoSchema = z.object({\n id: z.string().describe('Platform identifier'),\n name: z.string().describe('Human-readable platform name'),\n isConfigured: z.boolean().describe('Whether the platform is ready to connect agents'),\n connectOptionsSchema: z.record(z.string(), z.unknown()).optional().describe('JSON Schema for connect options'),\n});\n\nconst channelInstallationInfoSchema = z.object({\n id: z.string().describe('Installation identifier'),\n platform: z.string().describe('Platform identifier'),\n agentId: z.string().describe('Connected agent identifier'),\n status: z.enum(['active', 'pending']).describe('Installation status'),\n displayName: z.string().optional().describe('Platform-specific display name'),\n installedAt: z.coerce.date().optional().describe('Installation timestamp'),\n});\n\nconst channelConnectOAuthSchema = z.object({\n type: z.literal('oauth').describe('OAuth-based connection requiring browser redirect'),\n authorizationUrl: z.string().describe('OAuth authorization URL for user redirect'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectDeepLinkSchema = z.object({\n type: z.literal('deep_link').describe('Deep-link connection requiring native app interaction'),\n url: z.string().describe('Deep link URL to open in platform app'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectImmediateSchema = z.object({\n type: z.literal('immediate').describe('Immediate connection with no user interaction needed'),\n installationId: z.string().describe('Installation identifier'),\n});\n\nconst channelConnectResultSchema = z.discriminatedUnion('type', [\n channelConnectOAuthSchema,\n channelConnectDeepLinkSchema,\n channelConnectImmediateSchema,\n]);\n\nexport const listChannelPlatformsResponseSchema = z.array(channelPlatformInfoSchema);\n\nexport const listChannelInstallationsResponseSchema = z.array(channelInstallationInfoSchema);\n\nexport const connectChannelResponseSchema = channelConnectResultSchema;\n\nexport const disconnectChannelResponseSchema = z.object({\n success: z.boolean(),\n});\n","import type { Mastra } from '@mastra/core';\nimport type { ChannelProvider } from '@mastra/core/channels';\nimport type { RequestContext } from '@mastra/core/di';\nimport { coreFeatures } from '@mastra/core/features';\n\nimport { MASTRA_USER_KEY } from '../constants';\nimport { HTTPException } from '../http-exception';\nimport {\n channelPlatformPathParams,\n channelAgentPathParams,\n connectChannelBodySchema,\n listChannelPlatformsResponseSchema,\n listChannelInstallationsResponseSchema,\n connectChannelResponseSchema,\n disconnectChannelResponseSchema,\n} from '../schemas/channels';\nimport { createRoute } from '../server-adapter/routes/route-builder';\n\nimport { assertWriteAccess, getCallerAuthorId, hasAdminBypass, hasScopedPermission } from './authorship';\nimport { handleError } from './error';\n\n// ============================================================================\n// Feature gate + helpers\n// ============================================================================\n\nfunction assertChannelsAvailable(): void {\n if (!coreFeatures.has('channels')) {\n throw new HTTPException(501, { message: 'Channels require a newer version of @mastra/core' });\n }\n}\n\nfunction getChannelOrThrow(mastra: Mastra, platform: string): ChannelProvider {\n const channels = Object.values(mastra.channels ?? {});\n const channel = channels.find(c => c.id === platform);\n if (!channel) {\n const available = channels.map(c => c.id).join(', ');\n throw new HTTPException(404, {\n message: `Channel \"${platform}\" is not registered. Available: ${available || 'none'}`,\n });\n }\n return channel;\n}\n\n/**\n * Unified connect/disconnect authorization.\n *\n * - Stored agent exists → same write access as editing the agent record.\n * - Code-defined agent (no stored record) → route's `requiresAuth` is the gate.\n * - Agent doesn't exist anywhere:\n * - connect → 404 (can't connect a channel to a non-existent agent)\n * - disconnect → orphan cleanup, gated on `channels:write`\n */\nasync function assertChannelAgentWriteAccess(\n mastra: Mastra,\n requestContext: RequestContext,\n agentId: string,\n action: 'connect' | 'disconnect',\n): Promise<void> {\n const storage = mastra.getStorage();\n const agentsStore = storage ? await storage.getStore('agents') : null;\n const stored = agentsStore ? await agentsStore.getById(agentId) : null;\n\n if (stored) {\n assertWriteAccess({\n requestContext,\n resource: 'agents',\n resourceId: agentId,\n action: 'edit',\n record: stored,\n });\n return;\n }\n\n // Not in stored-agents (or storage doesn't support it). Check the runtime\n // registry for a code-defined agent.\n const codeDefined = mastra.getAgentById(agentId);\n if (codeDefined) {\n // Code-defined agents have no owner/ACL — route's requiresAuth /\n // requiresPermission is the gate. Pass-through.\n return;\n }\n\n if (action === 'connect') {\n throw new HTTPException(404, { message: `Agent \"${agentId}\" not found` });\n }\n\n // Disconnect against an unknown agentId = orphan cleanup (stored agent was\n // deleted but the channel installation row is still around). Allow it, but\n // gate on channels:write so this isn't an \"any authenticated user\" backdoor.\n // Follow the same no-auth-configured pass-through as assertWriteAccess.\n const callerAuthorId = getCallerAuthorId(requestContext);\n if (!callerAuthorId && !requestContext.get(MASTRA_USER_KEY)) return;\n if (hasAdminBypass(requestContext, 'channels')) return;\n if (hasScopedPermission({ requestContext, resource: 'channels', action: 'write' })) return;\n\n throw new HTTPException(404, { message: 'Not found' });\n}\n\n// ============================================================================\n// Route Definitions\n// ============================================================================\n\n/**\n * GET /channels/platforms - List available channel platforms\n */\nexport const LIST_CHANNEL_PLATFORMS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/platforms',\n responseType: 'json',\n responseSchema: listChannelPlatformsResponseSchema,\n summary: 'List channel platforms',\n description: 'Returns available channel platforms and their configuration status',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra }) => {\n assertChannelsAvailable();\n try {\n const channels = Object.values(mastra.channels ?? {});\n return channels.map(channel => {\n if (channel.getInfo) {\n return channel.getInfo();\n }\n return {\n id: channel.id,\n name: channel.id.charAt(0).toUpperCase() + channel.id.slice(1),\n isConfigured: true,\n };\n });\n } catch (error) {\n return handleError(error, 'Error listing channel platforms');\n }\n },\n});\n\n/**\n * GET /channels/:platform/installations - List installations for a platform\n */\nexport const LIST_CHANNEL_INSTALLATIONS_ROUTE = createRoute({\n method: 'GET',\n path: '/channels/:platform/installations',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n responseSchema: listChannelInstallationsResponseSchema,\n summary: 'List channel installations',\n description: 'Returns all active and pending installations for a channel platform',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, platform }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.listInstallations) {\n return [];\n }\n\n return await channel.listInstallations();\n } catch (error) {\n return handleError(error, 'Error listing channel installations');\n }\n },\n});\n\n/**\n * POST /channels/:platform/connect - Connect an agent to a platform\n */\nexport const CONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/connect',\n responseType: 'json',\n pathParamSchema: channelPlatformPathParams,\n bodySchema: connectChannelBodySchema,\n responseSchema: connectChannelResponseSchema,\n summary: 'Connect agent to channel',\n description: 'Creates a platform app for the agent and returns an OAuth authorization URL',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId, options }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.connect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic connection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'connect');\n\n return await channel.connect(agentId, options);\n } catch (error) {\n return handleError(error, 'Error connecting agent to channel');\n }\n },\n});\n\n/**\n * POST /channels/:platform/:agentId/disconnect - Disconnect an agent from a platform\n */\nexport const DISCONNECT_CHANNEL_ROUTE = createRoute({\n method: 'POST',\n path: '/channels/:platform/:agentId/disconnect',\n responseType: 'json',\n pathParamSchema: channelAgentPathParams,\n responseSchema: disconnectChannelResponseSchema,\n summary: 'Disconnect agent from channel',\n description: 'Deletes the platform app and cleans up the installation',\n tags: ['Channels'],\n requiresAuth: true,\n handler: async ({ mastra, requestContext, platform, agentId }) => {\n assertChannelsAvailable();\n try {\n const channel = getChannelOrThrow(mastra, platform);\n\n if (!channel.disconnect) {\n throw new HTTPException(400, {\n message: `Channel \"${platform}\" does not support programmatic disconnection`,\n });\n }\n\n await assertChannelAgentWriteAccess(mastra, requestContext, agentId, 'disconnect');\n\n await channel.disconnect(agentId);\n return { success: true };\n } catch (error) {\n return handleError(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AGH,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,SAAS;GAE9E,OAAO,MAAM,QAAQ,QAAQ,SAAS,OAAO;EAC/C,SAAS,OAAO;GACd,OAAOK,8BAAAA,YAAY,OAAO,mCAAmC;EAC/D;CACF;AACF,CAAC;;;;AAKD,MAAa,2BAA2BD,sBAAAA,YAAY;CAClD,QAAQ;CACR,MAAM;CACN,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,SAAS;CACT,aAAa;CACb,MAAM,CAAC,UAAU;CACjB,cAAc;CACd,SAAS,OAAO,EAAE,QAAQ,gBAAgB,UAAU,cAAc;EAChE,wBAAwB;EACxB,IAAI;GACF,MAAM,UAAU,kBAAkB,QAAQ,QAAQ;GAElD,IAAI,CAAC,QAAQ,YACX,MAAM,IAAIJ,uBAAAA,cAAc,KAAK,EAC3B,SAAS,YAAY,SAAS,+CAChC,CAAC;GAGH,MAAM,8BAA8B,QAAQ,gBAAgB,SAAS,YAAY;GAEjF,MAAM,QAAQ,WAAW,OAAO;GAChC,OAAO,EAAE,SAAS,KAAK;EACzB,SAAS,OAAO;GACd,OAAOK,8BAAAA,YAAY,OAAO,wCAAwC;EACpE;CACF;AACF,CAAC"}
@@ -4693,7 +4693,7 @@ function splitLines(text) {
4693
4693
  return result;
4694
4694
  }
4695
4695
  //#endregion
4696
- //#region ../memory/dist/src-B_n15_Xg.js
4696
+ //#region ../memory/dist/src-DGdlH4fo.js
4697
4697
  var __defProp$3 = Object.defineProperty;
4698
4698
  var __exportAll = (all, no_symbols) => {
4699
4699
  let target = {};
@@ -25971,7 +25971,7 @@ var SyncObservationStrategy = class extends ObservationStrategy {
25971
25971
  },
25972
25972
  lastObservedMessageCursor: getLastObservedMessageCursor(messages)
25973
25973
  });
25974
- await this.storage.updateThread({
25974
+ await this.storage.patchThread({
25975
25975
  id: threadId,
25976
25976
  ...shouldUpdateThreadTitle ? { title: newTitle } : {},
25977
25977
  metadata: newMetadata
@@ -26161,7 +26161,7 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
26161
26161
  ...metadataUpdate.extracted ?? {}
26162
26162
  }
26163
26163
  });
26164
- await this.storage.updateThread({
26164
+ await this.storage.patchThread({
26165
26165
  id: threadId,
26166
26166
  ...shouldUpdateThreadTitle ? { title: newTitle } : {},
26167
26167
  metadata: newMetadata
@@ -26504,7 +26504,7 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
26504
26504
  },
26505
26505
  lastObservedMessageCursor: update.lastObservedMessageCursor
26506
26506
  });
26507
- await this.storage.updateThread({
26507
+ await this.storage.patchThread({
26508
26508
  id: update.threadId,
26509
26509
  ...shouldUpdateThreadTitle ? { title: newTitle } : {},
26510
26510
  metadata: newMetadata
@@ -27435,7 +27435,7 @@ async function persistThreadExtractedValues(storage, extractors, threadId, value
27435
27435
  ...metadataUpdate.extracted ?? {}
27436
27436
  }
27437
27437
  });
27438
- await storage.updateThread({
27438
+ await storage.patchThread({
27439
27439
  id: threadId,
27440
27440
  metadata: newMetadata
27441
27441
  });
@@ -30402,7 +30402,7 @@ ${formattedMessages}
30402
30402
  const oldTitle = thread.title?.trim();
30403
30403
  const newTitle = chunkThreadTitle?.trim();
30404
30404
  const shouldUpdateThreadTitle = !!newTitle && newTitle.length >= 3 && newTitle !== oldTitle;
30405
- await this.storage.updateThread({
30405
+ await this.storage.patchThread({
30406
30406
  id: threadId,
30407
30407
  ...shouldUpdateThreadTitle ? { title: newTitle } : {},
30408
30408
  metadata: newMetadata
@@ -30620,7 +30620,7 @@ ${formattedMessages}
30620
30620
  ...metadataUpdate.extracted ?? {}
30621
30621
  }
30622
30622
  });
30623
- await this.storage.updateThread({
30623
+ await this.storage.patchThread({
30624
30624
  id: threadId,
30625
30625
  metadata: newMetadata
30626
30626
  });
@@ -31647,7 +31647,7 @@ var Memory = class extends MastraMemory {
31647
31647
  return savedThread;
31648
31648
  }
31649
31649
  async updateThread({ id, title, metadata, memoryConfig }) {
31650
- const updatedThread = await (await this.getMemoryStore()).updateThread({
31650
+ const updatedThread = await (await this.getMemoryStore()).patchThread({
31651
31651
  id,
31652
31652
  title,
31653
31653
  metadata
@@ -31738,7 +31738,7 @@ var Memory = class extends MastraMemory {
31738
31738
  else {
31739
31739
  const thread = await this.getThreadById({ threadId });
31740
31740
  if (!thread) throw new Error(`Thread ${threadId} not found`);
31741
- await memoryStore.updateThread({
31741
+ await memoryStore.patchThread({
31742
31742
  id: threadId,
31743
31743
  metadata: {
31744
31744
  ...thread.metadata,
@@ -31826,7 +31826,7 @@ ${workingMemory}`;
31826
31826
  } else {
31827
31827
  const thread = await this.getThreadById({ threadId });
31828
31828
  if (!thread) throw new Error(`Thread ${threadId} not found`);
31829
- await memoryStore.updateThread({
31829
+ await memoryStore.patchThread({
31830
31830
  id: threadId,
31831
31831
  metadata: {
31832
31832
  ...thread.metadata,
@@ -43543,4 +43543,4 @@ const agentBuilderWorkflows = {
43543
43543
  //#endregion
43544
43544
  export { agentBuilderWorkflows };
43545
43545
 
43546
- //# sourceMappingURL=dist-CzzxT_L5.js.map
43546
+ //# sourceMappingURL=dist-7r8jzEWH.js.map