decocms 3.18.4 → 3.18.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/dist/client/assets/{AlertCircle-DBLUz--u.js → AlertCircle-CFR8yUWR.js} +1 -1
  2. package/dist/client/assets/{ArrowUpRight-l-GcKPYK.js → ArrowUpRight-CrbV7ou8.js} +1 -1
  3. package/dist/client/assets/{Check-BxIVbrMR.js → Check-B9hfWsRx.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-rFqh1KDn.js → CheckCircle-CfP6WFYZ.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-P5aorJ8-.js → ChevronDown-DYNS9bwS.js} +1 -1
  6. package/dist/client/assets/{ChevronLeft-e8a25ahy.js → ChevronLeft-rD5M2ZRF.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-WB5knV5A.js → ChevronRight-C5EQU2rb.js} +1 -1
  8. package/dist/client/assets/{ChevronUp-nQBmktAW.js → ChevronUp-CyZ3QaHa.js} +1 -1
  9. package/dist/client/assets/{Container-Dls_ClFq.js → Container-CNNo1Nks.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-CxHHcGx6.js → DotsVertical-BWGsv_FX.js} +1 -1
  11. package/dist/client/assets/{Eye-EKPlnsLc.js → Eye-Bu0Ufapt.js} +1 -1
  12. package/dist/client/assets/{FilterLines-DqQIAzT9.js → FilterLines-DnGixxOc.js} +1 -1
  13. package/dist/client/assets/{Globe01-Tm1ARX4Z.js → Globe01-Dn-7lt6y.js} +1 -1
  14. package/dist/client/assets/{HardDrive-JzeH-CyJ.js → HardDrive-DJI6GUQN.js} +1 -1
  15. package/dist/client/assets/{Key01-CeoBFgZd.js → Key01-MCYKKSfj.js} +1 -1
  16. package/dist/client/assets/{LayoutLeft-xp2y9xUi.js → LayoutLeft-abYqzLTU.js} +1 -1
  17. package/dist/client/assets/{LinkExternal01-BrCQL34C.js → LinkExternal01-C4y2ImGq.js} +1 -1
  18. package/dist/client/assets/{Monitor01-DhIohKdB.js → Monitor01-W3GTE_xd.js} +1 -1
  19. package/dist/client/assets/{Palette-DcvO-xme.js → Palette-BXIs0-8F.js} +1 -1
  20. package/dist/client/assets/{Play-Cl-75oPS.js → Play-C5v-iUhy.js} +1 -1
  21. package/dist/client/assets/{Plus-DMk97-_x.js → Plus-C8tm3Xca.js} +1 -1
  22. package/dist/client/assets/{RefreshCcw01-BKQsxntF.js → RefreshCcw01-DoZ6SFXF.js} +1 -1
  23. package/dist/client/assets/{SearchMd-D5J9uZcf.js → SearchMd-D_aIpwNH.js} +1 -1
  24. package/dist/client/assets/{Settings02-VViB9t6t.js → Settings02-BVvz8SBR.js} +1 -1
  25. package/dist/client/assets/{Shield01-D5gYDa2-.js → Shield01-BGbN_ZpD.js} +1 -1
  26. package/dist/client/assets/{Star01--s8ZFg64.js → Star01-B37pyPSw.js} +1 -1
  27. package/dist/client/assets/{Stars01-BidgaxVI.js → Stars01-CCz6h1EF.js} +1 -1
  28. package/dist/client/assets/{Stars02-CIMeB8Tw.js → Stars02-BYOghE4k.js} +1 -1
  29. package/dist/client/assets/{Sun-F5_OmHwF.js → Sun-dXEAEgi_.js} +1 -1
  30. package/dist/client/assets/{SwitchHorizontal01-BDAEnkfq.js → SwitchHorizontal01-07Capu2l.js} +1 -1
  31. package/dist/client/assets/{Tool01-BgJ0N26M.js → Tool01-Br0Ztm5O.js} +1 -1
  32. package/dist/client/assets/{Trash01-C7l0NheK.js → Trash01-DjVPjypU.js} +1 -1
  33. package/dist/client/assets/{Upload01-BpTwEhwN.js → Upload01-B2OX8x5z.js} +1 -1
  34. package/dist/client/assets/{User01-61G-I9Nt.js → User01-CKftXs9E.js} +1 -1
  35. package/dist/client/assets/{Users01-DedWtozu.js → Users01-pexT5CAb.js} +1 -1
  36. package/dist/client/assets/{Users03-DhyPNTfH.js → Users03-DwZKdQjy.js} +1 -1
  37. package/dist/client/assets/{X-gpy8SRoe.js → X-CGB-Sljd.js} +1 -1
  38. package/dist/client/assets/{XCircle-B8hhQ7We.js → XCircle-D396Uh8b.js} +1 -1
  39. package/dist/client/assets/{XClose-BIl1LPyR.js → XClose-CU-N-nf4.js} +1 -1
  40. package/dist/client/assets/{Zap-DRW8v7hZ.js → Zap-BVJoCQ65.js} +1 -1
  41. package/dist/client/assets/{ZapSquare-DwVlJ80d.js → ZapSquare-gKVsVjsm.js} +1 -1
  42. package/dist/client/assets/{ZoomOut-CTra4wHa.js → ZoomOut-v8u1i9bA.js} +1 -1
  43. package/dist/client/assets/{access-gate-uwoZnAgx.js → access-gate-CIARCHrH.js} +1 -1
  44. package/dist/client/assets/{accordion-B0fd1tnF.js → accordion-BGMg7q4u.js} +1 -1
  45. package/dist/client/assets/{add-section-modal-DiKHi0M1.js → add-section-modal-PKbhb9V5.js} +1 -1
  46. package/dist/client/assets/{agent-capabilities-BjTqE21c.js → agent-capabilities-BmaI2kRr.js} +1 -1
  47. package/dist/client/assets/{agent-icon-DZCJD2_a.js → agent-icon-BWjIr0jC.js} +1 -1
  48. package/dist/client/assets/{agent-icons-jN-Zyl-6.js → agent-icons-Bb4xoV1J.js} +1 -1
  49. package/dist/client/assets/{agents-list-B-auSMeU.js → agents-list-CH-rX6lo.js} +1 -1
  50. package/dist/client/assets/{ai-providers-9z8nTePs.js → ai-providers-CERsKWm8.js} +1 -1
  51. package/dist/client/assets/{alert-CXw2R1J0.js → alert-BlXV4W1T.js} +1 -1
  52. package/dist/client/assets/{alert-dialog-BEqZ9uGO.js → alert-dialog-BdR_e0yA.js} +1 -1
  53. package/dist/client/assets/app-editor-Bt-pin6U.js +1 -0
  54. package/dist/client/assets/{auth-catchall-Bfw73AGa.js → auth-catchall-i8UWGg_6.js} +1 -1
  55. package/dist/client/assets/{auth-split-layout-BReVBoRk.js → auth-split-layout-TBFJthLS.js} +1 -1
  56. package/dist/client/assets/{automation-list-row-DijFSvDw.js → automation-list-row-BIi_rsBV.js} +1 -1
  57. package/dist/client/assets/{automation-runs-hCC2W9Z-.js → automation-runs-DvU8o3Xf.js} +1 -1
  58. package/dist/client/assets/{automations-CmCVzo7I.js → automations-CL9gaTTQ.js} +1 -1
  59. package/dist/client/assets/{avatar-Bcbs0fiL.js → avatar-7trj7GoD.js} +1 -1
  60. package/dist/client/assets/{badge-BARx7FvE.js → badge-DANKrOoZ.js} +1 -1
  61. package/dist/client/assets/{brand-context-DdQzgdZa.js → brand-context-C_bcrFVw.js} +1 -1
  62. package/dist/client/assets/{buckets-uoDmahjJ.js → buckets-So5pSPsk.js} +1 -1
  63. package/dist/client/assets/{calendar-B30GJXaY.js → calendar-BIdArY5z.js} +1 -1
  64. package/dist/client/assets/{capability-load-error-ClqXQbgV.js → capability-load-error-C-iuUVr7.js} +1 -1
  65. package/dist/client/assets/{card-opRPZv32.js → card-B-Dm5nez.js} +1 -1
  66. package/dist/client/assets/{chat-context-BbbKc5EF.js → chat-context-Bgf1-hOl.js} +1 -1
  67. package/dist/client/assets/{checkbox-wlYL0b3G.js → checkbox-DrL1UUx3.js} +1 -1
  68. package/dist/client/assets/{cli-auth-success-Bs1_vcy6.js → cli-auth-success-6DoLxMmf.js} +1 -1
  69. package/dist/client/assets/{collection-detail-C2S9fIG-.js → collection-detail-D3TZYHTO.js} +1 -1
  70. package/dist/client/assets/{collection-display-button-Cay-ZdpD.js → collection-display-button-Cy4QeOkL.js} +1 -1
  71. package/dist/client/assets/{collection-search-C3Lp1ZRv.js → collection-search-BR1gqxz_.js} +1 -1
  72. package/dist/client/assets/{collection-table-wrapper-BnCe5cyI.js → collection-table-wrapper-BiGSiy2I.js} +1 -1
  73. package/dist/client/assets/{collection-tabs-BoQd-dND.js → collection-tabs-CTyOGjGP.js} +1 -1
  74. package/dist/client/assets/{collections-BaDzxzwW.js → collections-DcrwOl55.js} +1 -1
  75. package/dist/client/assets/{command-DWpPyJE7.js → command-DbKWEekc.js} +1 -1
  76. package/dist/client/assets/{connect-desktop-dialog-Cy-b1jPM.js → connect-desktop-dialog-3t8GXV2K.js} +1 -1
  77. package/dist/client/assets/{connection-card-BI-CSazh.js → connection-card-C6L-1Dt9.js} +1 -1
  78. package/dist/client/assets/{connection-detail-OEPQ1Wwv.js → connection-detail-CrPqTSWg.js} +1 -1
  79. package/dist/client/assets/{connection-form-helpers-CbxXqT_u.js → connection-form-helpers-C24n-KRp.js} +1 -1
  80. package/dist/client/assets/{connections-XD7RqsTp.js → connections-BkGValv7.js} +1 -1
  81. package/dist/client/assets/{constants-Cee8XKoZ.js → constants-BpU7QaRR.js} +1 -1
  82. package/dist/client/assets/{decopilot-sse-pool-DiOxs3f4.js → decopilot-sse-pool-BS4aL56C.js} +1 -1
  83. package/dist/client/assets/{dialog-CFcYm0YL.js → dialog-Cr6AICtN.js} +1 -1
  84. package/dist/client/assets/{domain-settings-BeRCH_mn.js → domain-settings-DBoxusra.js} +1 -1
  85. package/dist/client/assets/{drawer-CG7DFuyM.js → drawer-DhC5GUfP.js} +1 -1
  86. package/dist/client/assets/{dropdown-menu-CKTrR8YS.js → dropdown-menu-xxrkWTrU.js} +1 -1
  87. package/dist/client/assets/{dynamic-plugin-layout-7IcBH65R.js → dynamic-plugin-layout-CUXnWXrk.js} +1 -1
  88. package/dist/client/assets/{empty-state-D653N76e.js → empty-state-B5DOepvp.js} +1 -1
  89. package/dist/client/assets/{empty-state-74R-YcQz.js → empty-state-c1WpU61C.js} +1 -1
  90. package/dist/client/assets/{extract-connection-data-BpQPulqJ.js → extract-connection-data-D0n_qfP0.js} +1 -1
  91. package/dist/client/assets/{features-DC4Mx65d.js → features-FNcdQED0.js} +1 -1
  92. package/dist/client/assets/{file-explorer-DI37WbgR.js → file-explorer-CH4JsLE7.js} +1 -1
  93. package/dist/client/assets/{file-type-icon-fKTDY3M7.js → file-type-icon-mQqy375a.js} +1 -1
  94. package/dist/client/assets/{files-ermEyeeq.js → files-CYh8EDna.js} +1 -1
  95. package/dist/client/assets/{form-BOkSmTHo.js → form-nBkrnKYT.js} +1 -1
  96. package/dist/client/assets/{general-CIbzkCUo.js → general-Qjl6AIoa.js} +1 -1
  97. package/dist/client/assets/{generate-id-CvWg9hET.js → generate-id-BxqIDlP-.js} +1 -1
  98. package/dist/client/assets/{github-repo-picker-qlUkWRPg.js → github-repo-picker-CAlIuMsf.js} +1 -1
  99. package/dist/client/assets/{header-tab-button-C4vmTyQ-.js → header-tab-button-DuxrFMNC.js} +1 -1
  100. package/dist/client/assets/{hover-card-BQqzA1_o.js → hover-card-BDQQtfoR.js} +1 -1
  101. package/dist/client/assets/{image-field-DKZ33h0l.js → image-field-BvPUDpE_.js} +1 -1
  102. package/dist/client/assets/{index-DAqM6n6y.js → index-3tzKBgE3.js} +1 -1
  103. package/dist/client/assets/{index-DcdwlrBS.js → index-B1HONnQz.js} +1 -1
  104. package/dist/client/assets/{index-CcNaSzIS.js → index-B4yTB-08.js} +1 -1
  105. package/dist/client/assets/{index-BEJQhciB.js → index-BQQLPj89.js} +1 -1
  106. package/dist/client/assets/{index-BtYLUKbU.js → index-Bg4PlNAz.js} +4 -4
  107. package/dist/client/assets/{index-9yLZw74n.js → index-Bjsbxruw.js} +1 -1
  108. package/dist/client/assets/{index-Bp-x4MAC.js → index-CD3ErgKH.js} +1 -1
  109. package/dist/client/assets/{index-DI_C2zjL.js → index-CYTMmI4-.js} +3 -3
  110. package/dist/client/assets/{index-CdECG0JX.js → index-Cc5RAl27.js} +1 -1
  111. package/dist/client/assets/{index-6hdndQvf.js → index-CgPh_9v0.js} +1 -1
  112. package/dist/client/assets/{index-BvVmJXZO.js → index-CiGFPef-.js} +1 -1
  113. package/dist/client/assets/{index-DKAPjhpZ.js → index-D0X6SE5D.js} +1 -1
  114. package/dist/client/assets/{index-BNRdhvYz.js → index-D1Xu8IIg.js} +1 -1
  115. package/dist/client/assets/{index-B6UNbCvs.js → index-DhmxSoe_.js} +1 -1
  116. package/dist/client/assets/{index-o8XwCFMV.js → index-_efubzEt.js} +1 -1
  117. package/dist/client/assets/{index-redirect-Db4r9v6-.js → index-redirect-CKD7qahx.js} +1 -1
  118. package/dist/client/assets/{infiniteQueryObserver-UtxmrGCk.js → infiniteQueryObserver-_kJzwhhc.js} +1 -1
  119. package/dist/client/assets/{input-D6XA36wX.js → input-D-pcUk2R.js} +1 -1
  120. package/dist/client/assets/{integration-icon-CDYbzYpO.js → integration-icon-8s47TlHj.js} +1 -1
  121. package/dist/client/assets/{label-DP3KsQ6l.js → label-C4YFSGkh.js} +1 -1
  122. package/dist/client/assets/{layout-paBHZrq0.js → layout-BKPlHc-n.js} +1 -1
  123. package/dist/client/assets/{login-Dd5gU9xf.js → login-Byecph1O.js} +1 -1
  124. package/dist/client/assets/{members-DHkEbny2.js → members-DuBRhg0r.js} +1 -1
  125. package/dist/client/assets/{monaco-editor-CqS2PrxS.js → monaco-editor-D6OkCytp.js} +1 -1
  126. package/dist/client/assets/{monitoring-stats-row-D1YkU8mA.js → monitoring-stats-row-CY6Ha1LI.js} +1 -1
  127. package/dist/client/assets/{oauth-callback-dhWNgkQO.js → oauth-callback-Df7qssiK.js} +1 -1
  128. package/dist/client/assets/{oauth-callback-ai-provider-BXsbx5oM.js → oauth-callback-ai-provider-BDaua880.js} +1 -1
  129. package/dist/client/assets/{onboarding-BeaJ_uSB.js → onboarding-r1YacWa9.js} +1 -1
  130. package/dist/client/assets/{org-install-Cp2eVvRj.js → org-install-Cs8QTj6u.js} +1 -1
  131. package/dist/client/assets/{org-layout-a0K80q4T.js → org-layout-BVmcHE-4.js} +1 -1
  132. package/dist/client/assets/{org-plugin-layout-BSiJYore.js → org-plugin-layout-CX1r-5I2.js} +1 -1
  133. package/dist/client/assets/{page-seo-form-3l62DB_T.js → page-seo-form-V-0EDccq.js} +1 -1
  134. package/dist/client/assets/page-seo-sheet-8s7JYrnX.js +1 -0
  135. package/dist/client/assets/{pair-d72l3oOt.js → pair-h8K88KOt.js} +1 -1
  136. package/dist/client/assets/{plugin-empty-state-DJKQIP1H.js → plugin-empty-state-CONMWhg0.js} +1 -1
  137. package/dist/client/assets/{plugin-header-wZ3SAPoW.js → plugin-header-CE6MNNms.js} +1 -1
  138. package/dist/client/assets/{plugin-layout-Bnm1d9fT.js → plugin-layout-CYoGuAyj.js} +1 -1
  139. package/dist/client/assets/{popover-LMWhCL8q.js → popover-BANf8yLu.js} +1 -1
  140. package/dist/client/assets/{post-editor-DYc1KPrG.js → post-editor-CnSiz5fI.js} +1 -1
  141. package/dist/client/assets/{primitives-DKgG_RLP.js → primitives-NmZthmgC.js} +1 -1
  142. package/dist/client/assets/{profile-sY3vkifi.js → profile-DJjVDv6i.js} +1 -1
  143. package/dist/client/assets/project-app-view-VznrqGg3.js +1 -0
  144. package/dist/client/assets/record-editor-DxeRhFbO.js +1 -0
  145. package/dist/client/assets/registry-XgmAouDD.js +2 -0
  146. package/dist/client/assets/{registry-layout-DICcLMZ-.js → registry-layout-CXazhpEp.js} +1 -1
  147. package/dist/client/assets/{require-capability-BaEq85xc.js → require-capability-CGpm8UPV.js} +1 -1
  148. package/dist/client/assets/{required-auth-layout-ctnrloiI.js → required-auth-layout-Bf5N9rDJ.js} +1 -1
  149. package/dist/client/assets/{reset-password-QZaqz6_E.js → reset-password-mBE2iIHp.js} +1 -1
  150. package/dist/client/assets/{resizable-Ctmig1x8.js → resizable-Ddg3V5j3.js} +1 -1
  151. package/dist/client/assets/{roles-l3bqeHe8.js → roles-DK4-rW17.js} +1 -1
  152. package/dist/client/assets/{save-status-CCYbhtqv.js → save-status-fods1xc4.js} +1 -1
  153. package/dist/client/assets/{schema-form-CYyNLLkP.js → schema-form-CAjqu2uG.js} +1 -1
  154. package/dist/client/assets/{scroll-area-ChLxDxAv.js → scroll-area-DmGYPK35.js} +1 -1
  155. package/dist/client/assets/{search-input-DlQucyGn.js → search-input-BXTV_9VX.js} +1 -1
  156. package/dist/client/assets/{secrets-DUz1PrMw.js → secrets-CZ-9G3RB.js} +1 -1
  157. package/dist/client/assets/{sections-editor-CjgAxmAC.js → sections-editor-7rAnT9_M.js} +1 -1
  158. package/dist/client/assets/{select-DiczE1GW.js → select-jsp5fXY0.js} +1 -1
  159. package/dist/client/assets/{select-model-BwFIV8qg.js → select-model-D3JQV1A5.js} +1 -1
  160. package/dist/client/assets/{seo-editor-SK8O4TOZ.js → seo-editor-Cx8n8-fk.js} +1 -1
  161. package/dist/client/assets/{settings-layout-B-mK5baR.js → settings-layout-B7r6IIZc.js} +1 -1
  162. package/dist/client/assets/{settings-section-COvXOm16.js → settings-section-DEvjEXH5.js} +1 -1
  163. package/dist/client/assets/{sheet-B1_zl6Wy.js → sheet-CCiL9Rx1.js} +1 -1
  164. package/dist/client/assets/{shell-controls-F9PQTaJd.js → shell-controls-CNRpV1G8.js} +1 -1
  165. package/dist/client/assets/{shell-layout-CVo7gBu0.js → shell-layout-4Otqvn6V.js} +1 -1
  166. package/dist/client/assets/{shell-route-loading-DlXSyVMe.js → shell-route-loading-VEHPoypz.js} +1 -1
  167. package/dist/client/assets/{sidebar-D_9iQq6y.js → sidebar-D4QGN150.js} +1 -1
  168. package/dist/client/assets/{skeleton-DvAAEHK-.js → skeleton-C860DLXd.js} +1 -1
  169. package/dist/client/assets/{sortable.esm-BcW2lbKS.js → sortable.esm-eUvRX07P.js} +1 -1
  170. package/dist/client/assets/{spinner-CIGunEVj.js → spinner-SoAzBRu5.js} +1 -1
  171. package/dist/client/assets/{sso-BkO-JF6F.js → sso-Bfk_g0TL.js} +1 -1
  172. package/dist/client/assets/{store-BP-9ENq2.js → store-BJosTGmr.js} +1 -1
  173. package/dist/client/assets/store-registry-BTGGC-wt.js +2 -0
  174. package/dist/client/assets/{switch-CvANR6OB.js → switch-B6FYx2Zc.js} +1 -1
  175. package/dist/client/assets/{tab-id-Bjr6GpO9.js → tab-id-Drq1ub6-.js} +1 -1
  176. package/dist/client/assets/{table-6ZxoVDj9.js → table-DFMJ-eRM.js} +1 -1
  177. package/dist/client/assets/{tabs-BXch7lF5.js → tabs-SJVibadV.js} +1 -1
  178. package/dist/client/assets/{task-status-FrpiwVZ0.js → task-status-BF-wuRit.js} +1 -1
  179. package/dist/client/assets/{textarea-CTP7aZSb.js → textarea-BAchOqVk.js} +1 -1
  180. package/dist/client/assets/{toggle-group-5ZT1fa--.js → toggle-group-BTjGOuTM.js} +1 -1
  181. package/dist/client/assets/{toolbar-Ct5Db6Po.js → toolbar-CmdfhWYZ.js} +1 -1
  182. package/dist/client/assets/{tools-list-BlrRNNBe.js → tools-list-BszIUu0D.js} +1 -1
  183. package/dist/client/assets/{tooltip-KdhQZ3ej.js → tooltip-MvQf34cR.js} +1 -1
  184. package/dist/client/assets/{types-Dw4nSNDC.js → types-zx3VQt0A.js} +1 -1
  185. package/dist/client/assets/{use-ai-providers-D_ipcxZj.js → use-ai-providers-RBWsRBul.js} +1 -1
  186. package/dist/client/assets/{use-automations-ByYKrwPE.js → use-automations-4DuoVFF-.js} +1 -1
  187. package/dist/client/assets/{use-capability-DySoFAxN.js → use-capability-GY56Aq-U.js} +1 -1
  188. package/dist/client/assets/{use-collections-XA0KebJY.js → use-collections-CHOLHlaO.js} +1 -1
  189. package/dist/client/assets/{use-connection-wp_lbmMU.js → use-connection-DCL84j8p.js} +1 -1
  190. package/dist/client/assets/{use-copy-BWvpIWuf.js → use-copy-CZCcde_V.js} +1 -1
  191. package/dist/client/assets/{use-create-virtual-mcp-W4rKr9xF.js → use-create-virtual-mcp-Bp8QWS-J.js} +1 -1
  192. package/dist/client/assets/{use-debounced-autosave-DWajIZmJ.js → use-debounced-autosave-BUUhL3Q8.js} +1 -1
  193. package/dist/client/assets/{use-delete-connection-C7S2ugSQ.js → use-delete-connection-DLZuwRwA.js} +1 -1
  194. package/dist/client/assets/{use-file-configs-C-sgICQR.js → use-file-configs-VVFmuRUF.js} +1 -1
  195. package/dist/client/assets/{use-infinite-scroll-Bk8f-w0n.js → use-infinite-scroll-C00mr_R7.js} +1 -1
  196. package/dist/client/assets/{use-list-state-DCu2_qcV.js → use-list-state-DjU1Jd9c.js} +1 -1
  197. package/dist/client/assets/{use-mcp-prompts-GwuiMx2k.js → use-mcp-prompts-DjqQzz4_.js} +1 -1
  198. package/dist/client/assets/{use-mcp-tools-BJM8Ch_b.js → use-mcp-tools-CwhhtPJ2.js} +1 -1
  199. package/dist/client/assets/{use-members-BFSN3QPN.js → use-members-B0bsMTWp.js} +1 -1
  200. package/dist/client/assets/{use-navigate-to-agent-D_yYvurh.js → use-navigate-to-agent-Bd17cKel.js} +1 -1
  201. package/dist/client/assets/{use-org-auth-client-D8sE5x8D.js → use-org-auth-client-DRAyyigI.js} +1 -1
  202. package/dist/client/assets/{use-org-sso-CDLauwp2.js → use-org-sso-Gf8w8-Af.js} +1 -1
  203. package/dist/client/assets/{use-organization-roles-Cr7Rw0vS.js → use-organization-roles-CA3vvLOp.js} +1 -1
  204. package/dist/client/assets/{use-organization-settings-DZ2KDW5r.js → use-organization-settings-VH1dAaB-.js} +1 -1
  205. package/dist/client/assets/{use-registry-connections-CkLpetCN.js → use-registry-connections-CEd66d0J.js} +1 -1
  206. package/dist/client/assets/{use-secrets-BCTkTNAt.js → use-secrets-CSPUKnZh.js} +1 -1
  207. package/dist/client/assets/{use-status-sounds-DuoYs6Rs.js → use-status-sounds-Fe3fNMtV.js} +1 -1
  208. package/dist/client/assets/{use-view-mode-DUw7PprD.js → use-view-mode-CSrEI-mI.js} +1 -1
  209. package/dist/client/assets/{use-virtual-mcp-BE7Deo6L.js → use-virtual-mcp-CKbigJu_.js} +1 -1
  210. package/dist/client/assets/useInfiniteQuery-lOvdtYux.js +1 -0
  211. package/dist/client/assets/{useRouterState-nKULYO8g.js → useRouterState-Correpna.js} +1 -1
  212. package/dist/client/assets/useSuspenseInfiniteQuery-BLxJD7-u.js +1 -0
  213. package/dist/client/assets/{user-DXVwfRLH.js → user-NCExnpy2.js} +1 -1
  214. package/dist/client/assets/{view-mode-toggle-GVqZ4OkD.js → view-mode-toggle-BHRZLbR0.js} +1 -1
  215. package/dist/client/assets/{workflow-C6bXXXmh.js → workflow-FAsin0ib.js} +1 -1
  216. package/dist/client/assets/workflow-detail-B1_R5HgL.js +1 -0
  217. package/dist/client/index.html +1 -1
  218. package/dist/server/cli.js +370 -364
  219. package/dist/server/migrate.js +1 -1
  220. package/dist/server/server.js +245 -245
  221. package/package.json +1 -1
  222. package/dist/client/assets/app-editor-L6xg0gr0.js +0 -1
  223. package/dist/client/assets/page-seo-sheet-BKqm5eyl.js +0 -1
  224. package/dist/client/assets/project-app-view-DZbc50FT.js +0 -1
  225. package/dist/client/assets/record-editor-CQX_ONN9.js +0 -1
  226. package/dist/client/assets/registry-Z2xBxz0q.js +0 -2
  227. package/dist/client/assets/store-registry-BTGA7RTa.js +0 -2
  228. package/dist/client/assets/useInfiniteQuery-DTZY836s.js +0 -1
  229. package/dist/client/assets/useSuspenseInfiniteQuery-BZcmZLll.js +0 -1
  230. package/dist/client/assets/workflow-detail-B7TlrPBG.js +0 -1
@@ -957,7 +957,7 @@ You are running the brand-context onboarding for the user's organization. Your o
957
957
  4. Do NOT call any other tools in this thread. Do NOT call \`brand_context_setup\` more than once.
958
958
 
959
959
  If the tool returns an error, surface the error message to the user and ask whether they want to try a different URL.
960
- `.trim();var yV=UW("site-diagnostics_"),Nv=yV.is,Mv=yV.get;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"])}),kV=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:kV,outputSchema:kV.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")}),xV=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()}),gV=y5.partial();import{z as C}from"zod";var z7=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")}),mV=z7.extend({selected_tools:z7.shape.selected_tools.optional(),selected_resources:z7.shape.selected_resources.optional(),selected_prompts:z7.shape.selected_prompts.optional()}),Wy=C.object({connectionId:C.string(),toolName:C.string(),label:C.string(),icon:C.string().nullable().optional()}),OW=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()})}),NW=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(OW).optional()}),uV=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()}),MW=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:NW.nullable().optional(),homeTile:uV.nullable().optional(),homeTiles:C.array(uV).nullable().optional(),homePrompts:C.array(C.string()).nullable().optional()});var PW=/^[A-Za-z_][A-Za-z0-9_]*$/,hV=C.string().min(1).regex(PW,{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:hV,kind:C.literal("literal"),value:C.string()}),C.object({key:hV,kind:C.literal("secret"),secretId:C.string().min(1)})]),wW=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.")}),EW=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 lV={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.")},RW=C.object(lV),vs=C.object({...lV,sandboxProviderKind:Ky.optional()});var q7=C.record(C.string().describe("userId"),C.record(C.string().describe("branch"),C.record(C.string().describe("sandboxProviderKind"),RW)));var pV=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:MW.nullable().optional().describe("UI customization settings"),githubRepo:EW.nullable().optional().describe("Linked GitHub repository"),runtime:wW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:q7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().describe("Metadata"),connections:C.array(z7).describe("Connections with their selected tools, resources, and prompts")}),iV=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:MW.nullable().optional().describe("UI customization settings"),githubRepo:EW.nullable().optional().describe("Linked GitHub repository"),runtime:wW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:q7.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(mV).describe("Connections to include/exclude (can be empty for exclusion mode)")}),cV=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:MW.nullable().optional().describe("UI customization settings"),githubRepo:EW.nullable().optional().describe("Linked GitHub repository"),runtime:wW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:q7.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(mV).optional().describe("New connections (replaces existing)")});var _W=["in_progress","requires_action","failed","completed"],dV=[..._W,"expired"],CW={STEP:"decopilot.step",FINISH:"decopilot.finish",THREAD_STATUS:"decopilot.thread.status"},nV=Object.values(CW);var rV=i6(L5(),1),aV=i6(tX(),1);function My(){let $=new rV.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return aV.default($),$}class oV{#$=My();#Z=new Map;getValidator($){let Z=Py($),Y=this.#Z.get(Z);if(!Y)Y=this.#$.compile($),this.#Z.set(Z,Y);let Q=Y;return(W)=>{if(Q(W))return{valid:!0,data:W,errorMessage:void 0};return{valid:!1,data:void 0,errorMessage:this.#$.errorsText(Q.errors)}}}}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 sV=new oV;var tV;(function($){$.Completable="McpCompletable"})(tV||(tV={}));import{ZodOptional as Ct}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 IW=null;function BL($){IW=$}function u1(){if(!IW)throw Error('Plugin storage not initialized. Make sure the "workflows" plugin is enabled.');return IW}function FL($){return{...$,steps:S1($.steps)??[],input_schema:S1($.input_schema)??null}}class fW{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 SW{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 fW(Z),executions:new SW(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 T5}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 g5}from"zod/v4";import{z as ty}from"zod/v4";import{z as UL}from"zod/v4";import{z as k5}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=T5.literal(Y);else if(typeof Y==="number")$.number=T5.literal(Y);else if(typeof Y==="boolean")$.boolean=T5.literal(Y);else if(Y===null)$.null=T5.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||g5.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=g5.object({}).passthrough()}}},ny=class{apply($,Z){let Y=Z;if(Y.maxProperties===void 0)return;if($.object!==!1){let Q=$.object||g5.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||g5.object({}).passthrough();$.object=Q.refine((W)=>Object.keys(W).length>=Y.minProperties,{message:`Object must have at least ${Y.minProperties} properties`})}}};function O7($,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)=>O7(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)&&O7($[W],Z[W]))}return!1}function ay(){return($)=>{if(!Array.isArray($))return!0;let Z=[];return $.every((Y)=>{if(Z.some((W)=>O7(Y,W)))return!1;return Z.push(Y),!0})}}function x5($,Z){return $.safeParse(Z).success}var oy=class{apply($,Z){if(!Z.not)return $;let Y=I1(Z.not);return $.refine((Q)=>!x5(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(!x5(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(!x5(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 k5.ZodObject||$ instanceof k5.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 k5.object(Q);else return k5.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)=>O7(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)=>O7(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(x5(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 bW 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 vW($){return $ instanceof Error?"errors"in $&&Array.isArray($.errors)?$.errors.map(vW).join(", "):("cause"in $)&&$.cause instanceof Error?`${$}: ${vW($.cause)}`:$.message:`${$}`}function jL($){return{type:$.type,message:$.message,code:$.code,defaultPrevented:$.defaultPrevented,cancelable:$.cancelable,timeStamp:$.timeStamp}}var zL=($)=>{throw TypeError($)},mW=($,Z,Y)=>Z.has($)||zL("Cannot "+Y),X1=($,Z,Y)=>(mW($,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)=>(mW($,Z,"write to private field"),Z.set($,Y),Y),G6=($,Z,Y)=>(mW($,Z,"access private method"),Y),Z0,W8,Y9,u5,h5,P7,W9,w7,x6,Q9,J9,X9,N7,v0,yW,TW,kW,AL,xW,gW,M7,uW,hW;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,u5),f1(this,h5),f1(this,P7),f1(this,W9),f1(this,w7,null),f1(this,x6),f1(this,Q9),f1(this,J9,null),f1(this,X9,null),f1(this,N7,null),f1(this,TW,async(W)=>{var J;X1(this,Q9).reset();let{body:G,redirected:K,status:B,headers:D}=W;if(B===204){G6(this,v0,M7).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,M7).call(this,`Non-200 status code (${B})`,B);return}if(!(D.get("content-type")||"").startsWith("text/event-stream")){G6(this,v0,M7).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,N7))==null||J.call(this,V),this.dispatchEvent(V),typeof G!="object"||!G||!("getReader"in G)){G6(this,v0,M7).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,uW).call(this))}while(q)}),f1(this,kW,(W)=>{q1(this,x6,void 0),!(W.name==="AbortError"||W.type==="aborted")&&G6(this,v0,uW).call(this,vW(W))}),f1(this,xW,(W)=>{typeof W.id=="string"&&q1(this,w7,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,gW,(W)=>{q1(this,P7,W)}),f1(this,hW,()=>{q1(this,W9,void 0),X1(this,Z0)===this.CONNECTING&&G6(this,v0,yW).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,xW),onRetry:X1(this,gW)})),q1(this,Z0,this.CONNECTING),q1(this,P7,3000),q1(this,h5,(Y=Z==null?void 0:Z.fetch)!=null?Y:globalThis.fetch),q1(this,u5,(Q=Z==null?void 0:Z.withCredentials)!=null?Q:!1),G6(this,v0,yW).call(this)}get readyState(){return X1(this,Z0)}get url(){return X1(this,W8).href}get withCredentials(){return X1(this,u5)}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,N7)}set onopen($){q1(this,N7,$)}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,u5=new WeakMap,h5=new WeakMap,P7=new WeakMap,W9=new WeakMap,w7=new WeakMap,x6=new WeakMap,Q9=new WeakMap,J9=new WeakMap,X9=new WeakMap,N7=new WeakMap,v0=new WeakSet,yW=function(){q1(this,Z0,this.CONNECTING),q1(this,x6,new AbortController),X1(this,h5)(X1(this,W8),G6(this,v0,AL).call(this)).then(X1(this,TW)).catch(X1(this,kW))},TW=new WeakMap,kW=new WeakMap,AL=function(){var $;let Z={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...X1(this,w7)?{"Last-Event-ID":X1(this,w7)}: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},xW=new WeakMap,gW=new WeakMap,M7=function($,Z){var Y;X1(this,Z0)!==this.CLOSED&&q1(this,Z0,this.CLOSED);let Q=new bW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q)},uW=function($,Z){var Y;if(X1(this,Z0)===this.CLOSED)return;q1(this,Z0,this.CONNECTING);let Q=new bW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q),q1(this,W9,setTimeout(X1(this,hW),X1(this,P7)))},hW=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 lW{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 pW{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 iW 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($,Z)}async listTools($,Z){return await this.request({method:"tools/list",params:$},i9,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 pW(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 lW(new URL($.url),J)}return new iW(new URL($.url),{requestInit:{headers:W,signal:Z,credentials:"include"}})};var ML=($)=>{try{return JSON.parse($)}catch{return $}},m5=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(!m5.has(D))m5.set(D,J());return await m5.get(D)}catch(V){console.error("Failed to list tools",V),m5.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 R01=new Proxy({},{get($,Z){if(Z==="toJSON")return null;if(Z==="forConnection")return(Y)=>l5({connection:Y});return global[Z]}});function l5($){return wL($)}var EL=($)=>{return{...zT($),forClient:(Z)=>{return l5({client:Z})},forConnection:(Z)=>{return l5({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 p5=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 i5($,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 cW=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
+ `.trim();var yV=UW("site-diagnostics_"),Nv=yV.is,Mv=yV.get;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"])}),kV=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:kV,outputSchema:kV.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")}),xV=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()}),gV=y5.partial();import{z as C}from"zod";var z7=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")}),mV=z7.extend({selected_tools:z7.shape.selected_tools.optional(),selected_resources:z7.shape.selected_resources.optional(),selected_prompts:z7.shape.selected_prompts.optional()}),Wy=C.object({connectionId:C.string(),toolName:C.string(),label:C.string(),icon:C.string().nullable().optional()}),OW=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()})}),NW=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(OW).optional()}),uV=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()}),MW=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:NW.nullable().optional(),homeTile:uV.nullable().optional(),homeTiles:C.array(uV).nullable().optional(),homePrompts:C.array(C.string()).nullable().optional()});var PW=/^[A-Za-z_][A-Za-z0-9_]*$/,hV=C.string().min(1).regex(PW,{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:hV,kind:C.literal("literal"),value:C.string()}),C.object({key:hV,kind:C.literal("secret"),secretId:C.string().min(1)})]),wW=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.")}),EW=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 lV={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.")},RW=C.object(lV),vs=C.object({...lV,sandboxProviderKind:Ky.optional()});var q7=C.record(C.string().describe("userId"),C.record(C.string().describe("branch"),C.record(C.string().describe("sandboxProviderKind"),RW)));var pV=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:MW.nullable().optional().describe("UI customization settings"),githubRepo:EW.nullable().optional().describe("Linked GitHub repository"),runtime:wW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:q7.optional().describe("Per-user, per-branch sandbox mapping: sandboxMap[userId][branch] -> { sandboxHandle, previewUrl }")}).loose().describe("Metadata"),connections:C.array(z7).describe("Connections with their selected tools, resources, and prompts")}),iV=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:MW.nullable().optional().describe("UI customization settings"),githubRepo:EW.nullable().optional().describe("Linked GitHub repository"),runtime:wW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:q7.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(mV).describe("Connections to include/exclude (can be empty for exclusion mode)")}),cV=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:MW.nullable().optional().describe("UI customization settings"),githubRepo:EW.nullable().optional().describe("Linked GitHub repository"),runtime:wW.nullable().optional().describe("User-pinned runtime config (package manager, dev port). Empty fields = autodetect."),sandboxMap:q7.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(mV).optional().describe("New connections (replaces existing)")});var _W=["in_progress","requires_action","failed","completed"],dV=[..._W,"expired"],CW={STEP:"decopilot.step",FINISH:"decopilot.finish",THREAD_STATUS:"decopilot.thread.status"},nV=Object.values(CW);var rV=i6(L5(),1),aV=i6(tX(),1);function My(){let $=new rV.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return aV.default($),$}class oV{#$=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 sV=new oV;var tV;(function($){$.Completable="McpCompletable"})(tV||(tV={}));import{ZodOptional as Ct}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 IW=null;function BL($){IW=$}function u1(){if(!IW)throw Error('Plugin storage not initialized. Make sure the "workflows" plugin is enabled.');return IW}function FL($){return{...$,steps:S1($.steps)??[],input_schema:S1($.input_schema)??null}}class fW{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 SW{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 fW(Z),executions:new SW(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 T5}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 g5}from"zod/v4";import{z as ty}from"zod/v4";import{z as UL}from"zod/v4";import{z as k5}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=T5.literal(Y);else if(typeof Y==="number")$.number=T5.literal(Y);else if(typeof Y==="boolean")$.boolean=T5.literal(Y);else if(Y===null)$.null=T5.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||g5.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=g5.object({}).passthrough()}}},ny=class{apply($,Z){let Y=Z;if(Y.maxProperties===void 0)return;if($.object!==!1){let Q=$.object||g5.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||g5.object({}).passthrough();$.object=Q.refine((W)=>Object.keys(W).length>=Y.minProperties,{message:`Object must have at least ${Y.minProperties} properties`})}}};function O7($,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)=>O7(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)&&O7($[W],Z[W]))}return!1}function ay(){return($)=>{if(!Array.isArray($))return!0;let Z=[];return $.every((Y)=>{if(Z.some((W)=>O7(Y,W)))return!1;return Z.push(Y),!0})}}function x5($,Z){return $.safeParse(Z).success}var oy=class{apply($,Z){if(!Z.not)return $;let Y=I1(Z.not);return $.refine((Q)=>!x5(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(!x5(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(!x5(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 k5.ZodObject||$ instanceof k5.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 k5.object(Q);else return k5.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)=>O7(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)=>O7(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(x5(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 bW 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 vW($){return $ instanceof Error?"errors"in $&&Array.isArray($.errors)?$.errors.map(vW).join(", "):("cause"in $)&&$.cause instanceof Error?`${$}: ${vW($.cause)}`:$.message:`${$}`}function jL($){return{type:$.type,message:$.message,code:$.code,defaultPrevented:$.defaultPrevented,cancelable:$.cancelable,timeStamp:$.timeStamp}}var zL=($)=>{throw TypeError($)},mW=($,Z,Y)=>Z.has($)||zL("Cannot "+Y),X1=($,Z,Y)=>(mW($,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)=>(mW($,Z,"write to private field"),Z.set($,Y),Y),G6=($,Z,Y)=>(mW($,Z,"access private method"),Y),Z0,W8,Y9,u5,h5,P7,W9,w7,x6,Q9,J9,X9,N7,v0,yW,TW,kW,AL,xW,gW,M7,uW,hW;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,u5),f1(this,h5),f1(this,P7),f1(this,W9),f1(this,w7,null),f1(this,x6),f1(this,Q9),f1(this,J9,null),f1(this,X9,null),f1(this,N7,null),f1(this,TW,async(W)=>{var J;X1(this,Q9).reset();let{body:G,redirected:K,status:B,headers:D}=W;if(B===204){G6(this,v0,M7).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,M7).call(this,`Non-200 status code (${B})`,B);return}if(!(D.get("content-type")||"").startsWith("text/event-stream")){G6(this,v0,M7).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,N7))==null||J.call(this,V),this.dispatchEvent(V),typeof G!="object"||!G||!("getReader"in G)){G6(this,v0,M7).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,uW).call(this))}while(q)}),f1(this,kW,(W)=>{q1(this,x6,void 0),!(W.name==="AbortError"||W.type==="aborted")&&G6(this,v0,uW).call(this,vW(W))}),f1(this,xW,(W)=>{typeof W.id=="string"&&q1(this,w7,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,gW,(W)=>{q1(this,P7,W)}),f1(this,hW,()=>{q1(this,W9,void 0),X1(this,Z0)===this.CONNECTING&&G6(this,v0,yW).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,xW),onRetry:X1(this,gW)})),q1(this,Z0,this.CONNECTING),q1(this,P7,3000),q1(this,h5,(Y=Z==null?void 0:Z.fetch)!=null?Y:globalThis.fetch),q1(this,u5,(Q=Z==null?void 0:Z.withCredentials)!=null?Q:!1),G6(this,v0,yW).call(this)}get readyState(){return X1(this,Z0)}get url(){return X1(this,W8).href}get withCredentials(){return X1(this,u5)}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,N7)}set onopen($){q1(this,N7,$)}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,u5=new WeakMap,h5=new WeakMap,P7=new WeakMap,W9=new WeakMap,w7=new WeakMap,x6=new WeakMap,Q9=new WeakMap,J9=new WeakMap,X9=new WeakMap,N7=new WeakMap,v0=new WeakSet,yW=function(){q1(this,Z0,this.CONNECTING),q1(this,x6,new AbortController),X1(this,h5)(X1(this,W8),G6(this,v0,AL).call(this)).then(X1(this,TW)).catch(X1(this,kW))},TW=new WeakMap,kW=new WeakMap,AL=function(){var $;let Z={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...X1(this,w7)?{"Last-Event-ID":X1(this,w7)}: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},xW=new WeakMap,gW=new WeakMap,M7=function($,Z){var Y;X1(this,Z0)!==this.CLOSED&&q1(this,Z0,this.CLOSED);let Q=new bW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q)},uW=function($,Z){var Y;if(X1(this,Z0)===this.CLOSED)return;q1(this,Z0,this.CONNECTING);let Q=new bW("error",{code:Z,message:$});(Y=X1(this,J9))==null||Y.call(this,Q),this.dispatchEvent(Q),q1(this,W9,setTimeout(X1(this,hW),X1(this,P7)))},hW=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 lW{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 pW{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 iW 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($,Z)}async listTools($,Z){return await this.request({method:"tools/list",params:$},i9,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 pW(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 lW(new URL($.url),J)}return new iW(new URL($.url),{requestInit:{headers:W,signal:Z,credentials:"include"}})};var ML=($)=>{try{return JSON.parse($)}catch{return $}},m5=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(!m5.has(D))m5.set(D,J());return await m5.get(D)}catch(V){console.error("Failed to list tools",V),m5.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 R01=new Proxy({},{get($,Z){if(Z==="toJSON")return null;if(Z==="forConnection")return(Y)=>l5({connection:Y});return global[Z]}});function l5($){return wL($)}var EL=($)=>{return{...zT($),forClient:(Z)=>{return l5({client:Z})},forConnection:(Z)=>{return l5({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 p5=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 i5($,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 cW=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": {