decocms 4.217.8 → 4.217.9

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 (227) hide show
  1. package/dist/client/assets/{AlertCircle-Bga4VN5B.js → AlertCircle-YANopvaV.js} +1 -1
  2. package/dist/client/assets/{AreaChart-DYKiSa2K.js → AreaChart-oVj-4ppY.js} +1 -1
  3. package/dist/client/assets/{ArrowLeft-xMXo6BPK.js → ArrowLeft-C2NHDUNk.js} +1 -1
  4. package/dist/client/assets/{ArrowUp-BHKOGLu4.js → ArrowUp-CA-JeTEm.js} +1 -1
  5. package/dist/client/assets/{ArrowUpRight-Cn20Sk0x.js → ArrowUpRight-CGzRPrr0.js} +1 -1
  6. package/dist/client/assets/{Check-BxFTgxHA.js → Check-_yM9Kata.js} +1 -1
  7. package/dist/client/assets/{CheckCircle-CGzJEuEh.js → CheckCircle-CMp6LH2F.js} +1 -1
  8. package/dist/client/assets/{ChevronDown-41uC0ngG.js → ChevronDown-CnG8qm4F.js} +1 -1
  9. package/dist/client/assets/{ChevronRight-BHJ-SInU.js → ChevronRight-DjrUg_vP.js} +1 -1
  10. package/dist/client/assets/{ChevronUp-7ITbV7zs.js → ChevronUp-CfalNwJz.js} +1 -1
  11. package/dist/client/assets/{Copy01-CPsQJa0x.js → Copy01-8EN_Tz0v.js} +1 -1
  12. package/dist/client/assets/{CpuChip01-0jvSS3X_.js → CpuChip01-CD9tYygV.js} +1 -1
  13. package/dist/client/assets/{CreditCard01-Pm272A86.js → CreditCard01-CMHezVuz.js} +1 -1
  14. package/dist/client/assets/{DotsVertical-DqP5n3NW.js → DotsVertical-c_jJEVfq.js} +1 -1
  15. package/dist/client/assets/{Eye-DkQiM6qH.js → Eye-BlyGwBoE.js} +1 -1
  16. package/dist/client/assets/{FilterLines-CcADCueV.js → FilterLines-B0IAq4Bw.js} +1 -1
  17. package/dist/client/assets/{Globe01-DVjtoRnk.js → Globe01-AhmdTdCP.js} +1 -1
  18. package/dist/client/assets/{Globe04-Copt8ryx.js → Globe04-C-xCjSzZ.js} +1 -1
  19. package/dist/client/assets/{HardDrive-DQX5BdCc.js → HardDrive-Bzv1ZxTg.js} +1 -1
  20. package/dist/client/assets/{Key01-C3MfSi_9.js → Key01-_ovUnw2E.js} +1 -1
  21. package/dist/client/assets/{LayoutLeft-C5Tj5bVc.js → LayoutLeft-Bt8A31Hh.js} +1 -1
  22. package/dist/client/assets/{LinkExternal01-CFNGGePo.js → LinkExternal01-DEdF618y.js} +1 -1
  23. package/dist/client/assets/{LogOut01-DvEiDcF6.js → LogOut01-Dr4jczWV.js} +1 -1
  24. package/dist/client/assets/{Monitor01-BMyk5x2r.js → Monitor01-Rv6tbeGr.js} +1 -1
  25. package/dist/client/assets/{Palette-C0JOSGpF.js → Palette-D0kYZjxJ.js} +1 -1
  26. package/dist/client/assets/{Play-BgUM9jus.js → Play-BSTx4hcz.js} +1 -1
  27. package/dist/client/assets/{Plus-D3iFTh2y.js → Plus-DLR-BZWG.js} +1 -1
  28. package/dist/client/assets/{SearchLg-2bzkKh9E.js → SearchLg-DJbLdv9B.js} +1 -1
  29. package/dist/client/assets/{SearchMd-CQRNS2ro.js → SearchMd-D3apVYNe.js} +1 -1
  30. package/dist/client/assets/{Settings02-B7xxQtWl.js → Settings02-B24PMNg2.js} +1 -1
  31. package/dist/client/assets/{Share07-DPsmM2I8.js → Share07-CAJgQr0K.js} +1 -1
  32. package/dist/client/assets/{Shield01-BbhOt1Rz.js → Shield01-CBepBzXN.js} +1 -1
  33. package/dist/client/assets/{Star01-DMAHw7Gn.js → Star01-CbQuMlX_.js} +1 -1
  34. package/dist/client/assets/{Stars01-CyelIOme.js → Stars01-DxGwL2oe.js} +1 -1
  35. package/dist/client/assets/{Stars02-B0CbLt9-.js → Stars02-CZ2diuR4.js} +1 -1
  36. package/dist/client/assets/{Sun-CxCMSYeT.js → Sun-BrwsBdX9.js} +1 -1
  37. package/dist/client/assets/{SwitchHorizontal01-CuDuyhGp.js → SwitchHorizontal01-oW92OCLr.js} +1 -1
  38. package/dist/client/assets/{Tool01-CGY1mD2b.js → Tool01-DmOt9QZ3.js} +1 -1
  39. package/dist/client/assets/{Tool02-BLnjUYfT.js → Tool02-DEPXfhTv.js} +1 -1
  40. package/dist/client/assets/{Trash01-C5O0GRBJ.js → Trash01-O3xNTX2z.js} +1 -1
  41. package/dist/client/assets/{TrendUp01-CgF6QakT.js → TrendUp01-BssFgTvI.js} +1 -1
  42. package/dist/client/assets/{Upload01-Dq--NNhe.js → Upload01-CS7Z0Zid.js} +1 -1
  43. package/dist/client/assets/{User01-D-6jIM9f.js → User01-qwduxIEA.js} +1 -1
  44. package/dist/client/assets/{Users01-BrsefcqU.js → Users01-BYwYg6v6.js} +1 -1
  45. package/dist/client/assets/{Users03-DCy0JySf.js → Users03-Ba5lB2eo.js} +1 -1
  46. package/dist/client/assets/{X-DtfEBbHG.js → X-C1nYB9YH.js} +1 -1
  47. package/dist/client/assets/{XCircle-DeEkQkaH.js → XCircle-BTyfLLAc.js} +1 -1
  48. package/dist/client/assets/{XClose-U9r8UfQj.js → XClose-yHK-SWjt.js} +1 -1
  49. package/dist/client/assets/{Zap-UYkLnDLc.js → Zap-BOjTuTOY.js} +1 -1
  50. package/dist/client/assets/{ZapSquare-CiJcJZ4r.js → ZapSquare-DNpVYX7y.js} +1 -1
  51. package/dist/client/assets/{access-gate-HH8VtZcb.js → access-gate-DkHjs4D5.js} +1 -1
  52. package/dist/client/assets/{agent-icon-D1lfWl9o.js → agent-icon-DENunf_C.js} +1 -1
  53. package/dist/client/assets/{agents-list-DGfKr9r6.js → agents-list-DiukD831.js} +1 -1
  54. package/dist/client/assets/{ai-providers-BPMhRuI1.js → ai-providers-DlRohwTs.js} +1 -1
  55. package/dist/client/assets/{alert-CYeDVd4R.js → alert-B92_AV4W.js} +1 -1
  56. package/dist/client/assets/{alert-dialog-BwJK38sm.js → alert-dialog-BWPe1taq.js} +1 -1
  57. package/dist/client/assets/{api-keys-DZNO3xLt.js → api-keys-DAoBqRRg.js} +1 -1
  58. package/dist/client/assets/{app-editor-DzcrYIzf.js → app-editor-6OniwMEI.js} +1 -1
  59. package/dist/client/assets/{auth-D0Zhv6zj.js → auth-C9KAUO2x.js} +1 -1
  60. package/dist/client/assets/{auth-catchall-Cn0-5Q-z.js → auth-catchall-CyfYFHSY.js} +1 -1
  61. package/dist/client/assets/{auth-entry-C4sEvh8w.js → auth-entry-DJauzPnX.js} +1 -1
  62. package/dist/client/assets/{auth-split-layout-BnRQ_Mf4.js → auth-split-layout-BbtvQcMk.js} +1 -1
  63. package/dist/client/assets/{authenticate-and-persist-oauth-BMr8pePK.js → authenticate-and-persist-oauth-DAcRcaAc.js} +1 -1
  64. package/dist/client/assets/{automation-list-row-DDE-04yh.js → automation-list-row-B97mrpWc.js} +1 -1
  65. package/dist/client/assets/{automation-runs-BQuvG4qs.js → automation-runs-i-JMJchX.js} +1 -1
  66. package/dist/client/assets/{automations-BMj0NOJZ.js → automations-P8Ohb4cW.js} +1 -1
  67. package/dist/client/assets/{avatar-D0383_Yh.js → avatar-DpDIwVT6.js} +1 -1
  68. package/dist/client/assets/{badge-C-2383vp.js → badge-C6QS_Nkz.js} +1 -1
  69. package/dist/client/assets/{billing-yfT9JxER.js → billing-DZwcYXni.js} +1 -1
  70. package/dist/client/assets/{block-document-DzCTFKaq.js → block-document-BR78w6hg.js} +1 -1
  71. package/dist/client/assets/{brand-context-PK1-QLPj.js → brand-context-CXmtOzZV.js} +1 -1
  72. package/dist/client/assets/{buckets-BvWzbv7c.js → buckets-C7Uk_03n.js} +1 -1
  73. package/dist/client/assets/{bulk-category-panel-IOwfF1yM.js → bulk-category-panel-BKO2kDxX.js} +1 -1
  74. package/dist/client/assets/{capability-load-error-Cg9RHaoe.js → capability-load-error-Bhwj6R8b.js} +1 -1
  75. package/dist/client/assets/{card-Bc2_9cxB.js → card-7-Rvcv0V.js} +1 -1
  76. package/dist/client/assets/{cards-CeLAIE7i.js → cards-dLyZx7mw.js} +1 -1
  77. package/dist/client/assets/{category-editor-B7l9jfwJ.js → category-editor-HcvpPYxp.js} +1 -1
  78. package/dist/client/assets/{chat-context-T2jyMMb1.js → chat-context-CPiVCs4X.js} +1 -1
  79. package/dist/client/assets/{checkbox--e3jpOpr.js → checkbox-CIt-fVYM.js} +1 -1
  80. package/dist/client/assets/{cli-auth-success-CovWLro5.js → cli-auth-success-DOC-Iq2K.js} +1 -1
  81. package/dist/client/assets/{collection-detail-DudDryd2.js → collection-detail-BrovA5wA.js} +1 -1
  82. package/dist/client/assets/{collection-display-button-DddgOorO.js → collection-display-button-D2Ixe-4O.js} +1 -1
  83. package/dist/client/assets/{collection-search-pib81zzM.js → collection-search-BsbT1_VJ.js} +1 -1
  84. package/dist/client/assets/{collection-table-wrapper-B8VNFYII.js → collection-table-wrapper-D9lkfLRm.js} +1 -1
  85. package/dist/client/assets/{collection-tabs-Rhsb5CbF.js → collection-tabs-D-No7VNv.js} +1 -1
  86. package/dist/client/assets/{command-Ba9-I8Fv.js → command-S_VwD71f.js} +1 -1
  87. package/dist/client/assets/{commerce-onboarding-C2gzjJmm.js → commerce-onboarding-C8gmkJWI.js} +1 -1
  88. package/dist/client/assets/{connect-_Yj5K-yn.js → connect-KG_9tzml.js} +1 -1
  89. package/dist/client/assets/{connection-cpL6QRw5.js → connection-CxVbXzun.js} +1 -1
  90. package/dist/client/assets/{connection-card-Cn2kbz4B.js → connection-card-B7o5eHRn.js} +1 -1
  91. package/dist/client/assets/{connection-detail-DOO8i870.js → connection-detail-zaDscvRE.js} +1 -1
  92. package/dist/client/assets/{connection-form-helpers-BcvfOPii.js → connection-form-helpers-1IsNe_0s.js} +1 -1
  93. package/dist/client/assets/{connections-NgYTYij9.js → connections-BiMSZulU.js} +1 -1
  94. package/dist/client/assets/{decopilot-sse-pool-BkuPyy75.js → decopilot-sse-pool-0yYdosm1.js} +1 -1
  95. package/dist/client/assets/{dialog-LHrJL8Jb.js → dialog-KVmwq_Qc.js} +1 -1
  96. package/dist/client/assets/{domain-settings-DRYYdTcv.js → domain-settings-Sm_l0QD0.js} +1 -1
  97. package/dist/client/assets/{drawer-B-beaQ30.js → drawer-B-Y2UX5N.js} +1 -1
  98. package/dist/client/assets/{dropdown-menu-C3jTmko2.js → dropdown-menu-C6VqtZwc.js} +1 -1
  99. package/dist/client/assets/{empty-state-g_MaCJFf.js → empty-state-CP8qjQO6.js} +1 -1
  100. package/dist/client/assets/{extract-connection-data-DF6mmqJu.js → extract-connection-data-BWs5oyY1.js} +1 -1
  101. package/dist/client/assets/{file-explorer-CtnGC29W.js → file-explorer-DMuUlIr6.js} +1 -1
  102. package/dist/client/assets/{file-type-icon-hfndNC8O.js → file-type-icon-CGDhFVoz.js} +1 -1
  103. package/dist/client/assets/{form-LNnM5qpe.js → form-Dfas8dgq.js} +1 -1
  104. package/dist/client/assets/{general-AF8eZKww.js → general-DPGn1OTQ.js} +1 -1
  105. package/dist/client/assets/{github-repo-picker-CQ6-vjp3.js → github-repo-picker-NVQdNcV8.js} +1 -1
  106. package/dist/client/assets/{hooks-jW8JuW5N.js → hooks-CrDskaxA.js} +1 -1
  107. package/dist/client/assets/{index-Bne9_-Ay.js → index-CR_pJhPh.js} +1 -1
  108. package/dist/client/assets/{index-Z2Ows-Wv.js → index-CoinV2k1.js} +1 -1
  109. package/dist/client/assets/{index-JXUo6Ytn.js → index-Cx51phWt.js} +1 -1
  110. package/dist/client/assets/{index-CDJMTL18.js → index-D63fA3gG.js} +1 -1
  111. package/dist/client/assets/{index-DMTFQFnP.js → index-DL8SQppt.js} +1 -1
  112. package/dist/client/assets/{index-DA9gaZTE.js → index-Df_DdNhm.js} +3 -3
  113. package/dist/client/assets/{index-DLTp6PNr.js → index-DnNkSLxJ.js} +4 -4
  114. package/dist/client/assets/{index-CSKsXcu0.js → index-Do5rVKnv.js} +1 -1
  115. package/dist/client/assets/{index-B1DWlEAL.js → index-ZJNM0vRS.js} +1 -1
  116. package/dist/client/assets/{index-BH_dwl88.js → index-qaHA-mXg.js} +1 -1
  117. package/dist/client/assets/{index-redirect-CoFlyr0w.js → index-redirect-CEeOwRLV.js} +1 -1
  118. package/dist/client/assets/{input-Dy6ibSRV.js → input-laD2Br4w.js} +1 -1
  119. package/dist/client/assets/{integration-icon-B4AiuMIS.js → integration-icon-7VKVHSTB.js} +1 -1
  120. package/dist/client/assets/{invite-member-dialog-KTcEKi1i.js → invite-member-dialog-CEirVNTW.js} +1 -1
  121. package/dist/client/assets/{label-YHz4GkBe.js → label-BNgIOKju.js} +1 -1
  122. package/dist/client/assets/{layout-Bs7OctOA.js → layout-Db5PfFl1.js} +1 -1
  123. package/dist/client/assets/{login-BB9J0d_v.js → login-DAKsMMtA.js} +1 -1
  124. package/dist/client/assets/{mcp-oauth-Dqkh-01U.js → mcp-oauth-BlVYhol1.js} +1 -1
  125. package/dist/client/assets/{members-dUbKYz_S.js → members-CN5folxm.js} +1 -1
  126. package/dist/client/assets/{monaco-editor-X3IiYrvs.js → monaco-editor-DYXnAJno.js} +1 -1
  127. package/dist/client/assets/{monitoring-stats-row-BfBMtAuH.js → monitoring-stats-row-GC7dfHNG.js} +1 -1
  128. package/dist/client/assets/{multi-select-Da2kxElQ.js → multi-select-EegTvXvx.js} +1 -1
  129. package/dist/client/assets/{oauth-callback-DU4wCS3J.js → oauth-callback-BANqgz-A.js} +1 -1
  130. package/dist/client/assets/{oauth-callback-ai-provider-BiEz_YJJ.js → oauth-callback-ai-provider-Cr5fsiVR.js} +1 -1
  131. package/dist/client/assets/{onboarding-CYb0M2ld.js → onboarding-C_LSWaOt.js} +1 -1
  132. package/dist/client/assets/{org-layout-CjxZtW4g.js → org-layout-CuALQS7R.js} +1 -1
  133. package/dist/client/assets/{organization-choice-CZ9U_pdH.js → organization-choice-B5Gp6bOl.js} +1 -1
  134. package/dist/client/assets/{orgs-0bqls1jL.js → orgs-xTBNpFxB.js} +1 -1
  135. package/dist/client/assets/{page-seo-form-s3cDp1tl.js → page-seo-form-BbVXWZ8C.js} +1 -1
  136. package/dist/client/assets/{popover-M0Jxuynj.js → popover-DfvuPJ5S.js} +1 -1
  137. package/dist/client/assets/{post-editor-DyL7Je51.js → post-editor-DCTUATmz.js} +1 -1
  138. package/dist/client/assets/{primitives-BcVi-I7X.js → primitives-D03pMV_e.js} +1 -1
  139. package/dist/client/assets/{profile-C1wl4xFH.js → profile-gjghePx-.js} +1 -1
  140. package/dist/client/assets/{project-app-view-CeUZ9fhT.js → project-app-view-C_G39p3k.js} +1 -1
  141. package/dist/client/assets/record-editor-BWI3uG0q.js +1 -0
  142. package/dist/client/assets/{redirect-editor-6gBts1ad.js → redirect-editor-DShYLc4a.js} +1 -1
  143. package/dist/client/assets/registry-Ckt6RXil.js +2 -0
  144. package/dist/client/assets/{registry-layout-Cqwz8bk8.js → registry-layout-2awTRcpL.js} +1 -1
  145. package/dist/client/assets/{reports-Bws61h0j.js → reports-DzOMfIEw.js} +1 -1
  146. package/dist/client/assets/{require-capability-C0j3LAkA.js → require-capability-Dt_fJbI7.js} +1 -1
  147. package/dist/client/assets/{required-auth-layout-BW7p1ko3.js → required-auth-layout-CwgyLQjW.js} +1 -1
  148. package/dist/client/assets/{reset-password-Carv8fX3.js → reset-password-B4_AmhRM.js} +1 -1
  149. package/dist/client/assets/{roles-dTTGl-B9.js → roles-CuRfn80H.js} +1 -1
  150. package/dist/client/assets/{search-input-BEwxP6F0.js → search-input-Kq3acqwZ.js} +1 -1
  151. package/dist/client/assets/{secrets-o5XQAkb9.js → secrets-BABBBLLH.js} +1 -1
  152. package/dist/client/assets/{sections-editor-DqXF242i.js → sections-editor-Te-DZ7PB.js} +1 -1
  153. package/dist/client/assets/{select-DW92fXVu.js → select-Bjq_STXX.js} +1 -1
  154. package/dist/client/assets/{select-model-_qBGCkYR.js → select-model-DiB5pV_r.js} +1 -1
  155. package/dist/client/assets/{self-tool-result-rlYuYCwi.js → self-tool-result-DH8agyht.js} +1 -1
  156. package/dist/client/assets/{seo-editor-Cr_2qD-i.js → seo-editor-BMDJC5oR.js} +1 -1
  157. package/dist/client/assets/{settings-layout-BCse14W6.js → settings-layout-7y3sx0yG.js} +1 -1
  158. package/dist/client/assets/{settings-section-luSFi2sS.js → settings-section-DjZJ-LbR.js} +1 -1
  159. package/dist/client/assets/{shell-controls-BG5l0vBK.js → shell-controls-Dzv8K5oh.js} +1 -1
  160. package/dist/client/assets/{shell-layout-B5gQHLFH.js → shell-layout-Ba8Uyrno.js} +1 -1
  161. package/dist/client/assets/{sidebar-DafD_5hD.js → sidebar-8zv8L9Jd.js} +1 -1
  162. package/dist/client/assets/{skeleton-C165FSgM.js → skeleton-CP0QRhuO.js} +1 -1
  163. package/dist/client/assets/{spinner-B730KihT.js → spinner-CK7GykFb.js} +1 -1
  164. package/dist/client/assets/{sso-qK7lBoo4.js → sso-Bp9RHPXI.js} +1 -1
  165. package/dist/client/assets/{store-FShWFn0e.js → store-Cihg1x0E.js} +1 -1
  166. package/dist/client/assets/store-registry-DudX6mkv.js +2 -0
  167. package/dist/client/assets/{studio-tools-DYaKK02D.js → studio-tools-oEy2pW8-.js} +1 -1
  168. package/dist/client/assets/{switch-B7lwHiHg.js → switch-B_V_VB_X.js} +1 -1
  169. package/dist/client/assets/{synced-repos-uqwY4MAA.js → synced-repos-CzWClVwS.js} +1 -1
  170. package/dist/client/assets/{tab-id-BuxAs-Ew.js → tab-id-CNaP44nw.js} +1 -1
  171. package/dist/client/assets/{table-C-X5BKja.js → table-JpnJhUGZ.js} +1 -1
  172. package/dist/client/assets/{tabs-BLMmkKwe.js → tabs-BBfgev8h.js} +1 -1
  173. package/dist/client/assets/{textarea-BQeeR5Ou.js → textarea-BCbuQyvB.js} +1 -1
  174. package/dist/client/assets/{toggle-group-KdjYeXN7.js → toggle-group-C3YodKD2.js} +1 -1
  175. package/dist/client/assets/{toolbar-CZ_88Skh.js → toolbar-CHUKkJsj.js} +1 -1
  176. package/dist/client/assets/{tooltip-D3oBsgIm.js → tooltip-BB33866h.js} +1 -1
  177. package/dist/client/assets/{track-theM2OCM.js → track-g7glZn0U.js} +1 -1
  178. package/dist/client/assets/{use-ai-providers-OnZchdSb.js → use-ai-providers-D9Px67Ld.js} +1 -1
  179. package/dist/client/assets/{use-api-keys-Cf4xy05a.js → use-api-keys-Dkcyg4av.js} +1 -1
  180. package/dist/client/assets/{use-automations-Qb0CvpaR.js → use-automations-CS-kiCvY.js} +1 -1
  181. package/dist/client/assets/{use-autosave-DmY5pLWZ.js → use-autosave-79oa6QTO.js} +1 -1
  182. package/dist/client/assets/{use-capability-EtiCeb4g.js → use-capability-BWFsZ59S.js} +1 -1
  183. package/dist/client/assets/{use-clock-tick-AY1ywc2U.js → use-clock-tick-DNPiU6f6.js} +1 -1
  184. package/dist/client/assets/{use-connection-BtiAJzpd.js → use-connection-BjeZB5GQ.js} +1 -1
  185. package/dist/client/assets/{use-copy-DHg_GTI5.js → use-copy-CtyoU7rm.js} +1 -1
  186. package/dist/client/assets/{use-create-virtual-mcp-C4NcRCYe.js → use-create-virtual-mcp-CkRsnxQZ.js} +1 -1
  187. package/dist/client/assets/{use-debounced-autosave-BOhMSXTa.js → use-debounced-autosave-CzEvpDBi.js} +1 -1
  188. package/dist/client/assets/{use-debounced-value-D3dmU87K.js → use-debounced-value-BmnilvmM.js} +1 -1
  189. package/dist/client/assets/{use-deco-credits-DQivbuvI.js → use-deco-credits-vFWhcWwk.js} +1 -1
  190. package/dist/client/assets/{use-decopilot-events-BhjwB8uz.js → use-decopilot-events-DsLlPy2w.js} +1 -1
  191. package/dist/client/assets/{use-delete-connection-BiuWNzJX.js → use-delete-connection-ByxU0zsX.js} +1 -1
  192. package/dist/client/assets/{use-deployment-admin-Dp2DkRAM.js → use-deployment-admin-CRpmxN1L.js} +1 -1
  193. package/dist/client/assets/{use-file-configs-BU6th4Q1.js → use-file-configs-DrIEELj-.js} +1 -1
  194. package/dist/client/assets/{use-infinite-scroll-klZZY37G.js → use-infinite-scroll-CyJ0jGAa.js} +1 -1
  195. package/dist/client/assets/{use-join-requests-CDlO-Yhc.js → use-join-requests-CHo0bOMk.js} +1 -1
  196. package/dist/client/assets/{use-mcp-client-BumIUrYG.js → use-mcp-client-B1xdlUsd.js} +1 -1
  197. package/dist/client/assets/{use-mcp-tools-Dp3IQW1e.js → use-mcp-tools-3qwKoFkS.js} +1 -1
  198. package/dist/client/assets/{use-members-CgZYVk-t.js → use-members-hnmKCsJu.js} +1 -1
  199. package/dist/client/assets/{use-mobile-Cug94apU.js → use-mobile-uWBsKGql.js} +1 -1
  200. package/dist/client/assets/{use-navigate-to-agent-KDOsBzLj.js → use-navigate-to-agent-e8Uu5e7U.js} +1 -1
  201. package/dist/client/assets/{use-open-billing-url-B9z8Goc4.js → use-open-billing-url-AP8BALpu.js} +1 -1
  202. package/dist/client/assets/{use-org-auth-client-C0h-qpY9.js → use-org-auth-client-DndIzSBg.js} +1 -1
  203. package/dist/client/assets/{use-org-sso-BUFrHF9n.js → use-org-sso-CT5l3aEK.js} +1 -1
  204. package/dist/client/assets/{use-organization-roles-RT4XVeyV.js → use-organization-roles-x4D5XHk7.js} +1 -1
  205. package/dist/client/assets/{use-organization-settings-CL3V58uS.js → use-organization-settings-C4YDsPdf.js} +1 -1
  206. package/dist/client/assets/{use-registry-connections-BDeNPODL.js → use-registry-connections-CyqpfWEE.js} +1 -1
  207. package/dist/client/assets/{use-secrets-pJLyrcBa.js → use-secrets-uJrc_1D5.js} +1 -1
  208. package/dist/client/assets/{use-section-preview-base-CoCond6W.js → use-section-preview-base-CO2PTO15.js} +1 -1
  209. package/dist/client/assets/{use-status-sounds-CuE5d30n.js → use-status-sounds-CP__NLZ3.js} +1 -1
  210. package/dist/client/assets/{use-tags-WsNWWpCv.js → use-tags-BfN_S1xl.js} +1 -1
  211. package/dist/client/assets/{use-view-mode-DLueOYnJ.js → use-view-mode-DDvfVh98.js} +1 -1
  212. package/dist/client/assets/{use-virtual-mcp-CD2s3ZEr.js → use-virtual-mcp-DktBkAIS.js} +1 -1
  213. package/dist/client/assets/useInfiniteQuery-BPPNBJID.js +1 -0
  214. package/dist/client/assets/{useRouterState-CT-p8d2x.js → useRouterState-vPVJWMx7.js} +1 -1
  215. package/dist/client/assets/useSuspenseInfiniteQuery-2FhEHxCw.js +1 -0
  216. package/dist/client/assets/{users-CoiRe8s-.js → users-Dn1SQzOV.js} +1 -1
  217. package/dist/client/assets/{variant-calendar-ByX-opNn.js → variant-calendar-Biyo-OfL.js} +1 -1
  218. package/dist/client/assets/{view-mode-toggle-DtYAiR1q.js → view-mode-toggle-CUdvzAq2.js} +1 -1
  219. package/dist/client/index.html +1 -1
  220. package/dist/server/cli.js +2 -2
  221. package/dist/server/server.js +1 -1
  222. package/package.json +1 -1
  223. package/dist/client/assets/record-editor-BJ9VYpRA.js +0 -1
  224. package/dist/client/assets/registry-DyNgZPIS.js +0 -2
  225. package/dist/client/assets/store-registry-Vg1KzVpo.js +0 -2
  226. package/dist/client/assets/useInfiniteQuery-CBjX7auT.js +0 -1
  227. package/dist/client/assets/useSuspenseInfiniteQuery-CTtBUjV7.js +0 -1
@@ -176,7 +176,7 @@ All managed services stopped.`)}async function df6($){let Z=[],X=KW($,"postgres"
176
176
  Usage: deco services <up|down|status>`),process.exit(1)}}var vd1=O(()=>{px()});function xd1($){Mm=Object.freeze($)}function a0(){if(!Mm)nf6();return Mm}function nf6(){if(Mm)return;let $={...process.env},Z=_10({port:$.PORT||"3000",home:$.DATA_DIR||$.DECOCMS_HOME||"",localMode:$.DECOCMS_LOCAL_MODE==="true",skipMigrations:!0,noTui:$.DECO_NO_TUI==="true",vitePort:$.VITE_PORT,baseUrl:$.BASE_URL},$);Mm=Object.freeze({...Z.settings,databaseUrl:$.DATABASE_URL||"postgresql://postgres:postgres@localhost:5432/postgres",natsUrls:($.NATS_URL||"nats://localhost:4222").split(",").map((X)=>X.trim()).filter(Boolean)})}var Mm=null;var k8=O(()=>{px()});import{context as pf6,propagation as tf6,SpanKind as of6,SpanStatusCode as Uu0}from"@opentelemetry/api";function af6($,Z){let X=$ instanceof Error?$.name:void 0;if(X==="TimeoutError")return"timeout";if(X==="AbortError")return"cancelled";if(Z?.aborted)return"cancelled";return null}function sf6($,Z){if(Z.startsWith("/_sandbox/")){if($===404)return"daemon_gone";if($===409)return"daemon_not_ready"}if($===404&&Z.includes("/sandboxclaims/"))return"claim_gone";return null}function ef6($,Z){if($===404&&(Z==="/.decofile"||Z==="/live/_meta"||Z==="/sprites.svg"))return"not_a_deco_site";return null}function $b6($){if(!($ instanceof Error))return!1;if($.message.includes("socket connection was closed"))return!0;let Z=$.code;return Z==="ECONNRESET"||Z==="EPIPE"}async function Zb6($,Z){let X,Q;if($ instanceof Request)X=new URL($.url),Q=Z?.method??$.method;else if($ instanceof URL)X=$,Q=Z?.method??"GET";else X=new URL($),Q=Z?.method??"GET";let Y=`${Q} ${X.host}`;return jw.startActiveSpan(Y,{kind:of6.CLIENT,attributes:{"http.request.method":Q,"url.full":X.href,"url.scheme":X.protocol.replace(":",""),"url.path":X.pathname,"url.query":X.search||void 0,"server.address":X.hostname,"server.port":X.port?Number(X.port):void 0}},async(G)=>{try{let J=new Headers(Z?.headers??($ instanceof Request?$.headers:{}));tf6.inject(pf6.active(),J,{set:(F,w,B)=>F.set(w,B)});let K={...Z,headers:J},W=await rf6($,K);G.setAttribute("http.response.status_code",W.status);let H=W.status===405&&Q==="GET"&&(J.get("accept")??"").includes("text/event-stream"),U=W.status>=400?sf6(W.status,X.pathname):null,N=W.status>=400?ef6(W.status,X.pathname):null;if(W.status>=400&&!H&&!U&&!N)G.setStatus({code:Uu0.ERROR,message:`HTTP ${W.status}`});else{if(U)G.setAttribute("sandbox.lifecycle",U);if(N)G.setAttribute("preview.probe",N);G.setStatus({code:Uu0.OK})}return W}catch(J){let K=Z?.signal??($ instanceof Request?$.signal:void 0),W=af6(J,K??void 0);if(W)G.setAttribute("abort.reason",W);else if($b6(J)&&X.pathname.startsWith("/_sandbox/"))G.setAttribute("sandbox.lifecycle","connection_closed");else G.recordException(J),G.setStatus({code:Uu0.ERROR,message:J instanceof Error?J.message:"Fetch failed"});throw J}finally{G.end()}})}function fd1(){globalThis.fetch=Zb6}var rf6;var bd1=O(()=>{t$();rf6=globalThis.fetch});import{join as Fu0}from"path";function jJ(){return Fu0(a0().dataDir,"logs")}function Wb(){return Fu0(a0().dataDir,"traces")}function bU(){return Fu0(a0().dataDir,"metrics")}function Pw($,Z){let X=$[Z];return X!=null?String(X):""}function Vm($,Z){let X=$[Z];return X!=null&&X!==""?String(X):null}function yd1($){let{attributes:Z}=$,X=Z[A4.IS_ERROR],Q=Z[A4.DURATION_MS];return{v:1,id:$.id,type:Pw(Z,A4.TYPE)||km,organization_id:Pw(Z,A4.ORGANIZATION_ID),connection_id:Pw(Z,A4.CONNECTION_ID),connection_title:Pw(Z,A4.CONNECTION_TITLE),tool_name:Pw(Z,A4.TOOL_NAME),input:Pw(Z,A4.INPUT),output:Pw(Z,A4.OUTPUT),is_error:X===!0||X===1||X==="true"?1:0,error_message:Vm(Z,A4.ERROR_MESSAGE),duration_ms:typeof Q==="number"?Q:Number(Q)||0,timestamp:new Date(Number($.timestampNano/1000000n)).toISOString(),user_id:Vm(Z,A4.USER_ID),request_id:Pw(Z,A4.REQUEST_ID),user_agent:Vm(Z,A4.USER_AGENT),virtual_mcp_id:Vm(Z,A4.VIRTUAL_MCP_ID),properties:Vm(Z,A4.PROPERTIES)}}function a50($){return $[0]*1000+$[1]/1e6}function Ub($){return new Date(a50($)).toISOString()}var Nu0="mcp.proxy.callTool",A4,km="tool_call",Hb="llm_call",r50="decopilot";var mY=O(()=>{k8();A4={TYPE:"studio.monitoring.type",ORGANIZATION_ID:"studio.monitoring.organization_id",CONNECTION_ID:"studio.monitoring.connection_id",CONNECTION_TITLE:"studio.monitoring.connection_title",TOOL_NAME:"studio.monitoring.tool_name",INPUT:"studio.monitoring.input",OUTPUT:"studio.monitoring.output",IS_ERROR:"studio.monitoring.is_error",ERROR_MESSAGE:"studio.monitoring.error_message",DURATION_MS:"studio.monitoring.duration_ms",USER_ID:"studio.monitoring.user_id",REQUEST_ID:"studio.monitoring.request_id",USER_AGENT:"studio.monitoring.user_agent",VIRTUAL_MCP_ID:"studio.monitoring.virtual_mcp_id",PROPERTIES:"studio.monitoring.properties"}});import{ExportResultCode as s50}from"@opentelemetry/core";import{mkdir as Xb6,rename as Qb6,writeFile as Yb6}from"fs/promises";import{join as e50}from"path";class eD{bufferItems=[];bufferBytes=0;flushTimer=null;flushQueue=Promise.resolve();basePath;flushThreshold;maxBufferBytes;isShutdown=!1;knownDirs=new Set;partitionKey;constructor($){this.basePath=$.basePath,this.flushThreshold=$.flushThreshold??1000,this.maxBufferBytes=$.maxBufferBytes??10485760,this.partitionKey=$.partitionKey;let Z=$.flushIntervalMs??60000;if(Z>0&&Z<3600000){if(this.flushTimer=setInterval(()=>{this.flush().catch((X)=>{console.error("[NDJSONExporter] Timer flush failed:",X)})},Z),this.flushTimer&&typeof this.flushTimer==="object"&&"unref"in this.flushTimer)this.flushTimer.unref()}}exportRows($){if(this.isShutdown)return Promise.resolve({code:s50.FAILED});for(let Z of $){let X=JSON.stringify(Z),Q=this.partitionKey?this.partitionKey(Z):"";this.bufferItems.push({partition:Q,json:X}),this.bufferBytes+=Buffer.byteLength(X,"utf8")+1}if(this.bufferItems.length>=this.flushThreshold||this.bufferBytes>=this.maxBufferBytes)return this.flush().then(()=>({code:s50.SUCCESS})).catch((Z)=>{return console.error("[NDJSONExporter] Flush failed:",Z),{code:s50.FAILED}});return Promise.resolve({code:s50.SUCCESS})}async shutdown(){if(this.isShutdown=!0,this.flushTimer)clearInterval(this.flushTimer),this.flushTimer=null;try{await this.flushQueue}catch{}if(this.bufferItems.length>0)await this.flush()}async forceFlush(){try{await this.flushQueue}catch{}if(this.bufferItems.length>0)await this.flush()}flush(){let Z=this.flushQueue.catch(()=>{}).then(()=>this.doFlush());return this.flushQueue=Z,Z}async doFlush(){if(this.bufferItems.length===0)return;let $=this.bufferItems;this.bufferItems=[],this.bufferBytes=0;let Z=new Map;for(let Y of $){let G=Z.get(Y.partition);if(!G)G=[],Z.set(Y.partition,G);G.push(Y.json)}let X=await Promise.allSettled(Array.from(Z.entries()).map(([Y,G])=>this.writeNDJSON(G,Y).then(()=>Y))),Q=X.find((Y)=>Y.status==="rejected");if(Q){let Y=new Set;for(let J of X)if(J.status==="fulfilled")Y.add(J.value);let G=$.filter((J)=>!Y.has(J.partition));this.bufferItems=G.concat(this.bufferItems),this.bufferBytes=0;for(let J of this.bufferItems)this.bufferBytes+=Buffer.byteLength(J.json,"utf8")+1;throw Q.reason}}async writeNDJSON($,Z){let X=new Date,Q=[String(X.getUTCFullYear()),String(X.getUTCMonth()+1).padStart(2,"0"),String(X.getUTCDate()).padStart(2,"0"),String(X.getUTCHours()).padStart(2,"0")],Y=Z?e50(this.basePath,Z,...Q):e50(this.basePath,...Q);if(!this.knownDirs.has(Y))await Xb6(Y,{recursive:!0,mode:448}),this.knownDirs.add(Y);let G=`${crypto.randomUUID()}.ndjson`,J=e50(Y,`.${G}.tmp`),K=e50(Y,G),W=$.join(`
177
177
  `)+`
178
178
  `;await Yb6(J,W,{mode:384}),await Qb6(J,K)}}var $90=()=>{};import{ExportResultCode as Gb6}from"@opentelemetry/core";class wu0{inner;constructor($){this.inner=new eD({...$,partitionKey:(Z)=>Z.organization_id})}export($,Z){let X=[];for(let Q of $){if(!Jb6.has(Q.attributes[A4.TYPE]))continue;let Y={};for(let[W,H]of Object.entries(Q.attributes))if(typeof H==="string"||typeof H==="number"||typeof H==="boolean")Y[W]=H;let G=Q.spanContext?.spanId??crypto.randomUUID(),J=Q.hrTime,K=BigInt(J[0])*1000000000n+BigInt(J[1]);X.push(yd1({id:G,timestampNano:K,attributes:Y}))}this.inner.exportRows(X).then((Q)=>Z(Q)).catch(()=>Z({code:Gb6.FAILED}))}async shutdown(){await this.inner.shutdown()}async forceFlush(){await this.inner.forceFlush()}}var Jb6;var gd1=O(()=>{mY();$90();Jb6=new Set([km,Hb])});import{ExportResultCode as Kb6}from"@opentelemetry/core";import{AggregationTemporality as Wb6,DataPointType as hd1}from"@opentelemetry/sdk-metrics";class Bu0{inner;constructor($){this.inner=new eD({...$,partitionKey:(Z)=>Z.organization_id})}selectAggregationTemporality($){return Wb6.DELTA}export($,Z){let X=[];for(let Q of $.scopeMetrics)for(let Y of Q.metrics){let{descriptor:G,dataPointType:J}=Y;if(J===hd1.SUM)for(let K of Y.dataPoints){let W=K.attributes;X.push({v:1,name:G.name,type:"sum",unit:G.unit,timestamp:Ub(K.endTime),organization_id:String(W["organization.id"]??""),connection_id:String(W["connection.id"]??""),tool_name:String(W["tool.name"]??""),status:String(W.status??""),error_type:String(W["error.type"]??""),value:K.value,hist_count:0,hist_sum:0,hist_min:0,hist_max:0,hist_boundaries:"[]",hist_bucket_counts:"[]"})}else if(J===hd1.HISTOGRAM)for(let K of Y.dataPoints){let{attributes:W,value:H}=K;X.push({v:1,name:G.name,type:"histogram",unit:G.unit,timestamp:Ub(K.endTime),organization_id:String(W["organization.id"]??""),connection_id:String(W["connection.id"]??""),tool_name:String(W["tool.name"]??""),status:String(W.status??""),error_type:String(W["error.type"]??""),value:H.count,hist_count:H.count,hist_sum:H.sum??0,hist_min:H.min??0,hist_max:H.max??0,hist_boundaries:JSON.stringify(H.buckets.boundaries),hist_bucket_counts:JSON.stringify(H.buckets.counts)})}}this.inner.exportRows(X).then((Q)=>Z(Q)).catch(()=>Z({code:Kb6.FAILED}))}async shutdown(){await this.inner.shutdown()}async forceFlush(){await this.inner.forceFlush()}}var ud1=O(()=>{mY();$90()});import{ExportResultCode as Hb6}from"@opentelemetry/core";function Ub6($){let Z=$.resource,X=Z.attributes["service.name"]??"unknown";return{v:1,trace_id:$.spanContext().traceId,span_id:$.spanContext().spanId,parent_span_id:$.parentSpanContext?.spanId||null,name:$.name,kind:$.kind,status:$.status.code,status_message:$.status.message||null,start_time:Ub($.startTime),end_time:Ub($.endTime),duration_ms:a50($.endTime)-a50($.startTime),service_name:X,attributes:JSON.stringify($.attributes),events:JSON.stringify($.events),links:JSON.stringify($.links),resource:JSON.stringify(Z.attributes)}}class Ou0{inner;constructor($){this.inner=new eD($)}export($,Z){let X=$.map(Ub6);this.inner.exportRows(X).then((Q)=>Z(Q)).catch(()=>Z({code:Hb6.FAILED}))}async shutdown(){await this.inner.shutdown()}async forceFlush(){await this.inner.forceFlush()}}var cd1=O(()=>{mY();$90()});function Nb($,Z=65536){if($.length<=Z&&Buffer.byteLength($,"utf8")<=Z)return $;let X=Z-Nb6;if(X<=0)return"... [TRUNCATED]".slice(0,Z);let Q=0,Y=0;for(let G of $){let J=G.charCodeAt(0)<=127?1:Buffer.byteLength(G,"utf8");if(Q+J>X)break;Q+=J,Y+=G.length}return $.slice(0,Y)+"... [TRUNCATED]"}var Nb6;var Lu0=O(()=>{Nb6=Buffer.byteLength("... [TRUNCATED]","utf8")});import{NOOP_LOGGER as Fb6}from"@opentelemetry/api-logs";function dd1($){ld1=$.getLogger(wb6,Bb6)}function md1(){return ld1}var wb6="studio.monitoring",Bb6="1.0.0",ld1;var Du0=O(()=>{ld1=Fb6});var pd1={};B0(pd1,{shouldSkipStudioContext:()=>Eu0,isServerPath:()=>Lb6,isHealthPath:()=>Sm,SYSTEM_PATHS:()=>O7});function Sm($){return $===O7.HEALTH||$===O7.HEALTH_LIVE||$===O7.HEALTH_READY}function id1($){return $===O7.HEALTH||$===O7.HEALTH_LIVE||$===O7.HEALTH_READY||$===O7.METRICS||$.startsWith($E.WELL_KNOWN)||$.startsWith(O7.DBOS_QUEUE_DEPTH_PREFIX)||$===O7.HOSTED_RUN_PENDING}function nd1($){return $.startsWith($E.API)}function Lb6($){return nd1($)||$==="/mcp"||$.startsWith($E.MCP)||$.startsWith($E.OAUTH_PROXY)||$.startsWith($E.ORG)||$.startsWith($E.REPORT)||id1($)}function Eu0($){return $==="/"||$.startsWith($E.API_AUTH)||$==="/api/trigger-callback"||id1($)||!nd1($)&&Ob6.test($)}var O7,$E,Ob6;var Z90=O(()=>{O7={HEALTH:"/health",HEALTH_LIVE:"/health/live",HEALTH_READY:"/health/ready",METRICS:"/metrics",DBOS_QUEUE_DEPTH_PREFIX:"/dbos-queue-depth/",HOSTED_RUN_PENDING:"/hosted-run-pending"},$E={API:"/api/",API_AUTH:"/api/auth/",MCP:"/mcp/",OAUTH_PROXY:"/oauth-proxy/",WELL_KNOWN:"/.well-known",ORG:"/org/",REPORT:"/report/"},Ob6=/\.(html|css|js|ico|svg|png|jpg|jpeg|gif|webp|woff|woff2)$/});import{SpanStatusCode as zu0}from"@opentelemetry/api";var Db6,Eb6=()=>Db6??=y8.createHistogram("http.server.request.duration",{description:"Duration of inbound HTTP requests handled by the API.",unit:"s",advice:{explicitBucketBoundaries:[0.005,0.01,0.025,0.05,0.075,0.1,0.25,0.5,0.75,1,2.5,5,7.5,10]}}),ju0=async($,Z)=>{if(Sm($.req.path))return Z();let X=$.req.raw,Q=new URL(X.url),Y=performance.now(),G=rd1(X),J=Pu0(X),K={"http.request.url":X.url,"http.request.method":X.method,"http.request.body.size":X.headers.get("content-length")??void 0,"url.scheme":Q.protocol.replace(":",""),"server.address":Q.host,"url.query":Q.search||void 0,"url.path":Q.pathname,"user_agent.original":X.headers.get("user-agent")??void 0,"request.internal":X.headers.has("traceparent"),...J?{"trace.debug.id":J}:{}};await jw.startActiveSpan(`${X.method} ${Q.pathname}`,{attributes:K},G,async(W)=>{$.set("rootSpan",W);try{await Z()}catch(H){W.recordException(H),W.setStatus({code:zu0.ERROR});let U=typeof H==="object"&&H&&"message"in H?String(H.message):JSON.stringify(H);throw console.error("error: ",U,K),H}finally{let H=$.res?.status??500,U=H>=500;W.setStatus({code:U?zu0.ERROR:zu0.OK}),W.setAttribute("http.response.status_code",H);let N=$.get("studioContext");if(N){if(N.auth.user?.id)W.setAttribute("studio.user.id",N.auth.user.id);if(N.auth.apiKey?.id)W.setAttribute("studio.api_key.id",N.auth.apiKey.id);if(N.organization?.id)W.setAttribute("studio.organization.id",N.organization.id)}if(J)od1($.res.headers,J);Eb6().record((performance.now()-Y)/1000,{"http.request.method":X.method,"http.route":$.req.routePath,"http.response.status_code":H}),W.end()}})};var td1=O(()=>{t$();Z90()});import{createContextKey as zb6,metrics as Qm1,propagation as jb6,ROOT_CONTEXT as Pb6,SpanStatusCode as ad1,trace as Tu0}from"@opentelemetry/api";import{logs as Ym1,SeverityNumber as bm}from"@opentelemetry/api-logs";import{OTLPLogExporter as sd1}from"@opentelemetry/exporter-logs-otlp-proto";import{PrometheusExporter as Ab6}from"@opentelemetry/exporter-prometheus";import{OTLPTraceExporter as Tb6}from"@opentelemetry/exporter-trace-otlp-proto";import{RuntimeNodeInstrumentation as Rb6}from"@opentelemetry/instrumentation-runtime-node";import{BatchLogRecordProcessor as Au0,LoggerProvider as ed1}from"@opentelemetry/sdk-logs";import{detectResources as Ib6,envDetector as qb6,hostDetector as Mb6,osDetector as Vb6,processDetector as kb6,resourceFromAttributes as $m1}from"@opentelemetry/resources";import{PeriodicExportingMetricReader as Sb6}from"@opentelemetry/sdk-metrics";import{NodeSDK as Cb6}from"@opentelemetry/sdk-node";import{BatchSpanProcessor as Zm1,SamplingDecision as Fb}from"@opentelemetry/sdk-trace-base";class Jm1{inner;ratio;constructor($,Z){this.inner=$;this.ratio=Z}onEmit($,Z){if($.severityNumber!==void 0&&$.severityNumber>=bm.ERROR||Math.random()<this.ratio)this.inner.onEmit($,Z)}forceFlush(){return this.inner.forceFlush()}shutdown(){return this.inner.shutdown()}}class Km1{inner;maxBytes;constructor($,Z){this.inner=$;this.maxBytes=Z}onEmit($,Z){let X=A4.OUTPUT,Q=$.attributes?.[X];if(typeof Q==="string"&&Q.length>this.maxBytes){let Y=Nb(Q,this.maxBytes);this.inner.onEmit({...$,attributes:{...$.attributes,[X]:Y}},Z)}else this.inner.onEmit($,Z)}forceFlush(){return this.inner.forceFlush()}shutdown(){return this.inner.shutdown()}}class Wm1{inner;constructor($){this.inner=$}shouldSample($,Z,X,Q,Y,G){let J=$.getValue(Gm1);if(!J){if(this.inner)return this.inner.shouldSample($,Z,X,Q,Y,G);return{decision:Fb.RECORD_AND_SAMPLED}}let K=Pu0(J);if(K)return{decision:Fb.RECORD_AND_SAMPLED,attributes:{"trace.debug.id":K}};if(this.inner){let W=this.inner.shouldSample($,Z,X,Q,Y,G);if(W.decision===Fb.RECORD_AND_SAMPLED){let H=crypto.randomUUID();W.attributes={...W.attributes??{},"trace.debug.id":H}}return W}return{decision:Fb.NOT_RECORD}}toString(){return"DebugSampler"}}class Hm1{ratio;constructor($){this.ratio=$}shouldSample(){if(Math.random()<this.ratio)return{decision:Fb.RECORD_AND_SAMPLED};return{decision:Fb.NOT_RECORD}}toString(){return`RatioSampler(${this.ratio})`}}function Um1(){if(Xm1)return;let $=a0(),Z=!!process.env.OTEL_EXPORTER_OTLP_ENDPOINT,X=Z?new Tb6:void 0;Cm=$.nodeEnv==="test"?null:new wu0({basePath:jJ()}),_m=$.nodeEnv==="test"?null:new Ou0({basePath:Wb()}),vm=$.nodeEnv==="test"?null:new Bu0({basePath:bU()}),xm=vm?new Sb6({exporter:vm,exportIntervalMillis:60000}):null;let Q=process.env.STUDIO_ENV??"production"??"unknown",Y={};if(!process.env.OTEL_RESOURCE_ATTRIBUTES?.includes("deployment.environment"))Y["deployment.environment"]=Q;new Cb6({serviceName:$.otelServiceName,resource:$m1(Y),metricReaders:[Ru0,...xm?[xm]:[]],sampler:xb6,spanProcessors:[...X?[new Zm1(X,{scheduledDelayMillis:60000,maxExportBatchSize:1000})]:[],..._m?[new Zm1(_m,{scheduledDelayMillis:60000,maxExportBatchSize:250})]:[]],instrumentations:[new Rb6]}).start(),y8=Qm1.getMeter("studio","1.0.0"),jw=Tu0.getTracer("studio","1.0.0");let J=Ib6({detectors:[qb6,Mb6,Vb6,kb6]}).merge($m1({"service.name":$.otelServiceName,...Y})),K=[];if(Z){let N=Q==="prod"||Q==="production"?1:0.1,F=process.env.INFRA_LOG_SAMPLE_RATIO,w=N;if(F!==void 0){let B=Number(F);if(Number.isFinite(B)&&B>=0&&B<=1)w=B;else console.warn(`[observability] Ignoring invalid INFRA_LOG_SAMPLE_RATIO="${F}" (expected 0..1); using ${N}`)}K.push(new Jm1(new Au0(new sd1),w))}fm=new ed1({resource:J,processors:K}),Ym1.setGlobalLoggerProvider(fm),Nm1=fm.getLogger("studio","1.0.0");let W=$.monitoringOtlpEndpoint??process.env.OTEL_EXPORTER_OTLP_ENDPOINT,H=[];if(W){let U=W.replace(/\/$/,""),N=U.endsWith("/v1/logs")?U:`${U}/v1/logs`;H.push(new Km1(new Au0(new sd1({url:N})),8000))}if(Cm)H.push(new Au0(Cm,{scheduledDelayMillis:60000,maxExportBatchSize:250}));X90=new ed1({resource:J,processors:H}),dd1(X90),fd1(),Xm1=!0}async function xQ(){let Z=(await Promise.allSettled([fm?fm.forceFlush():Promise.resolve(),(async()=>{if(X90)await X90.forceFlush();if(Cm)await Cm.forceFlush()})(),(async()=>{let X=Tu0.getTracerProvider();if("forceFlush"in X)await X.forceFlush();if(_m)await _m.forceFlush()})(),(async()=>{if(xm)await xm.forceFlush();if(vm)await vm.forceFlush()})()])).find((X)=>X.status==="rejected");if(Z)throw Z.reason}function Fm1($,Z,X){return jw.startActiveSpan($,{attributes:X},async(Q)=>{try{let Y=await Z(Q);return Q.setStatus({code:ad1.OK}),Y}catch(Y){let G=Y instanceof Error?Y:Error(String(Y??"unknown"));throw Q.setStatus({code:ad1.ERROR,message:G.message}),Q.recordException(G),Y}finally{Q.end()}})}var _b6="__d",Gm1,vb6=1,Pu0=($)=>{let X=new URL($.url).searchParams.get(_b6);if(X==="")return crypto.randomUUID();if(!X)X=$.headers.get("x-trace-debug-id");return X},od1=($,Z)=>{try{$.set("x-trace-debug-id",Z)}catch{}},Ru0,xb6,Cm=null,_m=null,vm=null,xm=null,fm=null,X90=null,Xm1=!1,jw,y8,Nm1,Iu0=($,Z,X)=>{let Q={},Y=X,G=X[X.length-1];if(G!==null&&typeof G==="object"&&!Array.isArray(G)&&!(G instanceof Error)&&Object.getPrototypeOf(G)===Object.prototype)Q=G,Y=X.slice(0,-1);let J=Y.map((K)=>{if(K instanceof Error)return`${K.name}: ${K.message}`;if(typeof K==="object")try{return JSON.stringify(K)}catch{return"[Object]"}return String(K)}).join(" ");Nm1.emit({severityNumber:$,severityText:Z,body:J,attributes:{"log.source":"console",...Q}})},qu0,rd1=($)=>{return jb6.extract(Pb6,$.headers,{get:(X,Q)=>X.get(Q)??void 0,keys:(X)=>[...X.keys()]}).setValue(Gm1,$)};var t$=O(()=>{bd1();gd1();ud1();cd1();mY();Lu0();k8();Du0();td1();Gm1=zb6("Current request");Ru0=new Ab6({preventServerStart:!0}),xb6=new Wm1(new Hm1(vb6));jw=Tu0.getTracer("studio","1.0.0"),y8=Qm1.getMeter("studio","1.0.0"),Nm1=Ym1.getLogger("studio","1.0.0"),qu0={error:console.error.bind(console),warn:console.warn.bind(console),debug:console.debug.bind(console)};console.error=(...$)=>{Iu0(bm.ERROR,"ERROR",$),qu0.error(...$)};console.warn=(...$)=>{Iu0(bm.WARN,"WARN",$),qu0.warn(...$)};console.debug=(...$)=>{Iu0(bm.DEBUG,"DEBUG",$),qu0.debug(...$)}});function ZE(){try{return process.memoryUsage()}catch{return null}}import{Session as fb6}from"inspector";function XE($,Z){return new Promise((X,Q)=>wb.post($,Z,(Y,G)=>Y?Q(Y):X(G??{})))}async function wm1($){try{return wb=new fb6,wb.connect(),await XE("Profiler.enable"),await XE("Profiler.setSamplingInterval",{interval:$}),await XE("Profiler.start"),Ob=!0,!0}catch{return Ob=!1,wb=null,!1}}function bb6($,Z){let{nodes:X,samples:Q,timeDeltas:Y}=$;if(!Q?.length)return null;let G=new Map,J=new Map;for(let L of X){G.set(L.id,L);for(let D of L.children??[])J.set(D,L.id)}let K=Math.max(1,Z)*1000,W=0,H=new Map;for(let L=Q.length-1;L>=0;L--){W+=Y[L]??0;let D=Q[L];if(D!==void 0)H.set(D,(H.get(D)??0)+1);if(W>=K)break}let U=-1,N=0;for(let[L,D]of H)if(D>N)N=D,U=L;if(U<0)return null;let F=[],w=new Set,B=U;while(B!=null&&!w.has(B)){w.add(B);let L=G.get(B);if(!L)break;let D=L.callFrame,E=D.url?` ${D.url}:${D.lineNumber+1}`:"";F.push(`${D.functionName||"(anonymous)"}${E}`),B=J.get(B)}return F}async function Bm1($){if(!Ob||!wb||Bb)return null;Bb=!0;try{let{profile:Z}=await XE("Profiler.stop"),X=Z?bb6(Z,$):null;return await XE("Profiler.start"),X}catch{return Ob=!1,null}finally{Bb=!1}}async function Om1(){if(!Ob||!wb||Bb)return;Bb=!0;try{await XE("Profiler.stop"),await XE("Profiler.start")}catch{Ob=!1}finally{Bb=!1}}var wb=null,Ob=!1,Bb=!1;var Lm1=()=>{};function Em1(){if(Mu0)return;let $=performance.now()+Vu0;Mu0=setInterval(()=>{let Z=performance.now();Dm1=Math.max(0,Z-$),$=Z+Vu0},Vu0),Mu0.unref?.()}function zm1(){return Em1(),Dm1}function jm1(){if(Em1(),process.env.EVENT_LOOP_MONITOR!=="1")return()=>{};let $=Number(process.env.EVENT_LOOP_INTERVAL_MS??250),Z=Number(process.env.EVENT_LOOP_SPIKE_MS??100),X=process.env.EVENT_LOOP_PROFILE==="1",Q=Number(process.env.EVENT_LOOP_PROFILE_MS??1000),Y=Number(process.env.EVENT_LOOP_PROFILE_INTERVAL_US??1e4),G=30000,J=performance.now();if(X)wm1(Y).then((H)=>{console.warn(JSON.stringify({msg:"event-loop-profiler",status:H?"started":"unavailable",intervalUs:Y}))});let K=y8.createHistogram("eventloop.delay",{description:"Event-loop lag measured as timer scheduling drift",unit:"ms"}),W=performance.now()+$;return Q90=setInterval(()=>{let H=performance.now(),U=Math.max(0,H-W);if(W=H+$,K.record(U),U>Z){let N=ZE();console.warn(JSON.stringify({msg:"event-loop-stall",ts:new Date().toISOString(),lagMs:Math.round(U),rss:N?.rss,heapUsed:N?.heapUsed,heapTotal:N?.heapTotal,external:N?.external}))}if(X){if(U>Q)Bm1(Math.round(U)).then((N)=>{if(N?.length)console.warn(JSON.stringify({msg:"event-loop-stall-profile",ts:new Date().toISOString(),lagMs:Math.round(U),stack:N}))}),J=H;else if(H-J>G)Om1(),J=H}},$),Q90.unref?.(),()=>{if(Q90)clearInterval(Q90)}}var Q90,Mu0,Dm1=0,Vu0=500;var ku0=O(()=>{t$();Lm1()});var Vm1={};B0(Vm1,{withSslmode:()=>Su0,getDbDialect:()=>gm,getDb:()=>N6,getDatabaseUrl:()=>Aw,createDatabase:()=>Mm1,closeDatabase:()=>Tw});import{Kysely as yb6,PostgresDialect as Tm1}from"kysely";import{Pool as Rm1}from"pg";function cb6($){let Z=$.connect.bind($);return $.connect=(X)=>{if(typeof X==="function")return Z(X);let Q=performance.now(),Y=Y90(),G=$.idleCount===0&&$.totalCount>=Y,J=$.idleCount;return Z().then((K)=>{let W=performance.now()-Q;if(Pm1().record(W,{"db.pool.outcome":G?"contended":"available"}),W>hb6)if(G)console.error("Slow db pool acquire \u2014 pool saturated:",{waitMs:W,total:$.totalCount,idle:$.idleCount,waiting:$.waitingCount,max:Y});else console.warn("Slow db pool acquire \u2014 event-loop lag (not pool):",{waitMs:W,idleAtStart:J,total:$.totalCount,max:Y});return K},(K)=>{throw Pm1().record(performance.now()-Q,{"db.pool.outcome":"error"}),K})},$}function qm1(){try{return a0().databasePgSsl}catch{return!1}}function Y90(){try{return a0().databasePoolMax}catch{return 10}}function lb6($){let Z=cb6(new Rm1({connectionString:$,max:Y90(),ssl:qm1(),...Im1})),X=new Tm1({pool:Z});return{type:"postgres",db:new yb6({dialect:X,log:ub6(Z)}),pool:Z}}function Aw(){return a0().databaseUrl}function Su0($,Z){if(!Z)return $;let X=new URL($);if(!X.searchParams.has("sslmode"))X.searchParams.set("sslmode","verify-full");return X.toString()}function gm($){let Z=$||Aw();return new Tm1({pool:new Rm1({connectionString:Z,max:Y90(),ssl:qm1(),...Im1})})}function Mm1($){let Z=$||Aw();return lb6(Z)}async function Tw($){if(await $.db.destroy(),!$.pool.ended)await $.pool.end();if($===ym)ym=null}function N6(){if(!ym)ym=Mm1(Aw());return ym}var gb6=()=>y8.createHistogram("db.query.duration",{description:"Database query execution duration in milliseconds",unit:"ms"}),Pm1=()=>y8.createHistogram("db.pool.acquire.duration",{description:"Time spent waiting to acquire a connection from the pool",unit:"ms"}),Am1=400,hb6=100,ub6=($)=>(Z)=>{let X={"db.statement":Z.query.sql,"db.status":Z.level==="error"?"error":"success"};if(Z.queryDurationMillis>Am1){let Q=zm1(),Y=Q>Am1/2;console.error(Y?"Slow query measurement \u2014 likely event-loop lag, not slow SQL:":"Slow query detected:",{durationMs:Z.queryDurationMillis,eventLoopLagMs:Math.round(Q),sql:Z.query.sql,pool:{total:$.totalCount,idle:$.idleCount,waiting:$.waitingCount,max:Y90()}})}if(gb6().record(Z.queryDurationMillis,X),Z.level==="error")console.error("Query failed:",{durationMs:Z.queryDurationMillis,error:Z.error,sql:Z.query.sql})},Im1,ym=null;var e7=O(()=>{k8();t$();ku0();Im1={keepAlive:!0,keepAliveInitialDelayMillis:1e4,idleTimeoutMillis:300000,connectionTimeoutMillis:30000,allowExitOnIdle:!0}});function Sm1($){let{port:Z,query:X}=$,{protocol:Q,path:Y,hostname:G}=$;if(Q&&Q.slice(-1)!==":")Q+=":";if(Z)G+=`:${Z}`;if(Y&&Y.charAt(0)!=="/")Y=`/${Y}`;let J=X?km1.buildQueryString(X):"";if(J&&J[0]!=="?")J=`?${J}`;let K="";if($.username!=null||$.password!=null){let H=$.username??"",U=$.password??"";K=`${H}:${U}@`}let W="";if($.fragment)W=`#${$.fragment}`;return`${Q}//${K}${G}${Y}${J}${W}`}var km1;var Cm1=O(()=>{km1=k(t10(),1)});var _m1="UNSIGNED-PAYLOAD",vm1="X-Amz-Content-Sha256";class G90{signer;constructor($){let Z={service:$.signingName||$.service||"s3",uriEscapePath:$.uriEscapePath||!1,applyChecksum:$.applyChecksum||!1,...$};this.signer=new xm1.SignatureV4MultiRegion(Z)}presign($,{unsignableHeaders:Z=new Set,hoistableHeaders:X=new Set,unhoistableHeaders:Q=new Set,...Y}={}){return this.prepareRequest($,{unsignableHeaders:Z,unhoistableHeaders:Q,hoistableHeaders:X}),this.signer.presign($,{expiresIn:900,unsignableHeaders:Z,unhoistableHeaders:Q,...Y})}presignWithCredentials($,Z,{unsignableHeaders:X=new Set,hoistableHeaders:Q=new Set,unhoistableHeaders:Y=new Set,...G}={}){return this.prepareRequest($,{unsignableHeaders:X,unhoistableHeaders:Y,hoistableHeaders:Q}),this.signer.presignWithCredentials($,Z,{expiresIn:900,unsignableHeaders:X,unhoistableHeaders:Y,...G})}prepareRequest($,{unsignableHeaders:Z=new Set,unhoistableHeaders:X=new Set,hoistableHeaders:Q=new Set}={}){Z.add("content-type"),Object.keys($.headers).map((K)=>K.toLowerCase()).filter((K)=>K.startsWith("x-amz-server-side-encryption")).forEach((K)=>{if(!Q.has(K))X.add(K)}),$.headers[vm1]=_m1;let Y=$.headers.host,G=$.port,J=`${$.hostname}${$.port!=null?":"+G:""}`;if(!Y||Y===$.hostname&&$.port!=null)$.headers.host=J}}var xm1;var Cu0=O(()=>{xm1=k(Mf(),1)});var fm1,bm1,J90=async($,Z,X={})=>{let Q,Y;if(typeof $.config.endpointProvider==="function"){let F=(await fm1.getEndpointFromInstructions(Z.input,Z.constructor,$.config)).properties?.authSchemes?.[0];if(F?.name==="sigv4a")Y=F?.signingRegionSet?.join(",");else Y=F?.signingRegion;Q=new G90({...$.config,signingName:F?.signingName,region:async()=>Y})}else Q=new G90($.config);let G=(N,F)=>async(w)=>{let{request:B}=w;if(!bm1.HttpRequest.isInstance(B))throw Error("Request to be presigned is not an valid HTTP request.");delete B.headers["amz-sdk-invocation-id"],delete B.headers["amz-sdk-request"],delete B.headers["x-amz-user-agent"];let L,D={...X,signingRegion:X.signingRegion??F.signing_region??Y,signingService:X.signingService??F.signing_service};if(F.s3ExpressIdentity)L=await Q.presignWithCredentials(B,F.s3ExpressIdentity,D);else L=await Q.presign(B,D);return{response:{},output:{$metadata:{httpStatusCode:200},presigned:L}}},J="presignInterceptMiddleware",K=$.middlewareStack.clone();K.addRelativeTo(G,{name:J,relation:"before",toMiddleware:"awsAuthMiddleware",override:!0});let W=Z.resolveMiddleware(K,$.config,{}),{output:H}=await W({input:Z.input}),{presigned:U}=H;return Sm1(U)};var ym1=O(()=>{Cm1();Cu0();fm1=k(U1(),1),bm1=k(n$(),1)});var gm1=O(()=>{ym1();Cu0()});import{extname as db6}from"path";function WW($){let Z;try{Z=decodeURIComponent($)}catch{Z=$}let Q=Z.replace(/\0/g,"").replace(/[\x00-\x1f\x7f]/g,"").replace(/\\/g,"/").split("/"),Y=[];for(let G of Q)if(G==="..")Y.pop();else if(G!=="."&&G!=="")Y.push(G);return Y.join("/")}function Rw($,Z){let X=WW(Z);if(!X)throw Error("Key is empty after sanitization");return`${$}/${X}`}function hm1($,Z){if(!Z)return`${$}/`;let X=WW(Z);return`${$}/${X}${X.endsWith("/")?"":"/"}`}function Lb($,Z,X){let Q=X.split("/").map(encodeURIComponent).join("/");return`${$}/api/${encodeURIComponent(Z)}/files/${Q}`}function _u0($,Z){let X=`${$}/`;if(Z.startsWith(X))return Z.slice(X.length);return Z}function gZ($){let Z=db6($).toLowerCase();return mb6[Z]??"application/octet-stream"}function K90($){let Z=$.split(";")[0].trim();if(ib6.has(Z))return!0;if(Z.startsWith("text/"))return!0;return!1}var mb6,ib6;var HW=O(()=>{mb6={".json":"application/json",".html":"text/html",".htm":"text/html",".css":"text/css",".js":"application/javascript",".mjs":"application/javascript",".ts":"text/typescript",".txt":"text/plain",".md":"text/markdown",".csv":"text/csv",".xml":"application/xml",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".pdf":"application/pdf",".zip":"application/zip",".gz":"application/gzip",".tar":"application/x-tar",".wasm":"application/wasm",".yaml":"application/yaml",".yml":"application/yaml",".toml":"application/toml"};ib6=new Set(["application/json","text/html","text/css","application/javascript","text/typescript","text/plain","text/markdown","text/csv","application/xml","image/svg+xml","application/yaml","application/toml"])});class vu0{client;bucket;constructor($){this.bucket=$.bucket,this.client=new s7({endpoint:$.endpoint,region:$.region,credentials:{accessKeyId:$.accessKeyId,secretAccessKey:$.secretAccessKey},forcePathStyle:$.forcePathStyle})}async getBytesOrPresign($,Z,X){let Q=Rw($,Z),Y=await this.client.send(new zJ({Bucket:this.bucket,Key:Q})),G=Y.ContentLength??0,J=Y.ContentType??gZ(Z);if(G>X.presignWhenLargerThan){let U=await J90(this.client,new vU({Bucket:this.bucket,Key:Q}),{expiresIn:X.presignExpiresIn??3600});return{error:"FILE_TOO_LARGE",size:G,maxInlineSize:X.presignWhenLargerThan,presignedUrl:U,contentType:J}}let W=await(await this.client.send(new vU({Bucket:this.bucket,Key:Q}))).Body.transformToByteArray(),H=K90(J);return{content:H?new TextDecoder().decode(W):Buffer.from(W).toString("base64"),contentType:J,encoding:H?"utf-8":"base64",size:G,lastModified:Y.LastModified,etag:Y.ETag}}async getBytes($,Z){let X=Rw($,Z);return(await this.client.send(new vU({Bucket:this.bucket,Key:X}))).Body.transformToByteArray()}async put($,Z,X,Q){let Y=Rw($,Z),G=Q?.contentType??gZ(Z);return{etag:(await this.client.send(new JW({Bucket:this.bucket,Key:Y,Body:typeof X==="string"?Buffer.from(X,"utf-8"):X,ContentType:G}))).ETag,key:Z}}async list($,Z){let X=hm1($,Z?.prefix),Q=await this.client.send(new lY({Bucket:this.bucket,Prefix:X,MaxKeys:Z?.maxKeys??1000,ContinuationToken:Z?.continuationToken,Delimiter:Z?.delimiter})),Y=Q.CommonPrefixes?.map((G)=>_u0($,G.Prefix??"")).filter(Boolean);return{objects:(Q.Contents??[]).map((G)=>({key:_u0($,G.Key??""),size:G.Size??0,lastModified:G.LastModified,etag:G.ETag})),isTruncated:Q.IsTruncated??!1,nextContinuationToken:Q.NextContinuationToken,commonPrefixes:Y&&Y.length>0?Y:void 0}}async delete($,Z){let X=Rw($,Z);await this.client.send(new $b({Bucket:this.bucket,Key:X}))}async head($,Z){let X=Rw($,Z),Q=await this.client.send(new zJ({Bucket:this.bucket,Key:X}));return{contentType:Q.ContentType??gZ(Z),size:Q.ContentLength??0,lastModified:Q.LastModified,etag:Q.ETag}}async presignedGetUrl($,Z,X=3600,Q){let Y=Rw($,Z);return J90(this.client,new vU({Bucket:this.bucket,Key:Y}),{expiresIn:X})}async presignedPutUrl($,Z,X=3600,Q){let Y=Rw($,Z);return J90(this.client,new JW({Bucket:this.bucket,Key:Y,ContentType:Q}),{expiresIn:X})}}var um1=O(()=>{Rm();gm1();HW()});function nb6(){let $=a0();return!!($.s3Endpoint&&$.s3Bucket&&$.s3AccessKeyId&&$.s3SecretAccessKey)}function iX(){if(hm!==void 0)return hm;if(!nb6())return hm=null,null;let $=a0();return hm=new vu0({endpoint:$.s3Endpoint,bucket:$.s3Bucket,region:$.s3Region,accessKeyId:$.s3AccessKeyId,secretAccessKey:$.s3SecretAccessKey,forcePathStyle:$.s3ForcePathStyle}),hm}var hm;var Iw=O(()=>{k8();um1()});function iY($,Z){return{getBytesOrPresign:(X,Q)=>$.getBytesOrPresign(Z,X,Q),getBytes:(X)=>$.getBytes(Z,X),put:(X,Q,Y)=>$.put(Z,X,Q,Y),list:(X)=>$.list(Z,X),delete:(X)=>$.delete(Z,X),head:(X)=>$.head(Z,X),presignedGetUrl:(X,Q,Y)=>$.presignedGetUrl(Z,X,Q,Y),presignedPutUrl:(X,Q,Y)=>$.presignedPutUrl(Z,X,Q,Y)}}import{createHash as pb6}from"crypto";function cm1($){let Z=$;while(Z?.[W90])Z=Z[W90];return Z}function cm($){let{objectStorage:Z,baseUrl:X,orgSlug:Q,prefix:Y="connection-icons",maxBytes:G=ob6,dryRun:J=!1}=$;return async(K)=>{if(typeof K!=="string")return K;let W=K.match(tb6);if(!W)return K;if(!Z||!Q)return K;let[,H,U]=W,N=H.toLowerCase(),F=ab6[N];if(!F)return K;if(Math.floor(U.length*3/4)>G)return console.warn(`[asset-hoister] asset exceeds ${G} bytes, keeping inline`),K;let w=Buffer.from(U,"base64"),B=pb6("sha256").update(w).digest("hex"),L=`${Y}/${B}.${F}`;if(J)return Lb(X,Q,L);try{return await Z.put(L,w,{contentType:N}),Lb(X,Q,L)}catch(D){return console.error("[asset-hoister] upload failed, keeping inline asset:",D),K}}}async function H90($,Z,X=0){if(X>rb6)return $;if(typeof $==="string")return await Z($)??$;if(Array.isArray($)){let Q=await Promise.all($.map((Y)=>H90(Y,Z,X+1)));return Q.some((Y,G)=>Y!==$[G])?Q:$}if($!==null&&typeof $==="object"){let Q=Object.entries($),Y=await Promise.all(Q.map(([,K])=>H90(K,Z,X+1))),G=!1,J={};return Q.forEach(([K,W],H)=>{if(J[K]=Y[H],Y[H]!==W)G=!0}),G?J:$}return $}function U90($,Z){return H90($,Z)}async function um($,Z){let X={...$};if(typeof X.icon==="string")X.icon=await Z(X.icon);if(X.metadata!==null&&typeof X.metadata==="object")X.metadata=await H90(X.metadata,Z);return X}function sb6($,Z){return new Proxy($,{get(X,Q,Y){if(Q===W90)return X;if(Q==="create")return async(J)=>X.create(await um(J,Z));if(Q==="createNew")return async(J)=>X.createNew(await um(J,Z));if(Q==="update")return async(J,K)=>X.update(J,await um(K,Z));let G=Reflect.get(X,Q,Y);return typeof G==="function"?G.bind(X):G}})}function eb6($,Z){return new Proxy($,{get(X,Q,Y){if(Q===W90)return X;if(Q==="create")return async(J,K,W,H)=>X.create(J,K,await um(W,Z),H);if(Q==="update")return async(J,K,W)=>X.update(J,K,await um(W,Z));let G=Reflect.get(X,Q,Y);return typeof G==="function"?G.bind(X):G}})}function xu0($,Z){let X=cm(Z);if(lm1($.connections))$.connections=sb6(cm1($.connections),X);if(lm1($.virtualMcps))$.virtualMcps=eb6(cm1($.virtualMcps),X)}function lm1($){return $!==null&&typeof $==="object"}var tb6,ob6=5242880,rb6=64,W90,ab6;var N90=O(()=>{HW();tb6=/^data:((?:image|audio|video)\/[^;,]+)(?:;[^,]+)?;base64,(.+)$/is,W90=Symbol("assetHoistingTarget"),ab6={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/x-icon":"ico","image/vnd.microsoft.icon":"ico","audio/mpeg":"mp3","audio/mp4":"m4a","audio/wav":"wav","audio/x-wav":"wav","audio/ogg":"ogg","audio/webm":"weba","audio/aac":"aac","video/mp4":"mp4","video/webm":"webm","video/ogg":"ogv","video/quicktime":"mov"}});function W9(){let $=a0();if($.baseUrl)return $.baseUrl;return`http://localhost:${$.port??3000}`}function dm1(){return`http://localhost:${a0().port??3000}`}function fQ(){return a0().publicUrl??W9()}var UZ=O(()=>{k8()});var mm1={};B0(mm1,{backfillThreadAssetsCommand:()=>$y6});import{sql as fu0}from"kysely";async function $y6($){let{dryRun:Z,batch:X}=$,Q=$.baseUrl??W9(),Y=iX();if(!Y)return console.error("[backfill-assets] Object storage (S3) is not configured \u2014 cannot hoist "+"inline media. Set S3_ENDPOINT/S3_BUCKET/S3_ACCESS_KEY_ID/S3_SECRET_ACCESS_KEY and retry."),1;if(/^https?:\/\/localhost(:|\/|$)/.test(Q))console.warn(`[backfill-assets] base URL resolves to "${Q}" \u2014 set BASE_URL `+"(or pass --base-url) to the public origin, or stored media URLs will be wrong.");let G=N6(),{db:J}=G,K;if($.org){let L=await J.selectFrom("organization").select(["id","slug"]).where((D)=>D.or([D("id","=",$.org),D("slug","=",$.org)])).executeTakeFirst();if(!L)return console.error(`[backfill-assets] org "${$.org}" not found (slug or id).`),await Tw(G).catch(()=>{}),1;K=L.id,console.log(`[backfill-assets] scoped to org ${L.slug??L.id} (${L.id})`)}console.log(`[backfill-assets] starting${Z?" (dry-run)":""} \u2014 target=${$.target} baseUrl=${Q} batch=${X}${$.limit?` limit=${$.limit}`:""}`);let W=new Map,H=(L,D,E)=>{let z=`${E}\x00${L}`,j=W.get(z);if(j)return j;let A=cm({objectStorage:iY(Y,L),baseUrl:Q,orgSlug:D??void 0,prefix:E,dryRun:Z});return W.set(z,A),A},U=async(L,D,E,z)=>{let j="";for(;;){let A=$.limit?$.limit-E.scanned:1/0;if(A<=0)break;let P=await L(j,Math.min(X,A));if(P.length===0)break;for(let I of P)j=I.id,E.scanned++,await D(I);console.log(`[backfill-assets] ${z}: scanned=${E.scanned} ${Z?"would-change":"changed"}=${E.changed} errors=${E.errors} cursor=${j}`)}},N={scanned:0,changed:0,errors:0},F={scanned:0,changed:0,errors:0},w={scanned:0,changed:0,errors:0};try{if($.target==="all"||$.target==="threads")await U((L,D)=>J.selectFrom("thread_messages as tm").innerJoin("threads as t","t.id","tm.thread_id").innerJoin("organization as o","o.id","t.organization_id").select(["tm.id as id",fu0`tm.parts`.as("parts"),fu0`tm.metadata`.as("metadata"),"t.organization_id as orgId","o.slug as orgSlug"]).where("tm.id",">",L).$if(!!K,(E)=>E.where("t.organization_id","=",K)).orderBy("tm.id","asc").limit(D).execute(),async(L)=>{try{if(!lm(L.parts)&&!lm(L.metadata))return;let D=H(L.orgId,L.orgSlug,"thread-assets"),E=JSON.parse(L.parts),z=await U90(E,D),j=z!==E,A=L.metadata!==null?JSON.parse(L.metadata):null,P=await U90(A,D),I=P!==A;if(!j&&!I)return;if(N.changed++,Z)return;await J.updateTable("thread_messages").set({parts:j?JSON.stringify(z):L.parts,metadata:I?JSON.stringify(P):L.metadata}).where("id","=",L.id).execute()}catch(D){N.errors++,console.error(`[backfill-assets] thread_message ${L.id} failed, skipping:`,D)}},N,"threads");if($.target==="all"||$.target==="connections")await U((L,D)=>J.selectFrom("connections as c").innerJoin("organization as o","o.id","c.organization_id").select(["c.id as id","c.icon as icon",fu0`c.metadata`.as("metadata"),"c.organization_id as orgId","o.slug as orgSlug"]).where("c.id",">",L).$if(!!K,(E)=>E.where("c.organization_id","=",K)).orderBy("c.id","asc").limit(D).execute(),async(L)=>{try{if(!lm(L.icon)&&!lm(L.metadata))return;let D=H(L.orgId,L.orgSlug,"connection-icons"),E=L.icon!==null?await D(L.icon):L.icon,z=E!==L.icon,j=L.metadata!==null?JSON.parse(L.metadata):null,A=await U90(j,D),P=A!==j;if(!z&&!P)return;if(F.changed++,Z)return;await J.updateTable("connections").set({icon:z?E??null:L.icon,metadata:P?JSON.stringify(A):L.metadata}).where("id","=",L.id).execute()}catch(D){F.errors++,console.error(`[backfill-assets] connection ${L.id} failed, skipping:`,D)}},F,"connections");if($.target==="all"||$.target==="organizations")await U((L,D)=>J.selectFrom("organization as o").select(["o.id as id","o.logo as logo","o.slug as orgSlug"]).where("o.id",">",L).$if(!!K,(E)=>E.where("o.id","=",K)).orderBy("o.id","asc").limit(D).execute(),async(L)=>{try{if(!lm(L.logo))return;let E=await H(L.id,L.orgSlug,"org-logos")(L.logo);if(E===L.logo)return;if(w.changed++,Z)return;await J.updateTable("organization").set({logo:E??null}).where("id","=",L.id).execute()}catch(D){w.errors++,console.error(`[backfill-assets] organization ${L.id} failed, skipping:`,D)}},w,"organizations")}finally{await Tw(G).catch(()=>{})}let B=Z?"would-change":"changed";return console.log("[backfill-assets] done \u2014 "+`threads(scanned=${N.scanned} ${B}=${N.changed} errors=${N.errors}) connections(scanned=${F.scanned} ${B}=${F.changed} errors=${F.errors}) organizations(scanned=${w.scanned} ${B}=${w.changed} errors=${w.errors})`),N.errors+F.errors+w.errors>0?1:0}var lm=($)=>$!==null&&($.includes("data:image/")||$.includes("data:audio/")||$.includes("data:video/"));var im1=O(()=>{e7();Iw();N90();UZ()});async function nm1($){let Z,X,Q=new Promise((J,K)=>{Z=J,X=K});Q.catch(()=>{});let Y=!1,G=Bun.serve({port:$.port??0,hostname:"127.0.0.1",fetch(J){if(Y)return new Response("",{status:204});let K=new URL(J.url),W=K.searchParams.get("code");if(K.searchParams.get("state")!==$.expectedState)return Y=!0,X(Error("OAuth state mismatch")),new Response("State mismatch \u2014 close this tab.",{status:400});if(!W)return Y=!0,X(Error("OAuth callback missing code")),new Response("Missing code \u2014 close this tab.",{status:400});return Y=!0,Z({code:W}),new Response(null,{status:302,headers:{location:$.successRedirectUrl}})}});return{url:`http://127.0.0.1:${G.port}`,waitForCallback:()=>Q,close:()=>G.stop(!0)}}import{createHash as Zy6,randomBytes as Xy6}from"crypto";function tm1(){let $=pm1(Xy6(32)),Z=pm1(Zy6("sha256").update($).digest());return{verifier:$,challenge:Z}}function pm1($){return $.toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var om1=()=>{};import{chmod as Qy6,mkdir as Yy6,readdir as Gy6,readFile as Jy6,rename as Ky6,rm as rm1,writeFile as Wy6}from"fs/promises";import{dirname as Hy6,join as yu0}from"path";function F90($,Z){if(!Z)return yu0($,"session.json");return yu0($,`session.${Uy6(Z)}.json`)}function Uy6($){let Z=$;try{Z=new URL($).host}catch{}return Z.replace(/[^a-zA-Z0-9.-]/g,"_")||"default"}async function bu0($){try{let Z=await Jy6($,"utf8"),X=JSON.parse(Z);if(!Ny6(X))return null;return X}catch{return null}}async function am1($){try{return(await Gy6($)).filter((X)=>/^session(\..+)?\.json$/.test(X)).map((X)=>yu0($,X))}catch{return[]}}async function w90($,Z){let X=await bu0(F90($,Z));if(X)return X;if(Z)return bu0(F90($));for(let Q of await am1($)){let Y=await bu0(Q);if(Y)return Y}return null}async function B90($,Z){let X=F90($,Z.target);await Yy6(Hy6(X),{recursive:!0});let Q=`${X}.tmp`;await Wy6(Q,JSON.stringify(Z,null,2),{mode:384}),await Qy6(Q,384),await Ky6(Q,X)}async function sm1($,Z){if(Z){await rm1(F90($,Z),{force:!0});return}for(let X of await am1($))await rm1(X,{force:!0})}function Ny6($){if(!$||typeof $!=="object")return!1;let Z=$;if(typeof Z.target!=="string"||typeof Z.clientId!=="string"||typeof Z.accessToken!=="string"||typeof Z.createdAt!=="string")return!1;if(!Z.user||typeof Z.user!=="object")return!1;if(typeof Z.user.sub!=="string")return!1;return!0}var O90=()=>{};var $i1={};B0($i1,{performInteractiveLogin:()=>em1,loginCommand:()=>Ly6});import{spawn as Fy6}from"child_process";import{randomUUID as wy6}from"crypto";async function em1($={}){let Z=($.target??By6).replace(/\/$/,""),X=$.fetch??fetch,Q=$.openBrowser??jy6,Y=wy6(),G=tm1(),J=await nm1({expectedState:Y,successRedirectUrl:`${Z}/cli/auth-success`});try{let K=`${J.url}/`,W=await Dy6(X,Z,K),H=new URLSearchParams({client_id:W,redirect_uri:K,response_type:"code",state:Y,scope:Oy6,code_challenge:G.challenge,code_challenge_method:"S256"}),U=`${Z}/login?${H.toString()}`;console.log(`Opening ${U} in your browser...`),await Q(U);let{code:N}=await J.waitForCallback(),F=await Ey6(X,Z,W,N,K,G.verifier);if(!F.id_token)throw Error("Token endpoint returned no id_token");let w=zy6(F.id_token);return{target:Z,clientId:W,user:{sub:w.sub,email:w.email,name:w.name},accessToken:F.access_token,refreshToken:F.refresh_token,expiresAt:F.expires_in?Math.floor(Date.now()/1000)+F.expires_in:void 0,createdAt:new Date().toISOString()}}finally{J.close()}}async function Ly6($){try{let Z=await em1({target:$.target,openBrowser:$.openBrowser,fetch:$.fetch});return await B90($.dataDir,Z),console.log(`Logged in as ${Z.user.email??Z.user.sub}.`),0}catch(Z){return console.error(`Login failed: ${Z instanceof Error?Z.message:String(Z)}`),1}}async function Dy6($,Z,X){let Q=await $(`${Z}/api/auth/mcp/register`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({client_name:"decocms-cli",redirect_uris:[X],grant_types:["authorization_code","refresh_token"],response_types:["code"],token_endpoint_auth_method:"none",application_type:"native"})});if(!Q.ok)throw Error(`Client registration failed: HTTP ${Q.status} ${await Q.text().catch(()=>"")}`);let Y=await Q.json();if(typeof Y?.client_id!=="string")throw Error("Client registration returned no client_id");return Y.client_id}async function Ey6($,Z,X,Q,Y,G){let J=new URLSearchParams({grant_type:"authorization_code",code:Q,redirect_uri:Y,client_id:X,code_verifier:G}),K=await $(`${Z}/api/auth/mcp/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:J.toString()});if(!K.ok)throw Error(`Token exchange failed: HTTP ${K.status} ${await K.text().catch(()=>"")}`);let W=await K.json();if(typeof W?.access_token!=="string")throw Error("Token endpoint returned no access_token");return W}function zy6($){let Z=$.split(".");if(Z.length!==3||!Z[1])throw Error("id_token is not a valid JWT");let X=JSON.parse(Buffer.from(Z[1],"base64url").toString("utf8"));if(typeof X.sub!=="string")throw Error("id_token has no sub claim");return{sub:X.sub,email:typeof X.email==="string"?X.email:void 0,name:typeof X.name==="string"?X.name:void 0}}async function jy6($){let Z,X;switch(process.platform){case"darwin":Z="open",X=[$];break;case"win32":Z="cmd",X=["/c","start","",$];break;default:Z="xdg-open",X=[$];break}await new Promise((Q)=>{let Y=Fy6(Z,X,{stdio:"ignore",detached:!0});Y.on("error",()=>{console.log(`Could not open browser automatically. Please open this URL manually:
179
- ${$}`),Q()}),Y.on("spawn",()=>{Y.unref(),Q()})})}var By6="https://studio.decocms.com",Oy6="openid profile email offline_access";var Zi1=O(()=>{om1();O90()});async function Xi1($,Z=fetch,X=Date.now){if(!$.refreshToken)throw new UW("invalid_grant","Session has no refresh token");let Q=new URLSearchParams({grant_type:"refresh_token",refresh_token:$.refreshToken,client_id:$.clientId}),Y;try{Y=await Z(`${$.target}/api/auth/mcp/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:Q.toString()})}catch(W){throw new UW("transient",W instanceof Error?W.message:String(W))}if(!Y.ok){let W=await Y.text().catch(()=>"");if(Y.status>=400&&Y.status<500)throw new UW("invalid_grant",`HTTP ${Y.status} ${W}`);throw new UW("transient",`HTTP ${Y.status} ${W}`)}let G=await Y.json();if(typeof G.access_token!=="string")throw new UW("transient","Token endpoint returned no access_token");let J=Number(G.expires_in),K=Number.isFinite(J)&&J>0?Math.floor(X()/1000)+J:$.expiresAt;return{...$,accessToken:G.access_token,refreshToken:G.refresh_token??$.refreshToken,expiresAt:K}}var UW;var gu0=O(()=>{UW=class UW extends Error{kind;constructor($,Z){super(Z);this.name="RefreshFailedError",this.kind=$}}});async function Qi1($){let Z=await w90($.dataDir,$.target);if(!Z)return null;let X=$.now??Date.now;if(!Ay6(Z,X()))return Z;try{let Q=await Xi1(Z,$.fetch,X);return await B90($.dataDir,Q),Q}catch(Q){if(Q instanceof UW&&Q.kind==="invalid_grant")return null;throw Q}}function Ay6($,Z){if($.expiresAt===void 0)return!1;let X=Math.floor(Z/1000);return $.expiresAt-Py6<X}var Py6=60;var Yi1=O(()=>{gu0();O90()});var Gi1={};B0(Gi1,{whoamiCommand:()=>Ty6});async function Ty6($){let Z;try{Z=await Qi1({dataDir:$.dataDir,fetch:$.fetch,now:$.now})}catch(X){if(X instanceof UW&&X.kind==="transient")return console.error(`Could not refresh session: ${X.message}. Run \`decocms auth login\` to authenticate.`),1;throw X}if(!Z)return console.error("Not logged in. Run `decocms auth login` to authenticate."),1;return console.log(`Target: ${Z.target}`),console.log(`User: ${Z.user.email??Z.user.sub}`),0}var Ji1=O(()=>{Yi1();gu0()});var Ki1={};B0(Ki1,{logoutCommand:()=>Ry6});async function Ry6($){if(!await w90($.dataDir))return console.log("Already logged out."),0;return await sm1($.dataDir),console.log("Logged out."),0}var Wi1=O(()=>{O90()});var E90={};B0(E90,{printBanner:()=>qy6,bannerLines:()=>Hi1,BANNER_LINES:()=>L90,BANNER_GRADIENT:()=>D90});function Iy6($){let Z=Number.parseInt($.slice(1),16);return[Z>>16&255,Z>>8&255,Z&255]}function Hi1($){let Z=L90.map((X,Q)=>{let[Y,G,J]=Iy6(D90[Q]);return`\x1B[38;2;${Y};${G};${J}m${X}\x1B[39m`});if($!==void 0)Z.push(`\x1B[2m v${$}\x1B[22m`);return Z}function qy6($){console.log("");for(let Z of Hi1($))console.log(Z);console.log("")}var L90,D90;var dm=O(()=>{L90=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588 \u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588 \u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2588 \u2591 \u2588\u2588\u2588 \u2591\u2591\u2591 \u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588"," \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588"," \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588\u2591\u2591\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588"," \u2591\u2588\u2588\u2588 \u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591 \u2588\u2591\u2591\u2588\u2588\u2588 \u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2588 \u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591 ","\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591\u2591\u2591 "],D90=["#00ff64","#00ee5e","#00dc56","#00c84e","#00b444","#00a03c","#008832","#006e28"]});import{randomBytes as My6}from"crypto";import{mkdirSync as Vy6,readFileSync as ky6,writeFileSync as Sy6}from"fs";import{join as Cy6}from"path";function Ui1($){let Z=Cy6($,_y6);try{let Q=ky6(Z,"utf8").trim();if(Q)return Q}catch{}let X=My6(32).toString("base64");return Vy6($,{recursive:!0}),Sy6(Z,X,{mode:384}),X}var _y6="local-auth-secret";var Ni1=()=>{};var Fi1={};B0(Fi1,{migrateBetterAuth:()=>hu0});import{getMigrations as vy6}from"better-auth/db";import{sso as xy6}from"@better-auth/sso";import{organization as fy6}from"@decocms/better-auth/plugins";import{admin as by6,apiKey as yy6,jwt as gy6,magicLink as hy6,mcp as uy6,openAPI as cy6}from"better-auth/plugins";import{emailOTP as ly6}from"better-auth/plugins/email-otp";async function hu0($){let X={database:gm($||Aw()),plugins:[fy6({dynamicAccessControl:{enabled:!0,enableCustomResources:!0}}),by6(),yy6(),gy6(),cy6(),uy6({loginPage:"/login"}),xy6(),hy6({sendMagicLink:async()=>{}}),ly6({sendVerificationOTP:async()=>{}})]},{toBeAdded:Q,toBeCreated:Y,runMigrations:G}=await vy6(X);if(!Q.length&&!Y.length)return"up to date";return await G(),`${Y.length+Q.length} table(s) migrated`}var uu0=O(()=>{e7()});var cu0={};B0(cu0,{up:()=>dy6,down:()=>my6});import{sql as NW}from"kysely";async function dy6($){await $.schema.createTable("connections").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organizationId","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("createdById","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("name","text",(Z)=>Z.notNull()).addColumn("description","text").addColumn("icon","text").addColumn("appName","text").addColumn("appId","text").addColumn("connectionType","text",(Z)=>Z.notNull()).addColumn("connectionUrl","text",(Z)=>Z.notNull()).addColumn("connectionToken","text").addColumn("connectionHeaders","text").addColumn("oauthConfig","text").addColumn("metadata","text").addColumn("tools","text").addColumn("bindings","text").addColumn("status","text",(Z)=>Z.notNull().defaultTo("active")).addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("api_keys").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("userId","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("name","text",(Z)=>Z.notNull()).addColumn("hashedKey","text",(Z)=>Z.notNull().unique()).addColumn("permissions","text",(Z)=>Z.notNull()).addColumn("expiresAt","text").addColumn("remaining","integer").addColumn("metadata","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("audit_logs").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organizationId","text").addColumn("userId","text",(Z)=>Z.references("user.id").onDelete("set null")).addColumn("connectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("toolName","text",(Z)=>Z.notNull()).addColumn("allowed","integer",(Z)=>Z.notNull()).addColumn("duration","integer").addColumn("timestamp","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("requestMetadata","text").execute(),await $.schema.createTable("oauth_clients").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("clientId","text",(Z)=>Z.notNull().unique()).addColumn("clientSecret","text").addColumn("clientName","text",(Z)=>Z.notNull()).addColumn("redirectUris","text",(Z)=>Z.notNull()).addColumn("grantTypes","text",(Z)=>Z.notNull()).addColumn("scope","text").addColumn("clientUri","text").addColumn("logoUri","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("oauth_authorization_codes").addColumn("code","text",(Z)=>Z.primaryKey()).addColumn("clientId","text",(Z)=>Z.notNull().references("oauth_clients.clientId").onDelete("cascade")).addColumn("userId","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("redirectUri","text",(Z)=>Z.notNull()).addColumn("scope","text").addColumn("codeChallenge","text").addColumn("codeChallengeMethod","text").addColumn("expiresAt","text",(Z)=>Z.notNull()).addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("oauth_refresh_tokens").addColumn("token","text",(Z)=>Z.primaryKey()).addColumn("clientId","text",(Z)=>Z.notNull().references("oauth_clients.clientId").onDelete("cascade")).addColumn("userId","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("scope","text").addColumn("expiresAt","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("downstream_tokens").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("connectionId","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("userId","text",(Z)=>Z.references("user.id").onDelete("cascade")).addColumn("accessToken","text",(Z)=>Z.notNull()).addColumn("refreshToken","text").addColumn("scope","text").addColumn("expiresAt","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createIndex("idx_connections_organizationId").on("connections").column("organizationId").execute(),await $.schema.createIndex("idx_audit_logs_organizationId").on("audit_logs").column("organizationId").execute(),await $.schema.createIndex("idx_audit_logs_userId").on("audit_logs").column("userId").execute(),await $.schema.createIndex("idx_audit_logs_timestamp").on("audit_logs").column("timestamp").execute()}async function my6($){await $.schema.dropTable("downstream_tokens").execute(),await $.schema.dropTable("oauth_refresh_tokens").execute(),await $.schema.dropTable("oauth_authorization_codes").execute(),await $.schema.dropTable("oauth_clients").execute(),await $.schema.dropTable("audit_logs").execute(),await $.schema.dropTable("api_keys").execute(),await $.schema.dropTable("connections").execute()}var wi1=()=>{};var lu0={};B0(lu0,{up:()=>iy6,down:()=>ny6});import{sql as Bi1}from"kysely";async function iy6($){await $.schema.createTable("organization_settings").addColumn("organizationId","text",(Z)=>Z.primaryKey().references("organization.id").onDelete("cascade")).addColumn("modelsBindingConnectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(Bi1`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(Bi1`CURRENT_TIMESTAMP`)).execute()}async function ny6($){await $.schema.dropTable("organization_settings").execute()}var Oi1=()=>{};var du0={};B0(du0,{up:()=>py6,down:()=>ty6});async function py6($){await $.schema.alterTable("connections").renameColumn("name","title").execute(),await $.schema.alterTable("connections").renameColumn("createdById","created_by").execute(),await $.schema.alterTable("connections").renameColumn("createdAt","created_at").execute(),await $.schema.alterTable("connections").renameColumn("updatedAt","updated_at").execute(),await $.schema.alterTable("connections").renameColumn("organizationId","organization_id").execute(),await $.schema.alterTable("connections").renameColumn("connectionType","connection_type").execute(),await $.schema.alterTable("connections").renameColumn("connectionUrl","connection_url").execute(),await $.schema.alterTable("connections").renameColumn("connectionToken","connection_token").execute(),await $.schema.alterTable("connections").renameColumn("connectionHeaders","connection_headers").execute(),await $.schema.alterTable("connections").renameColumn("oauthConfig","oauth_config").execute(),await $.schema.alterTable("connections").renameColumn("appName","app_name").execute(),await $.schema.alterTable("connections").renameColumn("appId","app_id").execute()}async function ty6($){await $.schema.alterTable("connections").renameColumn("title","name").execute(),await $.schema.alterTable("connections").renameColumn("created_by","createdById").execute(),await $.schema.alterTable("connections").renameColumn("created_at","createdAt").execute(),await $.schema.alterTable("connections").renameColumn("updated_at","updatedAt").execute(),await $.schema.alterTable("connections").renameColumn("organization_id","organizationId").execute(),await $.schema.alterTable("connections").renameColumn("connection_type","connectionType").execute(),await $.schema.alterTable("connections").renameColumn("connection_url","connectionUrl").execute(),await $.schema.alterTable("connections").renameColumn("connection_token","connectionToken").execute(),await $.schema.alterTable("connections").renameColumn("connection_headers","connectionHeaders").execute(),await $.schema.alterTable("connections").renameColumn("oauth_config","oauthConfig").execute(),await $.schema.alterTable("connections").renameColumn("app_name","appName").execute(),await $.schema.alterTable("connections").renameColumn("app_id","appId").execute()}var mu0={};B0(mu0,{up:()=>oy6,down:()=>ry6});async function oy6($){await $.schema.createTable("organization_settings_new").addColumn("organizationId","text",(Z)=>Z.primaryKey().references("organization.id").onDelete("cascade")).addColumn("createdAt","text",(Z)=>Z.notNull()).addColumn("updatedAt","text",(Z)=>Z.notNull()).execute(),await $.insertInto("organization_settings_new").columns(["organizationId","createdAt","updatedAt"]).expression((Z)=>Z.selectFrom("organization_settings").select(["organizationId","createdAt","updatedAt"])).execute(),await $.schema.dropTable("organization_settings").execute(),await $.schema.alterTable("organization_settings_new").renameTo("organization_settings").execute()}async function ry6($){await $.schema.createTable("organization_settings_new").addColumn("organizationId","text",(Z)=>Z.primaryKey().references("organization.id").onDelete("cascade")).addColumn("modelsBindingConnectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("createdAt","text",(Z)=>Z.notNull()).addColumn("updatedAt","text",(Z)=>Z.notNull()).execute(),await $.insertInto("organization_settings_new").columns(["organizationId","modelsBindingConnectionId","createdAt","updatedAt"]).expression((Z)=>Z.selectFrom("organization_settings").select(["organizationId",Z.val(null).as("modelsBindingConnectionId"),"createdAt","updatedAt"])).execute(),await $.schema.dropTable("organization_settings").execute(),await $.schema.alterTable("organization_settings_new").renameTo("organization_settings").execute()}var iu0={};B0(iu0,{up:()=>ay6,down:()=>sy6});async function ay6($){await $.schema.alterTable("connections").addColumn("configuration_state","text").execute(),await $.schema.alterTable("connections").addColumn("configuration_scopes","text").execute()}async function sy6($){await $.schema.alterTable("connections").dropColumn("configuration_state").execute(),await $.schema.alterTable("connections").dropColumn("configuration_scopes").execute()}var nu0={};B0(nu0,{up:()=>$g6,down:()=>Zg6});import{sql as ey6}from"kysely";async function $g6($){await $.schema.alterTable("organization_settings").addColumn("sidebar_items",ey6`text`).execute()}async function Zg6($){await $.schema.alterTable("organization_settings").dropColumn("sidebar_items").execute()}var Li1=()=>{};var pu0={};B0(pu0,{up:()=>Xg6,down:()=>Qg6});async function Xg6($){await $.schema.createTable("monitoring_logs").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("connection_id","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("connection_title","text",(Z)=>Z.notNull()).addColumn("tool_name","text",(Z)=>Z.notNull()).addColumn("input","text",(Z)=>Z.notNull()).addColumn("output","text",(Z)=>Z.notNull()).addColumn("is_error","integer",(Z)=>Z.notNull()).addColumn("error_message","text").addColumn("duration_ms","integer",(Z)=>Z.notNull()).addColumn("timestamp","text",(Z)=>Z.notNull()).addColumn("user_id","text").addColumn("request_id","text",(Z)=>Z.notNull()).execute(),await $.schema.createIndex("monitoring_logs_org_timestamp").on("monitoring_logs").columns(["organization_id","timestamp"]).execute(),await $.schema.createIndex("monitoring_logs_connection_timestamp").on("monitoring_logs").columns(["connection_id","timestamp"]).execute(),await $.schema.createIndex("monitoring_logs_is_error").on("monitoring_logs").columns(["organization_id","is_error","timestamp"]).execute()}async function Qg6($){await $.schema.dropIndex("monitoring_logs_is_error").execute(),await $.schema.dropIndex("monitoring_logs_connection_timestamp").execute(),await $.schema.dropIndex("monitoring_logs_org_timestamp").execute(),await $.schema.dropTable("monitoring_logs").execute()}var tu0={};B0(tu0,{up:()=>Yg6,down:()=>Gg6});import{sql as mm}from"kysely";async function Yg6($){await $.schema.createTable("events").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("type","text",(Z)=>Z.notNull()).addColumn("source","text",(Z)=>Z.notNull()).addColumn("specversion","text",(Z)=>Z.notNull().defaultTo("1.0")).addColumn("subject","text").addColumn("time","text",(Z)=>Z.notNull()).addColumn("datacontenttype","text",(Z)=>Z.notNull().defaultTo("application/json")).addColumn("dataschema","text").addColumn("data","text").addColumn("cron","varchar(255)").addColumn("status","text",(Z)=>Z.notNull().defaultTo("pending")).addColumn("attempts","integer",(Z)=>Z.notNull().defaultTo(0)).addColumn("last_error","text").addColumn("next_retry_at","text").addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("event_subscriptions").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("connection_id","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("publisher","text").addColumn("event_type","text",(Z)=>Z.notNull()).addColumn("filter","text").addColumn("enabled","integer",(Z)=>Z.notNull().defaultTo(1)).addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("event_deliveries").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("event_id","text",(Z)=>Z.notNull()).addColumn("subscription_id","text",(Z)=>Z.notNull().references("event_subscriptions.id").onDelete("cascade")).addColumn("status","text",(Z)=>Z.notNull().defaultTo("pending")).addColumn("attempts","integer",(Z)=>Z.notNull().defaultTo(0)).addColumn("last_error","text").addColumn("delivered_at","text").addColumn("next_retry_at","text").addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).execute(),await $.schema.createIndex("idx_events_org_status").on("events").columns(["organization_id","status"]).execute(),await $.schema.createIndex("idx_events_source").on("events").columns(["source"]).execute(),await $.schema.createIndex("idx_events_type").on("events").columns(["type"]).execute(),await $.schema.createIndex("idx_events_retry").on("events").columns(["status","next_retry_at"]).execute(),await $.schema.createIndex("idx_subscriptions_connection").on("event_subscriptions").columns(["connection_id"]).execute(),await $.schema.createIndex("idx_subscriptions_type").on("event_subscriptions").columns(["event_type"]).execute(),await $.schema.createIndex("idx_subscriptions_org_enabled").on("event_subscriptions").columns(["organization_id","enabled"]).execute(),await $.schema.createIndex("idx_subscriptions_unique").on("event_subscriptions").columns(["connection_id","event_type","publisher","filter"]).unique().execute(),await $.schema.createIndex("idx_deliveries_event").on("event_deliveries").columns(["event_id"]).execute(),await $.schema.createIndex("idx_deliveries_subscription_status").on("event_deliveries").columns(["subscription_id","status"]).execute(),await $.schema.createIndex("idx_deliveries_retry").on("event_deliveries").columns(["status","next_retry_at"]).execute()}async function Gg6($){await $.schema.dropIndex("idx_deliveries_retry").execute(),await $.schema.dropIndex("idx_deliveries_subscription_status").execute(),await $.schema.dropIndex("idx_deliveries_event").execute(),await $.schema.dropIndex("idx_subscriptions_unique").execute(),await $.schema.dropIndex("idx_subscriptions_org_enabled").execute(),await $.schema.dropIndex("idx_subscriptions_type").execute(),await $.schema.dropIndex("idx_subscriptions_connection").execute(),await $.schema.dropIndex("idx_events_retry").execute(),await $.schema.dropIndex("idx_events_type").execute(),await $.schema.dropIndex("idx_events_source").execute(),await $.schema.dropIndex("idx_events_org_status").execute(),await $.schema.dropTable("event_deliveries").execute(),await $.schema.dropTable("event_subscriptions").execute(),await $.schema.dropTable("events").execute()}var Di1=()=>{};var ou0={};B0(ou0,{up:()=>Kg6,down:()=>Wg6});import{sql as Jg6}from"kysely";async function Kg6($){await $.schema.dropTable("audit_logs").ifExists().execute()}async function Wg6($){await $.schema.createTable("audit_logs").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organizationId","text").addColumn("userId","text",(Z)=>Z.references("user.id").onDelete("set null")).addColumn("connectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("toolName","text",(Z)=>Z.notNull()).addColumn("allowed","integer",(Z)=>Z.notNull()).addColumn("duration","integer").addColumn("timestamp","text",(Z)=>Z.notNull().defaultTo(Jg6`CURRENT_TIMESTAMP`)).addColumn("requestMetadata","text").execute(),await $.schema.createIndex("idx_audit_logs_organizationId").on("audit_logs").column("organizationId").execute(),await $.schema.createIndex("idx_audit_logs_userId").on("audit_logs").column("userId").execute(),await $.schema.createIndex("idx_audit_logs_timestamp").on("audit_logs").column("timestamp").execute()}var Ei1=()=>{};var ru0={};B0(ru0,{up:()=>Hg6,down:()=>Ug6});import{sql as z90}from"kysely";async function Hg6($){await $.schema.createTable("gateways").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("tool_selection_strategy","text").addColumn("status","text",(Z)=>Z.notNull().defaultTo("active")).addColumn("is_default","integer",(Z)=>Z.notNull().defaultTo(0)).addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(z90`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(z90`CURRENT_TIMESTAMP`)).addColumn("created_by","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("updated_by","text").execute(),await $.schema.createTable("gateway_connections").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("gateway_id","text",(Z)=>Z.notNull().references("gateways.id").onDelete("cascade")).addColumn("connection_id","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("selected_tools","text").addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(z90`CURRENT_TIMESTAMP`)).execute(),await $.schema.createIndex("idx_gateways_org").on("gateways").columns(["organization_id"]).execute(),await $.schema.createIndex("idx_gateways_org_status").on("gateways").columns(["organization_id","status"]).execute(),await z90`CREATE UNIQUE INDEX idx_gateways_default_per_org ON gateways (organization_id) WHERE is_default = 1`.execute($),await $.schema.createIndex("idx_gateway_connections_gateway").on("gateway_connections").columns(["gateway_id"]).execute(),await $.schema.createIndex("idx_gateway_connections_connection").on("gateway_connections").columns(["connection_id"]).execute(),await $.schema.createIndex("idx_gateway_connections_unique").on("gateway_connections").columns(["gateway_id","connection_id"]).unique().execute()}async function Ug6($){await $.schema.dropIndex("idx_gateway_connections_unique").execute(),await $.schema.dropIndex("idx_gateway_connections_connection").execute(),await $.schema.dropIndex("idx_gateway_connections_gateway").execute(),await $.schema.dropIndex("idx_gateways_default_per_org").execute(),await $.schema.dropIndex("idx_gateways_org_status").execute(),await $.schema.dropIndex("idx_gateways_org").execute(),await $.schema.dropTable("gateway_connections").execute(),await $.schema.dropTable("gateways").execute()}var zi1=()=>{};var au0={};B0(au0,{up:()=>Ng6,down:()=>Fg6});async function Ng6($){await $.schema.alterTable("gateways").addColumn("icon","text").execute()}async function Fg6($){await $.schema.alterTable("gateways").dropColumn("icon").execute()}var su0={};B0(su0,{up:()=>wg6,down:()=>Bg6});import{sql as j90}from"kysely";async function wg6($){await $.schema.alterTable("gateways").addColumn("tool_selection_mode","text",(Z)=>Z.notNull().defaultTo("inclusion")).execute(),await j90`
179
+ ${$}`),Q()}),Y.on("spawn",()=>{Y.unref(),Q()})})}var By6="https://studio.decocms.com",Oy6="openid profile email offline_access";var Zi1=O(()=>{om1();O90()});async function Xi1($,Z=fetch,X=Date.now){if(!$.refreshToken)throw new UW("invalid_grant","Session has no refresh token");let Q=new URLSearchParams({grant_type:"refresh_token",refresh_token:$.refreshToken,client_id:$.clientId}),Y;try{Y=await Z(`${$.target}/api/auth/mcp/token`,{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:Q.toString()})}catch(H){throw new UW("transient",H instanceof Error?H.message:String(H))}if(!Y.ok){let H=await Y.text().catch(()=>"");if(Y.status>=400&&Y.status<500)throw new UW("invalid_grant",`HTTP ${Y.status} ${H}`);throw new UW("transient",`HTTP ${Y.status} ${H}`)}let G=await Y.json();if(typeof G.access_token!=="string"||!G.access_token)throw new UW("transient","Token endpoint returned no access_token");let J=Number(G.expires_in),K=Number.isFinite(J)&&J>0?Math.floor(X()/1000)+J:$.expiresAt,W=typeof G.refresh_token==="string"&&G.refresh_token?G.refresh_token:$.refreshToken;return{...$,accessToken:G.access_token,refreshToken:W,expiresAt:K}}var UW;var gu0=O(()=>{UW=class UW extends Error{kind;constructor($,Z){super(Z);this.name="RefreshFailedError",this.kind=$}}});async function Qi1($){let Z=await w90($.dataDir,$.target);if(!Z)return null;let X=$.now??Date.now;if(!Ay6(Z,X()))return Z;try{let Q=await Xi1(Z,$.fetch,X);return await B90($.dataDir,Q),Q}catch(Q){if(Q instanceof UW&&Q.kind==="invalid_grant")return null;throw Q}}function Ay6($,Z){if($.expiresAt===void 0)return!1;let X=Math.floor(Z/1000);return $.expiresAt-Py6<X}var Py6=60;var Yi1=O(()=>{gu0();O90()});var Gi1={};B0(Gi1,{whoamiCommand:()=>Ty6});async function Ty6($){let Z;try{Z=await Qi1({dataDir:$.dataDir,fetch:$.fetch,now:$.now})}catch(X){if(X instanceof UW&&X.kind==="transient")return console.error(`Could not refresh session: ${X.message}. Run \`decocms auth login\` to authenticate.`),1;throw X}if(!Z)return console.error("Not logged in. Run `decocms auth login` to authenticate."),1;return console.log(`Target: ${Z.target}`),console.log(`User: ${Z.user.email??Z.user.sub}`),0}var Ji1=O(()=>{Yi1();gu0()});var Ki1={};B0(Ki1,{logoutCommand:()=>Ry6});async function Ry6($){if(!await w90($.dataDir))return console.log("Already logged out."),0;return await sm1($.dataDir),console.log("Logged out."),0}var Wi1=O(()=>{O90()});var E90={};B0(E90,{printBanner:()=>qy6,bannerLines:()=>Hi1,BANNER_LINES:()=>L90,BANNER_GRADIENT:()=>D90});function Iy6($){let Z=Number.parseInt($.slice(1),16);return[Z>>16&255,Z>>8&255,Z&255]}function Hi1($){let Z=L90.map((X,Q)=>{let[Y,G,J]=Iy6(D90[Q]);return`\x1B[38;2;${Y};${G};${J}m${X}\x1B[39m`});if($!==void 0)Z.push(`\x1B[2m v${$}\x1B[22m`);return Z}function qy6($){console.log("");for(let Z of Hi1($))console.log(Z);console.log("")}var L90,D90;var dm=O(()=>{L90=[" \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588 ","\u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588 \u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588 \u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2588 \u2591 \u2588\u2588\u2588 \u2591\u2591\u2591 \u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588"," \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588"," \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588\u2591\u2591\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591\u2588\u2588\u2588"," \u2591\u2588\u2588\u2588 \u2588\u2588\u2588 \u2591\u2588\u2588\u2588 \u2591 \u2588\u2591\u2591\u2588\u2588\u2588 \u2588\u2588\u2588\u2591\u2591\u2588\u2588\u2588 \u2588\u2588\u2588 "," \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591 ","\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 \u2591\u2591\u2591\u2591\u2591\u2591\u2591 "],D90=["#00ff64","#00ee5e","#00dc56","#00c84e","#00b444","#00a03c","#008832","#006e28"]});import{randomBytes as My6}from"crypto";import{mkdirSync as Vy6,readFileSync as ky6,writeFileSync as Sy6}from"fs";import{join as Cy6}from"path";function Ui1($){let Z=Cy6($,_y6);try{let Q=ky6(Z,"utf8").trim();if(Q)return Q}catch{}let X=My6(32).toString("base64");return Vy6($,{recursive:!0}),Sy6(Z,X,{mode:384}),X}var _y6="local-auth-secret";var Ni1=()=>{};var Fi1={};B0(Fi1,{migrateBetterAuth:()=>hu0});import{getMigrations as vy6}from"better-auth/db";import{sso as xy6}from"@better-auth/sso";import{organization as fy6}from"@decocms/better-auth/plugins";import{admin as by6,apiKey as yy6,jwt as gy6,magicLink as hy6,mcp as uy6,openAPI as cy6}from"better-auth/plugins";import{emailOTP as ly6}from"better-auth/plugins/email-otp";async function hu0($){let X={database:gm($||Aw()),plugins:[fy6({dynamicAccessControl:{enabled:!0,enableCustomResources:!0}}),by6(),yy6(),gy6(),cy6(),uy6({loginPage:"/login"}),xy6(),hy6({sendMagicLink:async()=>{}}),ly6({sendVerificationOTP:async()=>{}})]},{toBeAdded:Q,toBeCreated:Y,runMigrations:G}=await vy6(X);if(!Q.length&&!Y.length)return"up to date";return await G(),`${Y.length+Q.length} table(s) migrated`}var uu0=O(()=>{e7()});var cu0={};B0(cu0,{up:()=>dy6,down:()=>my6});import{sql as NW}from"kysely";async function dy6($){await $.schema.createTable("connections").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organizationId","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("createdById","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("name","text",(Z)=>Z.notNull()).addColumn("description","text").addColumn("icon","text").addColumn("appName","text").addColumn("appId","text").addColumn("connectionType","text",(Z)=>Z.notNull()).addColumn("connectionUrl","text",(Z)=>Z.notNull()).addColumn("connectionToken","text").addColumn("connectionHeaders","text").addColumn("oauthConfig","text").addColumn("metadata","text").addColumn("tools","text").addColumn("bindings","text").addColumn("status","text",(Z)=>Z.notNull().defaultTo("active")).addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("api_keys").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("userId","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("name","text",(Z)=>Z.notNull()).addColumn("hashedKey","text",(Z)=>Z.notNull().unique()).addColumn("permissions","text",(Z)=>Z.notNull()).addColumn("expiresAt","text").addColumn("remaining","integer").addColumn("metadata","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("audit_logs").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organizationId","text").addColumn("userId","text",(Z)=>Z.references("user.id").onDelete("set null")).addColumn("connectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("toolName","text",(Z)=>Z.notNull()).addColumn("allowed","integer",(Z)=>Z.notNull()).addColumn("duration","integer").addColumn("timestamp","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("requestMetadata","text").execute(),await $.schema.createTable("oauth_clients").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("clientId","text",(Z)=>Z.notNull().unique()).addColumn("clientSecret","text").addColumn("clientName","text",(Z)=>Z.notNull()).addColumn("redirectUris","text",(Z)=>Z.notNull()).addColumn("grantTypes","text",(Z)=>Z.notNull()).addColumn("scope","text").addColumn("clientUri","text").addColumn("logoUri","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("oauth_authorization_codes").addColumn("code","text",(Z)=>Z.primaryKey()).addColumn("clientId","text",(Z)=>Z.notNull().references("oauth_clients.clientId").onDelete("cascade")).addColumn("userId","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("redirectUri","text",(Z)=>Z.notNull()).addColumn("scope","text").addColumn("codeChallenge","text").addColumn("codeChallengeMethod","text").addColumn("expiresAt","text",(Z)=>Z.notNull()).addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("oauth_refresh_tokens").addColumn("token","text",(Z)=>Z.primaryKey()).addColumn("clientId","text",(Z)=>Z.notNull().references("oauth_clients.clientId").onDelete("cascade")).addColumn("userId","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("scope","text").addColumn("expiresAt","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("downstream_tokens").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("connectionId","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("userId","text",(Z)=>Z.references("user.id").onDelete("cascade")).addColumn("accessToken","text",(Z)=>Z.notNull()).addColumn("refreshToken","text").addColumn("scope","text").addColumn("expiresAt","text").addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(NW`CURRENT_TIMESTAMP`)).execute(),await $.schema.createIndex("idx_connections_organizationId").on("connections").column("organizationId").execute(),await $.schema.createIndex("idx_audit_logs_organizationId").on("audit_logs").column("organizationId").execute(),await $.schema.createIndex("idx_audit_logs_userId").on("audit_logs").column("userId").execute(),await $.schema.createIndex("idx_audit_logs_timestamp").on("audit_logs").column("timestamp").execute()}async function my6($){await $.schema.dropTable("downstream_tokens").execute(),await $.schema.dropTable("oauth_refresh_tokens").execute(),await $.schema.dropTable("oauth_authorization_codes").execute(),await $.schema.dropTable("oauth_clients").execute(),await $.schema.dropTable("audit_logs").execute(),await $.schema.dropTable("api_keys").execute(),await $.schema.dropTable("connections").execute()}var wi1=()=>{};var lu0={};B0(lu0,{up:()=>iy6,down:()=>ny6});import{sql as Bi1}from"kysely";async function iy6($){await $.schema.createTable("organization_settings").addColumn("organizationId","text",(Z)=>Z.primaryKey().references("organization.id").onDelete("cascade")).addColumn("modelsBindingConnectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("createdAt","text",(Z)=>Z.notNull().defaultTo(Bi1`CURRENT_TIMESTAMP`)).addColumn("updatedAt","text",(Z)=>Z.notNull().defaultTo(Bi1`CURRENT_TIMESTAMP`)).execute()}async function ny6($){await $.schema.dropTable("organization_settings").execute()}var Oi1=()=>{};var du0={};B0(du0,{up:()=>py6,down:()=>ty6});async function py6($){await $.schema.alterTable("connections").renameColumn("name","title").execute(),await $.schema.alterTable("connections").renameColumn("createdById","created_by").execute(),await $.schema.alterTable("connections").renameColumn("createdAt","created_at").execute(),await $.schema.alterTable("connections").renameColumn("updatedAt","updated_at").execute(),await $.schema.alterTable("connections").renameColumn("organizationId","organization_id").execute(),await $.schema.alterTable("connections").renameColumn("connectionType","connection_type").execute(),await $.schema.alterTable("connections").renameColumn("connectionUrl","connection_url").execute(),await $.schema.alterTable("connections").renameColumn("connectionToken","connection_token").execute(),await $.schema.alterTable("connections").renameColumn("connectionHeaders","connection_headers").execute(),await $.schema.alterTable("connections").renameColumn("oauthConfig","oauth_config").execute(),await $.schema.alterTable("connections").renameColumn("appName","app_name").execute(),await $.schema.alterTable("connections").renameColumn("appId","app_id").execute()}async function ty6($){await $.schema.alterTable("connections").renameColumn("title","name").execute(),await $.schema.alterTable("connections").renameColumn("created_by","createdById").execute(),await $.schema.alterTable("connections").renameColumn("created_at","createdAt").execute(),await $.schema.alterTable("connections").renameColumn("updated_at","updatedAt").execute(),await $.schema.alterTable("connections").renameColumn("organization_id","organizationId").execute(),await $.schema.alterTable("connections").renameColumn("connection_type","connectionType").execute(),await $.schema.alterTable("connections").renameColumn("connection_url","connectionUrl").execute(),await $.schema.alterTable("connections").renameColumn("connection_token","connectionToken").execute(),await $.schema.alterTable("connections").renameColumn("connection_headers","connectionHeaders").execute(),await $.schema.alterTable("connections").renameColumn("oauth_config","oauthConfig").execute(),await $.schema.alterTable("connections").renameColumn("app_name","appName").execute(),await $.schema.alterTable("connections").renameColumn("app_id","appId").execute()}var mu0={};B0(mu0,{up:()=>oy6,down:()=>ry6});async function oy6($){await $.schema.createTable("organization_settings_new").addColumn("organizationId","text",(Z)=>Z.primaryKey().references("organization.id").onDelete("cascade")).addColumn("createdAt","text",(Z)=>Z.notNull()).addColumn("updatedAt","text",(Z)=>Z.notNull()).execute(),await $.insertInto("organization_settings_new").columns(["organizationId","createdAt","updatedAt"]).expression((Z)=>Z.selectFrom("organization_settings").select(["organizationId","createdAt","updatedAt"])).execute(),await $.schema.dropTable("organization_settings").execute(),await $.schema.alterTable("organization_settings_new").renameTo("organization_settings").execute()}async function ry6($){await $.schema.createTable("organization_settings_new").addColumn("organizationId","text",(Z)=>Z.primaryKey().references("organization.id").onDelete("cascade")).addColumn("modelsBindingConnectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("createdAt","text",(Z)=>Z.notNull()).addColumn("updatedAt","text",(Z)=>Z.notNull()).execute(),await $.insertInto("organization_settings_new").columns(["organizationId","modelsBindingConnectionId","createdAt","updatedAt"]).expression((Z)=>Z.selectFrom("organization_settings").select(["organizationId",Z.val(null).as("modelsBindingConnectionId"),"createdAt","updatedAt"])).execute(),await $.schema.dropTable("organization_settings").execute(),await $.schema.alterTable("organization_settings_new").renameTo("organization_settings").execute()}var iu0={};B0(iu0,{up:()=>ay6,down:()=>sy6});async function ay6($){await $.schema.alterTable("connections").addColumn("configuration_state","text").execute(),await $.schema.alterTable("connections").addColumn("configuration_scopes","text").execute()}async function sy6($){await $.schema.alterTable("connections").dropColumn("configuration_state").execute(),await $.schema.alterTable("connections").dropColumn("configuration_scopes").execute()}var nu0={};B0(nu0,{up:()=>$g6,down:()=>Zg6});import{sql as ey6}from"kysely";async function $g6($){await $.schema.alterTable("organization_settings").addColumn("sidebar_items",ey6`text`).execute()}async function Zg6($){await $.schema.alterTable("organization_settings").dropColumn("sidebar_items").execute()}var Li1=()=>{};var pu0={};B0(pu0,{up:()=>Xg6,down:()=>Qg6});async function Xg6($){await $.schema.createTable("monitoring_logs").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("connection_id","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("connection_title","text",(Z)=>Z.notNull()).addColumn("tool_name","text",(Z)=>Z.notNull()).addColumn("input","text",(Z)=>Z.notNull()).addColumn("output","text",(Z)=>Z.notNull()).addColumn("is_error","integer",(Z)=>Z.notNull()).addColumn("error_message","text").addColumn("duration_ms","integer",(Z)=>Z.notNull()).addColumn("timestamp","text",(Z)=>Z.notNull()).addColumn("user_id","text").addColumn("request_id","text",(Z)=>Z.notNull()).execute(),await $.schema.createIndex("monitoring_logs_org_timestamp").on("monitoring_logs").columns(["organization_id","timestamp"]).execute(),await $.schema.createIndex("monitoring_logs_connection_timestamp").on("monitoring_logs").columns(["connection_id","timestamp"]).execute(),await $.schema.createIndex("monitoring_logs_is_error").on("monitoring_logs").columns(["organization_id","is_error","timestamp"]).execute()}async function Qg6($){await $.schema.dropIndex("monitoring_logs_is_error").execute(),await $.schema.dropIndex("monitoring_logs_connection_timestamp").execute(),await $.schema.dropIndex("monitoring_logs_org_timestamp").execute(),await $.schema.dropTable("monitoring_logs").execute()}var tu0={};B0(tu0,{up:()=>Yg6,down:()=>Gg6});import{sql as mm}from"kysely";async function Yg6($){await $.schema.createTable("events").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("type","text",(Z)=>Z.notNull()).addColumn("source","text",(Z)=>Z.notNull()).addColumn("specversion","text",(Z)=>Z.notNull().defaultTo("1.0")).addColumn("subject","text").addColumn("time","text",(Z)=>Z.notNull()).addColumn("datacontenttype","text",(Z)=>Z.notNull().defaultTo("application/json")).addColumn("dataschema","text").addColumn("data","text").addColumn("cron","varchar(255)").addColumn("status","text",(Z)=>Z.notNull().defaultTo("pending")).addColumn("attempts","integer",(Z)=>Z.notNull().defaultTo(0)).addColumn("last_error","text").addColumn("next_retry_at","text").addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("event_subscriptions").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organization_id","text",(Z)=>Z.notNull().references("organization.id").onDelete("cascade")).addColumn("connection_id","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("publisher","text").addColumn("event_type","text",(Z)=>Z.notNull()).addColumn("filter","text").addColumn("enabled","integer",(Z)=>Z.notNull().defaultTo(1)).addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).execute(),await $.schema.createTable("event_deliveries").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("event_id","text",(Z)=>Z.notNull()).addColumn("subscription_id","text",(Z)=>Z.notNull().references("event_subscriptions.id").onDelete("cascade")).addColumn("status","text",(Z)=>Z.notNull().defaultTo("pending")).addColumn("attempts","integer",(Z)=>Z.notNull().defaultTo(0)).addColumn("last_error","text").addColumn("delivered_at","text").addColumn("next_retry_at","text").addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(mm`CURRENT_TIMESTAMP`)).execute(),await $.schema.createIndex("idx_events_org_status").on("events").columns(["organization_id","status"]).execute(),await $.schema.createIndex("idx_events_source").on("events").columns(["source"]).execute(),await $.schema.createIndex("idx_events_type").on("events").columns(["type"]).execute(),await $.schema.createIndex("idx_events_retry").on("events").columns(["status","next_retry_at"]).execute(),await $.schema.createIndex("idx_subscriptions_connection").on("event_subscriptions").columns(["connection_id"]).execute(),await $.schema.createIndex("idx_subscriptions_type").on("event_subscriptions").columns(["event_type"]).execute(),await $.schema.createIndex("idx_subscriptions_org_enabled").on("event_subscriptions").columns(["organization_id","enabled"]).execute(),await $.schema.createIndex("idx_subscriptions_unique").on("event_subscriptions").columns(["connection_id","event_type","publisher","filter"]).unique().execute(),await $.schema.createIndex("idx_deliveries_event").on("event_deliveries").columns(["event_id"]).execute(),await $.schema.createIndex("idx_deliveries_subscription_status").on("event_deliveries").columns(["subscription_id","status"]).execute(),await $.schema.createIndex("idx_deliveries_retry").on("event_deliveries").columns(["status","next_retry_at"]).execute()}async function Gg6($){await $.schema.dropIndex("idx_deliveries_retry").execute(),await $.schema.dropIndex("idx_deliveries_subscription_status").execute(),await $.schema.dropIndex("idx_deliveries_event").execute(),await $.schema.dropIndex("idx_subscriptions_unique").execute(),await $.schema.dropIndex("idx_subscriptions_org_enabled").execute(),await $.schema.dropIndex("idx_subscriptions_type").execute(),await $.schema.dropIndex("idx_subscriptions_connection").execute(),await $.schema.dropIndex("idx_events_retry").execute(),await $.schema.dropIndex("idx_events_type").execute(),await $.schema.dropIndex("idx_events_source").execute(),await $.schema.dropIndex("idx_events_org_status").execute(),await $.schema.dropTable("event_deliveries").execute(),await $.schema.dropTable("event_subscriptions").execute(),await $.schema.dropTable("events").execute()}var Di1=()=>{};var ou0={};B0(ou0,{up:()=>Kg6,down:()=>Wg6});import{sql as Jg6}from"kysely";async function Kg6($){await $.schema.dropTable("audit_logs").ifExists().execute()}async function Wg6($){await $.schema.createTable("audit_logs").ifNotExists().addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("organizationId","text").addColumn("userId","text",(Z)=>Z.references("user.id").onDelete("set null")).addColumn("connectionId","text",(Z)=>Z.references("connections.id").onDelete("set null")).addColumn("toolName","text",(Z)=>Z.notNull()).addColumn("allowed","integer",(Z)=>Z.notNull()).addColumn("duration","integer").addColumn("timestamp","text",(Z)=>Z.notNull().defaultTo(Jg6`CURRENT_TIMESTAMP`)).addColumn("requestMetadata","text").execute(),await $.schema.createIndex("idx_audit_logs_organizationId").on("audit_logs").column("organizationId").execute(),await $.schema.createIndex("idx_audit_logs_userId").on("audit_logs").column("userId").execute(),await $.schema.createIndex("idx_audit_logs_timestamp").on("audit_logs").column("timestamp").execute()}var Ei1=()=>{};var ru0={};B0(ru0,{up:()=>Hg6,down:()=>Ug6});import{sql as z90}from"kysely";async function Hg6($){await $.schema.createTable("gateways").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("tool_selection_strategy","text").addColumn("status","text",(Z)=>Z.notNull().defaultTo("active")).addColumn("is_default","integer",(Z)=>Z.notNull().defaultTo(0)).addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(z90`CURRENT_TIMESTAMP`)).addColumn("updated_at","text",(Z)=>Z.notNull().defaultTo(z90`CURRENT_TIMESTAMP`)).addColumn("created_by","text",(Z)=>Z.notNull().references("user.id").onDelete("cascade")).addColumn("updated_by","text").execute(),await $.schema.createTable("gateway_connections").addColumn("id","text",(Z)=>Z.primaryKey()).addColumn("gateway_id","text",(Z)=>Z.notNull().references("gateways.id").onDelete("cascade")).addColumn("connection_id","text",(Z)=>Z.notNull().references("connections.id").onDelete("cascade")).addColumn("selected_tools","text").addColumn("created_at","text",(Z)=>Z.notNull().defaultTo(z90`CURRENT_TIMESTAMP`)).execute(),await $.schema.createIndex("idx_gateways_org").on("gateways").columns(["organization_id"]).execute(),await $.schema.createIndex("idx_gateways_org_status").on("gateways").columns(["organization_id","status"]).execute(),await z90`CREATE UNIQUE INDEX idx_gateways_default_per_org ON gateways (organization_id) WHERE is_default = 1`.execute($),await $.schema.createIndex("idx_gateway_connections_gateway").on("gateway_connections").columns(["gateway_id"]).execute(),await $.schema.createIndex("idx_gateway_connections_connection").on("gateway_connections").columns(["connection_id"]).execute(),await $.schema.createIndex("idx_gateway_connections_unique").on("gateway_connections").columns(["gateway_id","connection_id"]).unique().execute()}async function Ug6($){await $.schema.dropIndex("idx_gateway_connections_unique").execute(),await $.schema.dropIndex("idx_gateway_connections_connection").execute(),await $.schema.dropIndex("idx_gateway_connections_gateway").execute(),await $.schema.dropIndex("idx_gateways_default_per_org").execute(),await $.schema.dropIndex("idx_gateways_org_status").execute(),await $.schema.dropIndex("idx_gateways_org").execute(),await $.schema.dropTable("gateway_connections").execute(),await $.schema.dropTable("gateways").execute()}var zi1=()=>{};var au0={};B0(au0,{up:()=>Ng6,down:()=>Fg6});async function Ng6($){await $.schema.alterTable("gateways").addColumn("icon","text").execute()}async function Fg6($){await $.schema.alterTable("gateways").dropColumn("icon").execute()}var su0={};B0(su0,{up:()=>wg6,down:()=>Bg6});import{sql as j90}from"kysely";async function wg6($){await $.schema.alterTable("gateways").addColumn("tool_selection_mode","text",(Z)=>Z.notNull().defaultTo("inclusion")).execute(),await j90`
180
180
  UPDATE gateways
181
181
  SET tool_selection_mode = CASE
182
182
  WHEN tool_selection_strategy = 'exclusion' THEN 'exclusion'
@@ -1332,7 +1332,7 @@ Usage: deco services <up|down|status>`),process.exit(1)}}var vd1=O(()=>{px()});f
1332
1332
  `.execute($);if(Number(W.rows[0]?.cnt)===0){console.warn(`Failed to migrate ${J}/${K}, keeping in old table`);continue}}await Pb`
1333
1333
  DELETE FROM kysely_migration WHERE name = ${X}
1334
1334
  `.execute($)}}async function ap1($){await pm6($),await tm6($);let Z=new op1({db:$,provider:{getMigrations:()=>Promise.resolve(Om0)}}),{error:X,results:Q}=await Z.migrateToLatest(),Y=0;if(Q?.forEach((G)=>{if(G.status==="Success")Y++;else if(G.status==="Error")console.error(`Failed to execute migration "${G.migrationName}"`)}),X)throw console.error("Failed to migrate"),console.error(X),X;return Y}async function om6($){let{keepOpen:Z=!1,database:X,skipBetterAuth:Q=!1}=$??{},Y="skipped";if(!Q&&!X)Y=await hu0();let G=X??N6(),J=async()=>{if(!Z&&!X)await Tw(G).catch((K)=>{console.warn("Warning: Error closing database:",K)})};try{let K=await ap1(G.db);return await J(),{betterAuth:Y,kysely:K}}catch(K){throw await J(),K}}async function rm6(){let $=N6(),Z=new op1({db:$.db,provider:{getMigrations:()=>Promise.resolve(Om0)}}),{error:X,results:Q}=await Z.migrateDown();if(Q?.forEach((Y)=>{if(Y.status==="Success")console.log(`\u2705 Migration "${Y.migrationName}" rolled back successfully`);else if(Y.status==="Error")console.error(`\u274C Failed to rollback migration "${Y.migrationName}"`)}),X)throw console.error("Failed to rollback migration"),console.error(X),X}var ep1=O(()=>{tp1();uu0();e7()});async function h90($){let Z={...process.env},X=_10($,Z);console.log(wB1(X.settings.encryptionKey));let Q=X.settings.betterAuthSecret||(X.settings.localMode?Ui1(X.settings.dataDir):""),{ensureServices:Y}=await Promise.resolve().then(() => (o50(),t50)),{outputs:G,services:J}=await Y({home:X.settings.dataDir,externalDatabaseUrl:X.externalDatabaseUrl,externalNatsUrl:X.externalNatsUrl});if(!X.skipMigrations){let{migrateBetterAuth:W}=await Promise.resolve().then(() => (uu0(),Fi1));await W(G.databaseUrl);let{createDatabase:H}=await Promise.resolve().then(() => (e7(),Vm1)),{migrateToLatest:U}=await Promise.resolve().then(() => (ep1(),sp1)),N=H(G.databaseUrl);await U({keepOpen:!0,database:N,skipBetterAuth:!0})}let K={...X.settings,betterAuthSecret:Q,databaseUrl:G.databaseUrl,natsUrls:G.natsUrls,...G.s3?{s3Endpoint:G.s3.endpoint,s3Bucket:G.s3.bucket,s3AccessKeyId:G.s3.accessKeyId,s3SecretAccessKey:G.s3.secretAccessKey,s3ForcePathStyle:G.s3.forcePathStyle}:{},...G.natsTunnel?{natsPublicUrl:G.natsTunnel.publicUrl,natsAccountJwt:G.natsTunnel.accountJwt,natsAccountSigningKey:G.natsTunnel.accountSigningKey,natsOperatorJwt:G.natsTunnel.operatorJwt,natsTunnelPublicEnabled:!0,natsCredsPath:G.natsTunnel.credsPath}:{}};return xd1(K),{settings:K,services:J.map((W)=>({name:W.name==="PostgreSQL"?"Postgres":W.name,port:W.port})),managedServiceNames:J.filter((W)=>W.owner==="managed").map((W)=>W.name)}}var Lm0=O(()=>{px();Ni1();k8()});var Xt1={};B0(Xt1,{updateService:()=>GE,subscribeCliState:()=>zm0,setTuiConsoleIntercepted:()=>u90,setServerUrl:()=>Xi,setMigrationsDone:()=>Zi,setDevMode:()=>em6,resetCliStateForTests:()=>am6,isTuiConsoleIntercepted:()=>c90,getCliState:()=>Em0,addLogEntry:()=>Vw});function $t1(){return{services:[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}],migrationsStatus:"pending",serverUrl:null,logs:[]}}function am6(){bQ=$t1()}function sm6(){return[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}]}function $i(){for(let $ of Dm0)$()}function Em0(){return bQ}function zm0($){return Dm0.add($),()=>Dm0.delete($)}function GE($){bQ={...bQ,services:bQ.services.map((Z)=>Z.name===$.name?$:Z)},$i()}function Zi(){bQ={...bQ,migrationsStatus:"done"},$i()}function Xi($){bQ={...bQ,serverUrl:$},$i()}function Vw($){let Z=[...bQ.logs,$];bQ={...bQ,logs:Z.length>500?Z.slice(-500):Z},$i()}function em6(){bQ={...bQ,services:[...sm6(),{name:"API",status:"pending",port:0},{name:"Vite",status:"pending",port:0}]},$i()}function u90($){Zt1=$}function c90(){return Zt1}var bQ,Dm0,Zt1=!1;var JE=O(()=>{bQ=$t1();Dm0=new Set});import{createServer as Qt1}from"net";function $i6($){return new Promise((Z)=>{let X=Qt1();X.once("error",()=>Z(!1)),X.listen($,"0.0.0.0",()=>{X.close(()=>Z(!0))})})}async function Qi($){if(await $i6($))return $;let Z=await new Promise((X,Q)=>{let Y=Qt1();Y.once("error",Q),Y.listen(0,"0.0.0.0",()=>{let G=Y.address(),J=typeof G==="object"&&G?G.port:0;Y.close(()=>X(J))})});return console.warn(`Port ${$} is in use, using port ${Z} instead.`),Z}var jm0=()=>{};function Yi($){return $.replace(/\x1b\[[0-9;]*m/g,"")}var Pm0={};B0(Pm0,{startDevServer:()=>Xi6});import{join as Zi6}from"path";function Yt1($){let Z=$.getReader(),X=new TextDecoder,Q="";function Y(){let G=Q.split(`
1335
- `);Q=G.pop()??"";for(let J of G){let K=Yi(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;Vw({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{for(;;){let{done:G,value:J}=await Z.read();if(G)break;Q+=X.decode(J,{stream:!0}),Y()}if(Q.trim()){let G=Yi(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)Vw({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function Xi6($){let{baseUrl:Z,noTui:X}=$,Q=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=Q?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=Q?await Qi(Number(Y)+1):await Qi(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await h90({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let L of W)GE({name:L.name,status:"ready",port:L.port});Zi();let U=Zi6(import.meta.dir,"..","..","..","..",".."),N=X===!0,F=Bun.spawn(["bun","run","dev:servers"],{cwd:U,env:{...process.env,PORT:String(K.port),VITE_PORT:String(Y),DATABASE_URL:K.databaseUrl,NATS_URL:K.natsUrls.join(","),NODE_ENV:K.nodeEnv,BASE_URL:G,DECOCMS_LOCAL_MODE:String(K.localMode),DECOCMS_HOME:K.dataDir,DATA_DIR:K.dataDir,DECO_CLI:"1",...K.betterAuthSecret?{BETTER_AUTH_SECRET:K.betterAuthSecret}:{},...K.s3Endpoint?{S3_ENDPOINT:K.s3Endpoint,S3_BUCKET:K.s3Bucket??"",S3_ACCESS_KEY_ID:K.s3AccessKeyId??"",S3_SECRET_ACCESS_KEY:K.s3SecretAccessKey??"",S3_FORCE_PATH_STYLE:String(K.s3ForcePathStyle)}:{},...K.natsPublicUrl&&K.natsAccountJwt&&K.natsAccountSigningKey?{NATS_PUBLIC_URL:K.natsPublicUrl,NATS_ACCOUNT_JWT:K.natsAccountJwt,NATS_ACCOUNT_SIGNING_KEY:K.natsAccountSigningKey,NATS_OPERATOR_JWT:K.natsOperatorJwt??"",NATS_TUNNEL_PUBLIC_ENABLED:"true",...K.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}}:{}},stdio:["inherit",N?"inherit":"pipe",N?"inherit":"pipe"]});if(!N)Yt1(F.stdout),Yt1(F.stderr);Xi(G),GE({name:"Vite",status:"ready",port:Number(Y)}),GE({name:"API",status:"ready",port:Number(K.port)});let B=async(L)=>{if(F.kill(L),await F.exited,H.length>0){let{stopServices:D}=await Promise.resolve().then(() => (o50(),t50));await D(K.dataDir)}};return process.on("SIGINT",()=>B("SIGINT")),process.on("SIGTERM",()=>B("SIGTERM")),{port:Number(Y),process:F}}var Am0=O(()=>{Lm0();JE();jm0()});var l90;var Tm0=O(()=>{l90={name:"decocms",version:"4.217.8",description:"Deco CMS \u2014 Self-hostable MCP Gateway for managing AI connections and tools",author:"Deco team",repository:{type:"git",url:"git+https://github.com/decocms/studio.git",directory:"apps/api"},bugs:{url:"https://github.com/decocms/studio/issues"},type:"module",bin:{deco:"./dist/server/cli.js"},files:["dist/**/*"],scripts:{dev:"bun run migrate && bun run dev:server","dev:server":"bun run --cwd=../../packages/sandbox build && NODE_ENV=development bun --env-file=.env --hot run src/index.ts",build:"bun run build:server","build:server":"bun run scripts/bundle-server-script.ts --dist ./dist/server","generate:tool-contracts":"bun run scripts/generate-tool-contracts.ts","db:migrate":"bun run ./dist/server/migrate.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts",test:"bun test src","better-auth:migrate":"bunx --bun @better-auth/cli migrate -y --config src/auth/index.ts",prepublishOnly:"bun run --cwd=../.. build:studio"},optionalDependencies:{"@duckdb/node-api":"^1.5.0-r.1"},dependencies:{"@ai-sdk/anthropic":"^3.0.85","@ai-sdk/google":"^3.0.83","@ai-sdk/openai":"^3.0.73","@anthropic-ai/sdk":"^0.105.0","@aws-sdk/client-s3":"^3.1013.0","@aws-sdk/client-sts":"^3.1013.0","@aws-sdk/lib-storage":"^3.1013.0","@aws-sdk/s3-request-presigner":"^3.1013.0","@clickhouse/client":"^1.8.1","@dbos-inc/dbos-sdk":"^4.21.6","@inkjs/ui":"^2.0.0","@nats-io/jetstream":"3.4.0","@nats-io/kv":"3.4.0","@nats-io/nats-core":"3.4.0","@nats-io/transport-node":"3.4.0","@openrouter/ai-sdk-provider":"^2.9.1","@opentelemetry/core":"^2.6.0","embedded-postgres":"^18.3.0-beta.16",ink:"^6.8.0",kysely:"^0.28.12","posthog-node":"^5.0.0",react:"^19.2.6","react-dom":"^19.2.6"},devDependencies:{"@ai-sdk/provider":"^3.0.10","@better-auth/sso":"1.4.1","@decocms/better-auth":"1.5.17","@decocms/bindings":"workspace:*","@decocms/mcp-utils":"workspace:*","@decocms/runtime":"workspace:*","@decocms/sandbox":"workspace:*","@decocms/shared":"workspace:*","@jitl/quickjs-wasmfile-release-sync":"0.31.0","@modelcontextprotocol/sdk":"1.29.0","@nats-io/jwt":"0.0.10-5","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.211.0","@opentelemetry/exporter-logs-otlp-proto":"^0.211.0","@opentelemetry/exporter-prometheus":"^0.208.0","@opentelemetry/exporter-trace-otlp-proto":"^0.207.0","@opentelemetry/instrumentation-runtime-node":"^0.24.0","@opentelemetry/resources":"^2.6.0","@opentelemetry/sdk-logs":"^0.211.0","@opentelemetry/sdk-metrics":"^2.2.0","@opentelemetry/sdk-node":"^0.207.0","@opentelemetry/sdk-trace-base":"^2.5.0","@types/bun":"^1.3.1","@types/google.maps":"^3.65.2","@types/pg":"^8.15.6","@types/react-syntax-highlighter":"^15.5.13","@vercel/nft":"^1.1.1",ai:"^6.0.208","better-auth":"1.4.22",croner:"^9.1.0",degit:"^2.8.4",hono:"^4.10.7",jose:"^6.0.11",nanoid:"^5.1.6",pg:"^8.16.3",typescript:"^7.0.2",typescript5:"npm:typescript@^5.9.3",zod:"4.3.6"},homepage:"https://github.com/decocms/studio",keywords:["mcp","model-context-protocol","ai","gateway","self-hosted","tools"],license:"MIT",publishConfig:{access:"public"}}});import{Box as Yi6,Text as Gt1}from"ink";import{jsx as Gi6,jsxs as Jt1}from"react/jsx-runtime";function Kt1({version:$}){return Jt1(Yi6,{flexDirection:"column",marginTop:1,children:[L90.map((Z,X)=>Gi6(Gt1,{color:D90[X],children:Z},X)),Jt1(Gt1,{dimColor:!0,children:[" v",$]})]})}var Wt1=O(()=>{dm()});import{Box as KE,Text as kw}from"ink";import{Spinner as Ji6}from"@inkjs/ui";import{jsx as nY,jsxs as Ab}from"react/jsx-runtime";function Ht1({status:$}){if($==="pending")return nY(Ji6,{label:""});return nY(kw,{color:"green",children:"\u2713"})}function Ki6($){return`${$.name}: ${$.port||"...."}`}function Ut1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return Ab(KE,{flexDirection:"column",paddingBottom:1,children:[nY(Kt1,{version:l90.version}),nY(KE,{marginBottom:1,children:nY(kw,{dimColor:!0,children:"\u2500".repeat(80)})}),nY(KE,{children:Ab(kw,{dimColor:!0,children:["Home: ",X]})}),Ab(KE,{gap:2,children:[$.map((Y)=>Ab(KE,{gap:1,children:[nY(kw,{children:Ki6(Y)}),nY(Ht1,{status:Y.status})]},Y.name)),Ab(KE,{gap:1,children:[nY(kw,{children:"Migrations"}),nY(Ht1,{status:Z})]})]}),nY(KE,{children:Q?Ab(kw,{children:["Open in browser: ",nY(kw,{color:"cyan",children:Q})]}):nY(kw,{dimColor:!0,children:"Starting..."})})]})}var Nt1=O(()=>{Tm0();Wt1()});import{Box as Wi6,Text as Gi}from"ink";import{jsx as Rm0,jsxs as Im0}from"react/jsx-runtime";function Hi6($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function Ft1({logs:$}){return Rm0(Wi6,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Rm0(Gi,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return Im0(Gi,{children:[Im0(Gi,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Rm0(Gi,{color:Hi6(Z.status),children:Z.status}),Im0(Gi,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var wt1=()=>{};var qm0={};B0(qm0,{App:()=>Fi6});import{Box as Ui6}from"ink";import{useSyncExternalStore as Ni6}from"react";import{jsx as Bt1,jsxs as wi6}from"react/jsx-runtime";function Fi6({home:$}){let Z=Ni6(zm0,Em0);return wi6(Ui6,{flexDirection:"column",children:[Bt1(Ut1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),Bt1(Ft1,{logs:Z.logs})]})}var Mm0=O(()=>{Nt1();wt1();JE()});var RJ="thread-gate",hU="decopilot-hosted-harness",X3="automations",Sw="background-tools",WE="task-board-github-reads";var Ot1="7";function Lt1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:Ot1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var Dt1=()=>{};function Bi6(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function Vm0($,Z){for(let X=0;X<$.length;X++){let Q=$[X];if(Q===void 0)continue;if(Q===Z)return $[X+1];if(Q.startsWith(`${Z}=`))return Q.slice(Z.length+1)}return}function Et1(){let $=Bi6();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:Vm0($,"--cpu-prof-dir")??process.cwd(),name:Vm0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(Vm0($,"--cpu-prof-interval")??1000),note:"profile is written on process exit"}));return}if(process.env.CPU_PROFILE)console.warn(JSON.stringify({msg:"cpu-profiling-requested-but-inactive",hint:'CPU profiling is a Bun launch flag. Set BUN_OPTIONS="--cpu-prof --cpu-prof-md --cpu-prof-dir=/tmp" before starting the process.'}))}function zt1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=ZE();if(!X)return;let Q={};try{let{heapStats:Y}=await import("bun:jsc"),G=Y(),J=Object.entries(G.objectTypeCounts).sort((K,W)=>W[1]-K[1]).slice(0,20);Q={objectCount:G.objectCount,heapSize:G.heapSize,top:Object.fromEntries(J)}}catch{}console.log(JSON.stringify({msg:"heap-watch",ts:new Date().toISOString(),uptimeS:Math.round(process.uptime()),rss:X.rss,heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers,...Q}))};return Z().catch(()=>{}),d90=setInterval(()=>void Z().catch(()=>{}),$),d90.unref?.(),process.on("SIGUSR2",()=>{try{let X=Bun.generateHeapSnapshot("v8"),Q=typeof X==="string"?X:JSON.stringify(X),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,Q),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(X){console.error("[heap-watch] snapshot failed:",X)}}),()=>{if(d90)clearInterval(d90)}}var d90;var jt1=()=>{};import*as Oi6 from"bun:jsc";function Pt1(){if(process.env.STALL_WATCHDOG!=="1")return()=>{};let $=Number(process.env.STALL_WATCHDOG_MS??100),Z=Number(process.env.STALL_WATCHDOG_TICK_MS??50);try{Li6()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let X,Q=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-Q;Q=G+Z;let K=[];try{K=Di6()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let U of K){let N=U.frames.find((B)=>B.sourceURL&&!/Unknown Executable/.test(B.category??""))??U.frames[0];if(!N)continue;let F=(N.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),w=`${N.name??"?"} @ ${F}:${N.line??"?"}`;W.set(w,(W.get(w)??0)+1)}let H=[...W.entries()].sort((U,N)=>N[1]-U[1]).slice(0,8).map(([U,N])=>({frame:U,count:N}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}X=setTimeout(Y,Z),X.unref?.()};return X=setTimeout(Y,Z),X.unref?.(),()=>{if(X)clearTimeout(X)}}var Li6,Di6;var At1=O(()=>{({startSamplingProfiler:Li6,samplingProfilerStackTraces:Di6}=Oi6)});function Tt1(){Et1();let $=[zt1(),jm1(),Pt1()];return()=>{for(let Z of $)Z()}}var Rt1=O(()=>{ku0();jt1();At1()});var HE=_((It1)=>{Object.defineProperty(It1,"__esModule",{value:!0});It1.RepublishHeaders=It1.DirectMsgHeaders=It1.JsHeaders=It1.AdvisoryKind=void 0;It1.isOrderedPushConsumerOptions=Ei6;It1.isPullConsumer=zi6;It1.isPushConsumer=ji6;It1.isBoundPushConsumerOptions=Pi6;function Ei6($){if($&&typeof $==="object")return"name_prefix"in $||"deliver_subject_prefix"in $||"filter_subjects"in $||"filter_subject"in $||"deliver_policy"in $||"opt_start_seq"in $||"opt_start_time"in $||"replay_policy"in $||"inactive_threshold"in $||"headers_only"in $||"deliver_prefix"in $;return!1}function zi6($){return $.isPullConsumer()}function ji6($){return $.isPushConsumer()}function Pi6($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}It1.AdvisoryKind={API:"api_audit",StreamAction:"stream_action",ConsumerAction:"consumer_action",SnapshotCreate:"snapshot_create",SnapshotComplete:"snapshot_complete",RestoreCreate:"restore_create",RestoreComplete:"restore_complete",MaxDeliver:"max_deliver",Terminated:"terminated",Ack:"consumer_ack",StreamLeaderElected:"stream_leader_elected",StreamQuorumLost:"stream_quorum_lost",ConsumerLeaderElected:"consumer_leader_elected",ConsumerQuorumLost:"consumer_quorum_lost"};It1.JsHeaders={StreamSourceHdr:"Nats-Stream-Source",LastConsumerSeqHdr:"Nats-Last-Consumer",LastStreamSeqHdr:"Nats-Last-Stream",ConsumerStalledHdr:"Nats-Consumer-Stalled",MessageSizeHdr:"Nats-Msg-Size",RollupHdr:"Nats-Rollup",RollupValueSubject:"sub",RollupValueAll:"all",PendingMessagesHdr:"Nats-Pending-Messages",PendingBytesHdr:"Nats-Pending-Bytes",RequiredApiLevel:"Nats-Required-Api-Level"};It1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};It1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var pY=_((Mt1)=>{Object.defineProperty(Mt1,"__esModule",{value:!0});Mt1.TD=Mt1.TE=Mt1.Empty=void 0;Mt1.encode=Si6;Mt1.decode=Ci6;Mt1.Empty=new Uint8Array(0);Mt1.TE=new TextEncoder;Mt1.TD=new TextDecoder;function ki6(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}function Si6(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(Mt1.TE.encode($[X]));if(Z.length===0)return Mt1.Empty;if(Z.length===1)return Z[0];return ki6(...Z)}function Ci6($){if(!$||$.length===0)return"";return Mt1.TD.decode($)}});var tY=_((St1)=>{Object.defineProperty(St1,"__esModule",{value:!0});St1.errors=St1.PermissionViolationError=St1.NoRespondersError=St1.TimeoutError=St1.RequestError=St1.ProtocolError=St1.ConnectionError=St1.DrainingConnectionError=St1.ClosedConnectionError=St1.AuthorizationError=St1.UserAuthenticationExpiredError=St1.InvalidOperationError=St1.InvalidArgumentError=St1.InvalidSubjectError=void 0;class Sm0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}St1.InvalidSubjectError=Sm0;class m90 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,X){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((Q)=>`'${Q}'`),$=$.join(",");else $=`'${$}'`;return new m90(`${$} ${Z}`,X)}}St1.InvalidArgumentError=m90;class Cm0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}St1.InvalidOperationError=Cm0;class i90 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new i90($);return null}}St1.UserAuthenticationExpiredError=i90;class n90 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],X=$.toLowerCase();for(let Q=0;Q<Z.length;Q++)if(X.indexOf(Z[Q])!==-1)return new n90($);return null}}St1.AuthorizationError=n90;class _m0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}St1.ClosedConnectionError=_m0;class vm0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}St1.DrainingConnectionError=vm0;class xm0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}St1.ConnectionError=xm0;class fm0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}St1.ProtocolError=fm0;class bm0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof p90}}St1.RequestError=bm0;class ym0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}St1.TimeoutError=ym0;class p90 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}St1.NoRespondersError=p90;class t90 extends Error{operation;subject;queue;constructor($,Z,X,Q,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=X,this.queue=Q}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let X="publish",Q="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(X=G[1].toLowerCase(),Q=G[2],X==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new t90($,X,Q,Y)}}St1.PermissionViolationError=t90;St1.errors={AuthorizationError:n90,ClosedConnectionError:_m0,ConnectionError:xm0,DrainingConnectionError:vm0,InvalidArgumentError:m90,InvalidOperationError:Cm0,InvalidSubjectError:Sm0,NoRespondersError:p90,PermissionViolationError:t90,ProtocolError:fm0,RequestError:bm0,TimeoutError:ym0,UserAuthenticationExpiredError:i90}});var IJ=_((ft1)=>{Object.defineProperty(ft1,"__esModule",{value:!0});ft1.SimpleMutex=ft1.Perf=void 0;ft1.extend=ti6;ft1.render=oi6;ft1.timeout=ri6;ft1.delay=ai6;ft1.deadline=si6;ft1.deferred=hm0;ft1.debugDeferred=ei6;ft1.shuffle=$n6;ft1.collect=Zn6;ft1.jitter=xt1;ft1.backoff=Xn6;ft1.nanos=Qn6;ft1.millis=Yn6;ft1.randomToken=Kn6;var pi6=pY(),gm0=tY();function ti6($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function oi6($){return pi6.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function ri6($,Z=!0){let X=Z?new gm0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new gm0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function ai6($=0){let Z,X=new Promise((Q)=>{let Y=setTimeout(()=>{Q()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),Q()}}});return Object.assign(X,Z)}async function si6($,Z=1000){let X=hm0(),Q=setTimeout(()=>{X.reject(new gm0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function hm0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function ei6(){let $={},Z=new Promise((X,Q)=>{$={resolve:(Y)=>{console.trace("resolve",Y),X(Y)},reject:(Y)=>{console.trace("reject"),Q(Y)}}});return Object.assign(Z,$)}function $n6($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function Zn6($){let Z=[];for await(let X of $)Z.push(X);return Z}class _t1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,X){let Q=this.timers.get(Z);if(Q===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(X);if(Y===void 0)throw Error(`${X} is not defined`);this.measures.set($,Y-Q)}getEntries(){let $=[];return this.measures.forEach((Z,X)=>{$.push({name:X,duration:Z})}),$}}ft1.Perf=_t1;class vt1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=hm0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}ft1.SimpleMutex=vt1;function xt1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function Xn6($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(X){return xt1(X>Z?$[Z]:$[X])}}}function Qn6($){return $*1e6}function Yn6($){return Math.floor($/1e6)}var Gn6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",uU=new Uint8Array(62);for(let $=0;$<62;$++)uU[$]=Gn6.charCodeAt($);var Jn6=218340105584896;function Kn6(){let $=Math.floor(Math.random()*Jn6),Z=$%62,X=uU[Z];$=($-Z)/62,Z=$%62;let Q=uU[Z];$=($-Z)/62,Z=$%62;let Y=uU[Z];$=($-Z)/62,Z=$%62;let G=uU[Z];$=($-Z)/62,Z=$%62;let J=uU[Z];$=($-Z)/62,Z=$%62;let K=uU[Z];$=($-Z)/62,Z=$%62;let W=uU[Z];$=($-Z)/62;let H=uU[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var dt1=_((ct1)=>{Object.defineProperty(ct1,"__esModule",{value:!0});ct1.nuid=ct1.NuidImpl=void 0;var Tn6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Cw=62,r90=12,ht1=10,yt1=33,Rn6=333,gt1=r90+ht1,cm0=new Uint8Array(Cw);for(let $=0;$<Cw;$++)cm0[$]=Tn6.charCodeAt($);var o90=4294967296,ut1=BigInt(Cw)**BigInt(ht1),Ji=Number(ut1/(1n<<32n)),um0=Number(ut1%(1n<<32n));function In6($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function qn6($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else In6($)}class lm0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(gt1),this.cbuf=new Uint8Array(r90),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(Ji+1)),this.seqLo=Math.floor(Math.random()*o90);while($++<8&&this.seqHi===Ji&&this.seqLo>=um0);if(this.seqHi===Ji&&this.seqLo>=um0)this.seqLo=0;this.inc=Math.random()*(Rn6-yt1)+yt1|0}setPre(){qn6(this.cbuf);for(let $=0;$<r90;$++)this.buf[$]=cm0[this.cbuf[$]%Cw]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=gt1-1;X>=r90;X--){let Q=Math.floor($/Cw),G=($-Q*Cw)*o90+Z,J=Math.floor(G/Cw),K=G-J*Cw;this.buf[X]=cm0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=o90)this.seqLo-=o90,this.seqHi+=1;if(this.seqHi>Ji||this.seqHi===Ji&&this.seqLo>=um0)this.setPre(),this.initSeqAndInc();this.fillSeq();let $=this.buf;return String.fromCharCode($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],$[8],$[9],$[10],$[11],$[12],$[13],$[14],$[15],$[16],$[17],$[18],$[19],$[20],$[21])}reset(){this.init()}}ct1.NuidImpl=lm0;ct1.nuid=new lm0});var pt1=_((it1)=>{Object.defineProperty(it1,"__esModule",{value:!0});it1.nuid=it1.Nuid=void 0;var mt1=dt1();it1.Nuid=mt1.NuidImpl;it1.nuid=mt1.nuid});var s90=_((a90)=>{Object.defineProperty(a90,"__esModule",{value:!0});a90.nuid=a90.Nuid=void 0;var tt1=pt1();Object.defineProperty(a90,"Nuid",{enumerable:!0,get:function(){return tt1.Nuid}});Object.defineProperty(a90,"nuid",{enumerable:!0,get:function(){return tt1.nuid}})});var _w=_((ot1)=>{Object.defineProperty(ot1,"__esModule",{value:!0});ot1.DEFAULT_HOST=ot1.DEFAULT_PORT=ot1.Match=void 0;ot1.syncIterator=_n6;ot1.createInbox=vn6;var Sn6=s90(),Cn6=tY();ot1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function _n6($){let Z=$[Symbol.asyncIterator]();return{async next(){let X=await Z.next();if(X.done)return Promise.resolve(null);return Promise.resolve(X.value)}}}function vn6($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw Cn6.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${Sn6.nuid.next()}`}ot1.DEFAULT_PORT=4222;ot1.DEFAULT_HOST="127.0.0.1"});var Ki=_((et1)=>{Object.defineProperty(et1,"__esModule",{value:!0});et1.DataBuffer=void 0;var at1=pY();class st1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}static fromAscii($){if(!$)$="";return at1.TE.encode($)}static toAscii($){return at1.TD.decode($)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){let $=new Uint8Array(this.byteLength),Z=0;for(let X=0;X<this.buffers.length;X++)$.set(this.buffers[X],Z),Z+=this.buffers[X].length;this.buffers.length=0,this.buffers.push($)}}shift(){if(this.buffers.length){let $=this.buffers.shift();if($)return this.byteLength-=$.length,$}return new Uint8Array(0)}drain($){if(this.buffers.length){this.pack();let Z=this.buffers.pop();if(Z){let X=this.byteLength;if($===void 0||$>X)$=X;let Q=Z.subarray(0,$);if(X>$)this.buffers.push(Z.subarray($));return this.byteLength=X-$,Q}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let X=0;X<Z.length;X++)if(Z[X]&&Z[X].length)this.buffers.push(Z[X]),this.byteLength+=Z[X].length}peek(){if(this.buffers.length)return this.pack(),this.buffers[0];return new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}et1.DataBuffer=st1});var UE=_((Xo1)=>{Object.defineProperty(Xo1,"__esModule",{value:!0});Xo1.LF=Xo1.CR=Xo1.CRLF=Xo1.CR_LF_LEN=Xo1.CR_LF=void 0;Xo1.setTransportFactory=cn6;Xo1.defaultPort=ln6;Xo1.getUrlParseFn=dn6;Xo1.newTransport=mn6;Xo1.getResolveFn=in6;Xo1.protoLen=Zo1;Xo1.extractProtocolMessage=nn6;var gn6=pY(),hn6=_w(),un6=Ki(),oY;function cn6($){oY=$}function ln6(){return oY!==void 0&&oY.defaultPort!==void 0?oY.defaultPort:hn6.DEFAULT_PORT}function dn6(){return oY!==void 0&&oY.urlParseFn?oY.urlParseFn:void 0}function mn6(){if(!oY||typeof oY.factory!=="function")throw Error("transport fn is not set");return oY.factory()}function in6(){return oY!==void 0&&oY.dnsResolveFn?oY.dnsResolveFn:void 0}Xo1.CR_LF=`\r
1335
+ `);Q=G.pop()??"";for(let J of G){let K=Yi(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;Vw({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{for(;;){let{done:G,value:J}=await Z.read();if(G)break;Q+=X.decode(J,{stream:!0}),Y()}if(Q.trim()){let G=Yi(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)Vw({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function Xi6($){let{baseUrl:Z,noTui:X}=$,Q=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=Q?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=Q?await Qi(Number(Y)+1):await Qi(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await h90({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let L of W)GE({name:L.name,status:"ready",port:L.port});Zi();let U=Zi6(import.meta.dir,"..","..","..","..",".."),N=X===!0,F=Bun.spawn(["bun","run","dev:servers"],{cwd:U,env:{...process.env,PORT:String(K.port),VITE_PORT:String(Y),DATABASE_URL:K.databaseUrl,NATS_URL:K.natsUrls.join(","),NODE_ENV:K.nodeEnv,BASE_URL:G,DECOCMS_LOCAL_MODE:String(K.localMode),DECOCMS_HOME:K.dataDir,DATA_DIR:K.dataDir,DECO_CLI:"1",...K.betterAuthSecret?{BETTER_AUTH_SECRET:K.betterAuthSecret}:{},...K.s3Endpoint?{S3_ENDPOINT:K.s3Endpoint,S3_BUCKET:K.s3Bucket??"",S3_ACCESS_KEY_ID:K.s3AccessKeyId??"",S3_SECRET_ACCESS_KEY:K.s3SecretAccessKey??"",S3_FORCE_PATH_STYLE:String(K.s3ForcePathStyle)}:{},...K.natsPublicUrl&&K.natsAccountJwt&&K.natsAccountSigningKey?{NATS_PUBLIC_URL:K.natsPublicUrl,NATS_ACCOUNT_JWT:K.natsAccountJwt,NATS_ACCOUNT_SIGNING_KEY:K.natsAccountSigningKey,NATS_OPERATOR_JWT:K.natsOperatorJwt??"",NATS_TUNNEL_PUBLIC_ENABLED:"true",...K.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}}:{}},stdio:["inherit",N?"inherit":"pipe",N?"inherit":"pipe"]});if(!N)Yt1(F.stdout),Yt1(F.stderr);Xi(G),GE({name:"Vite",status:"ready",port:Number(Y)}),GE({name:"API",status:"ready",port:Number(K.port)});let B=async(L)=>{if(F.kill(L),await F.exited,H.length>0){let{stopServices:D}=await Promise.resolve().then(() => (o50(),t50));await D(K.dataDir)}};return process.on("SIGINT",()=>B("SIGINT")),process.on("SIGTERM",()=>B("SIGTERM")),{port:Number(Y),process:F}}var Am0=O(()=>{Lm0();JE();jm0()});var l90;var Tm0=O(()=>{l90={name:"decocms",version:"4.217.9",description:"Deco CMS \u2014 Self-hostable MCP Gateway for managing AI connections and tools",author:"Deco team",repository:{type:"git",url:"git+https://github.com/decocms/studio.git",directory:"apps/api"},bugs:{url:"https://github.com/decocms/studio/issues"},type:"module",bin:{deco:"./dist/server/cli.js"},files:["dist/**/*"],scripts:{dev:"bun run migrate && bun run dev:server","dev:server":"bun run --cwd=../../packages/sandbox build && NODE_ENV=development bun --env-file=.env --hot run src/index.ts",build:"bun run build:server","build:server":"bun run scripts/bundle-server-script.ts --dist ./dist/server","generate:tool-contracts":"bun run scripts/generate-tool-contracts.ts","db:migrate":"bun run ./dist/server/migrate.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts",test:"bun test src","better-auth:migrate":"bunx --bun @better-auth/cli migrate -y --config src/auth/index.ts",prepublishOnly:"bun run --cwd=../.. build:studio"},optionalDependencies:{"@duckdb/node-api":"^1.5.0-r.1"},dependencies:{"@ai-sdk/anthropic":"^3.0.85","@ai-sdk/google":"^3.0.83","@ai-sdk/openai":"^3.0.73","@anthropic-ai/sdk":"^0.105.0","@aws-sdk/client-s3":"^3.1013.0","@aws-sdk/client-sts":"^3.1013.0","@aws-sdk/lib-storage":"^3.1013.0","@aws-sdk/s3-request-presigner":"^3.1013.0","@clickhouse/client":"^1.8.1","@dbos-inc/dbos-sdk":"^4.21.6","@inkjs/ui":"^2.0.0","@nats-io/jetstream":"3.4.0","@nats-io/kv":"3.4.0","@nats-io/nats-core":"3.4.0","@nats-io/transport-node":"3.4.0","@openrouter/ai-sdk-provider":"^2.9.1","@opentelemetry/core":"^2.6.0","embedded-postgres":"^18.3.0-beta.16",ink:"^6.8.0",kysely:"^0.28.12","posthog-node":"^5.0.0",react:"^19.2.6","react-dom":"^19.2.6"},devDependencies:{"@ai-sdk/provider":"^3.0.10","@better-auth/sso":"1.4.1","@decocms/better-auth":"1.5.17","@decocms/bindings":"workspace:*","@decocms/mcp-utils":"workspace:*","@decocms/runtime":"workspace:*","@decocms/sandbox":"workspace:*","@decocms/shared":"workspace:*","@jitl/quickjs-wasmfile-release-sync":"0.31.0","@modelcontextprotocol/sdk":"1.29.0","@nats-io/jwt":"0.0.10-5","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.211.0","@opentelemetry/exporter-logs-otlp-proto":"^0.211.0","@opentelemetry/exporter-prometheus":"^0.208.0","@opentelemetry/exporter-trace-otlp-proto":"^0.207.0","@opentelemetry/instrumentation-runtime-node":"^0.24.0","@opentelemetry/resources":"^2.6.0","@opentelemetry/sdk-logs":"^0.211.0","@opentelemetry/sdk-metrics":"^2.2.0","@opentelemetry/sdk-node":"^0.207.0","@opentelemetry/sdk-trace-base":"^2.5.0","@types/bun":"^1.3.1","@types/google.maps":"^3.65.2","@types/pg":"^8.15.6","@types/react-syntax-highlighter":"^15.5.13","@vercel/nft":"^1.1.1",ai:"^6.0.208","better-auth":"1.4.22",croner:"^9.1.0",degit:"^2.8.4",hono:"^4.10.7",jose:"^6.0.11",nanoid:"^5.1.6",pg:"^8.16.3",typescript:"^7.0.2",typescript5:"npm:typescript@^5.9.3",zod:"4.3.6"},homepage:"https://github.com/decocms/studio",keywords:["mcp","model-context-protocol","ai","gateway","self-hosted","tools"],license:"MIT",publishConfig:{access:"public"}}});import{Box as Yi6,Text as Gt1}from"ink";import{jsx as Gi6,jsxs as Jt1}from"react/jsx-runtime";function Kt1({version:$}){return Jt1(Yi6,{flexDirection:"column",marginTop:1,children:[L90.map((Z,X)=>Gi6(Gt1,{color:D90[X],children:Z},X)),Jt1(Gt1,{dimColor:!0,children:[" v",$]})]})}var Wt1=O(()=>{dm()});import{Box as KE,Text as kw}from"ink";import{Spinner as Ji6}from"@inkjs/ui";import{jsx as nY,jsxs as Ab}from"react/jsx-runtime";function Ht1({status:$}){if($==="pending")return nY(Ji6,{label:""});return nY(kw,{color:"green",children:"\u2713"})}function Ki6($){return`${$.name}: ${$.port||"...."}`}function Ut1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return Ab(KE,{flexDirection:"column",paddingBottom:1,children:[nY(Kt1,{version:l90.version}),nY(KE,{marginBottom:1,children:nY(kw,{dimColor:!0,children:"\u2500".repeat(80)})}),nY(KE,{children:Ab(kw,{dimColor:!0,children:["Home: ",X]})}),Ab(KE,{gap:2,children:[$.map((Y)=>Ab(KE,{gap:1,children:[nY(kw,{children:Ki6(Y)}),nY(Ht1,{status:Y.status})]},Y.name)),Ab(KE,{gap:1,children:[nY(kw,{children:"Migrations"}),nY(Ht1,{status:Z})]})]}),nY(KE,{children:Q?Ab(kw,{children:["Open in browser: ",nY(kw,{color:"cyan",children:Q})]}):nY(kw,{dimColor:!0,children:"Starting..."})})]})}var Nt1=O(()=>{Tm0();Wt1()});import{Box as Wi6,Text as Gi}from"ink";import{jsx as Rm0,jsxs as Im0}from"react/jsx-runtime";function Hi6($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function Ft1({logs:$}){return Rm0(Wi6,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Rm0(Gi,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return Im0(Gi,{children:[Im0(Gi,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Rm0(Gi,{color:Hi6(Z.status),children:Z.status}),Im0(Gi,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var wt1=()=>{};var qm0={};B0(qm0,{App:()=>Fi6});import{Box as Ui6}from"ink";import{useSyncExternalStore as Ni6}from"react";import{jsx as Bt1,jsxs as wi6}from"react/jsx-runtime";function Fi6({home:$}){let Z=Ni6(zm0,Em0);return wi6(Ui6,{flexDirection:"column",children:[Bt1(Ut1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),Bt1(Ft1,{logs:Z.logs})]})}var Mm0=O(()=>{Nt1();wt1();JE()});var RJ="thread-gate",hU="decopilot-hosted-harness",X3="automations",Sw="background-tools",WE="task-board-github-reads";var Ot1="7";function Lt1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:Ot1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var Dt1=()=>{};function Bi6(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function Vm0($,Z){for(let X=0;X<$.length;X++){let Q=$[X];if(Q===void 0)continue;if(Q===Z)return $[X+1];if(Q.startsWith(`${Z}=`))return Q.slice(Z.length+1)}return}function Et1(){let $=Bi6();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:Vm0($,"--cpu-prof-dir")??process.cwd(),name:Vm0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(Vm0($,"--cpu-prof-interval")??1000),note:"profile is written on process exit"}));return}if(process.env.CPU_PROFILE)console.warn(JSON.stringify({msg:"cpu-profiling-requested-but-inactive",hint:'CPU profiling is a Bun launch flag. Set BUN_OPTIONS="--cpu-prof --cpu-prof-md --cpu-prof-dir=/tmp" before starting the process.'}))}function zt1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=ZE();if(!X)return;let Q={};try{let{heapStats:Y}=await import("bun:jsc"),G=Y(),J=Object.entries(G.objectTypeCounts).sort((K,W)=>W[1]-K[1]).slice(0,20);Q={objectCount:G.objectCount,heapSize:G.heapSize,top:Object.fromEntries(J)}}catch{}console.log(JSON.stringify({msg:"heap-watch",ts:new Date().toISOString(),uptimeS:Math.round(process.uptime()),rss:X.rss,heapUsed:X.heapUsed,heapTotal:X.heapTotal,external:X.external,arrayBuffers:X.arrayBuffers,...Q}))};return Z().catch(()=>{}),d90=setInterval(()=>void Z().catch(()=>{}),$),d90.unref?.(),process.on("SIGUSR2",()=>{try{let X=Bun.generateHeapSnapshot("v8"),Q=typeof X==="string"?X:JSON.stringify(X),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,Q),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(X){console.error("[heap-watch] snapshot failed:",X)}}),()=>{if(d90)clearInterval(d90)}}var d90;var jt1=()=>{};import*as Oi6 from"bun:jsc";function Pt1(){if(process.env.STALL_WATCHDOG!=="1")return()=>{};let $=Number(process.env.STALL_WATCHDOG_MS??100),Z=Number(process.env.STALL_WATCHDOG_TICK_MS??50);try{Li6()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let X,Q=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-Q;Q=G+Z;let K=[];try{K=Di6()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let U of K){let N=U.frames.find((B)=>B.sourceURL&&!/Unknown Executable/.test(B.category??""))??U.frames[0];if(!N)continue;let F=(N.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),w=`${N.name??"?"} @ ${F}:${N.line??"?"}`;W.set(w,(W.get(w)??0)+1)}let H=[...W.entries()].sort((U,N)=>N[1]-U[1]).slice(0,8).map(([U,N])=>({frame:U,count:N}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}X=setTimeout(Y,Z),X.unref?.()};return X=setTimeout(Y,Z),X.unref?.(),()=>{if(X)clearTimeout(X)}}var Li6,Di6;var At1=O(()=>{({startSamplingProfiler:Li6,samplingProfilerStackTraces:Di6}=Oi6)});function Tt1(){Et1();let $=[zt1(),jm1(),Pt1()];return()=>{for(let Z of $)Z()}}var Rt1=O(()=>{ku0();jt1();At1()});var HE=_((It1)=>{Object.defineProperty(It1,"__esModule",{value:!0});It1.RepublishHeaders=It1.DirectMsgHeaders=It1.JsHeaders=It1.AdvisoryKind=void 0;It1.isOrderedPushConsumerOptions=Ei6;It1.isPullConsumer=zi6;It1.isPushConsumer=ji6;It1.isBoundPushConsumerOptions=Pi6;function Ei6($){if($&&typeof $==="object")return"name_prefix"in $||"deliver_subject_prefix"in $||"filter_subjects"in $||"filter_subject"in $||"deliver_policy"in $||"opt_start_seq"in $||"opt_start_time"in $||"replay_policy"in $||"inactive_threshold"in $||"headers_only"in $||"deliver_prefix"in $;return!1}function zi6($){return $.isPullConsumer()}function ji6($){return $.isPushConsumer()}function Pi6($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}It1.AdvisoryKind={API:"api_audit",StreamAction:"stream_action",ConsumerAction:"consumer_action",SnapshotCreate:"snapshot_create",SnapshotComplete:"snapshot_complete",RestoreCreate:"restore_create",RestoreComplete:"restore_complete",MaxDeliver:"max_deliver",Terminated:"terminated",Ack:"consumer_ack",StreamLeaderElected:"stream_leader_elected",StreamQuorumLost:"stream_quorum_lost",ConsumerLeaderElected:"consumer_leader_elected",ConsumerQuorumLost:"consumer_quorum_lost"};It1.JsHeaders={StreamSourceHdr:"Nats-Stream-Source",LastConsumerSeqHdr:"Nats-Last-Consumer",LastStreamSeqHdr:"Nats-Last-Stream",ConsumerStalledHdr:"Nats-Consumer-Stalled",MessageSizeHdr:"Nats-Msg-Size",RollupHdr:"Nats-Rollup",RollupValueSubject:"sub",RollupValueAll:"all",PendingMessagesHdr:"Nats-Pending-Messages",PendingBytesHdr:"Nats-Pending-Bytes",RequiredApiLevel:"Nats-Required-Api-Level"};It1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};It1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var pY=_((Mt1)=>{Object.defineProperty(Mt1,"__esModule",{value:!0});Mt1.TD=Mt1.TE=Mt1.Empty=void 0;Mt1.encode=Si6;Mt1.decode=Ci6;Mt1.Empty=new Uint8Array(0);Mt1.TE=new TextEncoder;Mt1.TD=new TextDecoder;function ki6(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}function Si6(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(Mt1.TE.encode($[X]));if(Z.length===0)return Mt1.Empty;if(Z.length===1)return Z[0];return ki6(...Z)}function Ci6($){if(!$||$.length===0)return"";return Mt1.TD.decode($)}});var tY=_((St1)=>{Object.defineProperty(St1,"__esModule",{value:!0});St1.errors=St1.PermissionViolationError=St1.NoRespondersError=St1.TimeoutError=St1.RequestError=St1.ProtocolError=St1.ConnectionError=St1.DrainingConnectionError=St1.ClosedConnectionError=St1.AuthorizationError=St1.UserAuthenticationExpiredError=St1.InvalidOperationError=St1.InvalidArgumentError=St1.InvalidSubjectError=void 0;class Sm0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}St1.InvalidSubjectError=Sm0;class m90 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,X){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((Q)=>`'${Q}'`),$=$.join(",");else $=`'${$}'`;return new m90(`${$} ${Z}`,X)}}St1.InvalidArgumentError=m90;class Cm0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}St1.InvalidOperationError=Cm0;class i90 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new i90($);return null}}St1.UserAuthenticationExpiredError=i90;class n90 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],X=$.toLowerCase();for(let Q=0;Q<Z.length;Q++)if(X.indexOf(Z[Q])!==-1)return new n90($);return null}}St1.AuthorizationError=n90;class _m0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}St1.ClosedConnectionError=_m0;class vm0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}St1.DrainingConnectionError=vm0;class xm0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}St1.ConnectionError=xm0;class fm0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}St1.ProtocolError=fm0;class bm0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof p90}}St1.RequestError=bm0;class ym0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}St1.TimeoutError=ym0;class p90 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}St1.NoRespondersError=p90;class t90 extends Error{operation;subject;queue;constructor($,Z,X,Q,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=X,this.queue=Q}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let X="publish",Q="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(X=G[1].toLowerCase(),Q=G[2],X==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new t90($,X,Q,Y)}}St1.PermissionViolationError=t90;St1.errors={AuthorizationError:n90,ClosedConnectionError:_m0,ConnectionError:xm0,DrainingConnectionError:vm0,InvalidArgumentError:m90,InvalidOperationError:Cm0,InvalidSubjectError:Sm0,NoRespondersError:p90,PermissionViolationError:t90,ProtocolError:fm0,RequestError:bm0,TimeoutError:ym0,UserAuthenticationExpiredError:i90}});var IJ=_((ft1)=>{Object.defineProperty(ft1,"__esModule",{value:!0});ft1.SimpleMutex=ft1.Perf=void 0;ft1.extend=ti6;ft1.render=oi6;ft1.timeout=ri6;ft1.delay=ai6;ft1.deadline=si6;ft1.deferred=hm0;ft1.debugDeferred=ei6;ft1.shuffle=$n6;ft1.collect=Zn6;ft1.jitter=xt1;ft1.backoff=Xn6;ft1.nanos=Qn6;ft1.millis=Yn6;ft1.randomToken=Kn6;var pi6=pY(),gm0=tY();function ti6($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function oi6($){return pi6.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function ri6($,Z=!0){let X=Z?new gm0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new gm0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function ai6($=0){let Z,X=new Promise((Q)=>{let Y=setTimeout(()=>{Q()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),Q()}}});return Object.assign(X,Z)}async function si6($,Z=1000){let X=hm0(),Q=setTimeout(()=>{X.reject(new gm0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function hm0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function ei6(){let $={},Z=new Promise((X,Q)=>{$={resolve:(Y)=>{console.trace("resolve",Y),X(Y)},reject:(Y)=>{console.trace("reject"),Q(Y)}}});return Object.assign(Z,$)}function $n6($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function Zn6($){let Z=[];for await(let X of $)Z.push(X);return Z}class _t1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,X){let Q=this.timers.get(Z);if(Q===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(X);if(Y===void 0)throw Error(`${X} is not defined`);this.measures.set($,Y-Q)}getEntries(){let $=[];return this.measures.forEach((Z,X)=>{$.push({name:X,duration:Z})}),$}}ft1.Perf=_t1;class vt1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=hm0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}ft1.SimpleMutex=vt1;function xt1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function Xn6($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(X){return xt1(X>Z?$[Z]:$[X])}}}function Qn6($){return $*1e6}function Yn6($){return Math.floor($/1e6)}var Gn6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",uU=new Uint8Array(62);for(let $=0;$<62;$++)uU[$]=Gn6.charCodeAt($);var Jn6=218340105584896;function Kn6(){let $=Math.floor(Math.random()*Jn6),Z=$%62,X=uU[Z];$=($-Z)/62,Z=$%62;let Q=uU[Z];$=($-Z)/62,Z=$%62;let Y=uU[Z];$=($-Z)/62,Z=$%62;let G=uU[Z];$=($-Z)/62,Z=$%62;let J=uU[Z];$=($-Z)/62,Z=$%62;let K=uU[Z];$=($-Z)/62,Z=$%62;let W=uU[Z];$=($-Z)/62;let H=uU[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var dt1=_((ct1)=>{Object.defineProperty(ct1,"__esModule",{value:!0});ct1.nuid=ct1.NuidImpl=void 0;var Tn6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Cw=62,r90=12,ht1=10,yt1=33,Rn6=333,gt1=r90+ht1,cm0=new Uint8Array(Cw);for(let $=0;$<Cw;$++)cm0[$]=Tn6.charCodeAt($);var o90=4294967296,ut1=BigInt(Cw)**BigInt(ht1),Ji=Number(ut1/(1n<<32n)),um0=Number(ut1%(1n<<32n));function In6($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function qn6($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else In6($)}class lm0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(gt1),this.cbuf=new Uint8Array(r90),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(Ji+1)),this.seqLo=Math.floor(Math.random()*o90);while($++<8&&this.seqHi===Ji&&this.seqLo>=um0);if(this.seqHi===Ji&&this.seqLo>=um0)this.seqLo=0;this.inc=Math.random()*(Rn6-yt1)+yt1|0}setPre(){qn6(this.cbuf);for(let $=0;$<r90;$++)this.buf[$]=cm0[this.cbuf[$]%Cw]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=gt1-1;X>=r90;X--){let Q=Math.floor($/Cw),G=($-Q*Cw)*o90+Z,J=Math.floor(G/Cw),K=G-J*Cw;this.buf[X]=cm0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=o90)this.seqLo-=o90,this.seqHi+=1;if(this.seqHi>Ji||this.seqHi===Ji&&this.seqLo>=um0)this.setPre(),this.initSeqAndInc();this.fillSeq();let $=this.buf;return String.fromCharCode($[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],$[8],$[9],$[10],$[11],$[12],$[13],$[14],$[15],$[16],$[17],$[18],$[19],$[20],$[21])}reset(){this.init()}}ct1.NuidImpl=lm0;ct1.nuid=new lm0});var pt1=_((it1)=>{Object.defineProperty(it1,"__esModule",{value:!0});it1.nuid=it1.Nuid=void 0;var mt1=dt1();it1.Nuid=mt1.NuidImpl;it1.nuid=mt1.nuid});var s90=_((a90)=>{Object.defineProperty(a90,"__esModule",{value:!0});a90.nuid=a90.Nuid=void 0;var tt1=pt1();Object.defineProperty(a90,"Nuid",{enumerable:!0,get:function(){return tt1.Nuid}});Object.defineProperty(a90,"nuid",{enumerable:!0,get:function(){return tt1.nuid}})});var _w=_((ot1)=>{Object.defineProperty(ot1,"__esModule",{value:!0});ot1.DEFAULT_HOST=ot1.DEFAULT_PORT=ot1.Match=void 0;ot1.syncIterator=_n6;ot1.createInbox=vn6;var Sn6=s90(),Cn6=tY();ot1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function _n6($){let Z=$[Symbol.asyncIterator]();return{async next(){let X=await Z.next();if(X.done)return Promise.resolve(null);return Promise.resolve(X.value)}}}function vn6($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw Cn6.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${Sn6.nuid.next()}`}ot1.DEFAULT_PORT=4222;ot1.DEFAULT_HOST="127.0.0.1"});var Ki=_((et1)=>{Object.defineProperty(et1,"__esModule",{value:!0});et1.DataBuffer=void 0;var at1=pY();class st1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let X=new Uint8Array(Z),Q=0;for(let Y=0;Y<$.length;Y++)X.set($[Y],Q),Q+=$[Y].length;return X}static fromAscii($){if(!$)$="";return at1.TE.encode($)}static toAscii($){return at1.TD.decode($)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){let $=new Uint8Array(this.byteLength),Z=0;for(let X=0;X<this.buffers.length;X++)$.set(this.buffers[X],Z),Z+=this.buffers[X].length;this.buffers.length=0,this.buffers.push($)}}shift(){if(this.buffers.length){let $=this.buffers.shift();if($)return this.byteLength-=$.length,$}return new Uint8Array(0)}drain($){if(this.buffers.length){this.pack();let Z=this.buffers.pop();if(Z){let X=this.byteLength;if($===void 0||$>X)$=X;let Q=Z.subarray(0,$);if(X>$)this.buffers.push(Z.subarray($));return this.byteLength=X-$,Q}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let X=0;X<Z.length;X++)if(Z[X]&&Z[X].length)this.buffers.push(Z[X]),this.byteLength+=Z[X].length}peek(){if(this.buffers.length)return this.pack(),this.buffers[0];return new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}et1.DataBuffer=st1});var UE=_((Xo1)=>{Object.defineProperty(Xo1,"__esModule",{value:!0});Xo1.LF=Xo1.CR=Xo1.CRLF=Xo1.CR_LF_LEN=Xo1.CR_LF=void 0;Xo1.setTransportFactory=cn6;Xo1.defaultPort=ln6;Xo1.getUrlParseFn=dn6;Xo1.newTransport=mn6;Xo1.getResolveFn=in6;Xo1.protoLen=Zo1;Xo1.extractProtocolMessage=nn6;var gn6=pY(),hn6=_w(),un6=Ki(),oY;function cn6($){oY=$}function ln6(){return oY!==void 0&&oY.defaultPort!==void 0?oY.defaultPort:hn6.DEFAULT_PORT}function dn6(){return oY!==void 0&&oY.urlParseFn?oY.urlParseFn:void 0}function mn6(){if(!oY||typeof oY.factory!=="function")throw Error("transport fn is not set");return oY.factory()}function in6(){return oY!==void 0&&oY.dnsResolveFn?oY.dnsResolveFn:void 0}Xo1.CR_LF=`\r
1336
1336
  `;Xo1.CR_LF_LEN=Xo1.CR_LF.length;Xo1.CRLF=un6.DataBuffer.fromAscii(Xo1.CR_LF);Xo1.CR=new Uint8Array(Xo1.CRLF)[0];Xo1.LF=new Uint8Array(Xo1.CRLF)[1];function Zo1($){for(let Z=0;Z<$.length;Z++){let X=Z+1;if($.byteLength>X&&$[Z]===Xo1.CR&&$[X]===Xo1.LF)return X+1}return 0}function nn6($){let Z=Zo1($);if(Z>0){let Q=new Uint8Array($).slice(0,Z);return gn6.TD.decode(Q)}return""}});var pm0=_((Uo1)=>{Object.defineProperty(Uo1,"__esModule",{value:!0});Uo1.ipV4=Ko1;Uo1.isIP=Qp6;Uo1.parseIP=Wo1;var Wi=4,NE=16,e90=48,Jo1=57,Yo1=65,Zp6=70,Go1=97,Xp6=102,nm0=16777215;function Ko1($,Z,X,Q){let Y=new Uint8Array(NE);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((J,K)=>{Y[K]=J}),Y[12]=$,Y[13]=Z,Y[14]=X,Y[15]=Q,Y}function Qp6($){return Wo1($)!==void 0}function Wo1($){for(let Z=0;Z<$.length;Z++)switch($[Z]){case".":return Ho1($);case":":return Yp6($)}return}function Ho1($){let Z=new Uint8Array(Wi);for(let X=0;X<Wi;X++){if($.length===0)return;if(X>0){if($[0]!==".")return;$=$.substring(1)}let{n:Q,c:Y,ok:G}=Gp6($);if(!G||Q>255)return;$=$.substring(Y),Z[X]=Q}return Ko1(Z[0],Z[1],Z[2],Z[3])}function Yp6($){let Z=new Uint8Array(NE),X=-1;if($.length>=2&&$[0]===":"&&$[1]===":"){if(X=0,$=$.substring(2),$.length===0)return Z}let Q=0;while(Q<NE){let{n:Y,c:G,ok:J}=Jp6($);if(!J||Y>65535)return;if(G<$.length&&$[G]==="."){if(X<0&&Q!=NE-Wi)return;if(Q+Wi>NE)return;let K=Ho1($);if(K===void 0)return;Z[Q]=K[12],Z[Q+1]=K[13],Z[Q+2]=K[14],Z[Q+3]=K[15],$="",Q+=Wi;break}if(Z[Q]=Y>>8,Z[Q+1]=Y,Q+=2,$=$.substring(G),$.length===0)break;if($[0]!==":"||$.length==1)return;if($=$.substring(1),$[0]===":"){if(X>=0)return;if(X=Q,$=$.substring(1),$.length===0)break}}if($.length!==0)return;if(Q<NE){if(X<0)return;let Y=NE-Q;for(let G=Q-1;G>=X;G--)Z[G+Y]=Z[G];for(let G=X+Y-1;G>=X;G--)Z[G]=0}else if(X>=0)return;return Z}function Gp6($){let Z=0,X=0;for(Z=0;Z<$.length&&e90<=$.charCodeAt(Z)&&$.charCodeAt(Z)<=Jo1;Z++)if(X=X*10+($.charCodeAt(Z)-e90),X>=nm0)return{n:nm0,c:Z,ok:!1};if(Z===0)return{n:0,c:0,ok:!1};return{n:X,c:Z,ok:!0}}function Jp6($){let Z=0,X=0;for(X=0;X<$.length;X++){if(e90<=$.charCodeAt(X)&&$.charCodeAt(X)<=Jo1)Z*=16,Z+=$.charCodeAt(X)-e90;else if(Go1<=$.charCodeAt(X)&&$.charCodeAt(X)<=Xp6)Z*=16,Z+=$.charCodeAt(X)-Go1+10;else if(Yo1<=$.charCodeAt(X)&&$.charCodeAt(X)<=Zp6)Z*=16,Z+=$.charCodeAt(X)-Yo1+10;else break;if(Z>=nm0)return{n:0,c:X,ok:!1}}if(X===0)return{n:0,c:X,ok:!1};return{n:Z,c:X,ok:!0}}});var em0=_((Fo1)=>{Object.defineProperty(Fo1,"__esModule",{value:!0});Fo1.Servers=Fo1.ServerImpl=void 0;Fo1.isIPV4OrHostname=No1;Fo1.hostPort=sm0;var tm0=UE(),om0=IJ(),rm0=pm0(),Up6=_w(),Np6=tY();function No1($){if($.indexOf("[")!==-1||$.indexOf("::")!==-1)return!1;if($.indexOf(".")!==-1)return!0;if($.split(":").length<=2)return!0;return!1}function am0($){return!No1($)}function Fp6($){let X=$.toUpperCase().indexOf("::FFFF:");if(X!==-1&&$.indexOf(".")!==-1){let Q=$.substring(X+7);return Q=Q.replace("[",""),Q.replace("]","")}return $}function sm0($){if($=$.trim(),$.match(/^(.*:\/\/)(.*)/m))$=$.replace(/^(.*:\/\/)(.*)/gm,"$2");if($=Fp6($),am0($)&&$.indexOf("[")===-1)$=`[${$}]`;let Z=am0($)?$.match(/(]:)(\d+)/):$.match(/(:)(\d+)/),X=Z&&Z.length===3&&Z[1]&&Z[2]?parseInt(Z[2]):Up6.DEFAULT_PORT,Y=new URL(`${X===80?"https":"http"}://${$}`);Y.port=`${X}`;let G=Y.hostname;if(G.charAt(0)==="[")G=G.substring(1,G.length-1);return{listen:Y.host,hostname:G,port:X}}class Tb{src;listen;hostname;port;didConnect;reconnects;lastConnect;gossiped;tlsName;resolves;constructor($,Z=!1){this.src=$,this.tlsName="";let X=sm0($);this.listen=X.listen,this.hostname=X.hostname,this.port=X.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=Z}toString(){return this.listen}async resolve($){if(!$.fn||$.resolve===!1)return[this];let Z=[];if((0,rm0.isIP)(this.hostname))return[this];else{let X=await $.fn(this.hostname);if($.debug)console.log(`resolve ${this.hostname} = ${X.join(",")}`);for(let Q of X){let Y=this.port===80?"https":"http",G=new URL(`${Y}://${am0(Q)?"["+Q+"]":Q}`);G.port=`${this.port}`;let J=new Tb(G.host,!1);J.tlsName=this.hostname,Z.push(J)}}if($.randomize)(0,om0.shuffle)(Z);return this.resolves=Z,Z}}Fo1.ServerImpl=Tb;class $Z0{firstSelect;servers;currentServer;tlsName;randomize;constructor($={}){this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=$.randomize||!1}setServers($){if(!Array.isArray($)||$.length===0)throw Np6.InvalidArgumentError.format("servers","cannot be empty");let Z=(0,tm0.getUrlParseFn)(),X=new Map;for(let Y of this.servers)X.set(Y.listen,Y);let Q=[];for(let Y of $){Y=Z?Z(Y):Y;let{listen:G}=sm0(Y),J=X.get(G);if(J)J.gossiped=!1,Q.push(J);else Q.push(new Tb(Y))}if(this.randomize)(0,om0.shuffle)(Q);if(this.servers=Q,this.currentServer===void 0||!Q.includes(this.currentServer))this.currentServer=Q[0],this.firstSelect=!0}clear(){this.servers.length=0}updateTLSName(){let $=this.getCurrentServer();if(!(0,rm0.isIP)($.hostname))this.tlsName=$.hostname,this.servers.forEach((Z)=>{if(Z.gossiped)Z.tlsName=this.tlsName})}getCurrentServer(){return this.currentServer}addServer($,Z=!1){let X=(0,tm0.getUrlParseFn)();$=X?X($):$;let Q=new Tb($,Z);if((0,rm0.isIP)(Q.hostname))Q.tlsName=this.tlsName;this.servers.push(Q)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;let $=this.servers.shift();if($)this.servers.push($),this.currentServer=$;return $}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer($){if($){let Z=this.servers.indexOf($);this.servers.splice(Z,1)}}snapshot(){return $Z0.freezeAll(this.servers)}snapshotForHandler(){let $=this.currentServer;if(!$)return this.snapshot();let Z=this.servers.indexOf($);if(Z<=0)return this.snapshot();return $Z0.freezeAll([$,...this.servers.slice(0,Z),...this.servers.slice(Z+1)])}static freezeAll($){return $.map((Z)=>Object.freeze({hostname:Z.hostname,port:Z.port,listen:Z.listen,src:Z.src,tlsName:Z.tlsName,reconnects:Z.reconnects,lastConnect:Z.lastConnect,gossiped:Z.gossiped,didConnect:Z.didConnect}))}find($){return this.servers.find((Z)=>Z.listen===$.listen)}setCurrent($){this.currentServer=$}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update($,Z){let X=[],Q=[],Y=(0,tm0.getUrlParseFn)(),G=new Map;if($.connect_urls&&$.connect_urls.length>0)$.connect_urls.forEach((K)=>{K=Y?Y(K,Z):K;let W=new Tb(K,!0);G.set(K,W)});let J=[];if(this.servers.forEach((K,W)=>{let H=K.listen;if(K.gossiped&&this.currentServer.listen!==H&&G.get(H)===void 0)J.push(W);G.delete(H)}),J.reverse(),J.forEach((K)=>{let W=this.servers.splice(K,1);Q=Q.concat(W[0].listen)}),G.forEach((K,W)=>{this.servers.push(K),X.push(W)}),this.randomize&&X.length>0){let K=this.currentServer,W=this.servers.filter((H)=>H!==K);(0,om0.shuffle)(W),this.servers=K?[K,...W]:W}return{added:X,deleted:Q}}}Fo1.Servers=$Z0});var ZZ0=_((Lo1)=>{Object.defineProperty(Lo1,"__esModule",{value:!0});Lo1.QueuedIteratorImpl=void 0;var $i0=IJ(),Bo1=tY();class Oo1{inflight;processed;received;noIterator;iterClosed;done;signal;yields;filtered;pendingFiltered;ctx;_data;err;time;profile;yielding;didBreak;constructor(){this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=(0,$i0.deferred)(),this.yields=[],this.iterClosed=(0,$i0.deferred)(),this.time=0,this.yielding=!1,this.didBreak=!1,this.profile=!1}[Symbol.asyncIterator](){return this.iterate()}push($){if(this.done)return;if(this.didBreak){if(typeof $==="function"){let Z=$;try{Z()}catch(X){}}return}if(typeof $==="function")this.pendingFiltered++;this.yields.push($),this.signal.resolve()}async*iterate(){if(this.noIterator)throw new Bo1.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new Bo1.InvalidOperationError("iterator is already yielding");this.yielding=!0;try{while(!0){if(this.yields.length===0)await this.signal;if(this.err)throw this.err;let $=this.yields;this.inflight=$.length,this.yields=[];for(let Z=0;Z<$.length;Z++){if(typeof $[Z]==="function"){this.pendingFiltered--;let Q=$[Z];try{Q()}catch(Y){throw Y}if(this.err)throw this.err;continue}this.processed++,this.inflight--;let X=this.profile?Date.now():0;yield $[Z],this.time=this.profile?Date.now()-X:0}if(this.done)break;else if(this.yields.length===0)$.length=0,this.yields=$,this.signal=(0,$i0.deferred)()}}finally{this.didBreak=!0,this.stop()}}stop($){if(this.done)return;this.err=$,this.done=!0,this.signal.resolve(),this.iterClosed.resolve($)}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}Lo1.QueuedIteratorImpl=Oo1});var Zi0=_((jo1)=>{Object.defineProperty(jo1,"__esModule",{value:!0});jo1.MuxSubscription=void 0;var Lp6=_w(),Eo1=tY();class zo1{baseInbox;reqs;constructor(){this.reqs=new Map}size(){return this.reqs.size}init($){return this.baseInbox=`${(0,Lp6.createInbox)($)}.`,this.baseInbox}add($){if(!isNaN($.received))$.received=0;this.reqs.set($.token,$)}get($){return this.reqs.get($)}cancel($){this.reqs.delete($.token)}getToken($){let Z=$.subject||"";if(Z.indexOf(this.baseInbox)===0)return Z.substring(this.baseInbox.length);return null}all(){return Array.from(this.reqs.values())}handleError($,Z){if($)return this.all().forEach((X)=>{X.resolver(Z,{})}),!0;if(Z.operation==="publish"){let X=this.all().find((Q)=>{return Q.requestSubject===Z.subject});if(X)return X.resolver(Z,{}),!0}return!1}dispatcher(){return($,Z)=>{let X=this.getToken(Z);if(X){let Q=this.get(X);if(Q){if($===null)$=Z?.data?.length===0&&Z.headers?.code===503?new Eo1.NoRespondersError(Q.requestSubject):null;Q.resolver($,Z)}}}}close(){let $=new Eo1.RequestError("connection closed");this.reqs.forEach((Z)=>{Z.resolver($,{})})}}jo1.MuxSubscription=zo1});var Xi0=_((To1)=>{Object.defineProperty(To1,"__esModule",{value:!0});To1.Heartbeat=void 0;var Dp6=IJ();class Ao1{ph;interval;maxOut;timer;pendings;constructor($,Z,X){this.ph=$,this.interval=Z,this.maxOut=X,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel($){if(this.timer)clearTimeout(this.timer),this.timer=void 0;if(this._reset(),$)this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:"ping",pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}let $=(0,Dp6.deferred)();this.ph.flush($).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push($),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(($)=>{return $.resolve(),!1})}}To1.Heartbeat=Ao1});var Gi0=_((Vo1)=>{Object.defineProperty(Vo1,"__esModule",{value:!0});Vo1.DenoBuffer=Vo1.MAX_SIZE=Vo1.AssertionError=void 0;Vo1.assert=qo1;Vo1.concat=Mo1;Vo1.append=zp6;Vo1.readAll=jp6;Vo1.writeAll=Pp6;var Ep6=pY();class Qi0 extends Error{constructor($){super($);this.name="AssertionError"}}Vo1.AssertionError=Qi0;function qo1($,Z="Assertion failed."){if(!$)throw new Qi0(Z)}var Io1=32768;Vo1.MAX_SIZE=4294967294;function XZ0($,Z,X=0){let Q=Z.byteLength-X;if($.byteLength>Q)$=$.subarray(0,Q);return Z.set($,X),$.byteLength}function Mo1($,Z){if($===void 0&&Z===void 0)return new Uint8Array(0);if($===void 0)return Z;if(Z===void 0)return $;let X=new Uint8Array($.length+Z.length);return X.set($,0),X.set(Z,$.length),X}function zp6($,Z){return Mo1($,Uint8Array.of(Z))}class Yi0{_buf;_off;constructor($){if(this._off=0,$==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array($)}bytes($={copy:!0}){if($.copy===!1)return this._buf.subarray(this._off);return this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate($){if($===0){this.reset();return}if($<0||$>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+$)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice($){let Z=this._buf.byteLength;if($<=this.capacity-Z)return this._reslice(Z+$),Z;return-1}_reslice($){qo1($<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,$)}readByte(){let $=new Uint8Array(1);if(this.read($))return $[0];return null}read($){if(this.empty()){if(this.reset(),$.byteLength===0)return 0;return null}let Z=XZ0(this._buf.subarray(this._off),$);return this._off+=Z,Z}writeByte($){return this.write(Uint8Array.of($))}writeString($){return this.write(Ep6.TE.encode($))}write($){let Z=this._grow($.byteLength);return XZ0($,this._buf,Z)}_grow($){let Z=this.length;if(Z===0&&this._off!==0)this.reset();let X=this._tryGrowByReslice($);if(X>=0)return X;let Q=this.capacity;if($<=Math.floor(Q/2)-Z)XZ0(this._buf.subarray(this._off),this._buf);else if(Q+$>Vo1.MAX_SIZE)throw Error("The buffer cannot be grown beyond the maximum size.");else{let Y=new Uint8Array(Math.min(2*Q+$,Vo1.MAX_SIZE));XZ0(this._buf.subarray(this._off),Y),this._buf=Y}return this._off=0,this._reslice(Math.min(Z+$,Vo1.MAX_SIZE)),Z}grow($){if($<0)throw Error("Buffer._grow: negative count");let Z=this._grow($);this._reslice(Z)}readFrom($){let Z=0,X=new Uint8Array(Io1);while(!0){let Q=this.capacity-this.length<Io1,Y=Q?X:new Uint8Array(this._buf.buffer,this.length),G=$.read(Y);if(G===null)return Z;if(Q)this.write(Y.subarray(0,G));else this._reslice(this.length+G);Z+=G}}}Vo1.DenoBuffer=Yi0;function jp6($){let Z=new Yi0;return Z.readFrom($),Z.bytes()}function Pp6($,Z){let X=0;while(X<Z.length)X+=$.write(Z.subarray(X))}});var Wi0=_((vo1)=>{Object.defineProperty(vo1,"__esModule",{value:!0});vo1.cc=vo1.State=vo1.Parser=vo1.Kind=void 0;vo1.describe=Vp6;var Ji0=Gi0(),Ki0=pY();vo1.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function Vp6($){let Z,X="";switch($.kind){case vo1.Kind.MSG:Z="MSG";break;case vo1.Kind.OK:Z="OK";break;case vo1.Kind.ERR:Z="ERR",X=Ki0.TD.decode($.data);break;case vo1.Kind.PING:Z="PING";break;case vo1.Kind.PONG:Z="PONG";break;case vo1.Kind.INFO:Z="INFO",X=Ki0.TD.decode($.data)}return`${Z}: ${X}`}function So1(){let $={};return $.sid=-1,$.hdr=-1,$.size=-1,$}var Co1=48,kp6=57,Rb=67108864;class _o1{dispatcher;state;as;drop;hdr;ma;argBuf;msgBuf;constructor($){this.dispatcher=$,this.state=vo1.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse($){let Z;for(Z=0;Z<$.length;Z++){let X=$[Z];switch(this.state){case vo1.State.OP_START:switch(X){case vo1.cc.M:case vo1.cc.m:this.state=vo1.State.OP_M,this.hdr=-1,this.ma=So1();break;case vo1.cc.H:case vo1.cc.h:this.state=vo1.State.OP_H,this.hdr=0,this.ma=So1();break;case vo1.cc.P:case vo1.cc.p:this.state=vo1.State.OP_P;break;case vo1.cc.PLUS:this.state=vo1.State.OP_PLUS;break;case vo1.cc.MINUS:this.state=vo1.State.OP_MINUS;break;case vo1.cc.I:case vo1.cc.i:this.state=vo1.State.OP_I;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_H:switch(X){case vo1.cc.M:case vo1.cc.m:this.state=vo1.State.OP_M;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_M:switch(X){case vo1.cc.S:case vo1.cc.s:this.state=vo1.State.OP_MS;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_MS:switch(X){case vo1.cc.G:case vo1.cc.g:this.state=vo1.State.OP_MSG;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_MSG:switch(X){case vo1.cc.SPACE:case vo1.cc.TAB:this.state=vo1.State.OP_MSG_SPC;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_MSG_SPC:switch(X){case vo1.cc.SPACE:case vo1.cc.TAB:continue;default:this.state=vo1.State.MSG_ARG,this.as=Z}break;case vo1.State.MSG_ARG:switch(X){case vo1.cc.CR:this.drop=1;break;case vo1.cc.NL:{let Q=this.argBuf?this.argBuf.bytes():$.subarray(this.as,Z-this.drop);this.processMsgArgs(Q),this.drop=0,this.as=Z+1,this.state=vo1.State.MSG_PAYLOAD,Z=this.as+this.ma.size-1;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;case vo1.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){let Q=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:vo1.Kind.MSG,msg:this.ma,data:Q}),this.argBuf=void 0,this.msgBuf=void 0,this.state=vo1.State.MSG_END}else{let Q=this.ma.size-this.msgBuf.length,Y=$.length-Z;if(Y<Q)Q=Y;if(Q>0)this.msgBuf.write($.subarray(Z,Z+Q)),Z=Z+Q-1;else this.msgBuf.writeByte(X)}else if(Z-this.as>=this.ma.size)this.dispatcher.push({kind:vo1.Kind.MSG,msg:this.ma,data:$.subarray(this.as,Z)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=vo1.State.MSG_END;break;case vo1.State.MSG_END:switch(X){case vo1.cc.NL:this.drop=0,this.as=Z+1,this.state=vo1.State.OP_START;break;default:continue}break;case vo1.State.OP_PLUS:switch(X){case vo1.cc.O:case vo1.cc.o:this.state=vo1.State.OP_PLUS_O;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_PLUS_O:switch(X){case vo1.cc.K:case vo1.cc.k:this.state=vo1.State.OP_PLUS_OK;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_PLUS_OK:switch(X){case vo1.cc.NL:this.dispatcher.push({kind:vo1.Kind.OK}),this.drop=0,this.state=vo1.State.OP_START;break}break;case vo1.State.OP_MINUS:switch(X){case vo1.cc.E:case vo1.cc.e:this.state=vo1.State.OP_MINUS_E;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_MINUS_E:switch(X){case vo1.cc.R:case vo1.cc.r:this.state=vo1.State.OP_MINUS_ER;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_MINUS_ER:switch(X){case vo1.cc.R:case vo1.cc.r:this.state=vo1.State.OP_MINUS_ERR;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_MINUS_ERR:switch(X){case vo1.cc.SPACE:case vo1.cc.TAB:this.state=vo1.State.OP_MINUS_ERR_SPC;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_MINUS_ERR_SPC:switch(X){case vo1.cc.SPACE:case vo1.cc.TAB:continue;default:this.state=vo1.State.MINUS_ERR_ARG,this.as=Z}break;case vo1.State.MINUS_ERR_ARG:switch(X){case vo1.cc.CR:this.drop=1;break;case vo1.cc.NL:{let Q;if(this.argBuf)Q=this.argBuf.bytes(),this.argBuf=void 0;else Q=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:vo1.Kind.ERR,data:Q}),this.drop=0,this.as=Z+1,this.state=vo1.State.OP_START;break}default:if(this.argBuf)this.argBuf.write(Uint8Array.of(X))}break;case vo1.State.OP_P:switch(X){case vo1.cc.I:case vo1.cc.i:this.state=vo1.State.OP_PI;break;case vo1.cc.O:case vo1.cc.o:this.state=vo1.State.OP_PO;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_PO:switch(X){case vo1.cc.N:case vo1.cc.n:this.state=vo1.State.OP_PON;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_PON:switch(X){case vo1.cc.G:case vo1.cc.g:this.state=vo1.State.OP_PONG;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_PONG:switch(X){case vo1.cc.NL:this.dispatcher.push({kind:vo1.Kind.PONG}),this.drop=0,this.state=vo1.State.OP_START;break}break;case vo1.State.OP_PI:switch(X){case vo1.cc.N:case vo1.cc.n:this.state=vo1.State.OP_PIN;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_PIN:switch(X){case vo1.cc.G:case vo1.cc.g:this.state=vo1.State.OP_PING;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_PING:switch(X){case vo1.cc.NL:this.dispatcher.push({kind:vo1.Kind.PING}),this.drop=0,this.state=vo1.State.OP_START;break}break;case vo1.State.OP_I:switch(X){case vo1.cc.N:case vo1.cc.n:this.state=vo1.State.OP_IN;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_IN:switch(X){case vo1.cc.F:case vo1.cc.f:this.state=vo1.State.OP_INF;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_INF:switch(X){case vo1.cc.O:case vo1.cc.o:this.state=vo1.State.OP_INFO;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_INFO:switch(X){case vo1.cc.SPACE:case vo1.cc.TAB:this.state=vo1.State.OP_INFO_SPC;break;default:throw this.fail($.subarray(Z))}break;case vo1.State.OP_INFO_SPC:switch(X){case vo1.cc.SPACE:case vo1.cc.TAB:continue;default:this.state=vo1.State.INFO_ARG,this.as=Z}break;case vo1.State.INFO_ARG:switch(X){case vo1.cc.CR:this.drop=1;break;case vo1.cc.NL:{let Q;if(this.argBuf)Q=this.argBuf.bytes(),this.argBuf=void 0;else Q=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:vo1.Kind.INFO,data:Q}),this.drop=0,this.as=Z+1,this.state=vo1.State.OP_START;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;default:throw this.fail($.subarray(Z))}}if((this.state===vo1.State.MSG_ARG||this.state===vo1.State.MINUS_ERR_ARG||this.state===vo1.State.INFO_ARG)&&!this.argBuf)this.argBuf=new Ji0.DenoBuffer($.subarray(this.as,Z-this.drop));if(this.state===vo1.State.MSG_PAYLOAD&&!this.msgBuf){if(!this.argBuf)this.cloneMsgArg();this.msgBuf=new Ji0.DenoBuffer($.subarray(this.as))}}cloneMsgArg(){let $=this.ma.subject.length,Z=this.ma.reply?this.ma.reply.length:0,X=new Uint8Array($+Z);if(X.set(this.ma.subject),this.ma.reply)X.set(this.ma.reply,$);if(this.argBuf=new Ji0.DenoBuffer(X),this.ma.subject=X.subarray(0,$),this.ma.reply)this.ma.reply=X.subarray($)}processMsgArgs($){if(this.hdr>=0)return this.processHeaderMsgArgs($);let Z=[],X=-1;for(let Q=0;Q<$.length;Q++)switch($[Q]){case vo1.cc.SPACE:case vo1.cc.TAB:case vo1.cc.CR:case vo1.cc.NL:if(X>=0)Z.push($.subarray(X,Q)),X=-1;break;default:if(X<0)X=Q}if(X>=0)Z.push($.subarray(X));switch(Z.length){case 3:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(Z[2],Rb);break;case 4:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=Z[2],this.ma.size=this.protoParseInt(Z[3],Rb);break;default:throw this.fail($,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail($,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail($,"processMsgArgs Bad or Missing Size Error")}fail($,Z=""){if(!Z)Z=`parse error [${this.state}]`;else Z=`${Z} [${this.state}]`;return Error(`${Z}: ${Ki0.TD.decode($)}`)}processHeaderMsgArgs($){let Z=[],X=-1;for(let Q=0;Q<$.length;Q++)switch($[Q]){case vo1.cc.SPACE:case vo1.cc.TAB:case vo1.cc.CR:case vo1.cc.NL:if(X>=0)Z.push($.subarray(X,Q)),X=-1;break;default:if(X<0)X=Q}if(X>=0)Z.push($.subarray(X));switch(Z.length){case 4:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(Z[2],Rb),this.ma.size=this.protoParseInt(Z[3],Rb);break;case 5:this.ma.subject=Z[0],this.ma.sid=this.protoParseInt(Z[1]),this.ma.reply=Z[2],this.ma.hdr=this.protoParseInt(Z[3],Rb),this.ma.size=this.protoParseInt(Z[4],Rb);break;default:throw this.fail($,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail($,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail($,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail($,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt($,Z){if($.length===0||$.length>15)return-1;let X=0;for(let Q=0;Q<$.length;Q++){if($[Q]<Co1||$[Q]>kp6)return-1;X=X*10+($[Q]-Co1)}return Z!==void 0&&X>Z?-1:X}}vo1.Parser=_o1;vo1.State={OP_START:0,OP_PLUS:1,OP_PLUS_O:2,OP_PLUS_OK:3,OP_MINUS:4,OP_MINUS_E:5,OP_MINUS_ER:6,OP_MINUS_ERR:7,OP_MINUS_ERR_SPC:8,MINUS_ERR_ARG:9,OP_M:10,OP_MS:11,OP_MSG:12,OP_MSG_SPC:13,MSG_ARG:14,MSG_PAYLOAD:15,MSG_END:16,OP_H:17,OP_P:18,OP_PI:19,OP_PIN:20,OP_PING:21,OP_PO:22,OP_PON:23,OP_PONG:24,OP_I:25,OP_IN:26,OP_INF:27,OP_INFO:28,OP_INFO_SPC:29,INFO_ARG:30};vo1.cc={CR:13,E:69,e:101,F:70,f:102,G:71,g:103,H:72,h:104,I:73,i:105,K:75,k:107,M:77,m:109,MINUS:45,N:78,n:110,NL:10,O:79,o:111,P:80,p:112,PLUS:43,R:82,r:114,S:83,s:115,SPACE:32,TAB:9}});var GZ0=_((fo1)=>{Object.defineProperty(fo1,"__esModule",{value:!0});fo1.MsgHdrsImpl=void 0;fo1.canonicalMIMEHeaderKey=Ui0;fo1.headers=_p6;var xo1=pY(),qJ=_w(),YZ0=tY();function Ui0($){let U=!0,N=Array($.length);for(let F=0;F<$.length;F++){let w=$.charCodeAt(F);if(w===58||w<33||w>126)throw YZ0.InvalidArgumentError.format("header",`'${$[F]}' is not a valid character in a header name`);if(U&&97<=w&&w<=122)w-=32;else if(!U&&65<=w&&w<=90)w+=32;N[F]=w,U=w==45}return String.fromCharCode(...N)}function _p6($=0,Z=""){if($===0&&Z!=="")throw YZ0.InvalidArgumentError.format("code","is required");else if($>0&&Z==="")throw YZ0.InvalidArgumentError.format("description","is required");return new Ib($,Z)}var Hi0="NATS/1.0";class Ib{_code;headers;_description;constructor($=0,Z=""){this._code=$,this._description=Z,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals($){if($&&this.headers.size===$.headers.size&&this._code===$._code){for(let[Z,X]of this.headers){let Q=$.values(Z);if(X.length!==Q.length)return!1;let Y=[...X].sort(),G=[...Q].sort();for(let J=0;J<Y.length;J++)if(Y[J]!==G[J])return!1}return!0}return!1}static decode($){let Z=new Ib,Q=xo1.TD.decode($).split(`\r
1337
1337
  `),Y=Q[0];if(Y!==Hi0){let G=Y.replace(Hi0,"").trim();if(G.length>0){if(Z._code=parseInt(G,10),isNaN(Z._code))Z._code=0;let J=Z._code.toString();G=G.replace(J,""),Z._description=G.trim()}}if(Q.length>=1)Q.slice(1).map((G)=>{if(G){let J=G.indexOf(":");if(J>-1){let K=G.slice(0,J),W=G.slice(J+1).trim();Z.append(K,W)}}});return Z}toString(){if(this.headers.size===0&&this._code===0)return"";let $=Hi0;if(this._code>0&&this._description!=="")$+=` ${this._code} ${this._description}`;for(let[Z,X]of this.headers)for(let Q=0;Q<X.length;Q++)$=`${$}\r
1338
1338
  ${Z}: ${X[Q]}`;return`${$}\r