decocms 3.21.0 → 3.21.1

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 (231) hide show
  1. package/dist/client/assets/{AlertCircle-CBwqugJe.js → AlertCircle-Di-V3umI.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight--24rRsQC.js → ArrowUpRight-C-T2gJLi.js} +1 -1
  3. package/dist/client/assets/{Check-BEDsGGM_.js → Check-BNom5dOo.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-CFdIOhwM.js → CheckCircle-DrDyiPu_.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-Y-7MoOW4.js → ChevronDown-B21_IsL3.js} +1 -1
  6. package/dist/client/assets/{ChevronLeft-BSf4mKrR.js → ChevronLeft-Ctye75GL.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-B1SVpAS5.js → ChevronRight-GBMV5yJO.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-DooNP946.js → ChevronUp-CGGIgndb.js} +1 -1
  9. package/dist/client/assets/{Container-BcM96X15.js → Container-BowdgJ62.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-kVh0UVRo.js → DotsVertical-C1UpLbMK.js} +1 -1
  11. package/dist/client/assets/{Eye-Bowp4iez.js → Eye-CCL1jvke.js} +1 -1
  12. package/dist/client/assets/{FilterLines-DXSEbwW6.js → FilterLines-CLU1cvnm.js} +1 -1
  13. package/dist/client/assets/{Globe01-CF7IqqKh.js → Globe01-Ca2CDUqL.js} +1 -1
  14. package/dist/client/assets/{HardDrive-CPqmzwVB.js → HardDrive-BRJbxTgf.js} +1 -1
  15. package/dist/client/assets/{Key01-NY-IsQgy.js → Key01-B0KHYY9A.js} +1 -1
  16. package/dist/client/assets/{LayoutLeft-BgC7aOjO.js → LayoutLeft-DQjoJnlv.js} +1 -1
  17. package/dist/client/assets/{LinkExternal01-Cgr3jZjD.js → LinkExternal01-BmWxPEFc.js} +1 -1
  18. package/dist/client/assets/{Monitor01-BLzNpHgz.js → Monitor01-CCpw9YsU.js} +1 -1
  19. package/dist/client/assets/{Palette-6N_c4T4_.js → Palette-DljqRkOL.js} +1 -1
  20. package/dist/client/assets/{Play-B9p1kZpZ.js → Play-BWZ7aOd4.js} +1 -1
  21. package/dist/client/assets/{Plus-Bymlyq77.js → Plus-BW-TIinL.js} +1 -1
  22. package/dist/client/assets/{RefreshCcw01-CR5XeXPv.js → RefreshCcw01-DoQ2Q5nQ.js} +1 -1
  23. package/dist/client/assets/{SearchMd-7k7TbMsJ.js → SearchMd-BrE4Lp2d.js} +1 -1
  24. package/dist/client/assets/{Settings02-DbR-330c.js → Settings02-CnuG-oH5.js} +1 -1
  25. package/dist/client/assets/{Shield01-wwDAi_uJ.js → Shield01-BAt9OJkk.js} +1 -1
  26. package/dist/client/assets/{Star01-DVebopnN.js → Star01-f8rMlJ5U.js} +1 -1
  27. package/dist/client/assets/{Stars01-CDcY9WwZ.js → Stars01-GUKoSsGN.js} +1 -1
  28. package/dist/client/assets/{Stars02-YwHPi-7I.js → Stars02-DApbfWB6.js} +1 -1
  29. package/dist/client/assets/{Sun-DXdRtf6l.js → Sun-BupjfBtR.js} +1 -1
  30. package/dist/client/assets/{SwitchHorizontal01-Dha4DHjZ.js → SwitchHorizontal01-CBvA0yYX.js} +1 -1
  31. package/dist/client/assets/{Tool01-BTE6nmQ4.js → Tool01-BGucVzDk.js} +1 -1
  32. package/dist/client/assets/{Trash01-B-X6RyaC.js → Trash01-DOwZGPnm.js} +1 -1
  33. package/dist/client/assets/{Upload01-DsBsPR-L.js → Upload01-ypYRbiXm.js} +1 -1
  34. package/dist/client/assets/{User01-Y_Kyyfi4.js → User01-iRKM2KTq.js} +1 -1
  35. package/dist/client/assets/{Users01-e0FZKqF3.js → Users01-CQjxMYXj.js} +1 -1
  36. package/dist/client/assets/{Users03-BwOA6RiF.js → Users03-Gpc8Fhl9.js} +1 -1
  37. package/dist/client/assets/{X-CeSkzEjM.js → X-D2-T6h59.js} +1 -1
  38. package/dist/client/assets/{XCircle-qkpSwHM6.js → XCircle-BD7UyEOF.js} +1 -1
  39. package/dist/client/assets/{XClose-CodFwf_E.js → XClose-qC7X4hjJ.js} +1 -1
  40. package/dist/client/assets/{Zap-Gvzp-SH3.js → Zap-BxPmO3d7.js} +1 -1
  41. package/dist/client/assets/{ZapSquare-M-fH4MJf.js → ZapSquare-DMyX_8RQ.js} +1 -1
  42. package/dist/client/assets/{ZoomOut-CgCAgEfn.js → ZoomOut-CrNlxKNu.js} +1 -1
  43. package/dist/client/assets/{access-gate-yH-Av9gZ.js → access-gate-BxaFZysE.js} +1 -1
  44. package/dist/client/assets/{accordion-Wptwv3ei.js → accordion-DBdAn4Yd.js} +1 -1
  45. package/dist/client/assets/{add-section-modal-C596gc6u.js → add-section-modal-Cp9ANpKI.js} +1 -1
  46. package/dist/client/assets/{agent-capabilities-pAj3t6Aa.js → agent-capabilities-DZnx6uxN.js} +1 -1
  47. package/dist/client/assets/{agent-icon-BDCTH9NT.js → agent-icon-DwlI421o.js} +1 -1
  48. package/dist/client/assets/{agent-icons-Jj9QCCT9.js → agent-icons-BpY_PoEJ.js} +1 -1
  49. package/dist/client/assets/{agents-list-DvLskc8Q.js → agents-list-7MDTRjEP.js} +1 -1
  50. package/dist/client/assets/{ai-providers-BBIu7ZXT.js → ai-providers-DCVu5rlW.js} +1 -1
  51. package/dist/client/assets/{alert-C6yRIixe.js → alert-9Uyq7_Yx.js} +1 -1
  52. package/dist/client/assets/{alert-dialog-DPYmMCbT.js → alert-dialog-Di87pvaw.js} +1 -1
  53. package/dist/client/assets/app-editor-BTJdqNFO.js +1 -0
  54. package/dist/client/assets/{auth-catchall-MOPzdxWf.js → auth-catchall-6sVJF5kF.js} +1 -1
  55. package/dist/client/assets/{auth-split-layout-CelS9Z9I.js → auth-split-layout-BB9gPhYr.js} +1 -1
  56. package/dist/client/assets/{automation-list-row-Cscfso-k.js → automation-list-row-CeYc1MAT.js} +1 -1
  57. package/dist/client/assets/{automation-runs-B9tKW-5u.js → automation-runs-bcYQjbYn.js} +1 -1
  58. package/dist/client/assets/{automations-BmKAo4DY.js → automations-OmisaDZA.js} +1 -1
  59. package/dist/client/assets/{avatar-CB3_y_zI.js → avatar-DpEGkmVF.js} +1 -1
  60. package/dist/client/assets/{badge-CQybGfxn.js → badge-CRBv_-v0.js} +1 -1
  61. package/dist/client/assets/{brand-context-BmtDTKSi.js → brand-context-BHMKdNZS.js} +1 -1
  62. package/dist/client/assets/{buckets-BdiAvpJ6.js → buckets-DdExZ8vz.js} +1 -1
  63. package/dist/client/assets/{calendar-BZZJ1lU5.js → calendar-04oidYi0.js} +1 -1
  64. package/dist/client/assets/{capability-load-error-BgxjXvkK.js → capability-load-error-DQKXVSLb.js} +1 -1
  65. package/dist/client/assets/{card-D-5GEcNj.js → card-DjCUI9mK.js} +1 -1
  66. package/dist/client/assets/{chat-context-CQ8Sv7Z0.js → chat-context-DCjkCe-V.js} +1 -1
  67. package/dist/client/assets/{checkbox-B6S6Zp2z.js → checkbox-C0J6d59Z.js} +1 -1
  68. package/dist/client/assets/{cli-auth-success-DqylkzZK.js → cli-auth-success-GR8P7inl.js} +1 -1
  69. package/dist/client/assets/{collection-detail-2BYHOr3-.js → collection-detail-BLTHo14O.js} +1 -1
  70. package/dist/client/assets/{collection-display-button-D3QV52tk.js → collection-display-button-vdVt1x-Y.js} +1 -1
  71. package/dist/client/assets/{collection-search-CwRnoUd2.js → collection-search-C9e8ytlm.js} +1 -1
  72. package/dist/client/assets/{collection-table-wrapper-DuBP5O7g.js → collection-table-wrapper-Ci3rF5jl.js} +1 -1
  73. package/dist/client/assets/{collection-tabs-BaSPyUXn.js → collection-tabs-DcsnhXJW.js} +1 -1
  74. package/dist/client/assets/{collections-CpOrr_Gv.js → collections-CFguVIuY.js} +1 -1
  75. package/dist/client/assets/{command-DprDJr8i.js → command-CHlhuzJ_.js} +1 -1
  76. package/dist/client/assets/{connect-desktop-dialog-Uaj5e58Y.js → connect-desktop-dialog-BSK9XSHH.js} +1 -1
  77. package/dist/client/assets/{connection-card-C5qc95C-.js → connection-card-DO9d3YRC.js} +1 -1
  78. package/dist/client/assets/{connection-detail-ClgTkTr2.js → connection-detail-SHOkB3xQ.js} +1 -1
  79. package/dist/client/assets/{connection-form-helpers-DWZPGoQ0.js → connection-form-helpers-C3edNmoP.js} +1 -1
  80. package/dist/client/assets/{connections-CNnVWMCc.js → connections-qKkqyM04.js} +1 -1
  81. package/dist/client/assets/{decopilot-sse-pool-oHmW4h5V.js → decopilot-sse-pool-BN3Fz4g5.js} +1 -1
  82. package/dist/client/assets/{dialog-CxQuymkd.js → dialog-fdhgLhBf.js} +1 -1
  83. package/dist/client/assets/{domain-settings-C-5nsb1F.js → domain-settings-DGN8lQXh.js} +1 -1
  84. package/dist/client/assets/{drawer-Cpdg2y8l.js → drawer-nppIIpnE.js} +1 -1
  85. package/dist/client/assets/{dropdown-menu-Kn1KFf_7.js → dropdown-menu-X3z-hQ2M.js} +1 -1
  86. package/dist/client/assets/{dynamic-plugin-layout-m2PVEPiw.js → dynamic-plugin-layout-DIHhoFb_.js} +1 -1
  87. package/dist/client/assets/{empty-state-CSC6EQIQ.js → empty-state-Bq6HhNrq.js} +1 -1
  88. package/dist/client/assets/{empty-state-B1_qnFui.js → empty-state-CQXcLTIH.js} +1 -1
  89. package/dist/client/assets/{extract-connection-data-DLKFWvUj.js → extract-connection-data-D6z7oijb.js} +1 -1
  90. package/dist/client/assets/{features-OWKqeKPc.js → features-G1sVG-es.js} +1 -1
  91. package/dist/client/assets/{file-explorer-cLwV2vYd.js → file-explorer-DXIRGCbx.js} +1 -1
  92. package/dist/client/assets/{file-type-icon-Bosly9dX.js → file-type-icon-B0iXSarG.js} +1 -1
  93. package/dist/client/assets/{files-DhKSL0bf.js → files-BBuiWUw0.js} +1 -1
  94. package/dist/client/assets/{form-BEq77uTF.js → form-l2US6lAY.js} +1 -1
  95. package/dist/client/assets/{general-BbVuoj3y.js → general-Che5cJxu.js} +1 -1
  96. package/dist/client/assets/{generate-id-CpIkXSfl.js → generate-id-RYRfDJEO.js} +1 -1
  97. package/dist/client/assets/{github-repo-picker-DeZ7XjfM.js → github-repo-picker-Bt39LytD.js} +1 -1
  98. package/dist/client/assets/{header-tab-button-B3Zn4qt-.js → header-tab-button-D5FVHg7C.js} +1 -1
  99. package/dist/client/assets/{hover-card-CiGu2Rc9.js → hover-card-CrD42WSD.js} +1 -1
  100. package/dist/client/assets/{image-field-KXYbIIcm.js → image-field-DmZve0TW.js} +1 -1
  101. package/dist/client/assets/{index-CgnnAE8X.js → index-BOMHJPUn.js} +1 -1
  102. package/dist/client/assets/{index-z3J3f1Ar.js → index-BUe0rEg1.js} +1 -1
  103. package/dist/client/assets/{index-DbKaISqA.js → index-BYXBOiLY.js} +1 -1
  104. package/dist/client/assets/{index-CtCvHbuC.js → index-BmZqEyVY.js} +1 -1
  105. package/dist/client/assets/{index-CLB6WU0x.js → index-Bu_CNCUZ.js} +1 -1
  106. package/dist/client/assets/{index-1x-cRIHB.js → index-C5tgiUEv.js} +1 -1
  107. package/dist/client/assets/{index-CVKiAO9w.js → index-Cm05rD4S.js} +1 -1
  108. package/dist/client/assets/{index-CByCDOy2.js → index-Cw0f814h.js} +1 -1
  109. package/dist/client/assets/{index-CYhCrWAi.js → index-CwDq8vs6.js} +4 -4
  110. package/dist/client/assets/{index-4wfPgw7r.js → index-D-CqRT4O.js} +1 -1
  111. package/dist/client/assets/{index-B7vG9XMB.js → index-D6idVW2n.js} +3 -3
  112. package/dist/client/assets/{index-BxXPz7Bo.js → index-DWvdSxPM.js} +1 -1
  113. package/dist/client/assets/{index-D54pKkTb.js → index-DeDtw-b1.js} +1 -1
  114. package/dist/client/assets/{index-DLL1noOh.js → index-Doc3AWor.js} +1 -1
  115. package/dist/client/assets/{index-0wo9R-KN.js → index-DwykyBcY.js} +1 -1
  116. package/dist/client/assets/{index-redirect-SPQ5XDqE.js → index-redirect-BqoA6RVo.js} +1 -1
  117. package/dist/client/assets/{infiniteQueryObserver-COC30QjI.js → infiniteQueryObserver-VyVFnsqY.js} +1 -1
  118. package/dist/client/assets/{input-BlbFVhmY.js → input-ChQ639sE.js} +1 -1
  119. package/dist/client/assets/{integration-icon-DV694Bxd.js → integration-icon-b2Rlb-Sb.js} +1 -1
  120. package/dist/client/assets/{label-DusmHQMe.js → label-rvaNBf1n.js} +1 -1
  121. package/dist/client/assets/{layout-CSvam0IG.js → layout-DmZgycrJ.js} +1 -1
  122. package/dist/client/assets/{login-BDEm2zEc.js → login-DFkji89I.js} +1 -1
  123. package/dist/client/assets/{members-Bomx0Sn5.js → members-Bm9cIL-1.js} +1 -1
  124. package/dist/client/assets/{monaco-editor-DkKdkwZa.js → monaco-editor-B2W8v7r6.js} +1 -1
  125. package/dist/client/assets/{monitoring-stats-row-CX_8bt9_.js → monitoring-stats-row-DdYAhJ5V.js} +1 -1
  126. package/dist/client/assets/{oauth-callback-CgtlvaLv.js → oauth-callback-C9xoFbd7.js} +1 -1
  127. package/dist/client/assets/{oauth-callback-ai-provider-BYMLI4dT.js → oauth-callback-ai-provider-CKDYX_RF.js} +1 -1
  128. package/dist/client/assets/{onboarding-BF9j6YV8.js → onboarding-CzS2cVPB.js} +1 -1
  129. package/dist/client/assets/{org-install-DGQXekU8.js → org-install-BaqJ9XwL.js} +1 -1
  130. package/dist/client/assets/{org-layout-bYdeQW0W.js → org-layout-S59SENMd.js} +1 -1
  131. package/dist/client/assets/{org-plugin-layout-CM3JP6B6.js → org-plugin-layout-CqsI9Bed.js} +1 -1
  132. package/dist/client/assets/{page-seo-form-DFQzldH7.js → page-seo-form-EuEyknEc.js} +1 -1
  133. package/dist/client/assets/page-seo-sheet-IswGsmwS.js +1 -0
  134. package/dist/client/assets/{pair-B6RPc276.js → pair-Bt2SA9Qp.js} +1 -1
  135. package/dist/client/assets/{plugin-empty-state-C4jzTlPx.js → plugin-empty-state-DSQFLxwe.js} +1 -1
  136. package/dist/client/assets/{plugin-header-CVstxVuf.js → plugin-header-DMRgUsQl.js} +1 -1
  137. package/dist/client/assets/{plugin-layout-CNVxRIAq.js → plugin-layout-TXD29kdN.js} +1 -1
  138. package/dist/client/assets/{popover-k1SAuM8F.js → popover-Rt3fpbO3.js} +1 -1
  139. package/dist/client/assets/{post-editor-CBrNSYLu.js → post-editor-Divs3dwJ.js} +1 -1
  140. package/dist/client/assets/{primitives-BSCmh5I1.js → primitives-XpLpFjB8.js} +1 -1
  141. package/dist/client/assets/{profile-BQ5pYJ22.js → profile-CHjI4ygW.js} +1 -1
  142. package/dist/client/assets/{project-app-view-v4OZRUM9.js → project-app-view-DHaXTs5T.js} +1 -1
  143. package/dist/client/assets/record-editor-BVLo6guS.js +1 -0
  144. package/dist/client/assets/registry-BYK9j9rQ.js +2 -0
  145. package/dist/client/assets/{registry-layout-DBMQThih.js → registry-layout-C7DwnK5e.js} +1 -1
  146. package/dist/client/assets/{require-capability-DSMbLiZI.js → require-capability-B4l3wBea.js} +1 -1
  147. package/dist/client/assets/{required-auth-layout-D9SRhJSc.js → required-auth-layout-CfzfhqYN.js} +1 -1
  148. package/dist/client/assets/{reset-password-C9Ln3Zoi.js → reset-password-BZ5l6irC.js} +1 -1
  149. package/dist/client/assets/{resizable-Ba9LvnO6.js → resizable-CA7mW65R.js} +1 -1
  150. package/dist/client/assets/{roles-NETfFBX2.js → roles-6C_YTupk.js} +1 -1
  151. package/dist/client/assets/save-referenced-block-DgXF7K9R.js +1 -0
  152. package/dist/client/assets/{save-status-DYfqaiw8.js → save-status-KIo_EK3u.js} +1 -1
  153. package/dist/client/assets/{schema-form-DrlyaJpj.js → schema-form-0q7FWymW.js} +1 -1
  154. package/dist/client/assets/{scroll-area-DYol0Grn.js → scroll-area-S5xU4-3T.js} +1 -1
  155. package/dist/client/assets/{search-input-nVygL8OB.js → search-input-bjsIuW3e.js} +1 -1
  156. package/dist/client/assets/{secrets-B4fzmsTc.js → secrets-oJC26E57.js} +1 -1
  157. package/dist/client/assets/{sections-editor-QyxhsS1_.js → sections-editor-BJkalQrn.js} +1 -1
  158. package/dist/client/assets/{select-B4unS8Yd.js → select-D-XBS65u.js} +1 -1
  159. package/dist/client/assets/{select-model-CKy0zqKb.js → select-model-BfrrA0rU.js} +1 -1
  160. package/dist/client/assets/{seo-editor-BdEjBqlb.js → seo-editor-DQqMio2v.js} +1 -1
  161. package/dist/client/assets/{settings-layout-DuBEt8Gq.js → settings-layout-mMyfgzSB.js} +1 -1
  162. package/dist/client/assets/{settings-section-B1XnnsKo.js → settings-section-DOJ8w47S.js} +1 -1
  163. package/dist/client/assets/{sheet-BBAkMmdU.js → sheet-BdF_K2dB.js} +1 -1
  164. package/dist/client/assets/{shell-controls-CpJ33jvP.js → shell-controls-BDGVwZm0.js} +1 -1
  165. package/dist/client/assets/{shell-layout-ZMa83VsB.js → shell-layout-652GQgyj.js} +1 -1
  166. package/dist/client/assets/{shell-route-loading-DSUwFCkI.js → shell-route-loading-DWdfT9on.js} +1 -1
  167. package/dist/client/assets/{sidebar-D5sx4cw7.js → sidebar-faIWOpU7.js} +1 -1
  168. package/dist/client/assets/{skeleton-DSWxpPIh.js → skeleton-CrWdoD9s.js} +1 -1
  169. package/dist/client/assets/{sortable.esm-DuiWwZfa.js → sortable.esm-DaLbqREa.js} +1 -1
  170. package/dist/client/assets/{spinner-DmCMgGSO.js → spinner-Ba6MQmcV.js} +1 -1
  171. package/dist/client/assets/{sso-DUBJz_x2.js → sso-BtgDVu5D.js} +1 -1
  172. package/dist/client/assets/{store-DYDE6pHq.js → store-De54zr2A.js} +1 -1
  173. package/dist/client/assets/store-registry-BBl5JK8R.js +2 -0
  174. package/dist/client/assets/{switch-kJsDxWvb.js → switch-Djy20jDK.js} +1 -1
  175. package/dist/client/assets/{tab-id-Bmckb_ZN.js → tab-id-DKNFO22m.js} +1 -1
  176. package/dist/client/assets/{table-Cx2A_sz5.js → table-Cy6WVAuu.js} +1 -1
  177. package/dist/client/assets/{tabs-B-z6K-Df.js → tabs-DI8qnoXf.js} +1 -1
  178. package/dist/client/assets/{task-status-C-gQCQz-.js → task-status-qWqGiUC6.js} +1 -1
  179. package/dist/client/assets/{textarea-WpZ6d3aj.js → textarea-FwxJbyLj.js} +1 -1
  180. package/dist/client/assets/{toggle-group-CS6geM2v.js → toggle-group-DLxiboB7.js} +1 -1
  181. package/dist/client/assets/{toolbar-B7mbC32u.js → toolbar-CMgp-9VS.js} +1 -1
  182. package/dist/client/assets/{tools-list-Cv15T5e5.js → tools-list-C_1FwcZ2.js} +1 -1
  183. package/dist/client/assets/{tooltip-CwxdEfJN.js → tooltip-BwAS3LmD.js} +1 -1
  184. package/dist/client/assets/{types-akMlG6_N.js → types-DpLGHfBV.js} +1 -1
  185. package/dist/client/assets/{use-ai-providers-DQ_Lg3nK.js → use-ai-providers-D_70D2KF.js} +1 -1
  186. package/dist/client/assets/{use-automations-DycGy3r5.js → use-automations-Bm_GDiS0.js} +1 -1
  187. package/dist/client/assets/{use-capability-BhXqmGDG.js → use-capability-BTcvzwTt.js} +1 -1
  188. package/dist/client/assets/{use-collections-BsA9K23E.js → use-collections-B1ftgmsC.js} +1 -1
  189. package/dist/client/assets/{use-connection-CJ6MBogv.js → use-connection-f6XTkb53.js} +1 -1
  190. package/dist/client/assets/{use-copy-BcPxqPQz.js → use-copy-N9ijygLT.js} +1 -1
  191. package/dist/client/assets/{use-create-virtual-mcp-pvfszp3d.js → use-create-virtual-mcp-DmpPKskK.js} +1 -1
  192. package/dist/client/assets/{use-debounced-autosave-DhKjGFFk.js → use-debounced-autosave-ChNaRP5S.js} +1 -1
  193. package/dist/client/assets/{use-delete-connection-CtnxdJxw.js → use-delete-connection-BwrylBgL.js} +1 -1
  194. package/dist/client/assets/{use-file-configs-2gqpEUPc.js → use-file-configs-Iu1ZGjUX.js} +1 -1
  195. package/dist/client/assets/{use-infinite-scroll-Dq4LQvGA.js → use-infinite-scroll-D4clS4iX.js} +1 -1
  196. package/dist/client/assets/{use-list-state-Jee6I2EQ.js → use-list-state-BDMoY8GZ.js} +1 -1
  197. package/dist/client/assets/{use-mcp-client-G3uFjg07.js → use-mcp-client-Dutz6IKN.js} +1 -1
  198. package/dist/client/assets/{use-mcp-prompts-oto_asve.js → use-mcp-prompts-DkrNbGZU.js} +1 -1
  199. package/dist/client/assets/{use-mcp-tools-CHLE0GCH.js → use-mcp-tools-Dk5wX_Q8.js} +1 -1
  200. package/dist/client/assets/{use-members-DX3EwEQX.js → use-members-73l6yAni.js} +1 -1
  201. package/dist/client/assets/{use-navigate-to-agent-CzNZ7f2D.js → use-navigate-to-agent-QL4LtHJV.js} +1 -1
  202. package/dist/client/assets/{use-org-auth-client-HBznaAU-.js → use-org-auth-client-CAvzSle5.js} +1 -1
  203. package/dist/client/assets/{use-org-sso-bBdDyUxO.js → use-org-sso-C7T4CeXS.js} +1 -1
  204. package/dist/client/assets/{use-organization-roles-DfBql3U5.js → use-organization-roles-CzFjc3MW.js} +1 -1
  205. package/dist/client/assets/{use-organization-settings-nE3QaAmY.js → use-organization-settings-t-yCPHX9.js} +1 -1
  206. package/dist/client/assets/{use-registry-connections-Bf4QfKOn.js → use-registry-connections-CZ4ax3LX.js} +1 -1
  207. package/dist/client/assets/{use-secrets-CMSnZcAo.js → use-secrets-Dor672jC.js} +1 -1
  208. package/dist/client/assets/{use-status-sounds-DpH3cDkD.js → use-status-sounds-J2lGW499.js} +1 -1
  209. package/dist/client/assets/{use-view-mode-YX6kaXqJ.js → use-view-mode-EyZ_szat.js} +1 -1
  210. package/dist/client/assets/{use-virtual-mcp-DLclk59A.js → use-virtual-mcp-BW5609Gn.js} +1 -1
  211. package/dist/client/assets/useInfiniteQuery-C4mxsTCl.js +1 -0
  212. package/dist/client/assets/{useRouterState-VGJ_ztuJ.js → useRouterState-vIbEdlN4.js} +1 -1
  213. package/dist/client/assets/useSuspenseInfiniteQuery-B8vt_oPd.js +1 -0
  214. package/dist/client/assets/{user-CvuJ8gsu.js → user-CkUI6Rtf.js} +1 -1
  215. package/dist/client/assets/{view-mode-toggle-Bd-KjzIY.js → view-mode-toggle-B0zSaOcF.js} +1 -1
  216. package/dist/client/assets/{workflow-BiwkeemM.js → workflow-CRNBsay_.js} +1 -1
  217. package/dist/client/assets/workflow-detail-DSkokxeb.js +1 -0
  218. package/dist/client/index.html +1 -1
  219. package/dist/server/cli.js +388 -387
  220. package/dist/server/migrate.js +1 -1
  221. package/dist/server/server.js +266 -266
  222. package/package.json +1 -1
  223. package/dist/client/assets/app-editor-X4geDaql.js +0 -1
  224. package/dist/client/assets/page-seo-sheet-CPW3cnfl.js +0 -1
  225. package/dist/client/assets/record-editor-OCeUQc_J.js +0 -1
  226. package/dist/client/assets/registry-CnAAEzHT.js +0 -2
  227. package/dist/client/assets/save-referenced-block-gIsmpl0Z.js +0 -1
  228. package/dist/client/assets/store-registry-D8gFa-sw.js +0 -2
  229. package/dist/client/assets/useInfiniteQuery-BYCGnaMl.js +0 -1
  230. package/dist/client/assets/useSuspenseInfiniteQuery-CttlyQrq.js +0 -1
  231. package/dist/client/assets/workflow-detail-BES81Spk.js +0 -1
@@ -957,7 +957,7 @@ ${$1}`,D++}else kV(N,E,v)?V=N.slice(N.charCodeAt(E+6)===Y8?E+7:E+6,f)||void 0:q(
957
957
  `,E)}return N.slice(E)}for(;E<N.length;){let f=N.indexOf("\r",E),v=N.indexOf(`
958
958
  `,E),y=-1;if(f!==-1&&v!==-1?y=f<v?f:v:f!==-1?f===N.length-1?y=-1:y=f:v!==-1&&(y=v),y===-1)break;q(N,E,y),E=y+1,N.charCodeAt(E-1)===Ov&&N.charCodeAt(E)===yV&&E++}return N.slice(E)}function q(N,E,f){if(E===f){M();return}let v=N.charCodeAt(E);if(TV(N,E,v)){let _1=N.charCodeAt(E+5)===Y8?E+6:E+5,W0=N.slice(_1,f);B=D===0?W0:`${B}
959
959
  ${W0}`,D++;return}if(kV(N,E,v)){V=N.slice(N.charCodeAt(E+6)===Y8?E+7:E+6,f)||void 0;return}if(v===105&&N.charCodeAt(E+1)===100&&N.charCodeAt(E+2)===58){let _1=N.slice(N.charCodeAt(E+3)===Y8?E+4:E+3,f);K=_1.includes("\x00")?void 0:_1;return}if(v===58){if(W){let _1=N.slice(E,f);W(_1.slice(N.charCodeAt(E+1)===Y8?2:1))}return}let y=N.slice(E,f),$1=y.indexOf(":");if($1===-1){O(y,"",y);return}let j1=y.slice(0,$1),X0=y.charCodeAt($1+1)===Y8?2:1,F0=y.slice($1+X0);O(j1,F0,y)}function O(N,E,f){switch(N){case"event":V=E||void 0;break;case"data":B=D===0?E:`${B}
960
- ${E}`,D++;break;case"id":K=E.includes("\x00")?void 0:E;break;case"retry":/^\d+$/.test(E)?Q(parseInt(E,10)):Y(new UW(`Invalid \`retry\` value: "${E}"`,{type:"invalid-retry",value:E,line:f}));break;default:Y(new UW(`Unknown field "${N.length>20?`${N.slice(0,20)}\u2026`:N}"`,{type:"unknown-field",field:N,value:E,line:f}));break}}function M(){D>0&&Z({id:K,event:V,data:B}),K=void 0,B="",D=0,V=void 0}function I(N={}){if(N.consume&&J.length>0){let E=J.join("");q(E,0,E.length)}G=!0,K=void 0,B="",D=0,V=void 0,J.length=0}return{feed:L,reset:I}}function TV($,Z,Y){return Y===100&&$.charCodeAt(Z+1)===97&&$.charCodeAt(Z+2)===116&&$.charCodeAt(Z+3)===97&&$.charCodeAt(Z+4)===58}function kV($,Z,Y){return Y===101&&$.charCodeAt(Z+1)===118&&$.charCodeAt(Z+2)===101&&$.charCodeAt(Z+3)===110&&$.charCodeAt(Z+4)===116&&$.charCodeAt(Z+5)===58}class jW extends TransformStream{constructor({onError:$,onRetry:Z,onComment:Y}={}){let Q;super({start(W){Q=b5({onEvent:(J)=>{W.enqueue(J)},onError(J){$==="terminate"?W.error(J):typeof $=="function"&&$(J)},onRetry:Z,onComment:Y})},transform(W){Q.feed(W)}})}}var Nv={initialReconnectionDelay:1000,maxReconnectionDelay:30000,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Q8 extends Error{constructor($,Z){super(`Streamable HTTP error: ${Z}`);this.code=$}}class v5{constructor($,Z){this._hasCompletedAuthFlow=!1,this._url=$,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=Z?.requestInit,this._authProvider=Z?.authProvider,this._fetch=Z?.fetch,this._fetchWithInit=q5(Z?.fetch,Z?.requestInit),this._sessionId=Z?.sessionId,this._reconnectionOptions=Z?.reconnectionOptions??Nv}async _authThenStart(){if(!this._authProvider)throw new e1("No auth provider");let $;try{$=await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(Z){throw this.onerror?.(Z),Z}if($!=="AUTHORIZED")throw new e1;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let $={};if(this._authProvider){let Y=await this._authProvider.tokens();if(Y)$.Authorization=`Bearer ${Y.access_token}`}if(this._sessionId)$["mcp-session-id"]=this._sessionId;if(this._protocolVersion)$["mcp-protocol-version"]=this._protocolVersion;let Z=o8(this._requestInit?.headers);return new Headers({...$,...Z})}async _startOrAuthSse($){let{resumptionToken:Z}=$;try{let Y=await this._commonHeaders();if(Y.set("Accept","text/event-stream"),Z)Y.set("last-event-id",Z);let Q=await(this._fetch??fetch)(this._url,{method:"GET",headers:Y,signal:this._abortController?.signal});if(!Q.ok){if(await Q.body?.cancel(),Q.status===401&&this._authProvider)return await this._authThenStart();if(Q.status===405)return;throw new Q8(Q.status,`Failed to open SSE stream: ${Q.statusText}`)}this._handleSseStream(Q.body,$,!0)}catch(Y){throw this.onerror?.(Y),Y}}_getNextReconnectionDelay($){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let Z=this._reconnectionOptions.initialReconnectionDelay,Y=this._reconnectionOptions.reconnectionDelayGrowFactor,Q=this._reconnectionOptions.maxReconnectionDelay;return Math.min(Z*Math.pow(Y,$),Q)}_scheduleReconnection($,Z=0){let Y=this._reconnectionOptions.maxRetries;if(Z>=Y){this.onerror?.(Error(`Maximum reconnection attempts (${Y}) exceeded.`));return}let Q=this._getNextReconnectionDelay(Z);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse($).catch((W)=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${W instanceof Error?W.message:String(W)}`)),this._scheduleReconnection($,Z+1)})},Q)}_handleSseStream($,Z,Y){if(!$)return;let{onresumptiontoken:Q,replayMessageId:W}=Z,J,G=!1,K=!1;(async()=>{try{let D=$.pipeThrough(new TextDecoderStream).pipeThrough(new jW({onRetry:(A)=>{this._serverRetryMs=A}})).getReader();while(!0){let{value:A,done:q}=await D.read();if(q)break;if(A.id)J=A.id,G=!0,Q?.(A.id);if(!A.data)continue;if(!A.event||A.event==="message")try{let O=w6.parse(JSON.parse(A.data));if(r6(O)){if(K=!0,W!==void 0)O.id=W}this.onmessage?.(O)}catch(O){this.onerror?.(O)}}if((Y||G)&&!K&&this._abortController&&!this._abortController.signal.aborted)this._scheduleReconnection({resumptionToken:J,onresumptiontoken:Q,replayMessageId:W},0)}catch(D){if(this.onerror?.(Error(`SSE stream disconnected: ${D}`)),(Y||G)&&!K&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:J,onresumptiontoken:Q,replayMessageId:W},0)}catch(A){this.onerror?.(Error(`Failed to reconnect: ${A instanceof Error?A.message:String(A)}`))}}})()}async start(){if(this._abortController)throw Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth($){if(!this._authProvider)throw new e1("No auth provider");if(await p0(this._authProvider,{serverUrl:this._url,authorizationCode:$,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1("Failed to authorize")}async close(){if(this._reconnectionTimeout)clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0;this._abortController?.abort(),this.onclose?.()}async send($,Z){try{let{resumptionToken:Y,onresumptiontoken:Q}=Z||{};if(Y){this._startOrAuthSse({resumptionToken:Y,replayMessageId:k9($)?$.id:void 0}).catch((L)=>this.onerror?.(L));return}let W=await this._commonHeaders();W.set("content-type","application/json"),W.set("accept","application/json, text/event-stream");let J={...this._requestInit,method:"POST",headers:W,body:JSON.stringify($),signal:this._abortController?.signal},G=await(this._fetch??fetch)(this._url,J),K=G.headers.get("mcp-session-id");if(K)this._sessionId=K;if(!G.ok){let L=await G.text().catch(()=>null);if(G.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Q8(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:A,scope:q}=Z9(G);if(this._resourceMetadataUrl=A,this._scope=q,await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1;return this._hasCompletedAuthFlow=!0,this.send($)}if(G.status===403&&this._authProvider){let{resourceMetadataUrl:A,scope:q,error:O}=Z9(G);if(O==="insufficient_scope"){let M=G.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===M)throw new Q8(403,"Server returned 403 after trying upscoping");if(q)this._scope=q;if(A)this._resourceMetadataUrl=A;if(this._lastUpscopingHeader=M??void 0,await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new e1;return this.send($)}}throw new Q8(G.status,`Error POSTing to endpoint: ${L}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,G.status===202){if(await G.body?.cancel(),fK($))this._startOrAuthSse({resumptionToken:void 0}).catch((L)=>this.onerror?.(L));return}let D=(Array.isArray($)?$:[$]).filter((L)=>("method"in L)&&("id"in L)&&L.id!==void 0).length>0,V=G.headers.get("content-type");if(D)if(V?.includes("text/event-stream"))this._handleSseStream(G.body,{onresumptiontoken:Q},!1);else if(V?.includes("application/json")){let L=await G.json(),A=Array.isArray(L)?L.map((q)=>w6.parse(q)):[w6.parse(L)];for(let q of A)this.onmessage?.(q)}else throw await G.body?.cancel(),new Q8(-1,`Unexpected content type: ${V}`);else await G.body?.cancel()}catch(Y){throw this.onerror?.(Y),Y}}get sessionId(){return this._sessionId}async terminateSession(){if(!this._sessionId)return;try{let $=await this._commonHeaders(),Z={...this._requestInit,method:"DELETE",headers:$,signal:this._abortController?.signal},Y=await(this._fetch??fetch)(this._url,Z);if(await Y.body?.cancel(),!Y.ok&&Y.status!==405)throw new Q8(Y.status,`Failed to terminate session: ${Y.statusText}`);this._sessionId=void 0}catch($){throw this.onerror?.($),$}}setProtocolVersion($){this._protocolVersion=$}get protocolVersion(){return this._protocolVersion}async resumeStream($,Z){await this._startOrAuthSse({resumptionToken:$,onresumptiontoken:Z?.onresumptiontoken})}}import{z as h}from"zod";var Zy=h.object({authorizationEndpoint:h.string().url(),tokenEndpoint:h.string().url(),introspectionEndpoint:h.string().url().optional(),clientId:h.string(),clientSecret:h.string().optional(),scopes:h.array(h.string()),grantType:h.enum(["authorization_code","client_credentials"])}),xV=h.object({type:h.literal("object"),properties:h.record(h.string(),h.unknown()).optional(),required:h.array(h.string()).optional()}).catchall(h.unknown()),Yy=C4.extend({inputSchema:xV,outputSchema:xV.optional()}),Qy=h.object({headers:h.record(h.string(),h.string()).optional()}),Xy=h.object({command:h.string().describe("Command to run (e.g., 'npx', 'node')"),args:h.array(h.string()).optional().describe("Command arguments"),cwd:h.string().optional().describe("Working directory"),envVars:h.record(h.string(),h.string()).optional().describe("Environment variables (encrypted in storage)")}),y5=h.object({id:h.string().describe("Unique identifier for the connection"),title:h.string().describe("Human-readable name for the connection"),created_at:h.string().describe("When the connection was created"),updated_at:h.string().describe("When the connection was last updated"),created_by:h.string().describe("User ID who created the connection"),updated_by:h.string().optional().describe("User ID who last updated the connection"),organization_id:h.string().describe("Organization ID this connection belongs to"),description:h.string().nullable().describe("Description of the connection"),icon:h.string().nullable().describe("Icon URL for the connection"),app_name:h.string().nullable().describe("Associated app name"),app_id:h.string().nullable().describe("Associated app ID"),slug:h.string().nullable().optional().describe("URL-safe slug derived from app_name, connection_url, or title"),connection_type:h.enum(["HTTP","SSE","Websocket","STDIO","VIRTUAL"]).describe("Type of connection"),connection_url:h.string().nullable().describe("URL for HTTP/SSE/WebSocket connections. virtual://$id for VIRTUAL. Null for STDIO."),connection_token:h.string().nullable().describe("Authentication token (for HTTP connections)"),connection_headers:h.union([Xy,Qy]).nullable().describe("Connection parameters. HTTP: { headers }. STDIO: { command, args, cwd, envVars }"),oauth_config:Zy.nullable().describe("OAuth configuration"),configuration_state:h.record(h.string(),h.unknown()).nullable().describe("Configuration state (decrypted)"),configuration_scopes:h.array(h.string()).nullable().optional().describe("Configuration scopes"),metadata:h.record(h.string(),h.unknown()).nullable().describe("Additional metadata (includes repository info)"),tools:h.array(Yy).nullable().describe("Discovered tools from MCP"),bindings:h.array(h.string()).nullable().describe("Detected bindings"),status:h.enum(["active","inactive","error"]).describe("Current status")}),gV=y5.omit({created_at:!0,updated_at:!0,created_by:!0,updated_by:!0,organization_id:!0,tools:!0,bindings:!0,status:!0}).partial({id:!0,description:!0,icon:!0,app_name:!0,app_id:!0,connection_url:!0,connection_token:!0,connection_headers:!0,oauth_config:!0,configuration_state:!0,configuration_scopes:!0,metadata:!0}).extend({icon:h.string().nullish()}),uV=y5.partial();import{z as C}from"zod";var A7=C.object({connection_id:C.string().describe("Connection ID"),selected_tools:C.array(C.string()).nullable().describe("Selected tool names. null = all tools included, array = only these tools included"),selected_resources:C.array(C.string()).nullable().describe("Selected resource URIs or patterns. Supports * and ** wildcards for pattern matching. null = all resources included, array = only these resources included"),selected_prompts:C.array(C.string()).nullable().describe("Selected prompt names. null = all prompts included, array = only these prompts included")}),lV=A7.extend({selected_tools:A7.shape.selected_tools.optional(),selected_resources:A7.shape.selected_resources.optional(),selected_prompts:A7.shape.selected_prompts.optional()}),Wy=C.object({connectionId:C.string(),toolName:C.string(),label:C.string(),icon:C.string().nullable().optional()}),MW=C.object({id:C.string().describe("Stable id; used as React key and ?tab= value"),title:C.string().describe("Tab label"),icon:C.string().optional().describe("Optional lucide icon name"),view:C.object({type:C.literal("ext-app"),appId:C.string(),args:C.record(C.string(),C.unknown()).optional()})}),PW=C.object({defaultMainView:C.object({type:C.string(),id:C.string().optional(),toolName:C.string().optional()}).nullable().optional(),chatDefaultOpen:C.boolean().nullable().optional(),tabs:C.array(MW).optional()}),hV=C.object({connectionId:C.string().optional().describe("Connection that owns the resource \u2014 the host opens a direct MCP client to this connection so the iframe can call tools by their bare names."),resourceUri:C.string().describe("ui:// resource URI exposed by `connectionId`. Read on the home page and rendered via MCPAppRenderer."),minHeight:C.number().int().positive().optional(),maxHeight:C.number().int().positive().optional()}),wW=C.object({banner:C.string().nullable().optional(),bannerColor:C.string().nullable().optional(),icon:C.string().nullable().optional(),themeColor:C.string().nullable().optional(),pinnedViews:C.array(Wy).nullable().optional(),layout:PW.nullable().optional(),homeTile:hV.nullable().optional(),homeTiles:C.array(hV).nullable().optional(),homePrompts:C.array(C.string()).nullable().optional()});var EW=/^[A-Za-z_][A-Za-z0-9_]*$/,mV=C.string().min(1).regex(EW,{message:"Env var key must start with a letter or underscore and contain only letters, digits, and underscores."}),Jy=C.discriminatedUnion("kind",[C.object({key:mV,kind:C.literal("literal"),value:C.string()}),C.object({key:mV,kind:C.literal("secret"),secretId:C.string().min(1)})]),RW=C.object({selected:C.string().nullable().optional().describe("User-selected package manager (npm | pnpm | yarn | bun | deno). Null/absent means autodetect on next SANDBOX_START."),port:C.string().nullable().optional().describe("User-selected dev server port as a string (allows '' / null for unset). Null/absent means autodetect."),path:C.string().nullable().optional().describe("Optional path (relative to repo root) to the directory containing package.json. Null/absent means repo root. Forwarded as `application.packageManager.path` to the daemon config."),env:C.array(Jy).nullable().optional().describe("Env vars injected on every SANDBOX_START. Literal entries inline their value; secret entries store a secretId that mesh resolves via the credential vault before posting /_sandbox/config.")}),_W=C.object({url:C.string().describe("GitHub repository URL"),owner:C.string().describe("Repository owner"),name:C.string().describe("Repository name"),installationId:C.number().optional().describe("GitHub App installation ID. Absent when the repo was linked without a GitHub connection (public-clone mode)."),connectionId:C.string().optional().describe("ID of the mcp-github connection used for authentication. Absent for public repos cloned without credentials.")}),Gy=C.enum(["agent-sandbox","user-desktop"]),Ky=C.enum(["agent-sandbox","user-desktop","cluster"]);var pV={sandboxHandle:C.string().describe("Provider-specific handle"),previewUrl:C.string().nullable().describe("URL where the sandbox's iframe-proxied UI is served, or null when the sandbox has no dev server (blank / tool sandboxes)."),sandboxApiUrl:C.string().nullable().optional().describe("Daemon's public URL \u2014 what cluster\u2192daemon RPCs target. Equal to previewUrl for user-desktop; null/absent for the agent-sandbox provider (routes through hosted ingress)."),sandboxProviderKind:Gy.optional(),createdAt:C.number().optional().describe("Epoch ms the entry was first written by SANDBOX_START. Used by the booting overlay to show a stable elapsed timer that survives browser reloads. Optional for backward compatibility with entries written before this field existed."),startedWith:C.object({packageManager:C.string().nullable().optional().describe("metadata.runtime.selected at the time of SANDBOX_START"),port:C.string().nullable().optional().describe("metadata.runtime.port at the time of SANDBOX_START"),path:C.string().nullable().optional().describe("metadata.runtime.path at the time of SANDBOX_START")}).optional().describe("Snapshot of metadata.runtime fields (selected/port/path) used at SANDBOX_START. The Preview tab compares the live metadata.runtime against this to decide if a restart is required to apply changes.")},CW=C.object(pV),xs=C.object({...pV,sandboxProviderKind:Ky.optional()});var z7=C.record(C.string().describe("userId"),C.record(C.string().describe("branch"),C.record(C.string().describe("sandboxProviderKind"),CW)));var iV=C.object({id:C.string().describe("Unique identifier"),title:C.string().describe("Human-readable name"),description:C.string().nullable().describe("Description"),icon:C.string().nullable().describe("Icon URL"),created_at:C.string().describe("Creation timestamp"),updated_at:C.string().describe("Last update timestamp"),created_by:C.string().describe("User ID who created this item"),updated_by:C.string().optional().describe("User ID who last updated this item"),organization_id:C.string().describe("Organization ID this item belongs to"),status:C.enum(["active","inactive"]).describe("Current status"),pinned:C.boolean().describe("Whether this space is pinned to the sidebar"),metadata:C.object({instructions:C.string().nullable().describe("Instructions also used as system prompt"),enabled_plugins:C.array(C.string()).nullable().optional().describe("List of enabled plugin IDs"),subAgents:C.array(C.string()).nullable().optional().describe("Allowlist of Virtual MCP (agent) IDs this agent may delegate to via subtask. null/absent = all active org agents; empty array = itself only (no cross-agent delegation)."),ui:wW.nullable().optional().describe("UI customization settings"),githubRepo:_W.nullable().optional().describe("Linked GitHub repository"),runtime:RW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:z7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().describe("Metadata"),connections:C.array(A7).describe("Connections with their selected tools, resources, and prompts")}),cV=C.object({title:C.string().min(1).max(255).describe("Name for the virtual MCP"),description:C.string().nullable().optional().describe("Optional description"),icon:C.string().nullish().describe("Optional icon URL"),status:C.enum(["active","inactive"]).optional().default("active").describe("Initial status"),pinned:C.boolean().optional().default(!1).describe("Pin to sidebar"),metadata:C.object({instructions:C.string().nullable().optional().describe("MCP server instructions"),enabled_plugins:C.array(C.string()).nullable().optional().describe("List of enabled plugin IDs"),subAgents:C.array(C.string()).nullable().optional().describe("Allowlist of Virtual MCP (agent) IDs this agent may delegate to via subtask. null/absent = all active org agents; empty array = itself only (no cross-agent delegation)."),ui:wW.nullable().optional().describe("UI customization settings"),githubRepo:_W.nullable().optional().describe("Linked GitHub repository"),runtime:RW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:z7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().nullable().optional().describe("Additional metadata including MCP server instructions"),connections:C.array(lV).describe("Connections to include/exclude (can be empty for exclusion mode)")}),dV=C.object({title:C.string().min(1).max(255).optional().describe("New name"),description:C.string().nullable().optional().describe("New description (null to clear)"),icon:C.string().nullish().describe("New icon URL"),status:C.enum(["active","inactive"]).optional().describe("New status"),pinned:C.boolean().optional().describe("Pin/unpin from sidebar"),metadata:C.object({instructions:C.string().nullable().optional().describe("MCP server instructions"),enabled_plugins:C.array(C.string()).nullable().optional().describe("List of enabled plugin IDs"),subAgents:C.array(C.string()).nullable().optional().describe("Allowlist of Virtual MCP (agent) IDs this agent may delegate to via subtask. null/absent = all active org agents; empty array = itself only (no cross-agent delegation)."),ui:wW.nullable().optional().describe("UI customization settings"),githubRepo:_W.nullable().optional().describe("Linked GitHub repository"),runtime:RW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:z7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().nullable().optional().describe("Additional metadata including MCP server instructions"),connections:C.array(lV).optional().describe("New connections (replaces existing)")});var IW=["in_progress","requires_action","failed","completed"],nV=[...IW,"expired"],fW={STEP:"decopilot.step",FINISH:"decopilot.finish",THREAD_STATUS:"decopilot.thread.status"},rV=Object.values(fW);var aV=i6(L5(),1),oV=i6(eX(),1);function My(){let $=new aV.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return oV.default($),$}class sV{#$=My();#Z=new Map;#Y=new WeakMap;getValidator($){let Z=this.#Y.get($);if(Z)return Z;let Y=Py($),Q=this.#Z.get(Y);if(!Q)Q=this.#$.compile($),this.#Z.set(Y,Q);let W=Q,J=(G)=>{if(W(G))return{valid:!0,data:G,errorMessage:void 0};return{valid:!1,data:void 0,errorMessage:this.#$.errorsText(W.errors)}};return this.#Y.set($,J),J}}function Py($){return JSON.stringify($,(Z,Y)=>{if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Object.fromEntries(Object.keys(Y).sort().map((Q)=>[Q,Y[Q]]));return Y})}var T5=new sV;var tV;(function($){$.Completable="McpCompletable"})(tV||(tV={}));import{ZodOptional as bt}from"zod";var QL="MCP Workflows",XL="Create workflows using your MCP tools";import{sql as WL}from"kysely";var JL={name:"001-workflows",async up($){await $.schema.createTable("workflow_collection").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("title","text",(Z)=>Z.notNull()).addColumn("description","text").addColumn("virtual_mcp_id","text",(Z)=>Z.notNull()).addColumn("steps","text",(Z)=>Z.notNull().defaultTo("[]")).addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(WL`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(WL`CURRENT_TIMESTAMP`)).addColumn("created_by","text").addColumn("updated_by","text").execute(),await $.schema.createIndex("idx_wf_collection_org").ifNotExists().on("workflow_collection").column("organization_id").execute(),await $.schema.createIndex("idx_wf_collection_created_at").ifNotExists().on("workflow_collection").column("created_at").execute(),await $.schema.createTable("workflow").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("workflow_collection_id","text").addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("steps","text",(Z)=>Z.notNull().defaultTo("[]")).addColumn("input","text").addColumn("virtual_mcp_id","text",(Z)=>Z.notNull()).addColumn("created_at_epoch_ms","bigint",(Z)=>Z.notNull()).addColumn("created_by","text").execute(),await $.schema.createIndex("idx_workflow_created_at").ifNotExists().on("workflow").column("created_at_epoch_ms").execute(),await $.schema.createIndex("idx_workflow_collection_id").ifNotExists().on("workflow").column("workflow_collection_id").execute(),await $.schema.createTable("workflow_execution").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("workflow_id","text",(Z)=>Z.notNull().references("workflow.id").onDelete("cascade")).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("status","text",(Z)=>Z.notNull().defaultTo("enqueued")).addColumn("input","text").addColumn("output","text").addColumn("error","text").addColumn("created_at","bigint",(Z)=>Z.notNull()).addColumn("updated_at","bigint",(Z)=>Z.notNull()).addColumn("start_at_epoch_ms","bigint").addColumn("started_at_epoch_ms","bigint").addColumn("completed_at_epoch_ms","bigint").addColumn("timeout_ms","bigint").addColumn("deadline_at_epoch_ms","bigint").addColumn("created_by","text").execute(),await $.schema.createIndex("idx_wf_execution_status").ifNotExists().on("workflow_execution").column("status").execute(),await $.schema.createIndex("idx_wf_execution_workflow_id").ifNotExists().on("workflow_execution").column("workflow_id").execute(),await $.schema.createIndex("idx_wf_execution_org").ifNotExists().on("workflow_execution").column("organization_id").execute(),await $.schema.createIndex("idx_wf_execution_created_at").ifNotExists().on("workflow_execution").column("created_at").execute(),await $.schema.createTable("workflow_execution_step_result").ifNotExists().addColumn("execution_id","text",(Z)=>Z.notNull().references("workflow_execution.id").onDelete("cascade")).addColumn("step_id","text",(Z)=>Z.notNull()).addColumn("started_at_epoch_ms","bigint").addColumn("completed_at_epoch_ms","bigint").addColumn("output","text").addColumn("error","text").addColumn("raw_tool_output","text").execute(),await $.schema.createIndex("idx_wf_step_result_pk").ifNotExists().on("workflow_execution_step_result").columns(["execution_id","step_id"]).unique().execute(),await $.schema.createIndex("idx_wf_step_result_execution").ifNotExists().on("workflow_execution_step_result").column("execution_id").execute()},async down($){await $.schema.dropIndex("idx_wf_step_result_execution").ifExists().execute(),await $.schema.dropIndex("idx_wf_step_result_pk").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_created_at").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_org").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_workflow_id").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_status").ifExists().execute(),await $.schema.dropIndex("idx_workflow_collection_id").ifExists().execute(),await $.schema.dropIndex("idx_workflow_created_at").ifExists().execute(),await $.schema.dropIndex("idx_wf_collection_created_at").ifExists().execute(),await $.schema.dropIndex("idx_wf_collection_org").ifExists().execute(),await $.schema.dropTable("workflow_execution_step_result").ifExists().execute(),await $.schema.dropTable("workflow_execution").ifExists().execute(),await $.schema.dropTable("workflow").ifExists().execute(),await $.schema.dropTable("workflow_collection").ifExists().execute()}};var GL={name:"002-execution-list-index",async up($){await $.schema.createIndex("idx_wf_execution_org_created_at").ifNotExists().on("workflow_execution").columns(["organization_id","created_at desc"]).execute()},async down($){await $.schema.dropIndex("idx_wf_execution_org_created_at").ifExists().execute()}};var KL={name:"003-retry-and-input-schema",async up($){await $.schema.alterTable("workflow_execution_step_result").addColumn("attempt_number","integer",(Z)=>Z.notNull().defaultTo(1)).execute(),await $.schema.alterTable("workflow_collection").addColumn("input_schema","text").execute()},async down($){await $.schema.alterTable("workflow_execution_step_result").dropColumn("attempt_number").execute(),await $.schema.alterTable("workflow_collection").dropColumn("input_schema").execute()}};var HL=[JL,GL,KL];function $0($){let Z=$;if(!Z.organization)throw Error("Organization context required for workflow tools");return Z}function S1($){if($===null||$===void 0)return null;if(typeof $==="object")return $;if(typeof $!=="string")return $;try{return JSON.parse($)}catch{return $}}var SW=null;function BL($){SW=$}function u1(){if(!SW)throw Error('Plugin storage not initialized. Make sure the "workflows" plugin is enabled.');return SW}function FL($){return{...$,steps:S1($.steps)??[],input_schema:S1($.input_schema)??null}}class bW{db;constructor($){this.db=$}async list($,Z={}){let{limit:Y=50,offset:Q=0}=Z,W=await this.db.selectFrom("workflow_collection").selectAll().where("organization_id","=",$).orderBy("created_at","desc").limit(Y).offset(Q).execute(),J=await this.db.selectFrom("workflow_collection").select((G)=>G.fn.countAll().as("count")).where("organization_id","=",$).executeTakeFirstOrThrow();return{items:W,totalCount:Number(J.count)}}async getById($,Z){let Y=await this.db.selectFrom("workflow_collection").selectAll().where("id","=",$).where("organization_id","=",Z).executeTakeFirst();return Y?FL(Y):null}async create($){let{input_schema:Z,...Y}=$,Q=await this.db.insertInto("workflow_collection").values({...Y,input_schema:Z!=null?JSON.stringify(Z):null}).returningAll().executeTakeFirstOrThrow();return FL(Q)}async update($,Z,Y){let{input_schema:Q,...W}=Y,J={...W,updated_at:new Date().toISOString()};if(Q!==void 0)J.input_schema=Q?JSON.stringify(Q):null;return await this.db.updateTable("workflow_collection").set(J).where("id","=",$).where("organization_id","=",Z).returningAll().executeTakeFirstOrThrow()}async delete($,Z){return await this.db.deleteFrom("workflow_collection").where("id","=",$).where("organization_id","=",Z).returningAll().executeTakeFirstOrThrow()}}function Ey($){return{...$,steps:S1($.steps)??[],input:S1($.input)??null}}function k6($){return{...$,output:S1($.output),error:S1($.error),raw_tool_output:S1($.raw_tool_output)}}class vW{db;constructor($){this.db=$}async _createWorkflow($,Z){let Y=crypto.randomUUID(),Q=Date.now();return await $.insertInto("workflow").values({id:Y,workflow_collection_id:Z.workflowCollectionId??null,organization_id:Z.organizationId,steps:JSON.stringify(Z.steps),input:Z.input?JSON.stringify(Z.input):null,virtual_mcp_id:Z.virtualMcpId,created_at_epoch_ms:Q,created_by:Z.createdBy??null}).execute(),{id:Y}}async createWorkflow($){return this._createWorkflow(this.db,$)}async getWorkflow($){let Z=await this.db.selectFrom("workflow").selectAll().where("id","=",$).executeTakeFirst();return Z?Ey(Z):null}async createExecution($){return this.db.transaction().execute(async(Z)=>{let Y=Date.now(),{id:Q}=await this._createWorkflow(Z,{organizationId:$.organizationId,workflowCollectionId:$.workflowCollectionId,virtualMcpId:$.virtualMcpId,input:$.input,steps:$.steps,createdBy:$.createdBy}),W=crypto.randomUUID(),J=$.startAtEpochMs??Y,G=$.timeoutMs?J+$.timeoutMs:null;return await Z.insertInto("workflow_execution").values({id:W,workflow_id:Q,organization_id:$.organizationId,status:"enqueued",input:$.input?JSON.stringify($.input):null,created_at:Y,updated_at:Y,start_at_epoch_ms:J,timeout_ms:$.timeoutMs??null,deadline_at_epoch_ms:G,created_by:$.createdBy??null}).execute(),{id:W}})}async getExecution($,Z){return await this.db.selectFrom("workflow_execution").selectAll().where("id","=",$).where("organization_id","=",Z).executeTakeFirst()??null}async getExecutionFull($,Z){let Y=await this.db.selectFrom("workflow_execution").selectAll().where("id","=",$).where("organization_id","=",Z).executeTakeFirst();if(!Y)return null;let Q=await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).execute();return{execution:Y,stepResults:Q.map(k6)}}async getExecutionContext($){let[Z,Y]=await Promise.all([this.db.selectFrom("workflow_execution as we").innerJoin("workflow as w","we.workflow_id","w.id").select(["we.id","we.status","we.workflow_id","we.deadline_at_epoch_ms","w.steps","w.input","w.virtual_mcp_id"]).where("we.id","=",$).executeTakeFirst(),this.db.selectFrom("workflow_execution_step_result").select(["step_id","started_at_epoch_ms","completed_at_epoch_ms","output","error","attempt_number"]).where("execution_id","=",$).execute()]);if(!Z)return null;return{execution:{id:Z.id,status:Z.status,workflow_id:Z.workflow_id,deadline_at_epoch_ms:Z.deadline_at_epoch_ms},workflow:{steps:S1(Z.steps)??[],input:S1(Z.input)??null,virtual_mcp_id:Z.virtual_mcp_id},stepResults:Y.map((Q)=>({step_id:Q.step_id,started_at_epoch_ms:Q.started_at_epoch_ms,completed_at_epoch_ms:Q.completed_at_epoch_ms,output:S1(Q.output),error:S1(Q.error),attempt_number:Q.attempt_number}))}}async claimExecution($){let Z=Date.now(),Y=await this.db.updateTable("workflow_execution").set({status:"running",updated_at:Z}).where("id","=",$).where("status","=","enqueued").returningAll().executeTakeFirst();if(!Y)return null;let Q=await this.getWorkflow(Y.workflow_id);if(!Q)throw Error(`Workflow ${Y.workflow_id} not found for execution ${$}`);return{execution:Y,workflow:Q}}async updateExecution($,Z,Y){let W={updated_at:Date.now()};if(Z.status!==void 0)W.status=Z.status;if(Z.output!==void 0)W.output=JSON.stringify(Z.output);if(Z.error!==void 0)W.error=JSON.stringify(Z.error);if(Z.completed_at_epoch_ms!==void 0)W.completed_at_epoch_ms=Z.completed_at_epoch_ms;let J=this.db.updateTable("workflow_execution").set(W).where("id","=",$);if(Y?.onlyIfStatus)J=J.where("status","=",Y.onlyIfStatus);return await J.returningAll().executeTakeFirst()??null}async cancelExecution($,Z){let Y=Date.now();return!!await this.db.updateTable("workflow_execution").set({status:"cancelled",updated_at:Y}).where("id","=",$).where("organization_id","=",Z).where("status","in",["enqueued","running"]).returningAll().executeTakeFirst()}async resumeExecution($,Z){return this.db.transaction().execute(async(Y)=>{let Q=Date.now(),W=await Y.selectFrom("workflow_execution").where("id","=",$).where("organization_id","=",Z).select(["status"]).executeTakeFirst();if(!W)return!1;let{status:J}=W;if(J==="success"){let B=await Y.selectFrom("workflow_execution_step_result").where("execution_id","=",$).where("error","is not",null).select(Y.fn.countAll().as("count")).executeTakeFirstOrThrow();if(Number(B.count)===0)return!1}else if(J!=="cancelled"&&J!=="error")return!1;await Y.updateTable("workflow_execution").set({status:"enqueued",updated_at:Q,completed_at_epoch_ms:null,error:null}).where("id","=",$).execute();let G=await Y.selectFrom("workflow_execution_step_result").where("execution_id","=",$).where("error","is not",null).where("step_id","like","%[%").select("step_id").execute(),K=new Set;for(let B of G)K.add(B.step_id.replace(/\[\d+\]$/,""));if(await Y.deleteFrom("workflow_execution_step_result").where("execution_id","=",$).where((B)=>B.or([B("completed_at_epoch_ms","is",null),B("error","is not",null)])).execute(),K.size>0)await Y.deleteFrom("workflow_execution_step_result").where("execution_id","=",$).where("step_id","in",[...K]).execute();return!0})}async listExecutions($,Z={}){let{limit:Y=50,offset:Q=0,status:W,workflowCollectionId:J}=Z,G=this.db.selectFrom("workflow_execution as we").innerJoin("workflow as w","we.workflow_id","w.id").leftJoin("workflow_collection as wc","w.workflow_collection_id","wc.id").select(["we.id","we.workflow_id","we.organization_id","we.status","we.input","we.output","we.error","we.created_at","we.updated_at","we.start_at_epoch_ms","we.started_at_epoch_ms","we.completed_at_epoch_ms","we.timeout_ms","we.deadline_at_epoch_ms","we.created_by","w.virtual_mcp_id"]).select((L)=>L.fn.coalesce("wc.title",L.val("Workflow Execution")).as("title")).where("we.organization_id","=",$);if(W)G=G.where("we.status","=",W);if(J)G=G.where("w.workflow_collection_id","=",J);let K=await G.orderBy("we.created_at","desc").limit(Y).offset(Q).execute(),B=this.db.selectFrom("workflow_execution as we").innerJoin("workflow as w","we.workflow_id","w.id").select((L)=>L.fn.countAll().as("count")).where("we.organization_id","=",$);if(W)B=B.where("we.status","=",W);if(J)B=B.where("w.workflow_collection_id","=",J);let D=await B.executeTakeFirstOrThrow(),V=Number(D.count);return{items:K,totalCount:V,hasMore:Q+K.length<V}}async createStepResult($){let Z=await this.db.insertInto("workflow_execution_step_result").values({execution_id:$.execution_id,step_id:$.step_id,started_at_epoch_ms:$.completed_at_epoch_ms?Date.now():null,completed_at_epoch_ms:$.completed_at_epoch_ms??null,output:$.output!==void 0?JSON.stringify($.output):null,error:$.error!==void 0?JSON.stringify($.error):null,attempt_number:1}).onConflict((Y)=>Y.columns(["execution_id","step_id"]).doNothing()).returningAll().executeTakeFirst();return Z?k6(Z):null}async updateStepResult($,Z,Y){let Q={};if(Y.output!==void 0)Q.output=Y.output===null?null:JSON.stringify(Y.output);if(Y.error!==void 0)Q.error=Y.error===null?null:JSON.stringify(Y.error);if(Y.started_at_epoch_ms!==void 0)Q.started_at_epoch_ms=Y.started_at_epoch_ms;if(Y.completed_at_epoch_ms!==void 0)Q.completed_at_epoch_ms=Y.completed_at_epoch_ms;if(Y.attempt_number!==void 0)Q.attempt_number=Y.attempt_number;if(Y.raw_tool_output!==void 0)Q.raw_tool_output=Y.raw_tool_output===null?null:JSON.stringify(Y.raw_tool_output);if(Object.keys(Q).length===0)return null;let W=await this.db.updateTable("workflow_execution_step_result").set(Q).where("execution_id","=",$).where("step_id","=",Z).returningAll().executeTakeFirst();return W?k6(W):null}async claimStepForRetry($,Z,Y){let Q=await this.db.updateTable("workflow_execution_step_result").set({started_at_epoch_ms:Date.now()}).where("execution_id","=",$).where("step_id","=",Z).where("attempt_number","=",Y).where("started_at_epoch_ms","is",null).returningAll().executeTakeFirst();return Q?k6(Q):null}async resetStepResultForRetry($,Z,Y){await this.updateStepResult($,Z,{completed_at_epoch_ms:null,output:null,error:null,started_at_epoch_ms:null,attempt_number:Y,raw_tool_output:null})}async checkpointAndTransform($,Z,Y,Q){await this.db.updateTable("workflow_execution_step_result").set({raw_tool_output:JSON.stringify(Y)}).where("execution_id","=",$).where("step_id","=",Z).execute();let W,J;try{let B=await Q(Y);W=B.output,J=B.error}catch(B){J=B instanceof Error?`Transform failed: ${B.message}`:`Transform failed: ${String(B)}`}let G={completed_at_epoch_ms:Date.now()};if(W!==void 0)G.output=JSON.stringify(W);if(J!==void 0)G.error=JSON.stringify(J);let K=await this.db.updateTable("workflow_execution_step_result").set(G).where("execution_id","=",$).where("step_id","=",Z).returningAll().executeTakeFirst();return K?k6(K):null}async getStepResult($,Z){let Y=await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).where("step_id","=",Z).executeTakeFirst();return Y?k6(Y):null}async getStepResults($){return(await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).execute()).map(k6)}async deleteStepResult($,Z){await this.db.deleteFrom("workflow_execution_step_result").where("execution_id","=",$).where("step_id","=",Z).execute()}async getStepResultsByPrefix($,Z){let Y=Z.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_");return(await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).where("step_id","like",`${Y}%`).orderBy("step_id").execute()).map(k6)}async recoverStuckExecutions(){return this.db.updateTable("workflow_execution").set({status:"enqueued",updated_at:Date.now()}).where("status","=","running").returning(["id","organization_id"]).execute()}}function DL($){let Z=$.db;return{collections:new bW(Z),executions:new vW(Z)}}import{z as c}from"zod";import{z as T}from"zod";import{z as q0}from"zod/v4";import{z as VL}from"zod/v4";import{z as k5}from"zod/v4";import{z as i0}from"zod/v4";import{z as Iy}from"zod/v4";import{z as X8}from"zod/v4";import{z as c0}from"zod/v4";import{z as b1}from"zod/v4";import{z as LL}from"zod/v4";import{z as u5}from"zod/v4";import{z as ty}from"zod/v4";import{z as UL}from"zod/v4";import{z as x5}from"zod/v4";import{z as GT}from"zod/v4";var Ry=class{apply($,Z){if(!Z.type)return;let Y=Array.isArray(Z.type)?Z.type:[Z.type],Q=new Set(Y);if(!Q.has("string"))$.string=!1;if(!Q.has("number")&&!Q.has("integer"))$.number=!1;if(!Q.has("boolean"))$.boolean=!1;if(!Q.has("null"))$.null=!1;if(!Q.has("array"))$.array=!1;if(!Q.has("object"))$.object=!1;if(Q.has("integer")&&$.number!==!1){let W=$.number||VL.number();if(W instanceof VL.ZodNumber)$.number=W.int()}}},_y=class{apply($,Z){if(Z.const===void 0)return;let Y=Z.const;if($.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1,typeof Y==="string")$.string=k5.literal(Y);else if(typeof Y==="number")$.number=k5.literal(Y);else if(typeof Y==="boolean")$.boolean=k5.literal(Y);else if(Y===null)$.null=k5.null();else if(Array.isArray(Y))$.array=void 0;else if(typeof Y==="object")$.object=void 0}},Cy=class{apply($,Z){if(!Z.enum)return;if(Z.enum.length===0){if(!Z.type)$.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1;return}let Y={string:Z.enum.filter((Q)=>typeof Q==="string"),number:Z.enum.filter((Q)=>typeof Q==="number"),boolean:Z.enum.filter((Q)=>typeof Q==="boolean"),null:Z.enum.filter((Q)=>Q===null),array:Z.enum.filter((Q)=>Array.isArray(Q)),object:Z.enum.filter((Q)=>typeof Q==="object"&&Q!==null&&!Array.isArray(Q))};$.string=this.createTypeSchema(Y.string,"string"),$.number=this.createTypeSchema(Y.number,"number"),$.boolean=this.createTypeSchema(Y.boolean,"boolean"),$.null=Y.null.length>0?i0.null():!1,$.array=Y.array.length>0?void 0:!1,$.object=Y.object.length>0?void 0:!1}createTypeSchema($,Z){if($.length===0)return!1;if($.length===1)return i0.literal($[0]);if(Z==="string")return i0.enum($);if(Z==="number"){let[Y,Q,...W]=$;return i0.union([i0.literal(Y),i0.literal(Q),...W.map((J)=>i0.literal(J))])}if(Z==="boolean")return i0.union([i0.literal(!0),i0.literal(!1)]);return!1}},fy=class{apply($,Z){let Y=Z;if(Y.type==="string"&&Y.format==="binary"&&Y.contentEncoding==="binary"){let Q=Iy.file();if(Y.minLength!==void 0)Q=Q.min(Y.minLength);if(Y.maxLength!==void 0)Q=Q.max(Y.maxLength);if(Y.contentMediaType!==void 0)Q=Q.mime(Y.contentMediaType);$.file=Q,$.string=!1}}},Sy=class{apply($,Z){let Y=Z;if(Z.type===void 0&&(Y.minLength!==void 0||Y.maxLength!==void 0||Y.pattern!==void 0)){if($.string===void 0)$.string=X8.string()}}},by=class{apply($,Z){let Y=Z;if(Y.minLength===void 0)return;if($.string!==!1){let Q=$.string||X8.string();if(Q instanceof X8.ZodString)$.string=Q.refine((W)=>{return Array.from(W).length>=Y.minLength},{message:`String must be at least ${Y.minLength} characters long`})}}},vy=class{apply($,Z){let Y=Z;if(Y.maxLength===void 0)return;if($.string!==!1){let Q=$.string||X8.string();if(Q instanceof X8.ZodString)$.string=Q.refine((W)=>{return Array.from(W).length<=Y.maxLength},{message:`String must be at most ${Y.maxLength} characters long`})}}},yy=class{apply($,Z){let Y=Z;if(!Y.pattern)return;if($.string!==!1){let Q=$.string||X8.string();if(Q instanceof X8.ZodString){let W=new RegExp(Y.pattern);$.string=Q.regex(W)}}}},Ty=class{apply($,Z){let Y=Z;if(Y.minimum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)$.number=Q.min(Y.minimum)}}},ky=class{apply($,Z){let Y=Z;if(Y.maximum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)$.number=Q.max(Y.maximum)}}},xy=class{apply($,Z){let Y=Z;if(Y.exclusiveMinimum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)if(typeof Y.exclusiveMinimum==="number")$.number=Q.gt(Y.exclusiveMinimum);else $.number=!1}}},gy=class{apply($,Z){let Y=Z;if(Y.exclusiveMaximum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)if(typeof Y.exclusiveMaximum==="number")$.number=Q.lt(Y.exclusiveMaximum);else $.number=!1}}},uy=class{apply($,Z){let Y=Z;if(Y.multipleOf===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)$.number=Q.refine((W)=>{if(Y.multipleOf===0)return!1;let J=W/Y.multipleOf,G=Math.round(J),K=Math.min(Math.abs(W)*Number.EPSILON*10,Math.abs(Y.multipleOf)*Number.EPSILON*10);return Math.abs(J-G)<=K/Math.abs(Y.multipleOf)},{message:`Must be a multiple of ${Y.multipleOf}`})}}},hy=class{apply($,Z){let Y=Z;if(Z.type===void 0&&(Y.minItems!==void 0||Y.maxItems!==void 0||Y.items!==void 0||Y.prefixItems!==void 0)){if($.array===void 0)$.array=b1.array(b1.any())}}},my=class{apply($,Z){let Y=Z;if(Y.minItems===void 0)return;if($.array!==!1)$.array=($.array||b1.array(b1.any())).min(Y.minItems)}},ly=class{apply($,Z){let Y=Z;if(Y.maxItems===void 0)return;if($.array!==!1)$.array=($.array||b1.array(b1.any())).max(Y.maxItems)}},py=class{apply($,Z){let Y=Z;if($.array===!1)return;if(Array.isArray(Y.items))$.array=$.array||b1.array(b1.any());else if(Y.items&&typeof Y.items!=="boolean"&&!Y.prefixItems){let Q=I1(Y.items),W=b1.array(Q);if($.array&&$.array instanceof b1.ZodArray){let J=$.array._def;if(J.checks)J.checks.forEach((G)=>{if(G._zod&&G._zod.def){let K=G._zod.def;if(K.check==="min_length"&&K.minimum!==void 0)W=W.min(K.minimum);else if(K.check==="max_length"&&K.maximum!==void 0)W=W.max(K.maximum)}})}$.array=W}else if(typeof Y.items==="boolean"&&Y.items===!1)if(!Y.prefixItems)$.array=b1.array(b1.any()).max(0);else $.array=$.array||b1.array(b1.any());else if(typeof Y.items==="boolean"&&Y.items===!0)$.array=$.array||b1.array(b1.any());else if(Y.prefixItems)$.array=$.array||b1.array(b1.any())}},iy=class{apply($,Z){if(Z.type!=="array")return;let Y=Z;if(!Array.isArray(Y.items))return;if($.array===!1)return;let Q=Y.items.map((J)=>I1(J)),W;if(Q.length===0)W=LL.tuple([]);else W=LL.tuple(Q);if(Y.minItems!==void 0&&Y.minItems>Q.length)W=!1;if(Y.maxItems!==void 0&&Y.maxItems<Q.length)W=!1;$.tuple=W,$.array=!1}},cy=class{apply($,Z){let Y=Z;if($.object===!1)return;if(Y.properties||Y.required||Y.additionalProperties!==void 0)$.object=$.object||u5.object({}).passthrough()}},dy=class{apply($,Z){let Y=Z;if(Z.type===void 0&&(Y.maxProperties!==void 0||Y.minProperties!==void 0)){if($.object===void 0)$.object=u5.object({}).passthrough()}}},ny=class{apply($,Z){let Y=Z;if(Y.maxProperties===void 0)return;if($.object!==!1){let Q=$.object||u5.object({}).passthrough();$.object=Q.refine((W)=>Object.keys(W).length<=Y.maxProperties,{message:`Object must have at most ${Y.maxProperties} properties`})}}},ry=class{apply($,Z){let Y=Z;if(Y.minProperties===void 0)return;if($.object!==!1){let Q=$.object||u5.object({}).passthrough();$.object=Q.refine((W)=>Object.keys(W).length>=Y.minProperties,{message:`Object must have at least ${Y.minProperties} properties`})}}};function q7($,Z){if($===Z)return!0;if($==null||Z==null)return $===Z;if(typeof $!==typeof Z)return!1;if(Array.isArray($)&&Array.isArray(Z)){if($.length!==Z.length)return!1;return $.every((Y,Q)=>q7(Y,Z[Q]))}if(typeof $==="object"&&typeof Z==="object"){let Y=Object.keys($),Q=Object.keys(Z);if(Y.length!==Q.length)return!1;return Y.every((W)=>Q.includes(W)&&q7($[W],Z[W]))}return!1}function ay(){return($)=>{if(!Array.isArray($))return!0;let Z=[];return $.every((Y)=>{if(Z.some((W)=>q7(Y,W)))return!1;return Z.push(Y),!0})}}function g5($,Z){return $.safeParse(Z).success}var oy=class{apply($,Z){if(!Z.not)return $;let Y=I1(Z.not);return $.refine((Q)=>!g5(Y,Q),{message:"Value must not match the 'not' schema"})}},sy=class{apply($,Z){if(Z.uniqueItems!==!0)return $;return $.refine(ay(),{message:"Array items must be unique"})}},ey=class{apply($,Z){if(!Z.allOf||Z.allOf.length===0)return $;return Z.allOf.map((Q)=>I1(Q)).reduce((Q,W)=>ty.intersection(Q,W),$)}},$T=class{apply($,Z){if(!Z.anyOf||Z.anyOf.length===0)return $;let Y=Z.anyOf.length===1?I1(Z.anyOf[0]):UL.union([I1(Z.anyOf[0]),I1(Z.anyOf[1]),...Z.anyOf.slice(2).map((Q)=>I1(Q))]);return UL.intersection($,Y)}},ZT=class{apply($,Z){if(!Z.oneOf||Z.oneOf.length===0)return $;let Y=Z.oneOf.map((Q)=>I1(Q));return $.refine((Q)=>{let W=0;for(let J of Y)if(J.safeParse(Q).success){if(W++,W>1)return!1}return W===1},{message:"Value must match exactly one of the oneOf schemas"})}},YT=class{apply($,Z){let Y=Z;if(Y.prefixItems&&Array.isArray(Y.prefixItems)){let W=Y.prefixItems.map((J)=>I1(J));return $.refine((J)=>{if(!Array.isArray(J))return!0;for(let G=0;G<Math.min(J.length,W.length);G++)if(!g5(W[G],J[G]))return!1;if(J.length>W.length){if(typeof Y.items==="boolean"&&Y.items===!1)return!1;else if(Y.items&&typeof Y.items==="object"&&!Array.isArray(Y.items)){let G=I1(Y.items);for(let K=W.length;K<J.length;K++)if(!g5(G,J[K]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return $}},QT=class{apply($,Z){let Y=Z;if(!Y.properties&&!Y.required&&Y.additionalProperties!==!1)return $;if($ instanceof x5.ZodObject||$ instanceof x5.ZodRecord){let Q={};if(Y.properties){for(let[W,J]of Object.entries(Y.properties))if(J!==void 0)Q[W]=I1(J)}if(Y.required&&Array.isArray(Y.required)){let W=new Set(Y.required);for(let J of Object.keys(Q))if(!W.has(J))Q[J]=Q[J].optional()}else for(let W of Object.keys(Q))Q[W]=Q[W].optional();if(Y.additionalProperties===!1)return x5.object(Q);else return x5.object(Q).passthrough()}return $.refine((Q)=>{if(typeof Q!=="object"||Q===null||Array.isArray(Q))return!0;if(Y.properties){for(let[W,J]of Object.entries(Y.properties))if(J!==void 0){if(Object.getOwnPropertyDescriptor(Q,W)!==void 0){if(!I1(J).safeParse(Q[W]).success)return!1}}}if(Y.required&&Array.isArray(Y.required)){for(let W of Y.required)if(Object.getOwnPropertyDescriptor(Q,W)===void 0)return!1}if(Y.additionalProperties===!1&&Y.properties){let W=new Set(Object.keys(Y.properties));for(let J in Q)if(!W.has(J))return!1}return!0},{message:"Object constraints validation failed"})}},XT=class{apply($,Z){if(!Z.enum||Z.enum.length===0)return $;let Y=Z.enum.filter((Q)=>Array.isArray(Q)||typeof Q==="object"&&Q!==null);if(Y.length===0)return $;return $.refine((Q)=>{if(typeof Q!=="object"||Q===null)return!0;return Y.some((W)=>q7(Q,W))},{message:"Value must match one of the enum values"})}},WT=class{apply($,Z){if(Z.const===void 0)return $;let Y=Z.const;if(typeof Y!=="object"||Y===null)return $;return $.refine((Q)=>q7(Q,Y),{message:"Value must equal the const value"})}},JT=class{apply($,Z){if(Z.description)$=$.describe(Z.description);return $}},KT=class{apply($,Z){var Y;let Q=Z;if(!((Y=Q.required)==null?void 0:Y.includes("__proto__"))||Z.type!==void 0)return $;return GT.any().refine((W)=>this.validateRequired(W,Q.required),{message:"Missing required properties"})}validateRequired($,Z){if(typeof $!=="object"||$===null||Array.isArray($))return!0;return Z.every((Y)=>Object.prototype.hasOwnProperty.call($,Y))}},HT=class{apply($,Z){var Y;let Q=Z;if(Q.contains===void 0)return $;let W=I1(Q.contains),J=(Y=Q.minContains)!=null?Y:1,G=Q.maxContains;return $.refine((K)=>{if(!Array.isArray(K))return!0;let B=0;for(let D of K)if(g5(W,D))B++;if(B<J)return!1;if(G!==void 0&&B>G)return!1;return!0},{message:"Array must contain required items matching the schema"})}},BT=class{apply($,Z){let{default:Y}=Z;if(Y===void 0)return $;if(!$.safeParse(Y).success)return $;return $.default(Y)}},FT=[new _y,new Cy,new Ry,new fy,new Sy,new hy,new dy,new by,new vy,new yy,new Ty,new ky,new xy,new gy,new uy,new iy,new my,new ly,new py,new ny,new ry,new cy],DT=[new KT,new XT,new WT,new ey,new $T,new ZT,new YT,new QT,new HT,new oy,new sy,new BT,new JT];function I1($){if(typeof $==="boolean")return $?q0.any():q0.never();let Z={};for(let W of FT)W.apply(Z,$);let Y=[];if(Z.string!==!1)Y.push(Z.string||q0.string());if(Z.number!==!1)Y.push(Z.number||q0.number());if(Z.boolean!==!1)Y.push(Z.boolean||q0.boolean());if(Z.null!==!1)Y.push(Z.null||q0.null());if(Z.array!==!1)Y.push(Z.array||q0.array(q0.any()));if(Z.tuple!==!1&&Z.tuple!==void 0)Y.push(Z.tuple);if(Z.object!==!1)if(Z.object)Y.push(Z.object);else{let W=q0.custom((J)=>{return typeof J==="object"&&J!==null&&!Array.isArray(J)},"Must be an object, not an array");Y.push(W)}if(Z.file!==!1&&Z.file!==void 0)Y.push(Z.file);let Q;if(Y.length===0)Q=q0.never();else if(Y.length===1)Q=Y[0];else if(!Object.keys($).some((J)=>J!=="$schema"&&J!=="title"&&J!=="description"))Q=q0.any();else Q=q0.union(Y);for(let W of DT)Q=W.apply(Q,$);return Q}class yW extends Event{constructor($,Z){var Y,Q;super($),this.code=(Y=Z==null?void 0:Z.code)!=null?Y:void 0,this.message=(Q=Z==null?void 0:Z.message)!=null?Q:void 0}[Symbol.for("nodejs.util.inspect.custom")]($,Z,Y){return Y(jL(this),Z)}[Symbol.for("Deno.customInspect")]($,Z){return $(jL(this),Z)}}function VT($){let Z=globalThis.DOMException;return typeof Z=="function"?new Z($,"SyntaxError"):SyntaxError($)}function TW($){return $ instanceof Error?"errors"in $&&Array.isArray($.errors)?$.errors.map(TW).join(", "):("cause"in $)&&$.cause instanceof Error?`${$}: ${TW($.cause)}`:$.message:`${$}`}function jL($){return{type:$.type,message:$.message,code:$.code,defaultPrevented:$.defaultPrevented,cancelable:$.cancelable,timeStamp:$.timeStamp}}var zL=($)=>{throw TypeError($)},pW=($,Z,Y)=>Z.has($)||zL("Cannot "+Y),X1=($,Z,Y)=>(pW($,Z,"read from private field"),Y?Y.call($):Z.get($)),f1=($,Z,Y)=>Z.has($)?zL("Cannot add the same private member more than once"):Z instanceof WeakSet?Z.add($):Z.set($,Y),q1=($,Z,Y,Q)=>(pW($,Z,"write to private field"),Z.set($,Y),Y),G6=($,Z,Y)=>(pW($,Z,"access private method"),Y),Z0,W8,Y9,h5,m5,M7,W9,P7,x6,Q9,J9,X9,O7,v0,kW,xW,gW,AL,uW,hW,N7,mW,lW;class G9 extends EventTarget{constructor($,Z){var Y,Q;super(),f1(this,v0),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,f1(this,Z0),f1(this,W8),f1(this,Y9),f1(this,h5),f1(this,m5),f1(this,M7),f1(this,W9),f1(this,P7,null),f1(this,x6),f1(this,Q9),f1(this,J9,null),f1(this,X9,null),f1(this,O7,null),f1(this,xW,async(W)=>{var J;X1(this,Q9).reset();let{body:G,redirected:K,status:B,headers:D}=W;if(B===204){G6(this,v0,N7).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(K?q1(this,Y9,new URL(W.url)):q1(this,Y9,void 0),B!==200){G6(this,v0,N7).call(this,`Non-200 status code (${B})`,B);return}if(!(D.get("content-type")||"").startsWith("text/event-stream")){G6(this,v0,N7).call(this,'Invalid content type, expected "text/event-stream"',B);return}if(X1(this,Z0)===this.CLOSED)return;q1(this,Z0,this.OPEN);let V=new Event("open");if((J=X1(this,O7))==null||J.call(this,V),this.dispatchEvent(V),typeof G!="object"||!G||!("getReader"in G)){G6(this,v0,N7).call(this,"Invalid response body, expected a web ReadableStream",B),this.close();return}let L=new TextDecoder,A=G.getReader(),q=!0;do{let{done:O,value:M}=await A.read();M&&X1(this,Q9).feed(L.decode(M,{stream:!O})),O&&(q=!1,X1(this,Q9).reset(),G6(this,v0,mW).call(this))}while(q)}),f1(this,gW,(W)=>{q1(this,x6,void 0),!(W.name==="AbortError"||W.type==="aborted")&&G6(this,v0,mW).call(this,TW(W))}),f1(this,uW,(W)=>{typeof W.id=="string"&&q1(this,P7,W.id);let J=new MessageEvent(W.event||"message",{data:W.data,origin:X1(this,Y9)?X1(this,Y9).origin:X1(this,W8).origin,lastEventId:W.id||""});X1(this,X9)&&(!W.event||W.event==="message")&&X1(this,X9).call(this,J),this.dispatchEvent(J)}),f1(this,hW,(W)=>{q1(this,M7,W)}),f1(this,lW,()=>{q1(this,W9,void 0),X1(this,Z0)===this.CONNECTING&&G6(this,v0,kW).call(this)});try{if($ instanceof URL)q1(this,W8,$);else if(typeof $=="string")q1(this,W8,new URL($,LT()));else throw Error("Invalid URL")}catch{throw VT("An invalid or illegal string was specified")}q1(this,Q9,b5({onEvent:X1(this,uW),onRetry:X1(this,hW)})),q1(this,Z0,this.CONNECTING),q1(this,M7,3000),q1(this,m5,(Y=Z==null?void 0:Z.fetch)!=null?Y:globalThis.fetch),q1(this,h5,(Q=Z==null?void 0:Z.withCredentials)!=null?Q:!1),G6(this,v0,kW).call(this)}get readyState(){return X1(this,Z0)}get url(){return X1(this,W8).href}get withCredentials(){return X1(this,h5)}get onerror(){return X1(this,J9)}set onerror($){q1(this,J9,$)}get onmessage(){return X1(this,X9)}set onmessage($){q1(this,X9,$)}get onopen(){return X1(this,O7)}set onopen($){q1(this,O7,$)}addEventListener($,Z,Y){let Q=Z;super.addEventListener($,Q,Y)}removeEventListener($,Z,Y){let Q=Z;super.removeEventListener($,Q,Y)}close(){X1(this,W9)&&clearTimeout(X1(this,W9)),X1(this,Z0)!==this.CLOSED&&(X1(this,x6)&&X1(this,x6).abort(),q1(this,Z0,this.CLOSED),q1(this,x6,void 0))}}Z0=new WeakMap,W8=new WeakMap,Y9=new WeakMap,h5=new WeakMap,m5=new WeakMap,M7=new WeakMap,W9=new WeakMap,P7=new WeakMap,x6=new WeakMap,Q9=new WeakMap,J9=new WeakMap,X9=new WeakMap,O7=new WeakMap,v0=new WeakSet,kW=function(){q1(this,Z0,this.CONNECTING),q1(this,x6,new AbortController),X1(this,m5)(X1(this,W8),G6(this,v0,AL).call(this)).then(X1(this,xW)).catch(X1(this,gW))},xW=new WeakMap,gW=new WeakMap,AL=function(){var $;let Z={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...X1(this,P7)?{"Last-Event-ID":X1(this,P7)}:void 0},cache:"no-store",signal:($=X1(this,x6))==null?void 0:$.signal};return"window"in globalThis&&(Z.credentials=this.withCredentials?"include":"same-origin"),Z},uW=new WeakMap,hW=new WeakMap,N7=function($,Z){var Y;X1(this,Z0)!==this.CLOSED&&q1(this,Z0,this.CLOSED);let Q=new yW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q)},mW=function($,Z){var Y;if(X1(this,Z0)===this.CLOSED)return;q1(this,Z0,this.CONNECTING);let Q=new yW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q),q1(this,W9,setTimeout(X1(this,lW),X1(this,M7)))},lW=new WeakMap,G9.CONNECTING=0,G9.OPEN=1,G9.CLOSED=2;function LT(){let $="document"in globalThis?globalThis.document:void 0;return $&&typeof $=="object"&&"baseURI"in $&&typeof $.baseURI=="string"?$.baseURI:void 0}class qL extends Error{constructor($,Z,Y){super(`SSE error: ${Z}`);this.code=$,this.event=Y}}class iW{constructor($,Z){this._url=$,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=Z?.eventSourceInit,this._requestInit=Z?.requestInit,this._authProvider=Z?.authProvider,this._fetch=Z?.fetch,this._fetchWithInit=q5(Z?.fetch,Z?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new e1("No auth provider");let $;try{$=await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(Z){throw this.onerror?.(Z),Z}if($!=="AUTHORIZED")throw new e1;return await this._startOrAuth()}async _commonHeaders(){let $={};if(this._authProvider){let Y=await this._authProvider.tokens();if(Y)$.Authorization=`Bearer ${Y.access_token}`}if(this._protocolVersion)$["mcp-protocol-version"]=this._protocolVersion;let Z=o8(this._requestInit?.headers);return new Headers({...$,...Z})}_startOrAuth(){let $=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((Z,Y)=>{this._eventSource=new G9(this._url.href,{...this._eventSourceInit,fetch:async(Q,W)=>{let J=await this._commonHeaders();J.set("Accept","text/event-stream");let G=await $(Q,{...W,headers:J});if(G.status===401&&G.headers.has("www-authenticate")){let{resourceMetadataUrl:K,scope:B}=Z9(G);this._resourceMetadataUrl=K,this._scope=B}return G}}),this._abortController=new AbortController,this._eventSource.onerror=(Q)=>{if(Q.code===401&&this._authProvider){this._authThenStart().then(Z,Y);return}let W=new qL(Q.code,Q.message,Q);Y(W),this.onerror?.(W)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",(Q)=>{let W=Q;try{if(this._endpoint=new URL(W.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(J){Y(J),this.onerror?.(J),this.close();return}Z()}),this._eventSource.onmessage=(Q)=>{let W=Q,J;try{J=w6.parse(JSON.parse(W.data))}catch(G){this.onerror?.(G);return}this.onmessage?.(J)}})}async start(){if(this._eventSource)throw Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth($){if(!this._authProvider)throw new e1("No auth provider");if(await p0(this._authProvider,{serverUrl:this._url,authorizationCode:$,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send($){if(!this._endpoint)throw Error("Not connected");try{let Z=await this._commonHeaders();Z.set("content-type","application/json");let Y={...this._requestInit,method:"POST",headers:Z,body:JSON.stringify($),signal:this._abortController?.signal},Q=await(this._fetch??fetch)(this._endpoint,Y);if(!Q.ok){let W=await Q.text().catch(()=>null);if(Q.status===401&&this._authProvider){let{resourceMetadataUrl:J,scope:G}=Z9(Q);if(this._resourceMetadataUrl=J,this._scope=G,await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1;return this.send($)}throw Error(`Error POSTing to endpoint (HTTP ${Q.status}): ${W}`)}await Q.body?.cancel()}catch(Z){throw this.onerror?.(Z),Z}}setProtocolVersion($){this._protocolVersion=$}}var UT="mcp";class cW{constructor($){this._url=$}start(){if(this._socket)throw Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise(($,Z)=>{this._socket=new WebSocket(this._url,UT),this._socket.onerror=(Y)=>{let Q="error"in Y?Y.error:Error(`WebSocket error: ${JSON.stringify(Y)}`);Z(Q),this.onerror?.(Q)},this._socket.onopen=()=>{$()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=(Y)=>{let Q;try{Q=w6.parse(JSON.parse(Y.data))}catch(W){this.onerror?.(W);return}this.onmessage?.(Q)}})}async close(){this._socket?.close()}send($){return new Promise((Z,Y)=>{if(!this._socket){Y(Error("Not connected"));return}this._socket?.send(JSON.stringify($)),Z()})}}class dW extends v5{constructor($,Z){super($,Z)}send($,Z){let Y=jT($);if(Y?.type==="emit")return this.onmessage?.(Y.message),Promise.resolve();if(Y?.type==="suppress")return Promise.resolve();return super.send($,Z)}}function jT($){let Z=$;if(!Z||typeof Z!=="object"||!("method"in Z))return null;switch(Z.method){case"initialize":{let Y=Z?.params?.protocolVersion;if(!Y)return null;return{type:"emit",message:{result:{protocolVersion:Y,capabilities:{tools:{}},serverInfo:{name:"deco-chat-server",version:"1.0.0"}},jsonrpc:Z.jsonrpc??"2.0",id:Z.id}}}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}class OL extends z5{constructor($,Z){super($,{jsonSchemaValidator:T5,...Z})}async listTools($,Z){return await this.request({method:"tools/list",params:$},p9,Z)}}var NL=async($,Z,Y)=>{let Q=AT($.connection,Z,Y);if(!Q)throw Error("Unknown MCP connection type");let W=new OL({name:$?.name??"MCP Client",version:"1.0.0"});return await W.connect(Q),{client:W}},AT=($,Z,Y)=>{if($.type==="Websocket")return new cW(new URL($.url));if($.type!=="SSE"&&$.type!=="HTTP")return null;let W={...$.token?{authorization:`Bearer ${$.token}`}:{},...Y??{},..."headers"in $?$.headers||{}:{}};if($.type==="SSE"){let J={requestInit:{headers:W,signal:Z}};if($.token)J.eventSourceInit={fetch:(G,K)=>{return fetch(G,{...K,headers:{...W,Accept:"text/event-stream"},signal:Z})}};return new iW(new URL($.url),J)}return new dW(new URL($.url),{requestInit:{headers:W,signal:Z,credentials:"include"}})};var ML=($)=>{try{return JSON.parse($)}catch{return $}},l5=new Map,PL=($,Z)=>{return{...$,id:$.name,inputSchema:$.inputSchema?I1($.inputSchema):void 0,outputSchema:$.outputSchema?I1($.outputSchema):void 0,execute:(Y)=>{return Z(Y.context,$.name)}}};function wL($){let Z=(Y)=>{if("connection"in $)return NL({connection:$.connection},void 0,Y);return $.client};return new Proxy({},{get(Y,Q){if(Q==="toJSON")return null;if(typeof Q!=="string")throw Error("Name must be a string");if(Q==="listTools")return K;async function W(B,D=Q){let V=$?.debugId?.(),L=V?{"x-trace-debug-id":V}:void 0,{client:A}=await Z(L),{structuredContent:q,isError:O,content:M}=await A.callTool({name:String(D),arguments:B});if(O){let N=M?.[0]?.text,E=typeof N==="string"?ML(N):null,f=E?.code&&typeof $?.getErrorByStatusCode==="function"?$.getErrorByStatusCode(E.code,E.message,E.traceId):null;if(f)throw f;throw Error(`Tool ${String(D)} returned an error: ${JSON.stringify(q??M)}`)}if(q!==void 0)return q;let I=M?.[0]?.text;return typeof I==="string"?ML(I):void 0}async function J(){let{client:B}=await Z(),{tools:D}=await B.listTools();return D}async function G(){if(!("connection"in $))return J();let B=$.connection,D=JSON.stringify(B);try{if(!l5.has(D))l5.set(D,J());return await l5.get(D)}catch(V){console.error("Failed to list tools",V),l5.delete(D);return}}async function K(){return(await G()??[]).map((D)=>PL(D,W))}return W.asTool=async()=>{let D=(await G()??[]).find((V)=>V.name===Q);if(!D)throw Error(`Tool ${Q} not found`);return PL(D,W)},W}})}var S01=new Proxy({},{get($,Z){if(Z==="toJSON")return null;if(Z==="forConnection")return(Y)=>p5({connection:Y});return global[Z]}});function p5($){return wL($)}var EL=($)=>{return{...zT($),forClient:(Z)=>{return p5({client:Z})},forConnection:(Z)=>{return p5({connection:Z})}}};function zT($){return{isImplementedBy:(Z)=>{for(let Y of $){let Q=typeof Y.name==="string"?new RegExp(`^${Y.name}$`):Y.name,W=Z.find((J)=>Q.test(J.name));if(!W&&Y.opt)continue;if(!W)return!1}return!0}}}import{z as s}from"zod";var i5=s.object({id:s.string().describe("Unique identifier for the entity"),title:s.string().describe("Human-readable title for the entity"),description:s.string().nullish().describe("Description of the entity"),created_at:s.string().datetime(),updated_at:s.string().datetime(),created_by:s.string().optional(),updated_by:s.string().optional()}),qT=s.object({field:s.array(s.string()),operator:s.enum(["eq","gt","gte","lt","lte","in","like","contains"]),value:s.unknown()}),RL=s.lazy(()=>s.union([qT,s.object({operator:s.enum(["and","or","not"]),conditions:s.array(RL)})])),OT=s.object({field:s.array(s.string()),direction:s.enum(["asc","desc"]),nulls:s.enum(["first","last"]).optional()}),NT=s.object({where:RL.optional().describe("Filter expression"),orderBy:s.array(OT).optional().describe("Sort expressions"),limit:s.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:s.number().int().min(0).optional().describe("Number of items to skip")});function MT($){return s.object({items:s.array($).describe("Array of collection items"),totalCount:s.number().int().min(0).optional().describe("Total number of matching items (if available)"),hasMore:s.boolean().optional().describe("Whether there are more items available")})}var PT=s.object({id:s.string().describe("ID of the entity to retrieve")});function wT($){return s.object({item:$.nullable().describe("The retrieved item, or null if not found")})}function ET($){return s.object({data:$.partial().describe("Data for the new entity (id may be auto-generated)")})}function RT($){return s.object({item:$.describe("The created entity with generated id")})}function _T($){return s.object({id:s.string().describe("ID of the entity to update"),data:$.partial().describe("Partial entity data to update")})}function CT($){return s.object({item:$.describe("The updated entity")})}var IT=s.object({id:s.string().describe("ID of the entity to delete")});function fT($){return s.object({item:$.describe("The deleted entity")})}function c5($,Z,Y){let Q=$.toUpperCase(),W=Y?.readOnly??!1,J=[{name:`COLLECTION_${Q}_LIST`,inputSchema:NT,outputSchema:MT(Z)},{name:`COLLECTION_${Q}_GET`,inputSchema:PT,outputSchema:wT(Z)}];if(!W)J.push({name:`COLLECTION_${Q}_CREATE`,inputSchema:ET(Z),outputSchema:RT(Z),opt:!0},{name:`COLLECTION_${Q}_UPDATE`,inputSchema:_T(Z),outputSchema:CT(Z),opt:!0},{name:`COLLECTION_${Q}_DELETE`,inputSchema:IT,outputSchema:fT(Z),opt:!0});return J}var nW=T.object({toolName:T.string().describe("Name of the tool to invoke on that connection"),transformCode:T.string().optional().describe("Pure TypeScript function for data transformation of the tool call result. Must be a TypeScript file that declares the Output interface and exports a default function: `interface Output { ... } export default async function(stepInput): Output { ... }`\n The stepInput will match with the tool call outputSchema. If transformCode is not provided, the tool call result will be used as the step output.\n Providing an transformCode is recommended because it both allows you to transform the data and validate it against a JSON Schema - tools are ephemeral and may return unexpected data.")}),ST=T.object({code:T.string().describe(`Pure TypeScript function for data transformation. Useful to merge data from multiple steps and transform it. Must be a TypeScript file that declares the Output interface and exports a default function: \`interface Output { ... } export default async function(stepInput): Output { ... }\`
960
+ ${E}`,D++;break;case"id":K=E.includes("\x00")?void 0:E;break;case"retry":/^\d+$/.test(E)?Q(parseInt(E,10)):Y(new UW(`Invalid \`retry\` value: "${E}"`,{type:"invalid-retry",value:E,line:f}));break;default:Y(new UW(`Unknown field "${N.length>20?`${N.slice(0,20)}\u2026`:N}"`,{type:"unknown-field",field:N,value:E,line:f}));break}}function M(){D>0&&Z({id:K,event:V,data:B}),K=void 0,B="",D=0,V=void 0}function I(N={}){if(N.consume&&J.length>0){let E=J.join("");q(E,0,E.length)}G=!0,K=void 0,B="",D=0,V=void 0,J.length=0}return{feed:L,reset:I}}function TV($,Z,Y){return Y===100&&$.charCodeAt(Z+1)===97&&$.charCodeAt(Z+2)===116&&$.charCodeAt(Z+3)===97&&$.charCodeAt(Z+4)===58}function kV($,Z,Y){return Y===101&&$.charCodeAt(Z+1)===118&&$.charCodeAt(Z+2)===101&&$.charCodeAt(Z+3)===110&&$.charCodeAt(Z+4)===116&&$.charCodeAt(Z+5)===58}class jW extends TransformStream{constructor({onError:$,onRetry:Z,onComment:Y}={}){let Q;super({start(W){Q=b5({onEvent:(J)=>{W.enqueue(J)},onError(J){$==="terminate"?W.error(J):typeof $=="function"&&$(J)},onRetry:Z,onComment:Y})},transform(W){Q.feed(W)}})}}var Nv={initialReconnectionDelay:1000,maxReconnectionDelay:30000,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Q8 extends Error{constructor($,Z){super(`Streamable HTTP error: ${Z}`);this.code=$}}class v5{constructor($,Z){this._hasCompletedAuthFlow=!1,this._url=$,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=Z?.requestInit,this._authProvider=Z?.authProvider,this._fetch=Z?.fetch,this._fetchWithInit=q5(Z?.fetch,Z?.requestInit),this._sessionId=Z?.sessionId,this._reconnectionOptions=Z?.reconnectionOptions??Nv}async _authThenStart(){if(!this._authProvider)throw new e1("No auth provider");let $;try{$=await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(Z){throw this.onerror?.(Z),Z}if($!=="AUTHORIZED")throw new e1;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let $={};if(this._authProvider){let Y=await this._authProvider.tokens();if(Y)$.Authorization=`Bearer ${Y.access_token}`}if(this._sessionId)$["mcp-session-id"]=this._sessionId;if(this._protocolVersion)$["mcp-protocol-version"]=this._protocolVersion;let Z=o8(this._requestInit?.headers);return new Headers({...$,...Z})}async _startOrAuthSse($){let{resumptionToken:Z}=$;try{let Y=await this._commonHeaders();if(Y.set("Accept","text/event-stream"),Z)Y.set("last-event-id",Z);let Q=await(this._fetch??fetch)(this._url,{method:"GET",headers:Y,signal:this._abortController?.signal});if(!Q.ok){if(await Q.body?.cancel(),Q.status===401&&this._authProvider)return await this._authThenStart();if(Q.status===405)return;throw new Q8(Q.status,`Failed to open SSE stream: ${Q.statusText}`)}this._handleSseStream(Q.body,$,!0)}catch(Y){throw this.onerror?.(Y),Y}}_getNextReconnectionDelay($){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let Z=this._reconnectionOptions.initialReconnectionDelay,Y=this._reconnectionOptions.reconnectionDelayGrowFactor,Q=this._reconnectionOptions.maxReconnectionDelay;return Math.min(Z*Math.pow(Y,$),Q)}_scheduleReconnection($,Z=0){let Y=this._reconnectionOptions.maxRetries;if(Z>=Y){this.onerror?.(Error(`Maximum reconnection attempts (${Y}) exceeded.`));return}let Q=this._getNextReconnectionDelay(Z);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse($).catch((W)=>{this.onerror?.(Error(`Failed to reconnect SSE stream: ${W instanceof Error?W.message:String(W)}`)),this._scheduleReconnection($,Z+1)})},Q)}_handleSseStream($,Z,Y){if(!$)return;let{onresumptiontoken:Q,replayMessageId:W}=Z,J,G=!1,K=!1;(async()=>{try{let D=$.pipeThrough(new TextDecoderStream).pipeThrough(new jW({onRetry:(A)=>{this._serverRetryMs=A}})).getReader();while(!0){let{value:A,done:q}=await D.read();if(q)break;if(A.id)J=A.id,G=!0,Q?.(A.id);if(!A.data)continue;if(!A.event||A.event==="message")try{let O=w6.parse(JSON.parse(A.data));if(r6(O)){if(K=!0,W!==void 0)O.id=W}this.onmessage?.(O)}catch(O){this.onerror?.(O)}}if((Y||G)&&!K&&this._abortController&&!this._abortController.signal.aborted)this._scheduleReconnection({resumptionToken:J,onresumptiontoken:Q,replayMessageId:W},0)}catch(D){if(this.onerror?.(Error(`SSE stream disconnected: ${D}`)),(Y||G)&&!K&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:J,onresumptiontoken:Q,replayMessageId:W},0)}catch(A){this.onerror?.(Error(`Failed to reconnect: ${A instanceof Error?A.message:String(A)}`))}}})()}async start(){if(this._abortController)throw Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth($){if(!this._authProvider)throw new e1("No auth provider");if(await p0(this._authProvider,{serverUrl:this._url,authorizationCode:$,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1("Failed to authorize")}async close(){if(this._reconnectionTimeout)clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0;this._abortController?.abort(),this.onclose?.()}async send($,Z){try{let{resumptionToken:Y,onresumptiontoken:Q}=Z||{};if(Y){this._startOrAuthSse({resumptionToken:Y,replayMessageId:k9($)?$.id:void 0}).catch((L)=>this.onerror?.(L));return}let W=await this._commonHeaders();W.set("content-type","application/json"),W.set("accept","application/json, text/event-stream");let J={...this._requestInit,method:"POST",headers:W,body:JSON.stringify($),signal:this._abortController?.signal},G=await(this._fetch??fetch)(this._url,J),K=G.headers.get("mcp-session-id");if(K)this._sessionId=K;if(!G.ok){let L=await G.text().catch(()=>null);if(G.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Q8(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:A,scope:q}=Z9(G);if(this._resourceMetadataUrl=A,this._scope=q,await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1;return this._hasCompletedAuthFlow=!0,this.send($)}if(G.status===403&&this._authProvider){let{resourceMetadataUrl:A,scope:q,error:O}=Z9(G);if(O==="insufficient_scope"){let M=G.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===M)throw new Q8(403,"Server returned 403 after trying upscoping");if(q)this._scope=q;if(A)this._resourceMetadataUrl=A;if(this._lastUpscopingHeader=M??void 0,await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new e1;return this.send($)}}throw new Q8(G.status,`Error POSTing to endpoint: ${L}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,G.status===202){if(await G.body?.cancel(),fK($))this._startOrAuthSse({resumptionToken:void 0}).catch((L)=>this.onerror?.(L));return}let D=(Array.isArray($)?$:[$]).filter((L)=>("method"in L)&&("id"in L)&&L.id!==void 0).length>0,V=G.headers.get("content-type");if(D)if(V?.includes("text/event-stream"))this._handleSseStream(G.body,{onresumptiontoken:Q},!1);else if(V?.includes("application/json")){let L=await G.json(),A=Array.isArray(L)?L.map((q)=>w6.parse(q)):[w6.parse(L)];for(let q of A)this.onmessage?.(q)}else throw await G.body?.cancel(),new Q8(-1,`Unexpected content type: ${V}`);else await G.body?.cancel()}catch(Y){throw this.onerror?.(Y),Y}}get sessionId(){return this._sessionId}async terminateSession(){if(!this._sessionId)return;try{let $=await this._commonHeaders(),Z={...this._requestInit,method:"DELETE",headers:$,signal:this._abortController?.signal},Y=await(this._fetch??fetch)(this._url,Z);if(await Y.body?.cancel(),!Y.ok&&Y.status!==405)throw new Q8(Y.status,`Failed to terminate session: ${Y.statusText}`);this._sessionId=void 0}catch($){throw this.onerror?.($),$}}setProtocolVersion($){this._protocolVersion=$}get protocolVersion(){return this._protocolVersion}async resumeStream($,Z){await this._startOrAuthSse({resumptionToken:$,onresumptiontoken:Z?.onresumptiontoken})}}import{z as h}from"zod";var Zy=h.object({authorizationEndpoint:h.string().url(),tokenEndpoint:h.string().url(),introspectionEndpoint:h.string().url().optional(),clientId:h.string(),clientSecret:h.string().optional(),scopes:h.array(h.string()),grantType:h.enum(["authorization_code","client_credentials"])}),xV=h.object({type:h.literal("object"),properties:h.record(h.string(),h.unknown()).optional(),required:h.array(h.string()).optional()}).catchall(h.unknown()),Yy=C4.extend({inputSchema:xV,outputSchema:xV.optional()}),Qy=h.object({headers:h.record(h.string(),h.string()).optional()}),Xy=h.object({command:h.string().describe("Command to run (e.g., 'npx', 'node')"),args:h.array(h.string()).optional().describe("Command arguments"),cwd:h.string().optional().describe("Working directory"),envVars:h.record(h.string(),h.string()).optional().describe("Environment variables (encrypted in storage)")}),y5=h.object({id:h.string().describe("Unique identifier for the connection"),title:h.string().describe("Human-readable name for the connection"),created_at:h.string().describe("When the connection was created"),updated_at:h.string().describe("When the connection was last updated"),created_by:h.string().describe("User ID who created the connection"),updated_by:h.string().optional().describe("User ID who last updated the connection"),organization_id:h.string().describe("Organization ID this connection belongs to"),description:h.string().nullable().describe("Description of the connection"),icon:h.string().nullable().describe("Icon URL for the connection"),app_name:h.string().nullable().describe("Associated app name"),app_id:h.string().nullable().describe("Associated app ID"),slug:h.string().nullable().optional().describe("URL-safe slug derived from app_name, connection_url, or title"),connection_type:h.enum(["HTTP","SSE","Websocket","STDIO","VIRTUAL"]).describe("Type of connection"),connection_url:h.string().nullable().describe("URL for HTTP/SSE/WebSocket connections. virtual://$id for VIRTUAL. Null for STDIO."),connection_token:h.string().nullable().describe("Authentication token (for HTTP connections)"),connection_headers:h.union([Xy,Qy]).nullable().describe("Connection parameters. HTTP: { headers }. STDIO: { command, args, cwd, envVars }"),oauth_config:Zy.nullable().describe("OAuth configuration"),configuration_state:h.record(h.string(),h.unknown()).nullable().describe("Configuration state (decrypted)"),configuration_scopes:h.array(h.string()).nullable().optional().describe("Configuration scopes"),metadata:h.record(h.string(),h.unknown()).nullable().describe("Additional metadata (includes repository info)"),tools:h.array(Yy).nullable().describe("Discovered tools from MCP"),bindings:h.array(h.string()).nullable().describe("Detected bindings"),status:h.enum(["active","inactive","error"]).describe("Current status")}),gV=y5.omit({created_at:!0,updated_at:!0,created_by:!0,updated_by:!0,organization_id:!0,tools:!0,bindings:!0,status:!0}).partial({id:!0,description:!0,icon:!0,app_name:!0,app_id:!0,connection_url:!0,connection_token:!0,connection_headers:!0,oauth_config:!0,configuration_state:!0,configuration_scopes:!0,metadata:!0}).extend({icon:h.string().nullish()}),uV=y5.partial();import{z as C}from"zod";var A7=C.object({connection_id:C.string().describe("Connection ID"),selected_tools:C.array(C.string()).nullable().describe("Selected tool names. null = all tools included, array = only these tools included"),selected_resources:C.array(C.string()).nullable().describe("Selected resource URIs or patterns. Supports * and ** wildcards for pattern matching. null = all resources included, array = only these resources included"),selected_prompts:C.array(C.string()).nullable().describe("Selected prompt names. null = all prompts included, array = only these prompts included")}),lV=A7.extend({selected_tools:A7.shape.selected_tools.optional(),selected_resources:A7.shape.selected_resources.optional(),selected_prompts:A7.shape.selected_prompts.optional()}),Wy=C.object({connectionId:C.string(),toolName:C.string(),label:C.string(),icon:C.string().nullable().optional()}),MW=C.object({id:C.string().describe("Stable id; used as React key and ?tab= value"),title:C.string().describe("Tab label"),icon:C.string().optional().describe("Optional lucide icon name"),view:C.object({type:C.literal("ext-app"),appId:C.string(),args:C.record(C.string(),C.unknown()).optional()})}),PW=C.object({defaultMainView:C.object({type:C.string(),id:C.string().optional(),toolName:C.string().optional()}).nullable().optional(),chatDefaultOpen:C.boolean().nullable().optional(),tabs:C.array(MW).optional()}),hV=C.object({connectionId:C.string().optional().describe("Connection that owns the resource \u2014 the host opens a direct MCP client to this connection so the iframe can call tools by their bare names."),resourceUri:C.string().describe("ui:// resource URI exposed by `connectionId`. Read on the home page and rendered via MCPAppRenderer."),minHeight:C.number().int().positive().optional(),maxHeight:C.number().int().positive().optional()}),wW=C.object({banner:C.string().nullable().optional(),bannerColor:C.string().nullable().optional(),icon:C.string().nullable().optional(),themeColor:C.string().nullable().optional(),pinnedViews:C.array(Wy).nullable().optional(),layout:PW.nullable().optional(),homeTile:hV.nullable().optional(),homeTiles:C.array(hV).nullable().optional(),homePrompts:C.array(C.string()).nullable().optional()});var EW=/^[A-Za-z_][A-Za-z0-9_]*$/,mV=C.string().min(1).regex(EW,{message:"Env var key must start with a letter or underscore and contain only letters, digits, and underscores."}),Jy=C.discriminatedUnion("kind",[C.object({key:mV,kind:C.literal("literal"),value:C.string()}),C.object({key:mV,kind:C.literal("secret"),secretId:C.string().min(1)})]),RW=C.object({selected:C.string().nullable().optional().describe("User-selected package manager (npm | pnpm | yarn | bun | deno). Null/absent means autodetect on next SANDBOX_START."),port:C.string().nullable().optional().describe("User-selected dev server port as a string (allows '' / null for unset). Null/absent means autodetect."),path:C.string().nullable().optional().describe("Optional path (relative to repo root) to the directory containing package.json. Null/absent means repo root. Forwarded as `application.packageManager.path` to the daemon config."),env:C.array(Jy).nullable().optional().describe("Env vars injected on every SANDBOX_START. Literal entries inline their value; secret entries store a secretId that mesh resolves via the credential vault before posting /_sandbox/config.")}),_W=C.object({url:C.string().describe("GitHub repository URL"),owner:C.string().describe("Repository owner"),name:C.string().describe("Repository name"),installationId:C.number().optional().describe("GitHub App installation ID. Absent when the repo was linked without a GitHub connection (public-clone mode)."),connectionId:C.string().optional().describe("ID of the mcp-github connection used for authentication. Absent for public repos cloned without credentials.")}),Gy=C.enum(["agent-sandbox","user-desktop"]),Ky=C.enum(["agent-sandbox","user-desktop","cluster"]);var pV={sandboxHandle:C.string().describe("Provider-specific handle"),previewUrl:C.string().nullable().describe("URL where the sandbox's iframe-proxied UI is served, or null when the sandbox has no dev server (blank / tool sandboxes)."),sandboxApiUrl:C.string().nullable().optional().describe("Daemon's public URL \u2014 what cluster\u2192daemon RPCs target. Equal to previewUrl for user-desktop; null/absent for the agent-sandbox provider (routes through hosted ingress)."),sandboxProviderKind:Gy.optional(),createdAt:C.number().optional().describe("Epoch ms the entry was first written by SANDBOX_START. Used by the booting overlay to show a stable elapsed timer that survives browser reloads. Optional for backward compatibility with entries written before this field existed."),startedWith:C.object({packageManager:C.string().nullable().optional().describe("metadata.runtime.selected at the time of SANDBOX_START"),port:C.string().nullable().optional().describe("metadata.runtime.port at the time of SANDBOX_START"),path:C.string().nullable().optional().describe("metadata.runtime.path at the time of SANDBOX_START")}).optional().describe("Snapshot of metadata.runtime fields (selected/port/path) used at SANDBOX_START. The Preview tab compares the live metadata.runtime against this to decide if a restart is required to apply changes.")},CW=C.object(pV),xs=C.object({...pV,sandboxProviderKind:Ky.optional()});var z7=C.record(C.string().describe("userId"),C.record(C.string().describe("branch"),C.record(C.string().describe("sandboxProviderKind"),CW)));var iV=C.object({id:C.string().describe("Unique identifier"),title:C.string().describe("Human-readable name"),description:C.string().nullable().describe("Description"),icon:C.string().nullable().describe("Icon URL"),created_at:C.string().describe("Creation timestamp"),updated_at:C.string().describe("Last update timestamp"),created_by:C.string().describe("User ID who created this item"),updated_by:C.string().optional().describe("User ID who last updated this item"),organization_id:C.string().describe("Organization ID this item belongs to"),status:C.enum(["active","inactive"]).describe("Current status"),pinned:C.boolean().describe("Whether this space is pinned to the sidebar"),metadata:C.object({instructions:C.string().nullable().describe("Instructions also used as system prompt"),enabled_plugins:C.array(C.string()).nullable().optional().describe("List of enabled plugin IDs"),subAgents:C.array(C.string()).nullable().optional().describe("Allowlist of Virtual MCP (agent) IDs this agent may delegate to via subtask. null/absent = all active org agents; empty array = itself only (no cross-agent delegation)."),ui:wW.nullable().optional().describe("UI customization settings"),githubRepo:_W.nullable().optional().describe("Linked GitHub repository"),runtime:RW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:z7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().describe("Metadata"),connections:C.array(A7).describe("Connections with their selected tools, resources, and prompts")}),cV=C.object({title:C.string().min(1).max(255).describe("Name for the virtual MCP"),description:C.string().nullable().optional().describe("Optional description"),icon:C.string().nullish().describe("Optional icon URL"),status:C.enum(["active","inactive"]).optional().default("active").describe("Initial status"),pinned:C.boolean().optional().default(!1).describe("Pin to sidebar"),metadata:C.object({instructions:C.string().nullable().optional().describe("MCP server instructions"),enabled_plugins:C.array(C.string()).nullable().optional().describe("List of enabled plugin IDs"),subAgents:C.array(C.string()).nullable().optional().describe("Allowlist of Virtual MCP (agent) IDs this agent may delegate to via subtask. null/absent = all active org agents; empty array = itself only (no cross-agent delegation)."),ui:wW.nullable().optional().describe("UI customization settings"),githubRepo:_W.nullable().optional().describe("Linked GitHub repository"),runtime:RW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:z7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().nullable().optional().describe("Additional metadata including MCP server instructions"),connections:C.array(lV).describe("Connections to include/exclude (can be empty for exclusion mode)")}),dV=C.object({title:C.string().min(1).max(255).optional().describe("New name"),description:C.string().nullable().optional().describe("New description (null to clear)"),icon:C.string().nullish().describe("New icon URL"),status:C.enum(["active","inactive"]).optional().describe("New status"),pinned:C.boolean().optional().describe("Pin/unpin from sidebar"),metadata:C.object({instructions:C.string().nullable().optional().describe("MCP server instructions"),enabled_plugins:C.array(C.string()).nullable().optional().describe("List of enabled plugin IDs"),subAgents:C.array(C.string()).nullable().optional().describe("Allowlist of Virtual MCP (agent) IDs this agent may delegate to via subtask. null/absent = all active org agents; empty array = itself only (no cross-agent delegation)."),ui:wW.nullable().optional().describe("UI customization settings"),githubRepo:_W.nullable().optional().describe("Linked GitHub repository"),runtime:RW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:z7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().nullable().optional().describe("Additional metadata including MCP server instructions"),connections:C.array(lV).optional().describe("New connections (replaces existing)")});var IW=["in_progress","requires_action","failed","completed"],nV=[...IW,"expired"],fW={STEP:"decopilot.step",FINISH:"decopilot.finish",THREAD_STATUS:"decopilot.thread.status"},rV=Object.values(fW);var aV=i6(L5(),1),oV=i6(eX(),1);function My(){let $=new aV.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0,code:{optimize:!1}});return oV.default($),$}class sV{#$=My();#Z=new Map;#Y=new WeakMap;getValidator($){let Z=this.#Y.get($);if(Z)return Z;let Y=Py($),Q=this.#Z.get(Y);if(!Q)Q=this.#$.compile($),this.#Z.set(Y,Q);let W=Q,J=(G)=>{if(W(G))return{valid:!0,data:G,errorMessage:void 0};return{valid:!1,data:void 0,errorMessage:this.#$.errorsText(W.errors)}};return this.#Y.set($,J),J}}function Py($){return JSON.stringify($,(Z,Y)=>{if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Object.fromEntries(Object.keys(Y).sort().map((Q)=>[Q,Y[Q]]));return Y})}var T5=new sV;var tV;(function($){$.Completable="McpCompletable"})(tV||(tV={}));import{ZodOptional as bt}from"zod";var QL="MCP Workflows",XL="Create workflows using your MCP tools";import{sql as WL}from"kysely";var JL={name:"001-workflows",async up($){await $.schema.createTable("workflow_collection").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("title","text",(Z)=>Z.notNull()).addColumn("description","text").addColumn("virtual_mcp_id","text",(Z)=>Z.notNull()).addColumn("steps","text",(Z)=>Z.notNull().defaultTo("[]")).addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(WL`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(WL`CURRENT_TIMESTAMP`)).addColumn("created_by","text").addColumn("updated_by","text").execute(),await $.schema.createIndex("idx_wf_collection_org").ifNotExists().on("workflow_collection").column("organization_id").execute(),await $.schema.createIndex("idx_wf_collection_created_at").ifNotExists().on("workflow_collection").column("created_at").execute(),await $.schema.createTable("workflow").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("workflow_collection_id","text").addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("steps","text",(Z)=>Z.notNull().defaultTo("[]")).addColumn("input","text").addColumn("virtual_mcp_id","text",(Z)=>Z.notNull()).addColumn("created_at_epoch_ms","bigint",(Z)=>Z.notNull()).addColumn("created_by","text").execute(),await $.schema.createIndex("idx_workflow_created_at").ifNotExists().on("workflow").column("created_at_epoch_ms").execute(),await $.schema.createIndex("idx_workflow_collection_id").ifNotExists().on("workflow").column("workflow_collection_id").execute(),await $.schema.createTable("workflow_execution").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("workflow_id","text",(Z)=>Z.notNull().references("workflow.id").onDelete("cascade")).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("status","text",(Z)=>Z.notNull().defaultTo("enqueued")).addColumn("input","text").addColumn("output","text").addColumn("error","text").addColumn("created_at","bigint",(Z)=>Z.notNull()).addColumn("updated_at","bigint",(Z)=>Z.notNull()).addColumn("start_at_epoch_ms","bigint").addColumn("started_at_epoch_ms","bigint").addColumn("completed_at_epoch_ms","bigint").addColumn("timeout_ms","bigint").addColumn("deadline_at_epoch_ms","bigint").addColumn("created_by","text").execute(),await $.schema.createIndex("idx_wf_execution_status").ifNotExists().on("workflow_execution").column("status").execute(),await $.schema.createIndex("idx_wf_execution_workflow_id").ifNotExists().on("workflow_execution").column("workflow_id").execute(),await $.schema.createIndex("idx_wf_execution_org").ifNotExists().on("workflow_execution").column("organization_id").execute(),await $.schema.createIndex("idx_wf_execution_created_at").ifNotExists().on("workflow_execution").column("created_at").execute(),await $.schema.createTable("workflow_execution_step_result").ifNotExists().addColumn("execution_id","text",(Z)=>Z.notNull().references("workflow_execution.id").onDelete("cascade")).addColumn("step_id","text",(Z)=>Z.notNull()).addColumn("started_at_epoch_ms","bigint").addColumn("completed_at_epoch_ms","bigint").addColumn("output","text").addColumn("error","text").addColumn("raw_tool_output","text").execute(),await $.schema.createIndex("idx_wf_step_result_pk").ifNotExists().on("workflow_execution_step_result").columns(["execution_id","step_id"]).unique().execute(),await $.schema.createIndex("idx_wf_step_result_execution").ifNotExists().on("workflow_execution_step_result").column("execution_id").execute()},async down($){await $.schema.dropIndex("idx_wf_step_result_execution").ifExists().execute(),await $.schema.dropIndex("idx_wf_step_result_pk").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_created_at").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_org").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_workflow_id").ifExists().execute(),await $.schema.dropIndex("idx_wf_execution_status").ifExists().execute(),await $.schema.dropIndex("idx_workflow_collection_id").ifExists().execute(),await $.schema.dropIndex("idx_workflow_created_at").ifExists().execute(),await $.schema.dropIndex("idx_wf_collection_created_at").ifExists().execute(),await $.schema.dropIndex("idx_wf_collection_org").ifExists().execute(),await $.schema.dropTable("workflow_execution_step_result").ifExists().execute(),await $.schema.dropTable("workflow_execution").ifExists().execute(),await $.schema.dropTable("workflow").ifExists().execute(),await $.schema.dropTable("workflow_collection").ifExists().execute()}};var GL={name:"002-execution-list-index",async up($){await $.schema.createIndex("idx_wf_execution_org_created_at").ifNotExists().on("workflow_execution").columns(["organization_id","created_at desc"]).execute()},async down($){await $.schema.dropIndex("idx_wf_execution_org_created_at").ifExists().execute()}};var KL={name:"003-retry-and-input-schema",async up($){await $.schema.alterTable("workflow_execution_step_result").addColumn("attempt_number","integer",(Z)=>Z.notNull().defaultTo(1)).execute(),await $.schema.alterTable("workflow_collection").addColumn("input_schema","text").execute()},async down($){await $.schema.alterTable("workflow_execution_step_result").dropColumn("attempt_number").execute(),await $.schema.alterTable("workflow_collection").dropColumn("input_schema").execute()}};var HL=[JL,GL,KL];function $0($){let Z=$;if(!Z.organization)throw Error("Organization context required for workflow tools");return Z}function S1($){if($===null||$===void 0)return null;if(typeof $==="object")return $;if(typeof $!=="string")return $;try{return JSON.parse($)}catch{return $}}var SW=null;function BL($){SW=$}function u1(){if(!SW)throw Error('Plugin storage not initialized. Make sure the "workflows" plugin is enabled.');return SW}function FL($){return{...$,steps:S1($.steps)??[],input_schema:S1($.input_schema)??null}}class bW{db;constructor($){this.db=$}async list($,Z={}){let{limit:Y=50,offset:Q=0}=Z,W=await this.db.selectFrom("workflow_collection").selectAll().where("organization_id","=",$).orderBy("created_at","desc").limit(Y).offset(Q).execute(),J=await this.db.selectFrom("workflow_collection").select((G)=>G.fn.countAll().as("count")).where("organization_id","=",$).executeTakeFirstOrThrow();return{items:W,totalCount:Number(J.count)}}async getById($,Z){let Y=await this.db.selectFrom("workflow_collection").selectAll().where("id","=",$).where("organization_id","=",Z).executeTakeFirst();return Y?FL(Y):null}async create($){let{input_schema:Z,...Y}=$,Q=await this.db.insertInto("workflow_collection").values({...Y,input_schema:Z!=null?JSON.stringify(Z):null}).returningAll().executeTakeFirstOrThrow();return FL(Q)}async update($,Z,Y){let{input_schema:Q,...W}=Y,J={...W,updated_at:new Date().toISOString()};if(Q!==void 0)J.input_schema=Q?JSON.stringify(Q):null;return await this.db.updateTable("workflow_collection").set(J).where("id","=",$).where("organization_id","=",Z).returningAll().executeTakeFirstOrThrow()}async delete($,Z){return await this.db.deleteFrom("workflow_collection").where("id","=",$).where("organization_id","=",Z).returningAll().executeTakeFirstOrThrow()}}function Ey($){return{...$,steps:S1($.steps)??[],input:S1($.input)??null}}function k6($){return{...$,output:S1($.output),error:S1($.error),raw_tool_output:S1($.raw_tool_output)}}class vW{db;constructor($){this.db=$}async _createWorkflow($,Z){let Y=crypto.randomUUID(),Q=Date.now();return await $.insertInto("workflow").values({id:Y,workflow_collection_id:Z.workflowCollectionId??null,organization_id:Z.organizationId,steps:JSON.stringify(Z.steps),input:Z.input?JSON.stringify(Z.input):null,virtual_mcp_id:Z.virtualMcpId,created_at_epoch_ms:Q,created_by:Z.createdBy??null}).execute(),{id:Y}}async createWorkflow($){return this._createWorkflow(this.db,$)}async getWorkflow($){let Z=await this.db.selectFrom("workflow").selectAll().where("id","=",$).executeTakeFirst();return Z?Ey(Z):null}async createExecution($){return this.db.transaction().execute(async(Z)=>{let Y=Date.now(),{id:Q}=await this._createWorkflow(Z,{organizationId:$.organizationId,workflowCollectionId:$.workflowCollectionId,virtualMcpId:$.virtualMcpId,input:$.input,steps:$.steps,createdBy:$.createdBy}),W=crypto.randomUUID(),J=$.startAtEpochMs??Y,G=$.timeoutMs?J+$.timeoutMs:null;return await Z.insertInto("workflow_execution").values({id:W,workflow_id:Q,organization_id:$.organizationId,status:"enqueued",input:$.input?JSON.stringify($.input):null,created_at:Y,updated_at:Y,start_at_epoch_ms:J,timeout_ms:$.timeoutMs??null,deadline_at_epoch_ms:G,created_by:$.createdBy??null}).execute(),{id:W}})}async getExecution($,Z){return await this.db.selectFrom("workflow_execution").selectAll().where("id","=",$).where("organization_id","=",Z).executeTakeFirst()??null}async getExecutionFull($,Z){let Y=await this.db.selectFrom("workflow_execution").selectAll().where("id","=",$).where("organization_id","=",Z).executeTakeFirst();if(!Y)return null;let Q=await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).execute();return{execution:Y,stepResults:Q.map(k6)}}async getExecutionContext($){let[Z,Y]=await Promise.all([this.db.selectFrom("workflow_execution as we").innerJoin("workflow as w","we.workflow_id","w.id").select(["we.id","we.status","we.workflow_id","we.deadline_at_epoch_ms","w.steps","w.input","w.virtual_mcp_id"]).where("we.id","=",$).executeTakeFirst(),this.db.selectFrom("workflow_execution_step_result").select(["step_id","started_at_epoch_ms","completed_at_epoch_ms","output","error","attempt_number"]).where("execution_id","=",$).execute()]);if(!Z)return null;return{execution:{id:Z.id,status:Z.status,workflow_id:Z.workflow_id,deadline_at_epoch_ms:Z.deadline_at_epoch_ms},workflow:{steps:S1(Z.steps)??[],input:S1(Z.input)??null,virtual_mcp_id:Z.virtual_mcp_id},stepResults:Y.map((Q)=>({step_id:Q.step_id,started_at_epoch_ms:Q.started_at_epoch_ms,completed_at_epoch_ms:Q.completed_at_epoch_ms,output:S1(Q.output),error:S1(Q.error),attempt_number:Q.attempt_number}))}}async claimExecution($){let Z=Date.now(),Y=await this.db.updateTable("workflow_execution").set({status:"running",updated_at:Z}).where("id","=",$).where("status","=","enqueued").returningAll().executeTakeFirst();if(!Y)return null;let Q=await this.getWorkflow(Y.workflow_id);if(!Q)throw Error(`Workflow ${Y.workflow_id} not found for execution ${$}`);return{execution:Y,workflow:Q}}async updateExecution($,Z,Y){let W={updated_at:Date.now()};if(Z.status!==void 0)W.status=Z.status;if(Z.output!==void 0)W.output=JSON.stringify(Z.output);if(Z.error!==void 0)W.error=JSON.stringify(Z.error);if(Z.completed_at_epoch_ms!==void 0)W.completed_at_epoch_ms=Z.completed_at_epoch_ms;let J=this.db.updateTable("workflow_execution").set(W).where("id","=",$);if(Y?.onlyIfStatus)J=J.where("status","=",Y.onlyIfStatus);return await J.returningAll().executeTakeFirst()??null}async cancelExecution($,Z){let Y=Date.now();return!!await this.db.updateTable("workflow_execution").set({status:"cancelled",updated_at:Y}).where("id","=",$).where("organization_id","=",Z).where("status","in",["enqueued","running"]).returningAll().executeTakeFirst()}async resumeExecution($,Z){return this.db.transaction().execute(async(Y)=>{let Q=Date.now(),W=await Y.selectFrom("workflow_execution").where("id","=",$).where("organization_id","=",Z).select(["status"]).executeTakeFirst();if(!W)return!1;let{status:J}=W;if(J==="success"){let B=await Y.selectFrom("workflow_execution_step_result").where("execution_id","=",$).where("error","is not",null).select(Y.fn.countAll().as("count")).executeTakeFirstOrThrow();if(Number(B.count)===0)return!1}else if(J!=="cancelled"&&J!=="error")return!1;await Y.updateTable("workflow_execution").set({status:"enqueued",updated_at:Q,completed_at_epoch_ms:null,error:null}).where("id","=",$).execute();let G=await Y.selectFrom("workflow_execution_step_result").where("execution_id","=",$).where("error","is not",null).where("step_id","like","%[%").select("step_id").execute(),K=new Set;for(let B of G)K.add(B.step_id.replace(/\[\d+\]$/,""));if(await Y.deleteFrom("workflow_execution_step_result").where("execution_id","=",$).where((B)=>B.or([B("completed_at_epoch_ms","is",null),B("error","is not",null)])).execute(),K.size>0)await Y.deleteFrom("workflow_execution_step_result").where("execution_id","=",$).where("step_id","in",[...K]).execute();return!0})}async listExecutions($,Z={}){let{limit:Y=50,offset:Q=0,status:W,workflowCollectionId:J}=Z,G=this.db.selectFrom("workflow_execution as we").innerJoin("workflow as w","we.workflow_id","w.id").leftJoin("workflow_collection as wc","w.workflow_collection_id","wc.id").select(["we.id","we.workflow_id","we.organization_id","we.status","we.input","we.output","we.error","we.created_at","we.updated_at","we.start_at_epoch_ms","we.started_at_epoch_ms","we.completed_at_epoch_ms","we.timeout_ms","we.deadline_at_epoch_ms","we.created_by","w.virtual_mcp_id"]).select((L)=>L.fn.coalesce("wc.title",L.val("Workflow Execution")).as("title")).where("we.organization_id","=",$);if(W)G=G.where("we.status","=",W);if(J)G=G.where("w.workflow_collection_id","=",J);let K=await G.orderBy("we.created_at","desc").limit(Y).offset(Q).execute(),B=this.db.selectFrom("workflow_execution as we").innerJoin("workflow as w","we.workflow_id","w.id").select((L)=>L.fn.countAll().as("count")).where("we.organization_id","=",$);if(W)B=B.where("we.status","=",W);if(J)B=B.where("w.workflow_collection_id","=",J);let D=await B.executeTakeFirstOrThrow(),V=Number(D.count);return{items:K,totalCount:V,hasMore:Q+K.length<V}}async createStepResult($){let Z=await this.db.insertInto("workflow_execution_step_result").values({execution_id:$.execution_id,step_id:$.step_id,started_at_epoch_ms:$.completed_at_epoch_ms?Date.now():null,completed_at_epoch_ms:$.completed_at_epoch_ms??null,output:$.output!==void 0?JSON.stringify($.output):null,error:$.error!==void 0?JSON.stringify($.error):null,attempt_number:1}).onConflict((Y)=>Y.columns(["execution_id","step_id"]).doNothing()).returningAll().executeTakeFirst();return Z?k6(Z):null}async updateStepResult($,Z,Y){let Q={};if(Y.output!==void 0)Q.output=Y.output===null?null:JSON.stringify(Y.output);if(Y.error!==void 0)Q.error=Y.error===null?null:JSON.stringify(Y.error);if(Y.started_at_epoch_ms!==void 0)Q.started_at_epoch_ms=Y.started_at_epoch_ms;if(Y.completed_at_epoch_ms!==void 0)Q.completed_at_epoch_ms=Y.completed_at_epoch_ms;if(Y.attempt_number!==void 0)Q.attempt_number=Y.attempt_number;if(Y.raw_tool_output!==void 0)Q.raw_tool_output=Y.raw_tool_output===null?null:JSON.stringify(Y.raw_tool_output);if(Object.keys(Q).length===0)return null;let W=await this.db.updateTable("workflow_execution_step_result").set(Q).where("execution_id","=",$).where("step_id","=",Z).returningAll().executeTakeFirst();return W?k6(W):null}async claimStepForRetry($,Z,Y){let Q=await this.db.updateTable("workflow_execution_step_result").set({started_at_epoch_ms:Date.now()}).where("execution_id","=",$).where("step_id","=",Z).where("attempt_number","=",Y).where("started_at_epoch_ms","is",null).returningAll().executeTakeFirst();return Q?k6(Q):null}async resetStepResultForRetry($,Z,Y){await this.updateStepResult($,Z,{completed_at_epoch_ms:null,output:null,error:null,started_at_epoch_ms:null,attempt_number:Y,raw_tool_output:null})}async checkpointAndTransform($,Z,Y,Q){await this.db.updateTable("workflow_execution_step_result").set({raw_tool_output:JSON.stringify(Y)}).where("execution_id","=",$).where("step_id","=",Z).execute();let W,J;try{let B=await Q(Y);W=B.output,J=B.error}catch(B){J=B instanceof Error?`Transform failed: ${B.message}`:`Transform failed: ${String(B)}`}let G={completed_at_epoch_ms:Date.now()};if(W!==void 0)G.output=JSON.stringify(W);if(J!==void 0)G.error=JSON.stringify(J);let K=await this.db.updateTable("workflow_execution_step_result").set(G).where("execution_id","=",$).where("step_id","=",Z).returningAll().executeTakeFirst();return K?k6(K):null}async getStepResult($,Z){let Y=await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).where("step_id","=",Z).executeTakeFirst();return Y?k6(Y):null}async getStepResults($){return(await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).execute()).map(k6)}async deleteStepResult($,Z){await this.db.deleteFrom("workflow_execution_step_result").where("execution_id","=",$).where("step_id","=",Z).execute()}async getStepResultsByPrefix($,Z){let Y=Z.replaceAll("\\","\\\\").replaceAll("%","\\%").replaceAll("_","\\_");return(await this.db.selectFrom("workflow_execution_step_result").selectAll().where("execution_id","=",$).where("step_id","like",`${Y}%`).orderBy("step_id").execute()).map(k6)}async recoverStuckExecutions(){return this.db.updateTable("workflow_execution").set({status:"enqueued",updated_at:Date.now()}).where("status","=","running").returning(["id","organization_id"]).execute()}}function DL($){let Z=$.db;return{collections:new bW(Z),executions:new vW(Z)}}import{z as c}from"zod";import{z as T}from"zod";import{z as q0}from"zod/v4";import{z as VL}from"zod/v4";import{z as k5}from"zod/v4";import{z as i0}from"zod/v4";import{z as Iy}from"zod/v4";import{z as X8}from"zod/v4";import{z as c0}from"zod/v4";import{z as b1}from"zod/v4";import{z as LL}from"zod/v4";import{z as u5}from"zod/v4";import{z as ty}from"zod/v4";import{z as UL}from"zod/v4";import{z as x5}from"zod/v4";import{z as GT}from"zod/v4";var Ry=class{apply($,Z){if(!Z.type)return;let Y=Array.isArray(Z.type)?Z.type:[Z.type],Q=new Set(Y);if(!Q.has("string"))$.string=!1;if(!Q.has("number")&&!Q.has("integer"))$.number=!1;if(!Q.has("boolean"))$.boolean=!1;if(!Q.has("null"))$.null=!1;if(!Q.has("array"))$.array=!1;if(!Q.has("object"))$.object=!1;if(Q.has("integer")&&$.number!==!1){let W=$.number||VL.number();if(W instanceof VL.ZodNumber)$.number=W.int()}}},_y=class{apply($,Z){if(Z.const===void 0)return;let Y=Z.const;if($.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1,typeof Y==="string")$.string=k5.literal(Y);else if(typeof Y==="number")$.number=k5.literal(Y);else if(typeof Y==="boolean")$.boolean=k5.literal(Y);else if(Y===null)$.null=k5.null();else if(Array.isArray(Y))$.array=void 0;else if(typeof Y==="object")$.object=void 0}},Cy=class{apply($,Z){if(!Z.enum)return;if(Z.enum.length===0){if(!Z.type)$.string=!1,$.number=!1,$.boolean=!1,$.null=!1,$.array=!1,$.object=!1;return}let Y={string:Z.enum.filter((Q)=>typeof Q==="string"),number:Z.enum.filter((Q)=>typeof Q==="number"),boolean:Z.enum.filter((Q)=>typeof Q==="boolean"),null:Z.enum.filter((Q)=>Q===null),array:Z.enum.filter((Q)=>Array.isArray(Q)),object:Z.enum.filter((Q)=>typeof Q==="object"&&Q!==null&&!Array.isArray(Q))};$.string=this.createTypeSchema(Y.string,"string"),$.number=this.createTypeSchema(Y.number,"number"),$.boolean=this.createTypeSchema(Y.boolean,"boolean"),$.null=Y.null.length>0?i0.null():!1,$.array=Y.array.length>0?void 0:!1,$.object=Y.object.length>0?void 0:!1}createTypeSchema($,Z){if($.length===0)return!1;if($.length===1)return i0.literal($[0]);if(Z==="string")return i0.enum($);if(Z==="number"){let[Y,Q,...W]=$;return i0.union([i0.literal(Y),i0.literal(Q),...W.map((J)=>i0.literal(J))])}if(Z==="boolean")return i0.union([i0.literal(!0),i0.literal(!1)]);return!1}},fy=class{apply($,Z){let Y=Z;if(Y.type==="string"&&Y.format==="binary"&&Y.contentEncoding==="binary"){let Q=Iy.file();if(Y.minLength!==void 0)Q=Q.min(Y.minLength);if(Y.maxLength!==void 0)Q=Q.max(Y.maxLength);if(Y.contentMediaType!==void 0)Q=Q.mime(Y.contentMediaType);$.file=Q,$.string=!1}}},Sy=class{apply($,Z){let Y=Z;if(Z.type===void 0&&(Y.minLength!==void 0||Y.maxLength!==void 0||Y.pattern!==void 0)){if($.string===void 0)$.string=X8.string()}}},by=class{apply($,Z){let Y=Z;if(Y.minLength===void 0)return;if($.string!==!1){let Q=$.string||X8.string();if(Q instanceof X8.ZodString)$.string=Q.refine((W)=>{return Array.from(W).length>=Y.minLength},{message:`String must be at least ${Y.minLength} characters long`})}}},vy=class{apply($,Z){let Y=Z;if(Y.maxLength===void 0)return;if($.string!==!1){let Q=$.string||X8.string();if(Q instanceof X8.ZodString)$.string=Q.refine((W)=>{return Array.from(W).length<=Y.maxLength},{message:`String must be at most ${Y.maxLength} characters long`})}}},yy=class{apply($,Z){let Y=Z;if(!Y.pattern)return;if($.string!==!1){let Q=$.string||X8.string();if(Q instanceof X8.ZodString){let W=new RegExp(Y.pattern);$.string=Q.regex(W)}}}},Ty=class{apply($,Z){let Y=Z;if(Y.minimum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)$.number=Q.min(Y.minimum)}}},ky=class{apply($,Z){let Y=Z;if(Y.maximum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)$.number=Q.max(Y.maximum)}}},xy=class{apply($,Z){let Y=Z;if(Y.exclusiveMinimum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)if(typeof Y.exclusiveMinimum==="number")$.number=Q.gt(Y.exclusiveMinimum);else $.number=!1}}},gy=class{apply($,Z){let Y=Z;if(Y.exclusiveMaximum===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)if(typeof Y.exclusiveMaximum==="number")$.number=Q.lt(Y.exclusiveMaximum);else $.number=!1}}},uy=class{apply($,Z){let Y=Z;if(Y.multipleOf===void 0)return;if($.number!==!1){let Q=$.number||c0.number();if(Q instanceof c0.ZodNumber)$.number=Q.refine((W)=>{if(Y.multipleOf===0)return!1;let J=W/Y.multipleOf,G=Math.round(J),K=Math.min(Math.abs(W)*Number.EPSILON*10,Math.abs(Y.multipleOf)*Number.EPSILON*10);return Math.abs(J-G)<=K/Math.abs(Y.multipleOf)},{message:`Must be a multiple of ${Y.multipleOf}`})}}},hy=class{apply($,Z){let Y=Z;if(Z.type===void 0&&(Y.minItems!==void 0||Y.maxItems!==void 0||Y.items!==void 0||Y.prefixItems!==void 0)){if($.array===void 0)$.array=b1.array(b1.any())}}},my=class{apply($,Z){let Y=Z;if(Y.minItems===void 0)return;if($.array!==!1)$.array=($.array||b1.array(b1.any())).min(Y.minItems)}},ly=class{apply($,Z){let Y=Z;if(Y.maxItems===void 0)return;if($.array!==!1)$.array=($.array||b1.array(b1.any())).max(Y.maxItems)}},py=class{apply($,Z){let Y=Z;if($.array===!1)return;if(Array.isArray(Y.items))$.array=$.array||b1.array(b1.any());else if(Y.items&&typeof Y.items!=="boolean"&&!Y.prefixItems){let Q=I1(Y.items),W=b1.array(Q);if($.array&&$.array instanceof b1.ZodArray){let J=$.array._def;if(J.checks)J.checks.forEach((G)=>{if(G._zod&&G._zod.def){let K=G._zod.def;if(K.check==="min_length"&&K.minimum!==void 0)W=W.min(K.minimum);else if(K.check==="max_length"&&K.maximum!==void 0)W=W.max(K.maximum)}})}$.array=W}else if(typeof Y.items==="boolean"&&Y.items===!1)if(!Y.prefixItems)$.array=b1.array(b1.any()).max(0);else $.array=$.array||b1.array(b1.any());else if(typeof Y.items==="boolean"&&Y.items===!0)$.array=$.array||b1.array(b1.any());else if(Y.prefixItems)$.array=$.array||b1.array(b1.any())}},iy=class{apply($,Z){if(Z.type!=="array")return;let Y=Z;if(!Array.isArray(Y.items))return;if($.array===!1)return;let Q=Y.items.map((J)=>I1(J)),W;if(Q.length===0)W=LL.tuple([]);else W=LL.tuple(Q);if(Y.minItems!==void 0&&Y.minItems>Q.length)W=!1;if(Y.maxItems!==void 0&&Y.maxItems<Q.length)W=!1;$.tuple=W,$.array=!1}},cy=class{apply($,Z){let Y=Z;if($.object===!1)return;if(Y.properties||Y.required||Y.additionalProperties!==void 0)$.object=$.object||u5.object({}).passthrough()}},dy=class{apply($,Z){let Y=Z;if(Z.type===void 0&&(Y.maxProperties!==void 0||Y.minProperties!==void 0)){if($.object===void 0)$.object=u5.object({}).passthrough()}}},ny=class{apply($,Z){let Y=Z;if(Y.maxProperties===void 0)return;if($.object!==!1){let Q=$.object||u5.object({}).passthrough();$.object=Q.refine((W)=>Object.keys(W).length<=Y.maxProperties,{message:`Object must have at most ${Y.maxProperties} properties`})}}},ry=class{apply($,Z){let Y=Z;if(Y.minProperties===void 0)return;if($.object!==!1){let Q=$.object||u5.object({}).passthrough();$.object=Q.refine((W)=>Object.keys(W).length>=Y.minProperties,{message:`Object must have at least ${Y.minProperties} properties`})}}};function q7($,Z){if($===Z)return!0;if($==null||Z==null)return $===Z;if(typeof $!==typeof Z)return!1;if(Array.isArray($)&&Array.isArray(Z)){if($.length!==Z.length)return!1;return $.every((Y,Q)=>q7(Y,Z[Q]))}if(typeof $==="object"&&typeof Z==="object"){let Y=Object.keys($),Q=Object.keys(Z);if(Y.length!==Q.length)return!1;return Y.every((W)=>Q.includes(W)&&q7($[W],Z[W]))}return!1}function ay(){return($)=>{if(!Array.isArray($))return!0;let Z=[];return $.every((Y)=>{if(Z.some((W)=>q7(Y,W)))return!1;return Z.push(Y),!0})}}function g5($,Z){return $.safeParse(Z).success}var oy=class{apply($,Z){if(!Z.not)return $;let Y=I1(Z.not);return $.refine((Q)=>!g5(Y,Q),{message:"Value must not match the 'not' schema"})}},sy=class{apply($,Z){if(Z.uniqueItems!==!0)return $;return $.refine(ay(),{message:"Array items must be unique"})}},ey=class{apply($,Z){if(!Z.allOf||Z.allOf.length===0)return $;return Z.allOf.map((Q)=>I1(Q)).reduce((Q,W)=>ty.intersection(Q,W),$)}},$T=class{apply($,Z){if(!Z.anyOf||Z.anyOf.length===0)return $;let Y=Z.anyOf.length===1?I1(Z.anyOf[0]):UL.union([I1(Z.anyOf[0]),I1(Z.anyOf[1]),...Z.anyOf.slice(2).map((Q)=>I1(Q))]);return UL.intersection($,Y)}},ZT=class{apply($,Z){if(!Z.oneOf||Z.oneOf.length===0)return $;let Y=Z.oneOf.map((Q)=>I1(Q));return $.refine((Q)=>{let W=0;for(let J of Y)if(J.safeParse(Q).success){if(W++,W>1)return!1}return W===1},{message:"Value must match exactly one of the oneOf schemas"})}},YT=class{apply($,Z){let Y=Z;if(Y.prefixItems&&Array.isArray(Y.prefixItems)){let W=Y.prefixItems.map((J)=>I1(J));return $.refine((J)=>{if(!Array.isArray(J))return!0;for(let G=0;G<Math.min(J.length,W.length);G++)if(!g5(W[G],J[G]))return!1;if(J.length>W.length){if(typeof Y.items==="boolean"&&Y.items===!1)return!1;else if(Y.items&&typeof Y.items==="object"&&!Array.isArray(Y.items)){let G=I1(Y.items);for(let K=W.length;K<J.length;K++)if(!g5(G,J[K]))return!1}}return!0},{message:"Array does not match prefixItems schema"})}return $}},QT=class{apply($,Z){let Y=Z;if(!Y.properties&&!Y.required&&Y.additionalProperties!==!1)return $;if($ instanceof x5.ZodObject||$ instanceof x5.ZodRecord){let Q={};if(Y.properties){for(let[W,J]of Object.entries(Y.properties))if(J!==void 0)Q[W]=I1(J)}if(Y.required&&Array.isArray(Y.required)){let W=new Set(Y.required);for(let J of Object.keys(Q))if(!W.has(J))Q[J]=Q[J].optional()}else for(let W of Object.keys(Q))Q[W]=Q[W].optional();if(Y.additionalProperties===!1)return x5.object(Q);else return x5.object(Q).passthrough()}return $.refine((Q)=>{if(typeof Q!=="object"||Q===null||Array.isArray(Q))return!0;if(Y.properties){for(let[W,J]of Object.entries(Y.properties))if(J!==void 0){if(Object.getOwnPropertyDescriptor(Q,W)!==void 0){if(!I1(J).safeParse(Q[W]).success)return!1}}}if(Y.required&&Array.isArray(Y.required)){for(let W of Y.required)if(Object.getOwnPropertyDescriptor(Q,W)===void 0)return!1}if(Y.additionalProperties===!1&&Y.properties){let W=new Set(Object.keys(Y.properties));for(let J in Q)if(!W.has(J))return!1}return!0},{message:"Object constraints validation failed"})}},XT=class{apply($,Z){if(!Z.enum||Z.enum.length===0)return $;let Y=Z.enum.filter((Q)=>Array.isArray(Q)||typeof Q==="object"&&Q!==null);if(Y.length===0)return $;return $.refine((Q)=>{if(typeof Q!=="object"||Q===null)return!0;return Y.some((W)=>q7(Q,W))},{message:"Value must match one of the enum values"})}},WT=class{apply($,Z){if(Z.const===void 0)return $;let Y=Z.const;if(typeof Y!=="object"||Y===null)return $;return $.refine((Q)=>q7(Q,Y),{message:"Value must equal the const value"})}},JT=class{apply($,Z){if(Z.description)$=$.describe(Z.description);return $}},KT=class{apply($,Z){var Y;let Q=Z;if(!((Y=Q.required)==null?void 0:Y.includes("__proto__"))||Z.type!==void 0)return $;return GT.any().refine((W)=>this.validateRequired(W,Q.required),{message:"Missing required properties"})}validateRequired($,Z){if(typeof $!=="object"||$===null||Array.isArray($))return!0;return Z.every((Y)=>Object.prototype.hasOwnProperty.call($,Y))}},HT=class{apply($,Z){var Y;let Q=Z;if(Q.contains===void 0)return $;let W=I1(Q.contains),J=(Y=Q.minContains)!=null?Y:1,G=Q.maxContains;return $.refine((K)=>{if(!Array.isArray(K))return!0;let B=0;for(let D of K)if(g5(W,D))B++;if(B<J)return!1;if(G!==void 0&&B>G)return!1;return!0},{message:"Array must contain required items matching the schema"})}},BT=class{apply($,Z){let{default:Y}=Z;if(Y===void 0)return $;if(!$.safeParse(Y).success)return $;return $.default(Y)}},FT=[new _y,new Cy,new Ry,new fy,new Sy,new hy,new dy,new by,new vy,new yy,new Ty,new ky,new xy,new gy,new uy,new iy,new my,new ly,new py,new ny,new ry,new cy],DT=[new KT,new XT,new WT,new ey,new $T,new ZT,new YT,new QT,new HT,new oy,new sy,new BT,new JT];function I1($){if(typeof $==="boolean")return $?q0.any():q0.never();let Z={};for(let W of FT)W.apply(Z,$);let Y=[];if(Z.string!==!1)Y.push(Z.string||q0.string());if(Z.number!==!1)Y.push(Z.number||q0.number());if(Z.boolean!==!1)Y.push(Z.boolean||q0.boolean());if(Z.null!==!1)Y.push(Z.null||q0.null());if(Z.array!==!1)Y.push(Z.array||q0.array(q0.any()));if(Z.tuple!==!1&&Z.tuple!==void 0)Y.push(Z.tuple);if(Z.object!==!1)if(Z.object)Y.push(Z.object);else{let W=q0.custom((J)=>{return typeof J==="object"&&J!==null&&!Array.isArray(J)},"Must be an object, not an array");Y.push(W)}if(Z.file!==!1&&Z.file!==void 0)Y.push(Z.file);let Q;if(Y.length===0)Q=q0.never();else if(Y.length===1)Q=Y[0];else if(!Object.keys($).some((J)=>J!=="$schema"&&J!=="title"&&J!=="description"))Q=q0.any();else Q=q0.union(Y);for(let W of DT)Q=W.apply(Q,$);return Q}class yW extends Event{constructor($,Z){var Y,Q;super($),this.code=(Y=Z==null?void 0:Z.code)!=null?Y:void 0,this.message=(Q=Z==null?void 0:Z.message)!=null?Q:void 0}[Symbol.for("nodejs.util.inspect.custom")]($,Z,Y){return Y(jL(this),Z)}[Symbol.for("Deno.customInspect")]($,Z){return $(jL(this),Z)}}function VT($){let Z=globalThis.DOMException;return typeof Z=="function"?new Z($,"SyntaxError"):SyntaxError($)}function TW($){return $ instanceof Error?"errors"in $&&Array.isArray($.errors)?$.errors.map(TW).join(", "):("cause"in $)&&$.cause instanceof Error?`${$}: ${TW($.cause)}`:$.message:`${$}`}function jL($){return{type:$.type,message:$.message,code:$.code,defaultPrevented:$.defaultPrevented,cancelable:$.cancelable,timeStamp:$.timeStamp}}var zL=($)=>{throw TypeError($)},pW=($,Z,Y)=>Z.has($)||zL("Cannot "+Y),X1=($,Z,Y)=>(pW($,Z,"read from private field"),Y?Y.call($):Z.get($)),f1=($,Z,Y)=>Z.has($)?zL("Cannot add the same private member more than once"):Z instanceof WeakSet?Z.add($):Z.set($,Y),q1=($,Z,Y,Q)=>(pW($,Z,"write to private field"),Z.set($,Y),Y),G6=($,Z,Y)=>(pW($,Z,"access private method"),Y),Z0,W8,Y9,h5,m5,M7,W9,P7,x6,Q9,J9,X9,O7,v0,kW,xW,gW,AL,uW,hW,N7,mW,lW;class G9 extends EventTarget{constructor($,Z){var Y,Q;super(),f1(this,v0),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,f1(this,Z0),f1(this,W8),f1(this,Y9),f1(this,h5),f1(this,m5),f1(this,M7),f1(this,W9),f1(this,P7,null),f1(this,x6),f1(this,Q9),f1(this,J9,null),f1(this,X9,null),f1(this,O7,null),f1(this,xW,async(W)=>{var J;X1(this,Q9).reset();let{body:G,redirected:K,status:B,headers:D}=W;if(B===204){G6(this,v0,N7).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(K?q1(this,Y9,new URL(W.url)):q1(this,Y9,void 0),B!==200){G6(this,v0,N7).call(this,`Non-200 status code (${B})`,B);return}if(!(D.get("content-type")||"").startsWith("text/event-stream")){G6(this,v0,N7).call(this,'Invalid content type, expected "text/event-stream"',B);return}if(X1(this,Z0)===this.CLOSED)return;q1(this,Z0,this.OPEN);let V=new Event("open");if((J=X1(this,O7))==null||J.call(this,V),this.dispatchEvent(V),typeof G!="object"||!G||!("getReader"in G)){G6(this,v0,N7).call(this,"Invalid response body, expected a web ReadableStream",B),this.close();return}let L=new TextDecoder,A=G.getReader(),q=!0;do{let{done:O,value:M}=await A.read();M&&X1(this,Q9).feed(L.decode(M,{stream:!O})),O&&(q=!1,X1(this,Q9).reset(),G6(this,v0,mW).call(this))}while(q)}),f1(this,gW,(W)=>{q1(this,x6,void 0),!(W.name==="AbortError"||W.type==="aborted")&&G6(this,v0,mW).call(this,TW(W))}),f1(this,uW,(W)=>{typeof W.id=="string"&&q1(this,P7,W.id);let J=new MessageEvent(W.event||"message",{data:W.data,origin:X1(this,Y9)?X1(this,Y9).origin:X1(this,W8).origin,lastEventId:W.id||""});X1(this,X9)&&(!W.event||W.event==="message")&&X1(this,X9).call(this,J),this.dispatchEvent(J)}),f1(this,hW,(W)=>{q1(this,M7,W)}),f1(this,lW,()=>{q1(this,W9,void 0),X1(this,Z0)===this.CONNECTING&&G6(this,v0,kW).call(this)});try{if($ instanceof URL)q1(this,W8,$);else if(typeof $=="string")q1(this,W8,new URL($,LT()));else throw Error("Invalid URL")}catch{throw VT("An invalid or illegal string was specified")}q1(this,Q9,b5({onEvent:X1(this,uW),onRetry:X1(this,hW)})),q1(this,Z0,this.CONNECTING),q1(this,M7,3000),q1(this,m5,(Y=Z==null?void 0:Z.fetch)!=null?Y:globalThis.fetch),q1(this,h5,(Q=Z==null?void 0:Z.withCredentials)!=null?Q:!1),G6(this,v0,kW).call(this)}get readyState(){return X1(this,Z0)}get url(){return X1(this,W8).href}get withCredentials(){return X1(this,h5)}get onerror(){return X1(this,J9)}set onerror($){q1(this,J9,$)}get onmessage(){return X1(this,X9)}set onmessage($){q1(this,X9,$)}get onopen(){return X1(this,O7)}set onopen($){q1(this,O7,$)}addEventListener($,Z,Y){let Q=Z;super.addEventListener($,Q,Y)}removeEventListener($,Z,Y){let Q=Z;super.removeEventListener($,Q,Y)}close(){X1(this,W9)&&clearTimeout(X1(this,W9)),X1(this,Z0)!==this.CLOSED&&(X1(this,x6)&&X1(this,x6).abort(),q1(this,Z0,this.CLOSED),q1(this,x6,void 0))}}Z0=new WeakMap,W8=new WeakMap,Y9=new WeakMap,h5=new WeakMap,m5=new WeakMap,M7=new WeakMap,W9=new WeakMap,P7=new WeakMap,x6=new WeakMap,Q9=new WeakMap,J9=new WeakMap,X9=new WeakMap,O7=new WeakMap,v0=new WeakSet,kW=function(){q1(this,Z0,this.CONNECTING),q1(this,x6,new AbortController),X1(this,m5)(X1(this,W8),G6(this,v0,AL).call(this)).then(X1(this,xW)).catch(X1(this,gW))},xW=new WeakMap,gW=new WeakMap,AL=function(){var $;let Z={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...X1(this,P7)?{"Last-Event-ID":X1(this,P7)}:void 0},cache:"no-store",signal:($=X1(this,x6))==null?void 0:$.signal};return"window"in globalThis&&(Z.credentials=this.withCredentials?"include":"same-origin"),Z},uW=new WeakMap,hW=new WeakMap,N7=function($,Z){var Y;X1(this,Z0)!==this.CLOSED&&q1(this,Z0,this.CLOSED);let Q=new yW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q)},mW=function($,Z){var Y;if(X1(this,Z0)===this.CLOSED)return;q1(this,Z0,this.CONNECTING);let Q=new yW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q),q1(this,W9,setTimeout(X1(this,lW),X1(this,M7)))},lW=new WeakMap,G9.CONNECTING=0,G9.OPEN=1,G9.CLOSED=2;function LT(){let $="document"in globalThis?globalThis.document:void 0;return $&&typeof $=="object"&&"baseURI"in $&&typeof $.baseURI=="string"?$.baseURI:void 0}class qL extends Error{constructor($,Z,Y){super(`SSE error: ${Z}`);this.code=$,this.event=Y}}class iW{constructor($,Z){this._url=$,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=Z?.eventSourceInit,this._requestInit=Z?.requestInit,this._authProvider=Z?.authProvider,this._fetch=Z?.fetch,this._fetchWithInit=q5(Z?.fetch,Z?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new e1("No auth provider");let $;try{$=await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(Z){throw this.onerror?.(Z),Z}if($!=="AUTHORIZED")throw new e1;return await this._startOrAuth()}async _commonHeaders(){let $={};if(this._authProvider){let Y=await this._authProvider.tokens();if(Y)$.Authorization=`Bearer ${Y.access_token}`}if(this._protocolVersion)$["mcp-protocol-version"]=this._protocolVersion;let Z=o8(this._requestInit?.headers);return new Headers({...$,...Z})}_startOrAuth(){let $=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((Z,Y)=>{this._eventSource=new G9(this._url.href,{...this._eventSourceInit,fetch:async(Q,W)=>{let J=await this._commonHeaders();J.set("Accept","text/event-stream");let G=await $(Q,{...W,headers:J});if(G.status===401&&G.headers.has("www-authenticate")){let{resourceMetadataUrl:K,scope:B}=Z9(G);this._resourceMetadataUrl=K,this._scope=B}return G}}),this._abortController=new AbortController,this._eventSource.onerror=(Q)=>{if(Q.code===401&&this._authProvider){this._authThenStart().then(Z,Y);return}let W=new qL(Q.code,Q.message,Q);Y(W),this.onerror?.(W)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",(Q)=>{let W=Q;try{if(this._endpoint=new URL(W.data,this._url),this._endpoint.origin!==this._url.origin)throw Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(J){Y(J),this.onerror?.(J),this.close();return}Z()}),this._eventSource.onmessage=(Q)=>{let W=Q,J;try{J=w6.parse(JSON.parse(W.data))}catch(G){this.onerror?.(G);return}this.onmessage?.(J)}})}async start(){if(this._eventSource)throw Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth($){if(!this._authProvider)throw new e1("No auth provider");if(await p0(this._authProvider,{serverUrl:this._url,authorizationCode:$,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send($){if(!this._endpoint)throw Error("Not connected");try{let Z=await this._commonHeaders();Z.set("content-type","application/json");let Y={...this._requestInit,method:"POST",headers:Z,body:JSON.stringify($),signal:this._abortController?.signal},Q=await(this._fetch??fetch)(this._endpoint,Y);if(!Q.ok){let W=await Q.text().catch(()=>null);if(Q.status===401&&this._authProvider){let{resourceMetadataUrl:J,scope:G}=Z9(Q);if(this._resourceMetadataUrl=J,this._scope=G,await p0(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new e1;return this.send($)}throw Error(`Error POSTing to endpoint (HTTP ${Q.status}): ${W}`)}await Q.body?.cancel()}catch(Z){throw this.onerror?.(Z),Z}}setProtocolVersion($){this._protocolVersion=$}}var UT="mcp";class cW{constructor($){this._url=$}start(){if(this._socket)throw Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise(($,Z)=>{this._socket=new WebSocket(this._url,UT),this._socket.onerror=(Y)=>{let Q="error"in Y?Y.error:Error(`WebSocket error: ${JSON.stringify(Y)}`);Z(Q),this.onerror?.(Q)},this._socket.onopen=()=>{$()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=(Y)=>{let Q;try{Q=w6.parse(JSON.parse(Y.data))}catch(W){this.onerror?.(W);return}this.onmessage?.(Q)}})}async close(){this._socket?.close()}send($){return new Promise((Z,Y)=>{if(!this._socket){Y(Error("Not connected"));return}this._socket?.send(JSON.stringify($)),Z()})}}class dW extends v5{constructor($,Z){super($,Z)}send($,Z){let Y=jT($);if(Y?.type==="emit")return this.onmessage?.(Y.message),Promise.resolve();if(Y?.type==="suppress")return Promise.resolve();return super.send($,Z)}}function jT($){let Z=$;if(!Z||typeof Z!=="object"||!("method"in Z))return null;switch(Z.method){case"initialize":{let Y=Z?.params?.protocolVersion;if(!Y)return null;return{type:"emit",message:{result:{protocolVersion:Y,capabilities:{tools:{}},serverInfo:{name:"deco-chat-server",version:"1.0.0"}},jsonrpc:Z.jsonrpc??"2.0",id:Z.id}}}case"notifications/roots/list_changed":case"notifications/initialized":case"notifications/cancelled":case"notifications/progress":return{type:"suppress"};default:return null}}class OL extends z5{constructor($,Z){super($,{jsonSchemaValidator:T5,...Z})}async listTools($,Z){return await this.request({method:"tools/list",params:$},p9,Z)}}var NL=async($,Z,Y)=>{let Q=AT($.connection,Z,Y);if(!Q)throw Error("Unknown MCP connection type");let W=new OL({name:$?.name??"MCP Client",version:"1.0.0"});return await W.connect(Q),{client:W}},AT=($,Z,Y)=>{if($.type==="Websocket")return new cW(new URL($.url));if($.type!=="SSE"&&$.type!=="HTTP")return null;let W={...$.token?{authorization:`Bearer ${$.token}`}:{},...Y??{},..."headers"in $?$.headers||{}:{}};if($.type==="SSE"){let J={requestInit:{headers:W,signal:Z}};if($.token)J.eventSourceInit={fetch:(G,K)=>{return fetch(G,{...K,headers:{...W,Accept:"text/event-stream"},signal:Z})}};return new iW(new URL($.url),J)}return new dW(new URL($.url),{requestInit:{headers:W,signal:Z,credentials:"include"}})};var ML=($)=>{try{return JSON.parse($)}catch{return $}},l5=new Map,PL=($,Z)=>{return{...$,id:$.name,inputSchema:$.inputSchema?I1($.inputSchema):void 0,outputSchema:$.outputSchema?I1($.outputSchema):void 0,execute:(Y)=>{return Z(Y.context,$.name)}}};function wL($){let Z=(Y)=>{if("connection"in $)return NL({connection:$.connection},void 0,Y);return $.client};return new Proxy({},{get(Y,Q){if(Q==="toJSON")return null;if(typeof Q!=="string")throw Error("Name must be a string");if(Q==="listTools")return K;async function W(B,D=Q){let V=$?.debugId?.(),L=V?{"x-trace-debug-id":V}:void 0,{client:A}=await Z(L),{structuredContent:q,isError:O,content:M}=await A.callTool({name:String(D),arguments:B});if(O){let N=M?.[0]?.text,E=typeof N==="string"?ML(N):null,f=E?.code&&typeof $?.getErrorByStatusCode==="function"?$.getErrorByStatusCode(E.code,E.message,E.traceId):null;if(f)throw f;throw Error(`Tool ${String(D)} returned an error: ${JSON.stringify(q??M)}`)}if(q!==void 0)return q;let I=M?.[0]?.text;return typeof I==="string"?ML(I):void 0}async function J(){let{client:B}=await Z(),{tools:D}=await B.listTools();return D}async function G(){if(!("connection"in $))return J();let B=$.connection,D=JSON.stringify(B);try{if(!l5.has(D))l5.set(D,J());return await l5.get(D)}catch(V){console.error("Failed to list tools",V),l5.delete(D);return}}async function K(){return(await G()??[]).map((D)=>PL(D,W))}return W.asTool=async()=>{let D=(await G()??[]).find((V)=>V.name===Q);if(!D)throw Error(`Tool ${Q} not found`);return PL(D,W)},W}})}var S01=new Proxy({},{get($,Z){if(Z==="toJSON")return null;if(Z==="forConnection")return(Y)=>p5({connection:Y});return global[Z]}});function p5($){return wL($)}var EL=($)=>{return{...zT($),forClient:(Z)=>{return p5({client:Z})},forConnection:(Z)=>{return p5({connection:Z})}}};function zT($){return{isImplementedBy:(Z)=>{for(let Y of $){let Q=typeof Y.name==="string"?new RegExp(`^${Y.name}$`):Y.name,W=Z.find((J)=>Q.test(J.name));if(!W&&Y.opt)continue;if(!W)return!1}return!0}}}import{z as s}from"zod";var i5=s.object({id:s.string().describe("Unique identifier for the entity"),title:s.string().describe("Human-readable title for the entity"),description:s.string().nullish().describe("Description of the entity"),created_at:s.string().datetime(),updated_at:s.string().datetime(),created_by:s.string().optional(),updated_by:s.string().optional()}),qT=s.object({field:s.array(s.string()),operator:s.enum(["eq","gt","gte","lt","lte","in","like","contains"]),value:s.unknown()}),RL=s.lazy(()=>s.union([qT,s.object({operator:s.enum(["and","or","not"]),conditions:s.array(RL)})])),OT=s.object({field:s.array(s.string()),direction:s.enum(["asc","desc"]),nulls:s.enum(["first","last"]).optional()}),NT=s.object({where:RL.optional().describe("Filter expression"),orderBy:s.array(OT).optional().describe("Sort expressions"),limit:s.number().int().min(1).max(1000).optional().describe("Maximum number of items to return"),offset:s.number().int().min(0).optional().describe("Number of items to skip")});function MT($){return s.object({items:s.array($).describe("Array of collection items"),totalCount:s.number().int().min(0).optional().describe("Total number of matching items (if available)"),hasMore:s.boolean().optional().describe("Whether there are more items available")})}var PT=s.object({id:s.string().describe("ID of the entity to retrieve")});function wT($){return s.object({item:$.nullable().describe("The retrieved item, or null if not found")})}function ET($){return s.object({data:$.partial().describe("Data for the new entity (id may be auto-generated)")})}function RT($){return s.object({item:$.describe("The created entity with generated id")})}function _T($){return s.object({id:s.string().describe("ID of the entity to update"),data:$.partial().describe("Partial entity data to update")})}function CT($){return s.object({item:$.describe("The updated entity")})}var IT=s.object({id:s.string().describe("ID of the entity to delete")});function fT($){return s.object({item:$.describe("The deleted entity")})}function c5($,Z,Y){let Q=$.toUpperCase(),W=Y?.readOnly??!1,J=[{name:`COLLECTION_${Q}_LIST`,inputSchema:NT,outputSchema:MT(Z)},{name:`COLLECTION_${Q}_GET`,inputSchema:PT,outputSchema:wT(Z)}];if(!W)J.push({name:`COLLECTION_${Q}_CREATE`,inputSchema:ET(Z),outputSchema:RT(Z),opt:!0},{name:`COLLECTION_${Q}_UPDATE`,inputSchema:_T(Z),outputSchema:CT(Z),opt:!0},{name:`COLLECTION_${Q}_DELETE`,inputSchema:IT,outputSchema:fT(Z),opt:!0});return J}var nW=T.object({toolName:T.string().describe("Name of the tool to invoke on that connection"),transformCode:T.string().optional().describe("Pure TypeScript function for data transformation of the tool call result. Must be a TypeScript file that declares the Output interface and exports a default function: `interface Output { ... } export default async function(stepInput): Output { ... }`\n The stepInput will match with the tool call outputSchema. If transformCode is not provided, the tool call result will be used as the step output.\n Providing an transformCode is recommended because it both allows you to transform the data and validate it against a JSON Schema - tools are ephemeral and may return unexpected data.")}),ST=T.object({code:T.string().describe(`Pure TypeScript function for data transformation. Useful to merge data from multiple steps and transform it. Must be a TypeScript file that declares the Output interface and exports a default function: \`interface Output { ... } export default async function(stepInput): Output { ... }\`
961
961
  The stepInput is the resolved value of the references in the input field. Example:
962
962
  {
963
963
  "input": {