decocms 4.243.14 → 4.243.16

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 (236) hide show
  1. package/dist/client/assets/{AlertCircle-CrDuIO-K.js → AlertCircle-C_BqxkYS.js} +1 -1
  2. package/dist/client/assets/{AreaChart-Bm61PhX1.js → AreaChart-B7Vjvvjv.js} +1 -1
  3. package/dist/client/assets/{ArrowLeft-CAknXa4X.js → ArrowLeft-rCXrqKOs.js} +1 -1
  4. package/dist/client/assets/{ArrowUp-DIxaV9Av.js → ArrowUp-DHXHkA57.js} +1 -1
  5. package/dist/client/assets/{ArrowUpRight-DHP3y875.js → ArrowUpRight-BNTqCGGC.js} +1 -1
  6. package/dist/client/assets/{Check-DQ_mSti_.js → Check-CInFGgM9.js} +1 -1
  7. package/dist/client/assets/{CheckCircle-BC1vtQnV.js → CheckCircle-BPQh2WSj.js} +1 -1
  8. package/dist/client/assets/{ChevronDown-CM757JJk.js → ChevronDown-G9B7RdRJ.js} +1 -1
  9. package/dist/client/assets/{ChevronRight-DSQRatby.js → ChevronRight-VJZp1sLB.js} +1 -1
  10. package/dist/client/assets/{ChevronSelectorVertical-DE8MWaeC.js → ChevronSelectorVertical-BGsPKuK_.js} +1 -1
  11. package/dist/client/assets/{ChevronUp-F5-pfgxA.js → ChevronUp-B35t1UZe.js} +1 -1
  12. package/dist/client/assets/{Copy01-DJhXFGmR.js → Copy01-Du_BX2eC.js} +1 -1
  13. package/dist/client/assets/{CreditCard01-AE9yMJL3.js → CreditCard01-B8_wzkbJ.js} +1 -1
  14. package/dist/client/assets/{DotsVertical-DxGrEOWA.js → DotsVertical-D_CkqHPK.js} +1 -1
  15. package/dist/client/assets/{Download01-CRgWn4pp.js → Download01-B7ZGloDx.js} +1 -1
  16. package/dist/client/assets/{Eye-DmUzUGpB.js → Eye-Cu1CMbnW.js} +1 -1
  17. package/dist/client/assets/{FilterLines-B04Nno83.js → FilterLines-I9HVcsix.js} +1 -1
  18. package/dist/client/assets/{Globe01-Dm1YbHfV.js → Globe01-DvxVAbEu.js} +1 -1
  19. package/dist/client/assets/{Globe04-DzAR39r-.js → Globe04-DWo8RVYB.js} +1 -1
  20. package/dist/client/assets/{HardDrive-CGM86W3w.js → HardDrive-BPoercM9.js} +1 -1
  21. package/dist/client/assets/{Key01-DntoqJwa.js → Key01-C9EA6-3X.js} +1 -1
  22. package/dist/client/assets/{LayoutLeft-DIU5T8Kr.js → LayoutLeft-DBSnfEmq.js} +1 -1
  23. package/dist/client/assets/{LinkExternal01-DohSj-TW.js → LinkExternal01-B3Rw8-tH.js} +1 -1
  24. package/dist/client/assets/{LockUnlocked01-CHySdX_R.js → LockUnlocked01-Daa6Affi.js} +1 -1
  25. package/dist/client/assets/{LogOut01-C9wIxpkt.js → LogOut01-DHFegKsF.js} +1 -1
  26. package/dist/client/assets/{Monitor01-BAB_vg_-.js → Monitor01-B_INSCSw.js} +1 -1
  27. package/dist/client/assets/{Palette-fCs4hauk.js → Palette-DU83-LmL.js} +1 -1
  28. package/dist/client/assets/{Play-ClHZmMoe.js → Play-CqwgtS0w.js} +1 -1
  29. package/dist/client/assets/{Plus-p4_cU8N7.js → Plus-SjHvojvA.js} +1 -1
  30. package/dist/client/assets/{SearchLg-Km-M6OZy.js → SearchLg-jR8PdTcA.js} +1 -1
  31. package/dist/client/assets/{SearchMd-C61i1pMs.js → SearchMd-fTZEvjhp.js} +1 -1
  32. package/dist/client/assets/{Settings02-C-HiDBaw.js → Settings02-CyQ_4zcu.js} +1 -1
  33. package/dist/client/assets/{Share07-Bc5qIpio.js → Share07-B1zLjBLA.js} +1 -1
  34. package/dist/client/assets/{Shield01-D-HQVoUu.js → Shield01-DaJr86l8.js} +1 -1
  35. package/dist/client/assets/{Stars01-BqGu_MMa.js → Stars01-CiQQWEJf.js} +1 -1
  36. package/dist/client/assets/{Stars02-C4ew6TCC.js → Stars02-DFfF8gym.js} +1 -1
  37. package/dist/client/assets/{Sun-BWex7y1T.js → Sun-DZ30u3up.js} +1 -1
  38. package/dist/client/assets/{SwitchHorizontal01-CNJw5L8m.js → SwitchHorizontal01-ru6oQ-Ne.js} +1 -1
  39. package/dist/client/assets/{Tool01-BhKdSP88.js → Tool01-CNB5JG5V.js} +1 -1
  40. package/dist/client/assets/{Tool02-CHteaICE.js → Tool02-BWyYg8Ma.js} +1 -1
  41. package/dist/client/assets/{Trash01-CcXY7Oq5.js → Trash01-C-Pu2sFS.js} +1 -1
  42. package/dist/client/assets/{TrendUp01-Fc993PdN.js → TrendUp01-BegPbUN9.js} +1 -1
  43. package/dist/client/assets/{Upload01-B8kERRFc.js → Upload01-CCjv17jL.js} +1 -1
  44. package/dist/client/assets/{User01-C8zZHO2B.js → User01-BnqzHs-B.js} +1 -1
  45. package/dist/client/assets/{Users01-DH7jFCFu.js → Users01-BPKbmUzc.js} +1 -1
  46. package/dist/client/assets/{Users03-Da8p-Ekm.js → Users03-gSrP0_JN.js} +1 -1
  47. package/dist/client/assets/{X-CPWTH8eh.js → X-Bv8aZrrr.js} +1 -1
  48. package/dist/client/assets/{XCircle-yd13JQWz.js → XCircle-Bmjn7En7.js} +1 -1
  49. package/dist/client/assets/{XClose-DaaGNPy7.js → XClose-DmL72eXg.js} +1 -1
  50. package/dist/client/assets/{YAxis-D-fFHUm8.js → YAxis-DJqlIxWf.js} +1 -1
  51. package/dist/client/assets/{Zap-CkZtVAXq.js → Zap-PWyJblse.js} +1 -1
  52. package/dist/client/assets/{ZapSquare-DdW92qNF.js → ZapSquare-DccwlHxL.js} +1 -1
  53. package/dist/client/assets/{access-gate-DqjonHA_.js → access-gate-DzABzYZN.js} +1 -1
  54. package/dist/client/assets/{agent-icon-Bcfp8-i2.js → agent-icon-CI6A_yeI.js} +1 -1
  55. package/dist/client/assets/{agents-list-CxE52kdx.js → agents-list-XHKx5OHO.js} +1 -1
  56. package/dist/client/assets/{ai-providers-CtR17067.js → ai-providers-DNGGtIph.js} +1 -1
  57. package/dist/client/assets/{alert-CclRrdY3.js → alert-AYU7MuYR.js} +1 -1
  58. package/dist/client/assets/{alert-dialog-CzAYHPpm.js → alert-dialog-DnO5HssT.js} +1 -1
  59. package/dist/client/assets/{api-keys-DfaGL4Et.js → api-keys-DqRQOfrd.js} +1 -1
  60. package/dist/client/assets/{app-editor-xFBYsnD5.js → app-editor-DWIdFFxa.js} +1 -1
  61. package/dist/client/assets/{auth-CXSZ9weC.js → auth-BWGSTe2L.js} +1 -1
  62. package/dist/client/assets/{auth-catchall-CRZ65MhE.js → auth-catchall-ChQY28-Q.js} +1 -1
  63. package/dist/client/assets/{auth-entry-5RXYnCQW.js → auth-entry-DvoXxqjV.js} +1 -1
  64. package/dist/client/assets/{auth-split-layout-Csh-4Qjd.js → auth-split-layout-B5eQ7Ngb.js} +1 -1
  65. package/dist/client/assets/{authenticate-and-persist-oauth-CYvFTsk9.js → authenticate-and-persist-oauth-BfePZSJJ.js} +1 -1
  66. package/dist/client/assets/{automation-list-row-4MS2Qv3m.js → automation-list-row-reSCSbQ4.js} +1 -1
  67. package/dist/client/assets/{automation-runs-C43Y1hE2.js → automation-runs-Dz7R0ss5.js} +1 -1
  68. package/dist/client/assets/{automations-BhBtHSLM.js → automations-BcqTVtg-.js} +1 -1
  69. package/dist/client/assets/{avatar-2kQ5gRA5.js → avatar-lZD43JTZ.js} +1 -1
  70. package/dist/client/assets/{badge-Ca9JSAWt.js → badge-DeJpm4bW.js} +1 -1
  71. package/dist/client/assets/{billing-BMjOFs54.js → billing-DeT87ttS.js} +1 -1
  72. package/dist/client/assets/{block-document-Dcdf6o5I.js → block-document-DKI6QQXO.js} +1 -1
  73. package/dist/client/assets/{buckets-DJ8fIEKy.js → buckets-fPELoUxv.js} +1 -1
  74. package/dist/client/assets/{bulk-category-panel-D82txuOX.js → bulk-category-panel-DAPX3OR4.js} +1 -1
  75. package/dist/client/assets/{capability-load-error-w1m3Y_pA.js → capability-load-error-CagBt27F.js} +1 -1
  76. package/dist/client/assets/{card-BO1SNdHX.js → card-zDO_w28X.js} +1 -1
  77. package/dist/client/assets/{cards-C3piepX9.js → cards-BmGzcm_x.js} +1 -1
  78. package/dist/client/assets/{category-editor-CYoKvTDQ.js → category-editor-BTaC69IB.js} +1 -1
  79. package/dist/client/assets/{chart-DrW12eH5.js → chart-Dx5g220h.js} +1 -1
  80. package/dist/client/assets/{chat-context-T31M8gD8.js → chat-context-DEvymuiY.js} +1 -1
  81. package/dist/client/assets/{checkbox-DdpV1h3c.js → checkbox-pJQdIT6S.js} +1 -1
  82. package/dist/client/assets/{choose-editor-BxTeXYer.js → choose-editor-BVTE38yF.js} +1 -1
  83. package/dist/client/assets/{cli-auth-success-DRPNLKGk.js → cli-auth-success-BmALgiir.js} +1 -1
  84. package/dist/client/assets/{collection-detail-B6f-sVqZ.js → collection-detail-BJUbTrdz.js} +1 -1
  85. package/dist/client/assets/{collection-display-button-t3Jrnotz.js → collection-display-button-B1-U1NKH.js} +1 -1
  86. package/dist/client/assets/{collection-search-DqwF3dov.js → collection-search-BRYqwtgT.js} +1 -1
  87. package/dist/client/assets/{collection-table-wrapper-C8_dtyS7.js → collection-table-wrapper-DHEjTvTG.js} +1 -1
  88. package/dist/client/assets/{collection-tabs-CcZ-KIzO.js → collection-tabs-CaP6TCvj.js} +1 -1
  89. package/dist/client/assets/{command-Caqi2e3L.js → command-CAsttCDp.js} +1 -1
  90. package/dist/client/assets/{commerce-onboarding-BJ3phSx5.js → commerce-onboarding-CzNAkLEn.js} +1 -1
  91. package/dist/client/assets/{connect-Dc3cV7MC.js → connect-DZYOvuoD.js} +1 -1
  92. package/dist/client/assets/{connection-CXsXACPa.js → connection-cDXQIc-V.js} +1 -1
  93. package/dist/client/assets/{connection-card-DWIkko7-.js → connection-card-1sCJUDx9.js} +1 -1
  94. package/dist/client/assets/{connection-detail-KfS10XdW.js → connection-detail-mnC7YZk1.js} +1 -1
  95. package/dist/client/assets/{connection-form-helpers-BksrukHo.js → connection-form-helpers-DAHqxfZV.js} +1 -1
  96. package/dist/client/assets/{connections-CXBc0jQj.js → connections-CZjI4cJh.js} +1 -1
  97. package/dist/client/assets/{decopilot-sse-pool-RWA5SqIm.js → decopilot-sse-pool-BamlDQlZ.js} +1 -1
  98. package/dist/client/assets/{dialog-C8c2jGp5.js → dialog-DpNH4YCP.js} +1 -1
  99. package/dist/client/assets/{domain-settings-DhZhIme9.js → domain-settings-BIGD7qz7.js} +1 -1
  100. package/dist/client/assets/{drawer-B8qcNIDt.js → drawer-Du0m0UPi.js} +1 -1
  101. package/dist/client/assets/{dropdown-menu-CESzJ7iq.js → dropdown-menu-Yn9qwmdM.js} +1 -1
  102. package/dist/client/assets/{empty-state-DVEOO36M.js → empty-state-IUXQrfrD.js} +1 -1
  103. package/dist/client/assets/{extract-connection-data-REAEe3pw.js → extract-connection-data-mtB0W2IC.js} +1 -1
  104. package/dist/client/assets/{file-explorer-D2u8-9ok.js → file-explorer-CXmE9xxI.js} +1 -1
  105. package/dist/client/assets/{file-type-icon-DW_vZ3mS.js → file-type-icon-DLpphwk3.js} +1 -1
  106. package/dist/client/assets/{form-C2KIY70K.js → form-DufAe7eW.js} +1 -1
  107. package/dist/client/assets/{general-BmWXQilF.js → general-BTM_RO9g.js} +1 -1
  108. package/dist/client/assets/{github-repo-picker-DE2z1i-C.js → github-repo-picker-D5LfaSIA.js} +1 -1
  109. package/dist/client/assets/{hooks-Dgi2Wrdl.js → hooks-Bflc4J5C.js} +1 -1
  110. package/dist/client/assets/{index-n_pUkv7o.js → index-B7BorFsI.js} +5 -5
  111. package/dist/client/assets/{index-Bkesjy-e.js → index-BOTaCqBI.js} +1 -1
  112. package/dist/client/assets/{index-BYG6TDF0.js → index-BV1y6WvY.js} +1 -1
  113. package/dist/client/assets/{index-IRl_LdwB.js → index-C1ptkkR_.js} +1 -1
  114. package/dist/client/assets/{index-BkN0i_Y9.js → index-CL5vaS6o.js} +1 -1
  115. package/dist/client/assets/{index-CI5UsS6K.js → index-CyzeTQD7.js} +1 -1
  116. package/dist/client/assets/{index-d-TgcEJV.js → index-DOIoCTdM.js} +1 -1
  117. package/dist/client/assets/{index-CZF8eW9j.js → index-DglsCH3H.js} +53 -53
  118. package/dist/client/assets/{index-tLP0STB1.js → index-DwhKnbgI.js} +1 -1
  119. package/dist/client/assets/{index-BOoQ9VdW.js → index-iKqZN1y9.js} +1 -1
  120. package/dist/client/assets/{index-redirect-Dw6MOoLE.js → index-redirect-B5PM7wYq.js} +1 -1
  121. package/dist/client/assets/{infra-billing-Dy6PQ9mu.js → infra-billing-C1NH7KmV.js} +1 -1
  122. package/dist/client/assets/{input-C-59skY6.js → input-D7epuK-Z.js} +1 -1
  123. package/dist/client/assets/{integration-icon-thwQmDUu.js → integration-icon-DafZl0ze.js} +1 -1
  124. package/dist/client/assets/{invite-member-dialog-QWwOoigm.js → invite-member-dialog-CD-gZGZ8.js} +1 -1
  125. package/dist/client/assets/{label-C_afEZyK.js → label-CvubZZ0I.js} +1 -1
  126. package/dist/client/assets/{layout-CXayjFpW.js → layout-C6MHkSVL.js} +1 -1
  127. package/dist/client/assets/{login-ACYXYmy9.js → login-CcwlfZz7.js} +1 -1
  128. package/dist/client/assets/{mcp-oauth-CVRYGLaa.js → mcp-oauth-Ct36wA9v.js} +1 -1
  129. package/dist/client/assets/{members-BLVZ009_.js → members-CnecFXCJ.js} +1 -1
  130. package/dist/client/assets/{monaco-editor-Dc5OzS-b.js → monaco-editor-BjYz-W4y.js} +1 -1
  131. package/dist/client/assets/{monitoring-stats-row-C8L90ZHI.js → monitoring-stats-row-BIX_AxBv.js} +1 -1
  132. package/dist/client/assets/{multi-select-B2y8Mk9t.js → multi-select-C2UnVLV1.js} +1 -1
  133. package/dist/client/assets/{oauth-callback-D43uCPT0.js → oauth-callback-BHDkJfeZ.js} +1 -1
  134. package/dist/client/assets/{oauth-callback-ai-provider-BQkgFC6A.js → oauth-callback-ai-provider-KQy-WADg.js} +1 -1
  135. package/dist/client/assets/{onboarding-Cl1ypAXc.js → onboarding-CM_nJ4S1.js} +1 -1
  136. package/dist/client/assets/{org-layout-BRa9rVtm.js → org-layout-XMs6bieV.js} +1 -1
  137. package/dist/client/assets/{organization-choice-CdBMPrAX.js → organization-choice-DpyYsqvA.js} +1 -1
  138. package/dist/client/assets/{orgs-Cx8rn8DP.js → orgs-BBc_RovK.js} +1 -1
  139. package/dist/client/assets/{page-seo-form-Ck3JIT76.js → page-seo-form-Dgs4JdJU.js} +1 -1
  140. package/dist/client/assets/{popover-o0e_Tvcf.js → popover-_GBl33O8.js} +1 -1
  141. package/dist/client/assets/{post-editor-CrxqNJcV.js → post-editor-C3SyTdqJ.js} +1 -1
  142. package/dist/client/assets/{primitives-DpgAZoo1.js → primitives-C7dSZv9u.js} +1 -1
  143. package/dist/client/assets/{profile-DuEZMXqd.js → profile-BKFtxcCJ.js} +1 -1
  144. package/dist/client/assets/{project-app-view-jnHaIken.js → project-app-view-BHipLaUP.js} +1 -1
  145. package/dist/client/assets/record-editor-BQGoU6hi.js +1 -0
  146. package/dist/client/assets/{redirect-editor-udj6U_qb.js → redirect-editor-BrRU3NGe.js} +1 -1
  147. package/dist/client/assets/registry-CHbNGqXD.js +2 -0
  148. package/dist/client/assets/{registry-layout-CA0dIAHp.js → registry-layout-CDQ29yoE.js} +1 -1
  149. package/dist/client/assets/{reports-BO7pkfGc.js → reports-DuAh46Yd.js} +1 -1
  150. package/dist/client/assets/{require-capability-CmDer7LY.js → require-capability-gHIwYkXk.js} +1 -1
  151. package/dist/client/assets/{required-auth-layout-CheXBljc.js → required-auth-layout-DuOdb_m7.js} +1 -1
  152. package/dist/client/assets/{reset-password-DTUMNvDr.js → reset-password-CHt3KKMU.js} +1 -1
  153. package/dist/client/assets/{roles-CuoPruPY.js → roles-B8oLIuHL.js} +1 -1
  154. package/dist/client/assets/{search-input-BWOB1dxm.js → search-input-CObIT_7a.js} +1 -1
  155. package/dist/client/assets/{secrets-khnZ1JE9.js → secrets-Dl_uvOnm.js} +1 -1
  156. package/dist/client/assets/{sections-editor-CHMZxcdt.js → sections-editor-knlXTLmf.js} +1 -1
  157. package/dist/client/assets/{select-BjLdAKRN.js → select-Dvpyj8NQ.js} +1 -1
  158. package/dist/client/assets/{select-model-C50sOZME.js → select-model-DzpbX8SS.js} +1 -1
  159. package/dist/client/assets/{self-tool-result-BHabvbVG.js → self-tool-result-DP8ab1C7.js} +1 -1
  160. package/dist/client/assets/{seo-editor-C6K32s25.js → seo-editor-JYaRXoHn.js} +1 -1
  161. package/dist/client/assets/{settings-layout-Dhg4tgk7.js → settings-layout-cNgazNYM.js} +1 -1
  162. package/dist/client/assets/{settings-section-DFFfOuRp.js → settings-section-W09oceW9.js} +1 -1
  163. package/dist/client/assets/{settings-subnav-DxIGDg-C.js → settings-subnav-emx7OuV6.js} +1 -1
  164. package/dist/client/assets/{shell-controls-CtkqT3bS.js → shell-controls-DdMCwcXE.js} +1 -1
  165. package/dist/client/assets/{shell-layout-ui9SII6o.js → shell-layout-TW_wA41L.js} +1 -1
  166. package/dist/client/assets/{sidebar-BYTgjbnI.js → sidebar-B2KhEaQf.js} +1 -1
  167. package/dist/client/assets/{skeleton-Bpyk0nMH.js → skeleton-BlZwbMCP.js} +1 -1
  168. package/dist/client/assets/{spinner-9ABT2ti7.js → spinner-MFNDKl-_.js} +1 -1
  169. package/dist/client/assets/{sso-Bl9rw6zW.js → sso-BuHi3YmG.js} +1 -1
  170. package/dist/client/assets/{store-7gXkG-g4.js → store-BAhFZ3y4.js} +1 -1
  171. package/dist/client/assets/store-registry-BuJIo1rg.js +2 -0
  172. package/dist/client/assets/{studio-tools-Bzmkx7kR.js → studio-tools-DcMPcKsR.js} +1 -1
  173. package/dist/client/assets/{switch-BYRMvuuJ.js → switch-jevNXNY5.js} +1 -1
  174. package/dist/client/assets/{synced-repos-0wclg7nW.js → synced-repos-2-TJwQq1.js} +1 -1
  175. package/dist/client/assets/{tab-id-CWz_S9PQ.js → tab-id-BqoCoJhy.js} +1 -1
  176. package/dist/client/assets/{table-DAF3mPot.js → table-BnzhPb_k.js} +1 -1
  177. package/dist/client/assets/{tabs-IjYokb6B.js → tabs-7kGeT9go.js} +1 -1
  178. package/dist/client/assets/{tasks-BzIcL749.js → tasks-DOS3dPav.js} +1 -1
  179. package/dist/client/assets/{textarea-C-cYMHmA.js → textarea-C7UW5eI1.js} +1 -1
  180. package/dist/client/assets/{toggle-group-g4btBExH.js → toggle-group-CAtHie06.js} +1 -1
  181. package/dist/client/assets/{toolbar-DlLSc2Nx.js → toolbar-Djmoj5MT.js} +1 -1
  182. package/dist/client/assets/{tooltip-nO4Wd1lE.js → tooltip-ocz-8ZiH.js} +1 -1
  183. package/dist/client/assets/{track-DKyvqVYN.js → track-B-qWZwKx.js} +1 -1
  184. package/dist/client/assets/{types-eTVfkr3u.js → types-Bdsm2j2P.js} +1 -1
  185. package/dist/client/assets/{use-ai-providers-DRDoUYXy.js → use-ai-providers-BN3bZalW.js} +1 -1
  186. package/dist/client/assets/{use-api-keys-DQkRL7C2.js → use-api-keys-C1YLxBWc.js} +1 -1
  187. package/dist/client/assets/{use-automations-CKGDAq-4.js → use-automations-BNeN7xfc.js} +1 -1
  188. package/dist/client/assets/{use-autosave-DPbs09hr.js → use-autosave-CoYBmgzS.js} +1 -1
  189. package/dist/client/assets/{use-capability-C0b8qjjf.js → use-capability-C58qo0xH.js} +1 -1
  190. package/dist/client/assets/{use-clock-tick-DSsyCvwK.js → use-clock-tick-BaMg9yqc.js} +1 -1
  191. package/dist/client/assets/{use-commerce-diagnostic-BRO8EDAq.js → use-commerce-diagnostic-4i7w8Clz.js} +1 -1
  192. package/dist/client/assets/{use-connection-BltOys1c.js → use-connection-Bk3MkNRE.js} +1 -1
  193. package/dist/client/assets/{use-copy-VC0r9iEh.js → use-copy-DEwTO3_J.js} +1 -1
  194. package/dist/client/assets/{use-create-virtual-mcp-D9CoJ0U5.js → use-create-virtual-mcp-BqhHC1uD.js} +1 -1
  195. package/dist/client/assets/{use-debounced-autosave-BWH9oyAO.js → use-debounced-autosave-DpFsTc9Z.js} +1 -1
  196. package/dist/client/assets/{use-debounced-value-xLDhPrQA.js → use-debounced-value-B_OE6aAs.js} +1 -1
  197. package/dist/client/assets/{use-decopilot-events-B0sNSz-b.js → use-decopilot-events-DX8x3a0A.js} +1 -1
  198. package/dist/client/assets/{use-delete-connection-K5Pdg6MU.js → use-delete-connection-BNGaa9qe.js} +1 -1
  199. package/dist/client/assets/{use-deployment-admin-CPxqOIUb.js → use-deployment-admin-BfyCG-4k.js} +1 -1
  200. package/dist/client/assets/{use-file-configs-BftSzLbr.js → use-file-configs-BIIie-dO.js} +1 -1
  201. package/dist/client/assets/{use-infinite-scroll-6er3xTHc.js → use-infinite-scroll-C0Nc5vtp.js} +1 -1
  202. package/dist/client/assets/{use-join-requests-Br7SOxen.js → use-join-requests-Ccmuw8Q_.js} +1 -1
  203. package/dist/client/assets/{use-mcp-client-Dq7jbheJ.js → use-mcp-client-BtmukcyN.js} +1 -1
  204. package/dist/client/assets/{use-mcp-tools-BdRkzPjU.js → use-mcp-tools-WuZKeXoU.js} +1 -1
  205. package/dist/client/assets/{use-members-BljNtuTA.js → use-members-xOMF6AK_.js} +1 -1
  206. package/dist/client/assets/{use-mobile-DR1RUy6m.js → use-mobile-DLrw2mfj.js} +1 -1
  207. package/dist/client/assets/{use-navigate-to-agent-DIpaPneu.js → use-navigate-to-agent-D-oaaZ5G.js} +1 -1
  208. package/dist/client/assets/{use-open-billing-url-DLgOEeH1.js → use-open-billing-url-CFaef0dg.js} +1 -1
  209. package/dist/client/assets/{use-org-auth-client-CCZhmNcA.js → use-org-auth-client-B4A7mgtf.js} +1 -1
  210. package/dist/client/assets/{use-org-repo-syncs-_Fy_LEU9.js → use-org-repo-syncs-D13KhS7c.js} +1 -1
  211. package/dist/client/assets/{use-org-sso-ZLVa6Klf.js → use-org-sso-D2JwPrAt.js} +1 -1
  212. package/dist/client/assets/{use-organization-roles-C8ZiGW-H.js → use-organization-roles-BLsWxlpF.js} +1 -1
  213. package/dist/client/assets/{use-organization-settings-BkwFEeyz.js → use-organization-settings-CGBhQFa1.js} +1 -1
  214. package/dist/client/assets/{use-registry-connections-CirR1Usp.js → use-registry-connections-B2fDGJK3.js} +1 -1
  215. package/dist/client/assets/{use-secrets-BuHf1xNW.js → use-secrets-DXlgv2yw.js} +1 -1
  216. package/dist/client/assets/{use-section-preview-base-CfRJmWe5.js → use-section-preview-base-D4oFfUr0.js} +1 -1
  217. package/dist/client/assets/{use-settings-tabs-CgIX4oCd.js → use-settings-tabs-DGzOtCun.js} +1 -1
  218. package/dist/client/assets/{use-status-sounds-rqI8dYNf.js → use-status-sounds-D-EIaw8A.js} +1 -1
  219. package/dist/client/assets/{use-tags-JNHXo9H7.js → use-tags-JLGPLIW-.js} +1 -1
  220. package/dist/client/assets/{use-view-mode-DDqWF3eX.js → use-view-mode-oCS_vizZ.js} +1 -1
  221. package/dist/client/assets/{use-virtual-mcp-OdTc8Q7z.js → use-virtual-mcp-C64K_52X.js} +1 -1
  222. package/dist/client/assets/useInfiniteQuery-Bh9IfQvx.js +1 -0
  223. package/dist/client/assets/{useRouterState-CV69R02o.js → useRouterState-B7ibUnMv.js} +1 -1
  224. package/dist/client/assets/useSuspenseInfiniteQuery-i0SzE3B3.js +1 -0
  225. package/dist/client/assets/{users-4AP2lRzC.js → users-DMyiJLoO.js} +1 -1
  226. package/dist/client/assets/{variant-calendar-B4BkwJhc.js → variant-calendar-Cle8X91Y.js} +1 -1
  227. package/dist/client/assets/{view-mode-toggle-DKesscf4.js → view-mode-toggle-DyWSYSri.js} +1 -1
  228. package/dist/client/index.html +1 -1
  229. package/dist/server/cli.js +3 -3
  230. package/dist/server/server.js +3 -3
  231. package/package.json +1 -1
  232. package/dist/client/assets/record-editor-CUhI0aE0.js +0 -1
  233. package/dist/client/assets/registry-DMv6dawm.js +0 -2
  234. package/dist/client/assets/store-registry-CGGSo0VL.js +0 -2
  235. package/dist/client/assets/useInfiniteQuery-BHLjleqi.js +0 -1
  236. package/dist/client/assets/useSuspenseInfiniteQuery-CzRwbdk7.js +0 -1
@@ -1371,7 +1371,7 @@ Usage: deco services <up|down|status>`),process.exit(1)}}var Gi1=w(()=>{Lf()});f
1371
1371
  `.execute($);if(Number(W.rows[0]?.cnt)===0){console.warn(`Failed to migrate ${J}/${K}, keeping in old table`);continue}}await mb`
1372
1372
  DELETE FROM kysely_migration WHERE name = ${X}
1373
1373
  `.execute($)}}async function To1($){await Ep6($),await jp6($);let Z=new Po1({db:$,provider:{getMigrations:()=>Promise.resolve(Ai0)}}),{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 zp6($){let{keepOpen:Z=!1,database:X,skipBetterAuth:Q=!1}=$??{},Y="skipped";if(!Q&&!X)Y=await ic0();let G=X??F6(),J=async()=>{if(!Z&&!X)await hB(G).catch((K)=>{console.warn("Warning: Error closing database:",K)})};try{let K=await To1(G.db);return await J(),{betterAuth:Y,kysely:K}}catch(K){throw await J(),K}}async function Pp6(){let $=F6(),Z=new Po1({db:$.db,provider:{getMigrations:()=>Promise.resolve(Ai0)}}),{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 Io1=w(()=>{zo1();nc0();QX()});async function RZ0($){let Z={...process.env},X=w80($,Z);console.log(hw1(X.settings.encryptionKey));let Q=X.settings.betterAuthSecret||(X.settings.localMode?fn1(X.settings.dataDir):""),{ensureServices:Y}=await Promise.resolve().then(() => (_90(),C90)),{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(() => (nc0(),yn1));await W(G.databaseUrl);let{createDatabase:H}=await Promise.resolve().then(() => (QX(),$n1)),{migrateToLatest:N}=await Promise.resolve().then(() => (Io1(),Ro1)),U=H(G.databaseUrl);await N({keepOpen:!0,database:U,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 Ji1(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 Ti0=w(()=>{Lf();bn1();C8()});var Vo1={};F0(Vo1,{updateService:()=>EE,subscribeCliState:()=>qi0,setTuiConsoleIntercepted:()=>IZ0,setServerUrl:()=>Ci,setMigrationsDone:()=>Si,setDevMode:()=>Rp6,resetCliStateForTests:()=>Ap6,isTuiConsoleIntercepted:()=>qZ0,getCliState:()=>Ii0,addLogEntry:()=>mB});function qo1(){return{services:[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}],migrationsStatus:"pending",serverUrl:null,logs:[]}}function Ap6(){lQ=qo1()}function Tp6(){return[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}]}function ki(){for(let $ of Ri0)$()}function Ii0(){return lQ}function qi0($){return Ri0.add($),()=>Ri0.delete($)}function EE($){lQ={...lQ,services:lQ.services.map((Z)=>Z.name===$.name?$:Z)},ki()}function Si(){lQ={...lQ,migrationsStatus:"done"},ki()}function Ci($){lQ={...lQ,serverUrl:$},ki()}function mB($){let Z=[...lQ.logs,$];lQ={...lQ,logs:Z.length>500?Z.slice(-500):Z},ki()}function Rp6(){lQ={...lQ,services:[...Tp6(),{name:"API",status:"pending",port:0},{name:"Vite",status:"pending",port:0}]},ki()}function IZ0($){Mo1=$}function qZ0(){return Mo1}var lQ,Ri0,Mo1=!1;var jE=w(()=>{lQ=qo1();Ri0=new Set});import{createServer as ko1}from"net";function Ip6($){return new Promise((Z)=>{let X=ko1();X.once("error",()=>Z(!1)),X.listen($,"0.0.0.0",()=>{X.close(()=>Z(!0))})})}async function _i($){if(await Ip6($))return $;let Z=await new Promise((X,Q)=>{let Y=ko1();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 Mi0=()=>{};function vi($){return $.replace(/\x1b\[[0-9;]*m/g,"")}var Vi0={};F0(Vi0,{startDevServer:()=>Mp6});import{join as qp6}from"path";function So1($){let Z=$.getReader(),X=new TextDecoder,Q="";function Y(){let G=Q.split(`
1374
- `);Q=G.pop()??"";for(let J of G){let K=vi(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;mB({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=vi(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)mB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function Mp6($){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 _i(Number(Y)+1):await _i(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await RZ0({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let L of W)EE({name:L.name,status:"ready",port:L.port});Si();let N=qp6(import.meta.dir,"..","..","..","..",".."),U=X===!0,F=Bun.spawn(["bun","run","dev:servers"],{cwd:N,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",U?"inherit":"pipe",U?"inherit":"pipe"]});if(!U)So1(F.stdout),So1(F.stderr);Ci(G),EE({name:"Vite",status:"ready",port:Number(Y)}),EE({name:"API",status:"ready",port:Number(K.port)});let O=async(L)=>{if(F.kill(L),await F.exited,H.length>0){let{stopServices:D}=await Promise.resolve().then(() => (_90(),C90));await D(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:F}}var ki0=w(()=>{Ti0();jE();Mi0()});var MZ0;var Si0=w(()=>{MZ0={name:"decocms",version:"4.243.14",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","db:migrate:dbos":"bun run ./dist/server/migrate-dbos.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts","migrate:dbos":"bun run src/database/migrate-dbos.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 kp6,Text as Co1}from"ink";import{jsx as Sp6,jsxs as _o1}from"react/jsx-runtime";function vo1({version:$}){return _o1(kp6,{flexDirection:"column",marginTop:1,children:[ZZ0.map((Z,X)=>Sp6(Co1,{color:XZ0[X],children:Z},X)),_o1(Co1,{dimColor:!0,children:[" v",$]})]})}var xo1=w(()=>{Ei()});import{Box as zE,Text as iB}from"ink";import{Spinner as Cp6}from"@inkjs/ui";import{jsx as aY,jsxs as ib}from"react/jsx-runtime";function fo1({status:$}){if($==="pending")return aY(Cp6,{label:""});return aY(iB,{color:"green",children:"\u2713"})}function _p6($){return`${$.name}: ${$.port||"...."}`}function bo1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return ib(zE,{flexDirection:"column",paddingBottom:1,children:[aY(vo1,{version:MZ0.version}),aY(zE,{marginBottom:1,children:aY(iB,{dimColor:!0,children:"\u2500".repeat(80)})}),aY(zE,{children:ib(iB,{dimColor:!0,children:["Home: ",X]})}),ib(zE,{gap:2,children:[$.map((Y)=>ib(zE,{gap:1,children:[aY(iB,{children:_p6(Y)}),aY(fo1,{status:Y.status})]},Y.name)),ib(zE,{gap:1,children:[aY(iB,{children:"Migrations"}),aY(fo1,{status:Z})]})]}),aY(zE,{children:Q?ib(iB,{children:["Open in browser: ",aY(iB,{color:"cyan",children:Q})]}):aY(iB,{dimColor:!0,children:"Starting..."})})]})}var yo1=w(()=>{Si0();xo1()});import{Box as vp6,Text as xi}from"ink";import{jsx as Ci0,jsxs as _i0}from"react/jsx-runtime";function xp6($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function go1({logs:$}){return Ci0(vp6,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Ci0(xi,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return _i0(xi,{children:[_i0(xi,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Ci0(xi,{color:xp6(Z.status),children:Z.status}),_i0(xi,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var ho1=()=>{};var vi0={};F0(vi0,{App:()=>yp6});import{Box as fp6}from"ink";import{useSyncExternalStore as bp6}from"react";import{jsx as uo1,jsxs as gp6}from"react/jsx-runtime";function yp6({home:$}){let Z=bp6(qi0,Ii0);return gp6(fp6,{flexDirection:"column",children:[uo1(bo1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),uo1(go1,{logs:Z.logs})]})}var xi0=w(()=>{yo1();ho1();jE()});var fJ="thread-gate",sN="decopilot-hosted-harness",eN="decopilot-hosted-harness-sandboxed",N3="automations",nB="background-tools",PE="task-board-github-reads",AE="jira-push";var co1="7";function lo1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:co1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var do1=()=>{};function hp6(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function fi0($,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 mo1(){let $=hp6();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:fi0($,"--cpu-prof-dir")??process.cwd(),name:fi0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(fi0($,"--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 io1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=OE();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(()=>{}),VZ0=setInterval(()=>void Z().catch(()=>{}),$),VZ0.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(VZ0)clearInterval(VZ0)}}var VZ0;var no1=()=>{};import*as up6 from"bun:jsc";function po1(){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{cp6()}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=lp6()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let N of K){let U=N.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??N.frames[0];if(!U)continue;let F=(U.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${U.name??"?"} @ ${F}:${U.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((N,U)=>U[1]-N[1]).slice(0,8).map(([N,U])=>({frame:N,count:U}));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 cp6,lp6;var to1=w(()=>{({startSamplingProfiler:cp6,samplingProfilerStackTraces:lp6}=up6)});function oo1(){mo1();let $=[io1(),ni1(),po1()];return()=>{for(let Z of $)Z()}}var ro1=w(()=>{fc0();no1();to1()});var TE=_((ao1)=>{Object.defineProperty(ao1,"__esModule",{value:!0});ao1.RepublishHeaders=ao1.DirectMsgHeaders=ao1.JsHeaders=ao1.AdvisoryKind=void 0;ao1.isOrderedPushConsumerOptions=dp6;ao1.isPullConsumer=mp6;ao1.isPushConsumer=ip6;ao1.isBoundPushConsumerOptions=np6;function dp6($){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 mp6($){return $.isPullConsumer()}function ip6($){return $.isPushConsumer()}function np6($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}ao1.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"};ao1.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"};ao1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};ao1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var sY=_((eo1)=>{Object.defineProperty(eo1,"__esModule",{value:!0});eo1.TD=eo1.TE=eo1.Empty=void 0;eo1.encode=Zt6;eo1.decode=Xt6;eo1.Empty=new Uint8Array(0);eo1.TE=new TextEncoder;eo1.TD=new TextDecoder;function $t6(...$){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 Zt6(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(eo1.TE.encode($[X]));if(Z.length===0)return eo1.Empty;if(Z.length===1)return Z[0];return $t6(...Z)}function Xt6($){if(!$||$.length===0)return"";return eo1.TD.decode($)}});var eY=_((Xr1)=>{Object.defineProperty(Xr1,"__esModule",{value:!0});Xr1.errors=Xr1.PermissionViolationError=Xr1.NoRespondersError=Xr1.TimeoutError=Xr1.RequestError=Xr1.ProtocolError=Xr1.ConnectionError=Xr1.DrainingConnectionError=Xr1.ClosedConnectionError=Xr1.AuthorizationError=Xr1.UserAuthenticationExpiredError=Xr1.InvalidOperationError=Xr1.InvalidArgumentError=Xr1.InvalidSubjectError=void 0;class yi0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}Xr1.InvalidSubjectError=yi0;class kZ0 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 kZ0(`${$} ${Z}`,X)}}Xr1.InvalidArgumentError=kZ0;class gi0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}Xr1.InvalidOperationError=gi0;class SZ0 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new SZ0($);return null}}Xr1.UserAuthenticationExpiredError=SZ0;class CZ0 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 CZ0($);return null}}Xr1.AuthorizationError=CZ0;class hi0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}Xr1.ClosedConnectionError=hi0;class ui0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}Xr1.DrainingConnectionError=ui0;class ci0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}Xr1.ConnectionError=ci0;class li0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}Xr1.ProtocolError=li0;class di0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof _Z0}}Xr1.RequestError=di0;class mi0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}Xr1.TimeoutError=mi0;class _Z0 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}Xr1.NoRespondersError=_Z0;class vZ0 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 vZ0($,X,Q,Y)}}Xr1.PermissionViolationError=vZ0;Xr1.errors={AuthorizationError:CZ0,ClosedConnectionError:hi0,ConnectionError:ci0,DrainingConnectionError:ui0,InvalidArgumentError:kZ0,InvalidOperationError:gi0,InvalidSubjectError:yi0,NoRespondersError:_Z0,PermissionViolationError:vZ0,ProtocolError:li0,RequestError:di0,TimeoutError:mi0,UserAuthenticationExpiredError:SZ0}});var bJ=_((Kr1)=>{Object.defineProperty(Kr1,"__esModule",{value:!0});Kr1.SimpleMutex=Kr1.Perf=void 0;Kr1.extend=jt6;Kr1.render=zt6;Kr1.timeout=Pt6;Kr1.delay=At6;Kr1.deadline=Tt6;Kr1.deferred=ni0;Kr1.debugDeferred=Rt6;Kr1.shuffle=It6;Kr1.collect=qt6;Kr1.jitter=Jr1;Kr1.backoff=Mt6;Kr1.nanos=Vt6;Kr1.millis=kt6;Kr1.randomToken=_t6;var Et6=sY(),ii0=eY();function jt6($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function zt6($){return Et6.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function Pt6($,Z=!0){let X=Z?new ii0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new ii0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function At6($=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 Tt6($,Z=1000){let X=ni0(),Q=setTimeout(()=>{X.reject(new ii0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function ni0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function Rt6(){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 It6($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function qt6($){let Z=[];for await(let X of $)Z.push(X);return Z}class Yr1{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})}),$}}Kr1.Perf=Yr1;class Gr1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=ni0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}Kr1.SimpleMutex=Gr1;function Jr1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function Mt6($=[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 Jr1(X>Z?$[Z]:$[X])}}}function Vt6($){return $*1e6}function kt6($){return Math.floor($/1e6)}var St6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",$U=new Uint8Array(62);for(let $=0;$<62;$++)$U[$]=St6.charCodeAt($);var Ct6=218340105584896;function _t6(){let $=Math.floor(Math.random()*Ct6),Z=$%62,X=$U[Z];$=($-Z)/62,Z=$%62;let Q=$U[Z];$=($-Z)/62,Z=$%62;let Y=$U[Z];$=($-Z)/62,Z=$%62;let G=$U[Z];$=($-Z)/62,Z=$%62;let J=$U[Z];$=($-Z)/62,Z=$%62;let K=$U[Z];$=($-Z)/62,Z=$%62;let W=$U[Z];$=($-Z)/62;let H=$U[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var wr1=_((Br1)=>{Object.defineProperty(Br1,"__esModule",{value:!0});Br1.nuid=Br1.NuidImpl=void 0;var tt6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",pB=62,fZ0=12,Ur1=10,Hr1=33,ot6=333,Nr1=fZ0+Ur1,ti0=new Uint8Array(pB);for(let $=0;$<pB;$++)ti0[$]=tt6.charCodeAt($);var xZ0=4294967296,Fr1=BigInt(pB)**BigInt(Ur1),fi=Number(Fr1/(1n<<32n)),pi0=Number(Fr1%(1n<<32n));function rt6($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function at6($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else rt6($)}class oi0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(Nr1),this.cbuf=new Uint8Array(fZ0),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(fi+1)),this.seqLo=Math.floor(Math.random()*xZ0);while($++<8&&this.seqHi===fi&&this.seqLo>=pi0);if(this.seqHi===fi&&this.seqLo>=pi0)this.seqLo=0;this.inc=Math.random()*(ot6-Hr1)+Hr1|0}setPre(){at6(this.cbuf);for(let $=0;$<fZ0;$++)this.buf[$]=ti0[this.cbuf[$]%pB]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=Nr1-1;X>=fZ0;X--){let Q=Math.floor($/pB),G=($-Q*pB)*xZ0+Z,J=Math.floor(G/pB),K=G-J*pB;this.buf[X]=ti0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=xZ0)this.seqLo-=xZ0,this.seqHi+=1;if(this.seqHi>fi||this.seqHi===fi&&this.seqLo>=pi0)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()}}Br1.NuidImpl=oi0;Br1.nuid=new oi0});var jr1=_((Dr1)=>{Object.defineProperty(Dr1,"__esModule",{value:!0});Dr1.nuid=Dr1.Nuid=void 0;var Lr1=wr1();Dr1.Nuid=Lr1.NuidImpl;Dr1.nuid=Lr1.nuid});var yZ0=_((bZ0)=>{Object.defineProperty(bZ0,"__esModule",{value:!0});bZ0.nuid=bZ0.Nuid=void 0;var zr1=jr1();Object.defineProperty(bZ0,"Nuid",{enumerable:!0,get:function(){return zr1.Nuid}});Object.defineProperty(bZ0,"nuid",{enumerable:!0,get:function(){return zr1.nuid}})});var tB=_((Pr1)=>{Object.defineProperty(Pr1,"__esModule",{value:!0});Pr1.DEFAULT_HOST=Pr1.DEFAULT_PORT=Pr1.Match=void 0;Pr1.syncIterator=Qo6;Pr1.createInbox=Yo6;var Zo6=yZ0(),Xo6=eY();Pr1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Qo6($){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 Yo6($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw Xo6.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${Zo6.nuid.next()}`}Pr1.DEFAULT_PORT=4222;Pr1.DEFAULT_HOST="127.0.0.1"});var bi=_((Ir1)=>{Object.defineProperty(Ir1,"__esModule",{value:!0});Ir1.DataBuffer=void 0;var Tr1=sY();class Rr1{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 Tr1.TE.encode($)}static toAscii($){return Tr1.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}}Ir1.DataBuffer=Rr1});var RE=_((Vr1)=>{Object.defineProperty(Vr1,"__esModule",{value:!0});Vr1.LF=Vr1.CR=Vr1.CRLF=Vr1.CR_LF_LEN=Vr1.CR_LF=void 0;Vr1.setTransportFactory=Fo6;Vr1.defaultPort=Bo6;Vr1.getUrlParseFn=Oo6;Vr1.newTransport=wo6;Vr1.getResolveFn=Lo6;Vr1.protoLen=Mr1;Vr1.extractProtocolMessage=Do6;var Ho6=sY(),No6=tB(),Uo6=bi(),$G;function Fo6($){$G=$}function Bo6(){return $G!==void 0&&$G.defaultPort!==void 0?$G.defaultPort:No6.DEFAULT_PORT}function Oo6(){return $G!==void 0&&$G.urlParseFn?$G.urlParseFn:void 0}function wo6(){if(!$G||typeof $G.factory!=="function")throw Error("transport fn is not set");return $G.factory()}function Lo6(){return $G!==void 0&&$G.dnsResolveFn?$G.dnsResolveFn:void 0}Vr1.CR_LF=`\r
1374
+ `);Q=G.pop()??"";for(let J of G){let K=vi(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;mB({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=vi(Q).replace(/^\[\d+\]\s*/,"").trim();if(G)mB({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function Mp6($){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 _i(Number(Y)+1):await _i(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await RZ0({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let L of W)EE({name:L.name,status:"ready",port:L.port});Si();let N=qp6(import.meta.dir,"..","..","..","..",".."),U=X===!0,F=Bun.spawn(["bun","run","dev:servers"],{cwd:N,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",U?"inherit":"pipe",U?"inherit":"pipe"]});if(!U)So1(F.stdout),So1(F.stderr);Ci(G),EE({name:"Vite",status:"ready",port:Number(Y)}),EE({name:"API",status:"ready",port:Number(K.port)});let O=async(L)=>{if(F.kill(L),await F.exited,H.length>0){let{stopServices:D}=await Promise.resolve().then(() => (_90(),C90));await D(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:F}}var ki0=w(()=>{Ti0();jE();Mi0()});var MZ0;var Si0=w(()=>{MZ0={name:"decocms",version:"4.243.16",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","db:migrate:dbos":"bun run ./dist/server/migrate-dbos.js",check:"tsc --noEmit",start:"bun run ./dist/server/server.js",migrate:"bun run src/database/migrate.ts","migrate:dbos":"bun run src/database/migrate-dbos.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 kp6,Text as Co1}from"ink";import{jsx as Sp6,jsxs as _o1}from"react/jsx-runtime";function vo1({version:$}){return _o1(kp6,{flexDirection:"column",marginTop:1,children:[ZZ0.map((Z,X)=>Sp6(Co1,{color:XZ0[X],children:Z},X)),_o1(Co1,{dimColor:!0,children:[" v",$]})]})}var xo1=w(()=>{Ei()});import{Box as zE,Text as iB}from"ink";import{Spinner as Cp6}from"@inkjs/ui";import{jsx as aY,jsxs as ib}from"react/jsx-runtime";function fo1({status:$}){if($==="pending")return aY(Cp6,{label:""});return aY(iB,{color:"green",children:"\u2713"})}function _p6($){return`${$.name}: ${$.port||"...."}`}function bo1({services:$,migrationsStatus:Z,home:X,serverUrl:Q}){return ib(zE,{flexDirection:"column",paddingBottom:1,children:[aY(vo1,{version:MZ0.version}),aY(zE,{marginBottom:1,children:aY(iB,{dimColor:!0,children:"\u2500".repeat(80)})}),aY(zE,{children:ib(iB,{dimColor:!0,children:["Home: ",X]})}),ib(zE,{gap:2,children:[$.map((Y)=>ib(zE,{gap:1,children:[aY(iB,{children:_p6(Y)}),aY(fo1,{status:Y.status})]},Y.name)),ib(zE,{gap:1,children:[aY(iB,{children:"Migrations"}),aY(fo1,{status:Z})]})]}),aY(zE,{children:Q?ib(iB,{children:["Open in browser: ",aY(iB,{color:"cyan",children:Q})]}):aY(iB,{dimColor:!0,children:"Starting..."})})]})}var yo1=w(()=>{Si0();xo1()});import{Box as vp6,Text as xi}from"ink";import{jsx as Ci0,jsxs as _i0}from"react/jsx-runtime";function xp6($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function go1({logs:$}){return Ci0(vp6,{flexDirection:"column",children:$.map((Z,X)=>{if(Z.rawLine)return Ci0(xi,{dimColor:!0,children:Z.rawLine},X);let Q=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return _i0(xi,{children:[_i0(xi,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),Ci0(xi,{color:xp6(Z.status),children:Z.status}),_i0(xi,{dimColor:!0,children:[" ",Q.padStart(8)]})]},X)})})}var ho1=()=>{};var vi0={};F0(vi0,{App:()=>yp6});import{Box as fp6}from"ink";import{useSyncExternalStore as bp6}from"react";import{jsx as uo1,jsxs as gp6}from"react/jsx-runtime";function yp6({home:$}){let Z=bp6(qi0,Ii0);return gp6(fp6,{flexDirection:"column",children:[uo1(bo1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),uo1(go1,{logs:Z.logs})]})}var xi0=w(()=>{yo1();ho1();jE()});var fJ="thread-gate",sN="decopilot-hosted-harness",eN="decopilot-hosted-harness-sandboxed",N3="automations",nB="background-tools",PE="task-board-github-reads",AE="jira-push";var co1="7";function lo1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:co1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var do1=()=>{};function hp6(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function fi0($,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 mo1(){let $=hp6();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:fi0($,"--cpu-prof-dir")??process.cwd(),name:fi0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(fi0($,"--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 io1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let X=OE();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(()=>{}),VZ0=setInterval(()=>void Z().catch(()=>{}),$),VZ0.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(VZ0)clearInterval(VZ0)}}var VZ0;var no1=()=>{};import*as up6 from"bun:jsc";function po1(){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{cp6()}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=lp6()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let N of K){let U=N.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??N.frames[0];if(!U)continue;let F=(U.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${U.name??"?"} @ ${F}:${U.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((N,U)=>U[1]-N[1]).slice(0,8).map(([N,U])=>({frame:N,count:U}));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 cp6,lp6;var to1=w(()=>{({startSamplingProfiler:cp6,samplingProfilerStackTraces:lp6}=up6)});function oo1(){mo1();let $=[io1(),ni1(),po1()];return()=>{for(let Z of $)Z()}}var ro1=w(()=>{fc0();no1();to1()});var TE=_((ao1)=>{Object.defineProperty(ao1,"__esModule",{value:!0});ao1.RepublishHeaders=ao1.DirectMsgHeaders=ao1.JsHeaders=ao1.AdvisoryKind=void 0;ao1.isOrderedPushConsumerOptions=dp6;ao1.isPullConsumer=mp6;ao1.isPushConsumer=ip6;ao1.isBoundPushConsumerOptions=np6;function dp6($){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 mp6($){return $.isPullConsumer()}function ip6($){return $.isPushConsumer()}function np6($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}ao1.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"};ao1.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"};ao1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};ao1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var sY=_((eo1)=>{Object.defineProperty(eo1,"__esModule",{value:!0});eo1.TD=eo1.TE=eo1.Empty=void 0;eo1.encode=Zt6;eo1.decode=Xt6;eo1.Empty=new Uint8Array(0);eo1.TE=new TextEncoder;eo1.TD=new TextDecoder;function $t6(...$){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 Zt6(...$){let Z=[];for(let X=0;X<$.length;X++)Z.push(eo1.TE.encode($[X]));if(Z.length===0)return eo1.Empty;if(Z.length===1)return Z[0];return $t6(...Z)}function Xt6($){if(!$||$.length===0)return"";return eo1.TD.decode($)}});var eY=_((Xr1)=>{Object.defineProperty(Xr1,"__esModule",{value:!0});Xr1.errors=Xr1.PermissionViolationError=Xr1.NoRespondersError=Xr1.TimeoutError=Xr1.RequestError=Xr1.ProtocolError=Xr1.ConnectionError=Xr1.DrainingConnectionError=Xr1.ClosedConnectionError=Xr1.AuthorizationError=Xr1.UserAuthenticationExpiredError=Xr1.InvalidOperationError=Xr1.InvalidArgumentError=Xr1.InvalidSubjectError=void 0;class yi0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}Xr1.InvalidSubjectError=yi0;class kZ0 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 kZ0(`${$} ${Z}`,X)}}Xr1.InvalidArgumentError=kZ0;class gi0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}Xr1.InvalidOperationError=gi0;class SZ0 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new SZ0($);return null}}Xr1.UserAuthenticationExpiredError=SZ0;class CZ0 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 CZ0($);return null}}Xr1.AuthorizationError=CZ0;class hi0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}Xr1.ClosedConnectionError=hi0;class ui0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}Xr1.DrainingConnectionError=ui0;class ci0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}Xr1.ConnectionError=ci0;class li0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}Xr1.ProtocolError=li0;class di0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof _Z0}}Xr1.RequestError=di0;class mi0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}Xr1.TimeoutError=mi0;class _Z0 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}Xr1.NoRespondersError=_Z0;class vZ0 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 vZ0($,X,Q,Y)}}Xr1.PermissionViolationError=vZ0;Xr1.errors={AuthorizationError:CZ0,ClosedConnectionError:hi0,ConnectionError:ci0,DrainingConnectionError:ui0,InvalidArgumentError:kZ0,InvalidOperationError:gi0,InvalidSubjectError:yi0,NoRespondersError:_Z0,PermissionViolationError:vZ0,ProtocolError:li0,RequestError:di0,TimeoutError:mi0,UserAuthenticationExpiredError:SZ0}});var bJ=_((Kr1)=>{Object.defineProperty(Kr1,"__esModule",{value:!0});Kr1.SimpleMutex=Kr1.Perf=void 0;Kr1.extend=jt6;Kr1.render=zt6;Kr1.timeout=Pt6;Kr1.delay=At6;Kr1.deadline=Tt6;Kr1.deferred=ni0;Kr1.debugDeferred=Rt6;Kr1.shuffle=It6;Kr1.collect=qt6;Kr1.jitter=Jr1;Kr1.backoff=Mt6;Kr1.nanos=Vt6;Kr1.millis=kt6;Kr1.randomToken=_t6;var Et6=sY(),ii0=eY();function jt6($,...Z){for(let X=0;X<Z.length;X++){let Q=Z[X];Object.keys(Q).forEach(function(Y){$[Y]=Q[Y]})}return $}function zt6($){return Et6.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function Pt6($,Z=!0){let X=Z?new ii0.TimeoutError:null,Q,Y,G=new Promise((J,K)=>{Q={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(X===null)K(new ii0.TimeoutError);else K(X)},$)});return Object.assign(G,Q)}function At6($=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 Tt6($,Z=1000){let X=ni0(),Q=setTimeout(()=>{X.reject(new ii0.TimeoutError)},Z);try{return await Promise.race([$,X])}finally{clearTimeout(Q)}}function ni0(){let $={},Z=new Promise((X,Q)=>{$={resolve:X,reject:Q}});return Object.assign(Z,$)}function Rt6(){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 It6($){for(let Z=$.length-1;Z>0;Z--){let X=Math.floor(Math.random()*(Z+1));[$[Z],$[X]]=[$[X],$[Z]]}return $}async function qt6($){let Z=[];for await(let X of $)Z.push(X);return Z}class Yr1{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})}),$}}Kr1.Perf=Yr1;class Gr1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=ni0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}Kr1.SimpleMutex=Gr1;function Jr1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function Mt6($=[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 Jr1(X>Z?$[Z]:$[X])}}}function Vt6($){return $*1e6}function kt6($){return Math.floor($/1e6)}var St6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",$U=new Uint8Array(62);for(let $=0;$<62;$++)$U[$]=St6.charCodeAt($);var Ct6=218340105584896;function _t6(){let $=Math.floor(Math.random()*Ct6),Z=$%62,X=$U[Z];$=($-Z)/62,Z=$%62;let Q=$U[Z];$=($-Z)/62,Z=$%62;let Y=$U[Z];$=($-Z)/62,Z=$%62;let G=$U[Z];$=($-Z)/62,Z=$%62;let J=$U[Z];$=($-Z)/62,Z=$%62;let K=$U[Z];$=($-Z)/62,Z=$%62;let W=$U[Z];$=($-Z)/62;let H=$U[$];return String.fromCharCode(X,Q,Y,G,J,K,W,H)}});var wr1=_((Br1)=>{Object.defineProperty(Br1,"__esModule",{value:!0});Br1.nuid=Br1.NuidImpl=void 0;var tt6="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",pB=62,fZ0=12,Ur1=10,Hr1=33,ot6=333,Nr1=fZ0+Ur1,ti0=new Uint8Array(pB);for(let $=0;$<pB;$++)ti0[$]=tt6.charCodeAt($);var xZ0=4294967296,Fr1=BigInt(pB)**BigInt(Ur1),fi=Number(Fr1/(1n<<32n)),pi0=Number(Fr1%(1n<<32n));function rt6($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function at6($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else rt6($)}class oi0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(Nr1),this.cbuf=new Uint8Array(fZ0),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(fi+1)),this.seqLo=Math.floor(Math.random()*xZ0);while($++<8&&this.seqHi===fi&&this.seqLo>=pi0);if(this.seqHi===fi&&this.seqLo>=pi0)this.seqLo=0;this.inc=Math.random()*(ot6-Hr1)+Hr1|0}setPre(){at6(this.cbuf);for(let $=0;$<fZ0;$++)this.buf[$]=ti0[this.cbuf[$]%pB]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let X=Nr1-1;X>=fZ0;X--){let Q=Math.floor($/pB),G=($-Q*pB)*xZ0+Z,J=Math.floor(G/pB),K=G-J*pB;this.buf[X]=ti0[K],$=Q,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=xZ0)this.seqLo-=xZ0,this.seqHi+=1;if(this.seqHi>fi||this.seqHi===fi&&this.seqLo>=pi0)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()}}Br1.NuidImpl=oi0;Br1.nuid=new oi0});var jr1=_((Dr1)=>{Object.defineProperty(Dr1,"__esModule",{value:!0});Dr1.nuid=Dr1.Nuid=void 0;var Lr1=wr1();Dr1.Nuid=Lr1.NuidImpl;Dr1.nuid=Lr1.nuid});var yZ0=_((bZ0)=>{Object.defineProperty(bZ0,"__esModule",{value:!0});bZ0.nuid=bZ0.Nuid=void 0;var zr1=jr1();Object.defineProperty(bZ0,"Nuid",{enumerable:!0,get:function(){return zr1.Nuid}});Object.defineProperty(bZ0,"nuid",{enumerable:!0,get:function(){return zr1.nuid}})});var tB=_((Pr1)=>{Object.defineProperty(Pr1,"__esModule",{value:!0});Pr1.DEFAULT_HOST=Pr1.DEFAULT_PORT=Pr1.Match=void 0;Pr1.syncIterator=Qo6;Pr1.createInbox=Yo6;var Zo6=yZ0(),Xo6=eY();Pr1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Qo6($){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 Yo6($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw Xo6.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${Zo6.nuid.next()}`}Pr1.DEFAULT_PORT=4222;Pr1.DEFAULT_HOST="127.0.0.1"});var bi=_((Ir1)=>{Object.defineProperty(Ir1,"__esModule",{value:!0});Ir1.DataBuffer=void 0;var Tr1=sY();class Rr1{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 Tr1.TE.encode($)}static toAscii($){return Tr1.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}}Ir1.DataBuffer=Rr1});var RE=_((Vr1)=>{Object.defineProperty(Vr1,"__esModule",{value:!0});Vr1.LF=Vr1.CR=Vr1.CRLF=Vr1.CR_LF_LEN=Vr1.CR_LF=void 0;Vr1.setTransportFactory=Fo6;Vr1.defaultPort=Bo6;Vr1.getUrlParseFn=Oo6;Vr1.newTransport=wo6;Vr1.getResolveFn=Lo6;Vr1.protoLen=Mr1;Vr1.extractProtocolMessage=Do6;var Ho6=sY(),No6=tB(),Uo6=bi(),$G;function Fo6($){$G=$}function Bo6(){return $G!==void 0&&$G.defaultPort!==void 0?$G.defaultPort:No6.DEFAULT_PORT}function Oo6(){return $G!==void 0&&$G.urlParseFn?$G.urlParseFn:void 0}function wo6(){if(!$G||typeof $G.factory!=="function")throw Error("transport fn is not set");return $G.factory()}function Lo6(){return $G!==void 0&&$G.dnsResolveFn?$G.dnsResolveFn:void 0}Vr1.CR_LF=`\r
1375
1375
  `;Vr1.CR_LF_LEN=Vr1.CR_LF.length;Vr1.CRLF=Uo6.DataBuffer.fromAscii(Vr1.CR_LF);Vr1.CR=new Uint8Array(Vr1.CRLF)[0];Vr1.LF=new Uint8Array(Vr1.CRLF)[1];function Mr1($){for(let Z=0;Z<$.length;Z++){let X=Z+1;if($.byteLength>X&&$[Z]===Vr1.CR&&$[X]===Vr1.LF)return X+1}return 0}function Do6($){let Z=Mr1($);if(Z>0){let Q=new Uint8Array($).slice(0,Z);return Ho6.TD.decode(Q)}return""}});var $n0=_((br1)=>{Object.defineProperty(br1,"__esModule",{value:!0});br1.ipV4=vr1;br1.isIP=Vo6;br1.parseIP=xr1;var yi=4,IE=16,gZ0=48,_r1=57,Sr1=65,qo6=70,Cr1=97,Mo6=102,ei0=16777215;function vr1($,Z,X,Q){let Y=new Uint8Array(IE);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 Vo6($){return xr1($)!==void 0}function xr1($){for(let Z=0;Z<$.length;Z++)switch($[Z]){case".":return fr1($);case":":return ko6($)}return}function fr1($){let Z=new Uint8Array(yi);for(let X=0;X<yi;X++){if($.length===0)return;if(X>0){if($[0]!==".")return;$=$.substring(1)}let{n:Q,c:Y,ok:G}=So6($);if(!G||Q>255)return;$=$.substring(Y),Z[X]=Q}return vr1(Z[0],Z[1],Z[2],Z[3])}function ko6($){let Z=new Uint8Array(IE),X=-1;if($.length>=2&&$[0]===":"&&$[1]===":"){if(X=0,$=$.substring(2),$.length===0)return Z}let Q=0;while(Q<IE){let{n:Y,c:G,ok:J}=Co6($);if(!J||Y>65535)return;if(G<$.length&&$[G]==="."){if(X<0&&Q!=IE-yi)return;if(Q+yi>IE)return;let K=fr1($);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+=yi;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<IE){if(X<0)return;let Y=IE-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 So6($){let Z=0,X=0;for(Z=0;Z<$.length&&gZ0<=$.charCodeAt(Z)&&$.charCodeAt(Z)<=_r1;Z++)if(X=X*10+($.charCodeAt(Z)-gZ0),X>=ei0)return{n:ei0,c:Z,ok:!1};if(Z===0)return{n:0,c:0,ok:!1};return{n:X,c:Z,ok:!0}}function Co6($){let Z=0,X=0;for(X=0;X<$.length;X++){if(gZ0<=$.charCodeAt(X)&&$.charCodeAt(X)<=_r1)Z*=16,Z+=$.charCodeAt(X)-gZ0;else if(Cr1<=$.charCodeAt(X)&&$.charCodeAt(X)<=Mo6)Z*=16,Z+=$.charCodeAt(X)-Cr1+10;else if(Sr1<=$.charCodeAt(X)&&$.charCodeAt(X)<=qo6)Z*=16,Z+=$.charCodeAt(X)-Sr1+10;else break;if(Z>=ei0)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 Jn0=_((gr1)=>{Object.defineProperty(gr1,"__esModule",{value:!0});gr1.Servers=gr1.ServerImpl=void 0;gr1.isIPV4OrHostname=yr1;gr1.hostPort=Gn0;var Zn0=RE(),Xn0=bJ(),Qn0=$n0(),fo6=tB(),bo6=eY();function yr1($){if($.indexOf("[")!==-1||$.indexOf("::")!==-1)return!1;if($.indexOf(".")!==-1)return!0;if($.split(":").length<=2)return!0;return!1}function Yn0($){return!yr1($)}function yo6($){let X=$.toUpperCase().indexOf("::FFFF:");if(X!==-1&&$.indexOf(".")!==-1){let Q=$.substring(X+7);return Q=Q.replace("[",""),Q.replace("]","")}return $}function Gn0($){if($=$.trim(),$.match(/^(.*:\/\/)(.*)/m))$=$.replace(/^(.*:\/\/)(.*)/gm,"$2");if($=yo6($),Yn0($)&&$.indexOf("[")===-1)$=`[${$}]`;let Z=Yn0($)?$.match(/(]:)(\d+)/):$.match(/(:)(\d+)/),X=Z&&Z.length===3&&Z[1]&&Z[2]?parseInt(Z[2]):fo6.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 nb{src;listen;hostname;port;didConnect;reconnects;lastConnect;gossiped;tlsName;resolves;constructor($,Z=!1){this.src=$,this.tlsName="";let X=Gn0($);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,Qn0.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}://${Yn0(Q)?"["+Q+"]":Q}`);G.port=`${this.port}`;let J=new nb(G.host,!1);J.tlsName=this.hostname,Z.push(J)}}if($.randomize)(0,Xn0.shuffle)(Z);return this.resolves=Z,Z}}gr1.ServerImpl=nb;class hZ0{firstSelect;servers;currentServer;tlsName;randomize;constructor($={}){this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=$.randomize||!1}setServers($){if(!Array.isArray($)||$.length===0)throw bo6.InvalidArgumentError.format("servers","cannot be empty");let Z=(0,Zn0.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}=Gn0(Y),J=X.get(G);if(J)J.gossiped=!1,Q.push(J);else Q.push(new nb(Y))}if(this.randomize)(0,Xn0.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,Qn0.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,Zn0.getUrlParseFn)();$=X?X($):$;let Q=new nb($,Z);if((0,Qn0.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 hZ0.freezeAll(this.servers)}snapshotForHandler(){let $=this.currentServer;if(!$)return this.snapshot();let Z=this.servers.indexOf($);if(Z<=0)return this.snapshot();return hZ0.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,Zn0.getUrlParseFn)(),G=new Map;if($.connect_urls&&$.connect_urls.length>0)$.connect_urls.forEach((K)=>{K=Y?Y(K,Z):K;let W=new nb(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,Xn0.shuffle)(W),this.servers=K?[K,...W]:W}return{added:X,deleted:Q}}}gr1.Servers=hZ0});var uZ0=_((lr1)=>{Object.defineProperty(lr1,"__esModule",{value:!0});lr1.QueuedIteratorImpl=void 0;var Kn0=bJ(),ur1=eY();class cr1{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,Kn0.deferred)(),this.yields=[],this.iterClosed=(0,Kn0.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 ur1.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new ur1.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,Kn0.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}}lr1.QueuedIteratorImpl=cr1});var Wn0=_((nr1)=>{Object.defineProperty(nr1,"__esModule",{value:!0});nr1.MuxSubscription=void 0;var co6=tB(),mr1=eY();class ir1{baseInbox;reqs;constructor(){this.reqs=new Map}size(){return this.reqs.size}init($){return this.baseInbox=`${(0,co6.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 mr1.NoRespondersError(Q.requestSubject):null;Q.resolver($,Z)}}}}close(){let $=new mr1.RequestError("connection closed");this.reqs.forEach((Z)=>{Z.resolver($,{})})}}nr1.MuxSubscription=ir1});var Hn0=_((or1)=>{Object.defineProperty(or1,"__esModule",{value:!0});or1.Heartbeat=void 0;var lo6=bJ();class tr1{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,lo6.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})}}or1.Heartbeat=tr1});var Fn0=_(($a1)=>{Object.defineProperty($a1,"__esModule",{value:!0});$a1.DenoBuffer=$a1.MAX_SIZE=$a1.AssertionError=void 0;$a1.assert=sr1;$a1.concat=er1;$a1.append=mo6;$a1.readAll=io6;$a1.writeAll=no6;var do6=sY();class Nn0 extends Error{constructor($){super($);this.name="AssertionError"}}$a1.AssertionError=Nn0;function sr1($,Z="Assertion failed."){if(!$)throw new Nn0(Z)}var ar1=32768;$a1.MAX_SIZE=4294967294;function cZ0($,Z,X=0){let Q=Z.byteLength-X;if($.byteLength>Q)$=$.subarray(0,Q);return Z.set($,X),$.byteLength}function er1($,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 mo6($,Z){return er1($,Uint8Array.of(Z))}class Un0{_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($){sr1($<=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=cZ0(this._buf.subarray(this._off),$);return this._off+=Z,Z}writeByte($){return this.write(Uint8Array.of($))}writeString($){return this.write(do6.TE.encode($))}write($){let Z=this._grow($.byteLength);return cZ0($,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)cZ0(this._buf.subarray(this._off),this._buf);else if(Q+$>$a1.MAX_SIZE)throw Error("The buffer cannot be grown beyond the maximum size.");else{let Y=new Uint8Array(Math.min(2*Q+$,$a1.MAX_SIZE));cZ0(this._buf.subarray(this._off),Y),this._buf=Y}return this._off=0,this._reslice(Math.min(Z+$,$a1.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(ar1);while(!0){let Q=this.capacity-this.length<ar1,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}}}$a1.DenoBuffer=Un0;function io6($){let Z=new Un0;return Z.readFrom($),Z.bytes()}function no6($,Z){let X=0;while(X<Z.length)X+=$.write(Z.subarray(X))}});var wn0=_((Ga1)=>{Object.defineProperty(Ga1,"__esModule",{value:!0});Ga1.cc=Ga1.State=Ga1.Parser=Ga1.Kind=void 0;Ga1.describe=eo6;var Bn0=Fn0(),On0=sY();Ga1.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function eo6($){let Z,X="";switch($.kind){case Ga1.Kind.MSG:Z="MSG";break;case Ga1.Kind.OK:Z="OK";break;case Ga1.Kind.ERR:Z="ERR",X=On0.TD.decode($.data);break;case Ga1.Kind.PING:Z="PING";break;case Ga1.Kind.PONG:Z="PONG";break;case Ga1.Kind.INFO:Z="INFO",X=On0.TD.decode($.data)}return`${Z}: ${X}`}function Xa1(){let $={};return $.sid=-1,$.hdr=-1,$.size=-1,$}var Qa1=48,$r6=57,pb=67108864;class Ya1{dispatcher;state;as;drop;hdr;ma;argBuf;msgBuf;constructor($){this.dispatcher=$,this.state=Ga1.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 Ga1.State.OP_START:switch(X){case Ga1.cc.M:case Ga1.cc.m:this.state=Ga1.State.OP_M,this.hdr=-1,this.ma=Xa1();break;case Ga1.cc.H:case Ga1.cc.h:this.state=Ga1.State.OP_H,this.hdr=0,this.ma=Xa1();break;case Ga1.cc.P:case Ga1.cc.p:this.state=Ga1.State.OP_P;break;case Ga1.cc.PLUS:this.state=Ga1.State.OP_PLUS;break;case Ga1.cc.MINUS:this.state=Ga1.State.OP_MINUS;break;case Ga1.cc.I:case Ga1.cc.i:this.state=Ga1.State.OP_I;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_H:switch(X){case Ga1.cc.M:case Ga1.cc.m:this.state=Ga1.State.OP_M;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_M:switch(X){case Ga1.cc.S:case Ga1.cc.s:this.state=Ga1.State.OP_MS;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MS:switch(X){case Ga1.cc.G:case Ga1.cc.g:this.state=Ga1.State.OP_MSG;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MSG:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:this.state=Ga1.State.OP_MSG_SPC;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MSG_SPC:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:continue;default:this.state=Ga1.State.MSG_ARG,this.as=Z}break;case Ga1.State.MSG_ARG:switch(X){case Ga1.cc.CR:this.drop=1;break;case Ga1.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=Ga1.State.MSG_PAYLOAD,Z=this.as+this.ma.size-1;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;case Ga1.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){let Q=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Ga1.Kind.MSG,msg:this.ma,data:Q}),this.argBuf=void 0,this.msgBuf=void 0,this.state=Ga1.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:Ga1.Kind.MSG,msg:this.ma,data:$.subarray(this.as,Z)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=Ga1.State.MSG_END;break;case Ga1.State.MSG_END:switch(X){case Ga1.cc.NL:this.drop=0,this.as=Z+1,this.state=Ga1.State.OP_START;break;default:continue}break;case Ga1.State.OP_PLUS:switch(X){case Ga1.cc.O:case Ga1.cc.o:this.state=Ga1.State.OP_PLUS_O;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PLUS_O:switch(X){case Ga1.cc.K:case Ga1.cc.k:this.state=Ga1.State.OP_PLUS_OK;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PLUS_OK:switch(X){case Ga1.cc.NL:this.dispatcher.push({kind:Ga1.Kind.OK}),this.drop=0,this.state=Ga1.State.OP_START;break}break;case Ga1.State.OP_MINUS:switch(X){case Ga1.cc.E:case Ga1.cc.e:this.state=Ga1.State.OP_MINUS_E;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_E:switch(X){case Ga1.cc.R:case Ga1.cc.r:this.state=Ga1.State.OP_MINUS_ER;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_ER:switch(X){case Ga1.cc.R:case Ga1.cc.r:this.state=Ga1.State.OP_MINUS_ERR;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_ERR:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:this.state=Ga1.State.OP_MINUS_ERR_SPC;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_MINUS_ERR_SPC:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:continue;default:this.state=Ga1.State.MINUS_ERR_ARG,this.as=Z}break;case Ga1.State.MINUS_ERR_ARG:switch(X){case Ga1.cc.CR:this.drop=1;break;case Ga1.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:Ga1.Kind.ERR,data:Q}),this.drop=0,this.as=Z+1,this.state=Ga1.State.OP_START;break}default:if(this.argBuf)this.argBuf.write(Uint8Array.of(X))}break;case Ga1.State.OP_P:switch(X){case Ga1.cc.I:case Ga1.cc.i:this.state=Ga1.State.OP_PI;break;case Ga1.cc.O:case Ga1.cc.o:this.state=Ga1.State.OP_PO;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PO:switch(X){case Ga1.cc.N:case Ga1.cc.n:this.state=Ga1.State.OP_PON;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PON:switch(X){case Ga1.cc.G:case Ga1.cc.g:this.state=Ga1.State.OP_PONG;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PONG:switch(X){case Ga1.cc.NL:this.dispatcher.push({kind:Ga1.Kind.PONG}),this.drop=0,this.state=Ga1.State.OP_START;break}break;case Ga1.State.OP_PI:switch(X){case Ga1.cc.N:case Ga1.cc.n:this.state=Ga1.State.OP_PIN;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PIN:switch(X){case Ga1.cc.G:case Ga1.cc.g:this.state=Ga1.State.OP_PING;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_PING:switch(X){case Ga1.cc.NL:this.dispatcher.push({kind:Ga1.Kind.PING}),this.drop=0,this.state=Ga1.State.OP_START;break}break;case Ga1.State.OP_I:switch(X){case Ga1.cc.N:case Ga1.cc.n:this.state=Ga1.State.OP_IN;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_IN:switch(X){case Ga1.cc.F:case Ga1.cc.f:this.state=Ga1.State.OP_INF;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_INF:switch(X){case Ga1.cc.O:case Ga1.cc.o:this.state=Ga1.State.OP_INFO;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_INFO:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:this.state=Ga1.State.OP_INFO_SPC;break;default:throw this.fail($.subarray(Z))}break;case Ga1.State.OP_INFO_SPC:switch(X){case Ga1.cc.SPACE:case Ga1.cc.TAB:continue;default:this.state=Ga1.State.INFO_ARG,this.as=Z}break;case Ga1.State.INFO_ARG:switch(X){case Ga1.cc.CR:this.drop=1;break;case Ga1.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:Ga1.Kind.INFO,data:Q}),this.drop=0,this.as=Z+1,this.state=Ga1.State.OP_START;break}default:if(this.argBuf)this.argBuf.writeByte(X)}break;default:throw this.fail($.subarray(Z))}}if((this.state===Ga1.State.MSG_ARG||this.state===Ga1.State.MINUS_ERR_ARG||this.state===Ga1.State.INFO_ARG)&&!this.argBuf)this.argBuf=new Bn0.DenoBuffer($.subarray(this.as,Z-this.drop));if(this.state===Ga1.State.MSG_PAYLOAD&&!this.msgBuf){if(!this.argBuf)this.cloneMsgArg();this.msgBuf=new Bn0.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 Bn0.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 Ga1.cc.SPACE:case Ga1.cc.TAB:case Ga1.cc.CR:case Ga1.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],pb);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],pb);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}: ${On0.TD.decode($)}`)}processHeaderMsgArgs($){let Z=[],X=-1;for(let Q=0;Q<$.length;Q++)switch($[Q]){case Ga1.cc.SPACE:case Ga1.cc.TAB:case Ga1.cc.CR:case Ga1.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],pb),this.ma.size=this.protoParseInt(Z[3],pb);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],pb),this.ma.size=this.protoParseInt(Z[4],pb);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]<Qa1||$[Q]>$r6)return-1;X=X*10+($[Q]-Qa1)}return Z!==void 0&&X>Z?-1:X}}Ga1.Parser=Ya1;Ga1.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};Ga1.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 mZ0=_((Ka1)=>{Object.defineProperty(Ka1,"__esModule",{value:!0});Ka1.MsgHdrsImpl=void 0;Ka1.canonicalMIMEHeaderKey=Dn0;Ka1.headers=Qr6;var Ja1=sY(),yJ=tB(),dZ0=eY();function Dn0($){let N=!0,U=Array($.length);for(let F=0;F<$.length;F++){let B=$.charCodeAt(F);if(B===58||B<33||B>126)throw dZ0.InvalidArgumentError.format("header",`'${$[F]}' is not a valid character in a header name`);if(N&&97<=B&&B<=122)B-=32;else if(!N&&65<=B&&B<=90)B+=32;U[F]=B,N=B==45}return String.fromCharCode(...U)}function Qr6($=0,Z=""){if($===0&&Z!=="")throw dZ0.InvalidArgumentError.format("code","is required");else if($>0&&Z==="")throw dZ0.InvalidArgumentError.format("description","is required");return new tb($,Z)}var Ln0="NATS/1.0";class tb{_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 tb,Q=Ja1.TD.decode($).split(`\r
1376
1376
  `),Y=Q[0];if(Y!==Ln0){let G=Y.replace(Ln0,"").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 $=Ln0;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
1377
1377
  ${Z}: ${X[Q]}`;return`${$}\r
@@ -2796,7 +2796,7 @@ ${KC8(Z.content)}
2796
2796
  `)X--;return $.slice(Z,X)}function An4($){let Z=[],X=0;while(X<$.length){let Q=Tn4($,X),Y=WC8($,X,"{noformat}"),G=WC8($,X,"{quote}"),J=[];if(Q)J.push({type:"code",...Q});if(Y)J.push({type:"code",lang:"",...Y});if(G)J.push({type:"quote",...G});let K=J.sort((W,H)=>W.start-H.start)[0];if(!K){Z.push({type:"text",content:$.slice(X)});break}if(K.start>X)Z.push({type:"text",content:$.slice(X,K.start)});Z.push(K),X=K.end}return Z}function Tn4($,Z){for(let X=$.indexOf("{code",Z);X!==-1;){let Q=$.indexOf("}",X);if(Q===-1)return null;let Y=$.slice(X+5,Q);if(Y===""||Y.startsWith(":")){let G=$.indexOf("{code}",Q+1);if(G===-1)return null;let J=Y.startsWith(":")?Y.slice(1).split("|")[0]??"":"";return{start:X,end:G+6,content:$.slice(Q+1,G),lang:J}}X=$.indexOf("{code",X+1)}return null}function WC8($,Z,X){let Q=$.indexOf(X,Z);if(Q===-1)return null;let Y=$.indexOf(X,Q+X.length);if(Y===-1)return null;return{start:Q,end:Y+X.length,content:$.slice(Q+X.length,Y)}}function HC8($){return $.split(`
2797
2797
  `).map(In4).join(`
2798
2798
  `)}function ZZ1($,Z){let X=0;while($[X]===Z)X++;return X}function Rn4($){let Z=$.trim();return Z.length>=4&&ZZ1(Z,"-")===Z.length}function In4($){let Z=$[1]??"";if($[0]==="h"&&Z>="1"&&Z<="6"&&$[2]===".")return`${"#".repeat(Number(Z))} ${Lv($.slice(3).trimStart())}`;if(Rn4($))return"---";let X=ZZ1($,"*");if(X>0&&$[X]===" ")return`${X===1?"*":`${" ".repeat(X-1)}-`} ${Lv($.slice(X+1))}`;let Q=ZZ1($,"#");if(Q>0&&$[Q]===" ")return`${" ".repeat(Q-1)}1. ${Lv($.slice(Q+1))}`;let Y=$.trimEnd();if(Y.startsWith("||")&&Y.endsWith("||")&&Y.length>4){let G=Y.slice(2,-2).split("||");return`${`| ${G.map((K)=>Lv(K.trim())).join(" | ")} |`}
2799
- |${G.map(()=>" --- ").join("|")}|`}if(Y.startsWith("|")&&Y.endsWith("|")&&Y.length>2)return`| ${Y.slice(1,-1).split("|").map((J)=>Lv(J.trim())).join(" | ")} |`;return Lv($)}function $Z1($){return($.startsWith("http://")||$.startsWith("https://"))&&!$.includes(" ")}function Lv($){let Z="",X=0;while(X<$.length){let Q=$[X]??"";if(Q==="{"){if($.startsWith("{{",X)){let Y=$.indexOf("}}",X+2);if(Y!==-1){Z+=`\`${$.slice(X+2,Y)}\``,X=Y+2;continue}}if($.startsWith("{color",X)){let Y=$.indexOf("}",X);if(Y!==-1){X=Y+1;continue}}}else if(Q==="["){let Y=$.indexOf("]",X);if(Y!==-1){let G=$.slice(X+1,Y),J=G.indexOf("|");if(J!==-1&&$Z1(G.slice(J+1))){Z+=`[${G.slice(0,J)}](${G.slice(J+1)})`,X=Y+1;continue}if($Z1(G)){Z+=G,X=Y+1;continue}}}else if(Q==="!"){let Y=$.indexOf("!",X+1);if(Y!==-1){let G=$.slice(X+1,Y),J=G.indexOf("|"),K=J===-1?G:G.slice(0,J);if($Z1(K)){Z+=`![](${K})`,X=Y+1;continue}}}else if(Q==="*"||Q==="_"){let Y=Vn4($,X,Q,Z.slice(-1)||" ");if(Y){Z+=Y.text,X=Y.next;continue}}Z+=Q,X++}return Z}function Vn4($,Z,X,Q){if(!qn4.includes(Q))return null;let Y=$[Z+1];if(!Y||Y===" "||Y===X)return null;for(let G=Z+2;G<$.length;G++){if($[G]!==X||$[G-1]===" ")continue;let J=$[G+1];if(J!==void 0&&!Mn4.includes(J))continue;let K=Lv($.slice(Z+1,G));return{text:X==="*"?`**${K}**`:`*${K}*`,next:G+1}}return null}var qn4=" ([{>",Mn4=` )]}.,:;!?{["'`;function Cn4($){let Z=$ instanceof Error?$.message:String($),X=Z.match(/failed \((\d+)\)/);if(X&&X[1]){let Q=parseInt(X[1],10);return Q>=500||Q===429}if(/returned invalid JSON/.test(Z))return!1;return!0}function QZ1($){let Z=$.trim().replace(/\/+$/,""),X=/^https?:\/\//i.test(Z)?Z:`https://${Z}`,Q;try{Q=new URL(X).hostname.toLowerCase()}catch{throw Error(`Invalid Jira site URL: ${$}`)}if(!_n4.test(Q))throw Error(`Invalid Jira site URL: ${$} \u2014 expected <your-site>.atlassian.net`);return`https://${Q}`}function XZ1($){if(!/^\d+$/.test($))throw Error(`Invalid Jira board id: ${$}`);return $}class gK{baseUrl;authHeader;constructor($,Z,X){this.baseUrl=QZ1($),this.authHeader=`Basic ${Buffer.from(`${Z}:${X}`).toString("base64")}`}async request($,Z,{idempotent:X=!0}={}){let Q=async()=>{let Y=await fetch(`${this.baseUrl}${$}`,{...Z,headers:{Authorization:this.authHeader,Accept:"application/json",...Z?.body?{"Content-Type":"application/json"}:{}},signal:AbortSignal.timeout(kn4)}),G=await Y.text().catch(()=>"");if(!Y.ok)throw Error(`Jira ${$} failed (${Y.status}): ${G.slice(0,300)}`);if(G==="")return;try{return JSON.parse(G)}catch(J){throw Error(`Jira ${$} returned invalid JSON: ${G.slice(0,300)}`,{cause:J})}};if(!X)return Q();return z5(Q,{maxAttempts:3,minTimeout:100,maxTimeout:5000,multiplier:2,jitter:1,isRetriable:Cn4})}async myself(){return this.request("/rest/api/3/myself")}async listBoards(){let $=[],Z=0;while($.length<200){let X=await this.request(`/rest/agile/1.0/board?startAt=${Z}&maxResults=50`);if($.push(...X.values.map((Q)=>({id:Q.id,name:Q.name,type:Q.type,projectKey:Q.location?.projectKey,projectName:Q.location?.projectName}))),X.isLast||X.values.length===0)break;Z+=X.values.length}return $}async getBoardColumns($){let Z=await this.request(`/rest/agile/1.0/board/${XZ1($)}/configuration`),X=new Map,Q=[];for(let Y of Z.columnConfig?.columns??[]){let G=[];for(let J of Y.statuses??[]){if(!X.has(J.id)){let K=await this.request(`/rest/api/3/status/${encodeURIComponent(J.id)}`);X.set(J.id,K.name)}G.push(X.get(J.id)??J.id)}Q.push({name:Y.name,statuses:G})}return Q}async listBoardIssues($){let Z=new URLSearchParams({startAt:String($.startAt),maxResults:"100",jql:$.jql,fields:Sn4}),X=await this.request(`/rest/agile/1.0/board/${XZ1($.boardId)}/issue?${Z}`);return{issues:X.issues??[],total:X.total}}async listBacklogIssueIds($){let Z=new Set,X=0;while(Z.size<5000){let Q=await this.request(`/rest/agile/1.0/board/${XZ1($)}/backlog?startAt=${X}&maxResults=100&fields=id`);for(let Y of Q.issues??[])Z.add(Y.id);if(X+=Q.issues?.length??0,X>=Q.total||(Q.issues?.length??0)===0)break}return Z}async listTransitions($){return(await this.request(`/rest/api/3/issue/${encodeURIComponent($)}/transitions`)).transitions??[]}async getStatusName($){return(await this.request(`/rest/api/3/issue/${encodeURIComponent($)}?fields=status`)).fields?.status?.name??null}async transitionIssue($,Z){await this.request(`/rest/api/3/issue/${encodeURIComponent($)}/transitions`,{method:"POST",body:JSON.stringify({transition:{id:Z}})},{idempotent:!1})}async listComments($){let Z=[],X=0;while(Z.length<1000){let Q=await this.request(`/rest/api/3/issue/${encodeURIComponent($)}/comment?startAt=${X}&maxResults=100&orderBy=created`);if(Z.push(...Q.comments),Z.length>=Q.total||Q.comments.length===0)break;X+=Q.comments.length}return Z}async addComment($,Z){return this.request(`/rest/api/3/issue/${encodeURIComponent($)}/comment`,{method:"POST",body:JSON.stringify({body:vn4(Z)})},{idempotent:!1})}}function vn4($){let Z=$.split(`
2799
+ |${G.map(()=>" --- ").join("|")}|`}if(Y.startsWith("|")&&Y.endsWith("|")&&Y.length>2)return`| ${Y.slice(1,-1).split("|").map((J)=>Lv(J.trim())).join(" | ")} |`;return Lv($)}function $Z1($){return($.startsWith("http://")||$.startsWith("https://"))&&!$.includes(" ")}function Lv($){let Z="",X=0;while(X<$.length){let Q=$[X]??"";if(Q==="{"){if($.startsWith("{{",X)){let Y=$.indexOf("}}",X+2);if(Y!==-1){Z+=`\`${$.slice(X+2,Y)}\``,X=Y+2;continue}}if($.startsWith("{color",X)){let Y=$.indexOf("}",X);if(Y!==-1){X=Y+1;continue}}}else if(Q==="["){let Y=$.indexOf("]",X);if(Y!==-1){let G=$.slice(X+1,Y),J=G.indexOf("|");if(J!==-1&&$Z1(G.slice(J+1))){Z+=`[${G.slice(0,J)}](${G.slice(J+1)})`,X=Y+1;continue}if($Z1(G)){Z+=G,X=Y+1;continue}}}else if(Q==="!"){let Y=$.indexOf("!",X+1);if(Y!==-1){let G=$.slice(X+1,Y),J=G.indexOf("|"),K=J===-1?G:G.slice(0,J);if($Z1(K)){Z+=`![](${K})`,X=Y+1;continue}}}else if(Q==="*"||Q==="_"){let Y=Vn4($,X,Q,Z.slice(-1)||" ");if(Y){Z+=Y.text,X=Y.next;continue}}Z+=Q,X++}return Z}function Vn4($,Z,X,Q){if(!qn4.includes(Q))return null;let Y=$[Z+1];if(!Y||Y===" "||Y===X)return null;for(let G=Z+2;G<$.length;G++){if($[G]!==X||$[G-1]===" ")continue;let J=$[G+1];if(J!==void 0&&!Mn4.includes(J))continue;let K=Lv($.slice(Z+1,G));return{text:X==="*"?`**${K}**`:`*${K}*`,next:G+1}}return null}var qn4=" ([{>",Mn4=` )]}.,:;!?{["'`;function Cn4($){let Z=$ instanceof Error?$.message:String($),X=Z.match(/failed \((\d+)\)/);if(X&&X[1]){let Q=parseInt(X[1],10);return Q>=500||Q===429}if(/returned invalid JSON/.test(Z))return!1;return!0}function QZ1($){let Z=$.trim().replace(/\/+$/,""),X=/^https?:\/\//i.test(Z)?Z:`https://${Z}`,Q;try{Q=new URL(X).hostname.toLowerCase()}catch{throw Error(`Invalid Jira site URL: ${$}`)}if(!_n4.test(Q))throw Error(`Invalid Jira site URL: ${$} \u2014 expected <your-site>.atlassian.net`);return`https://${Q}`}function XZ1($){if(!/^\d+$/.test($))throw Error(`Invalid Jira board id: ${$}`);return $}class gK{baseUrl;authHeader;constructor($,Z,X){this.baseUrl=QZ1($),this.authHeader=`Basic ${Buffer.from(`${Z}:${X}`).toString("base64")}`}async request($,Z,{idempotent:X=!0}={}){let Q=async()=>{let Y=await fetch(`${this.baseUrl}${$}`,{...Z,headers:{Authorization:this.authHeader,Accept:"application/json",...Z?.body?{"Content-Type":"application/json"}:{}},signal:AbortSignal.timeout(kn4)}),G;try{G=await Y.text()}catch(J){throw Error(`Jira ${$} failed to read response body`,{cause:J})}if(!Y.ok)throw Error(`Jira ${$} failed (${Y.status}): ${G.slice(0,300)}`);if(G==="")return;try{return JSON.parse(G)}catch(J){throw Error(`Jira ${$} returned invalid JSON: ${G.slice(0,300)}`,{cause:J})}};if(!X)return Q();return z5(Q,{maxAttempts:3,minTimeout:100,maxTimeout:5000,multiplier:2,jitter:1,isRetriable:Cn4})}async myself(){return this.request("/rest/api/3/myself")}async listBoards(){let $=[],Z=0;while($.length<200){let X=await this.request(`/rest/agile/1.0/board?startAt=${Z}&maxResults=50`);if($.push(...X.values.map((Q)=>({id:Q.id,name:Q.name,type:Q.type,projectKey:Q.location?.projectKey,projectName:Q.location?.projectName}))),X.isLast||X.values.length===0)break;Z+=X.values.length}return $}async getBoardColumns($){let Z=await this.request(`/rest/agile/1.0/board/${XZ1($)}/configuration`),X=new Map,Q=[];for(let Y of Z.columnConfig?.columns??[]){let G=[];for(let J of Y.statuses??[]){if(!X.has(J.id)){let K=await this.request(`/rest/api/3/status/${encodeURIComponent(J.id)}`);X.set(J.id,K.name)}G.push(X.get(J.id)??J.id)}Q.push({name:Y.name,statuses:G})}return Q}async listBoardIssues($){let Z=new URLSearchParams({startAt:String($.startAt),maxResults:"100",jql:$.jql,fields:Sn4}),X=await this.request(`/rest/agile/1.0/board/${XZ1($.boardId)}/issue?${Z}`);return{issues:X.issues??[],total:X.total}}async listBacklogIssueIds($){let Z=new Set,X=0;while(Z.size<5000){let Q=await this.request(`/rest/agile/1.0/board/${XZ1($)}/backlog?startAt=${X}&maxResults=100&fields=id`);for(let Y of Q.issues??[])Z.add(Y.id);if(X+=Q.issues?.length??0,X>=Q.total||(Q.issues?.length??0)===0)break}return Z}async listTransitions($){return(await this.request(`/rest/api/3/issue/${encodeURIComponent($)}/transitions`)).transitions??[]}async getStatusName($){return(await this.request(`/rest/api/3/issue/${encodeURIComponent($)}?fields=status`)).fields?.status?.name??null}async transitionIssue($,Z){await this.request(`/rest/api/3/issue/${encodeURIComponent($)}/transitions`,{method:"POST",body:JSON.stringify({transition:{id:Z}})},{idempotent:!1})}async listComments($){let Z=[],X=0;while(Z.length<1000){let Q=await this.request(`/rest/api/3/issue/${encodeURIComponent($)}/comment?startAt=${X}&maxResults=100&orderBy=created`);if(Z.push(...Q.comments),Z.length>=Q.total||Q.comments.length===0)break;X+=Q.comments.length}return Z}async addComment($,Z){return this.request(`/rest/api/3/issue/${encodeURIComponent($)}/comment`,{method:"POST",body:JSON.stringify({body:vn4(Z)})},{idempotent:!1})}}function vn4($){let Z=$.split(`
2800
2800
  `).filter((X)=>X.trim()!=="");return{type:"doc",version:1,content:Z.length>0?Z.map((X)=>({type:"paragraph",content:[{type:"text",text:X}]})):[{type:"paragraph",content:[]}]}}function OA0($){if(typeof $==="string")return NC8($);if(!$||typeof $!=="object")return"";let Z=$;if(Z.type==="text")return Z.text??"";if(Z.type==="hardBreak")return`
2801
2801
  `;let X=(Array.isArray(Z.content)?Z.content:[]).map(OA0);if(Z.type==="doc")return X.filter((Q)=>Q.trim()!=="").join(`
2802
2802
 
@@ -2862,7 +2862,7 @@ ${$.description}
2862
2862
  `):Z?.pr?[`This task already has an open pull request #${Z.pr.number} (${Z.pr.url}), and you are already on its branch.`,"Continue that work: commit and push to update the SAME pull request \u2014 do NOT open a new one or start a new branch. If you find it already does everything the task asks, say so and stop rather than changing it.",""].join(`
2863
2863
  `):"","How to work:","- First decide whether this task requires changing code in a repository. Some tasks (research, answering a question, planning) don't. If it doesn't, just do the work directly \u2014 don't load a repo or open a PR.",Z?.pr?"- If it DOES need code changes: use the `load_repo` tool to load the relevant repository, make the change, then commit and push to the pull request named above.":"- If it DOES need code changes: use the `load_repo` tool to load the relevant repository, then make the change, commit on a new branch, push, and open a pull request. Only then does a PR apply.","- Prefer the GitHub tool to open the PR. If it errors or targets the wrong repo, fall back to `git push` + the GitHub REST API (the auth token is embedded in the `origin` URL).","- If a dev server is running it hot-reloads your changes \u2014 don't restart it, hunt for its port, or run a full typecheck/build just to verify a small edit.","- Change only what the task needs. Don't trace the definition of a pre-existing symbol that's incidental to your change \u2014 note it in one line and move on. Prefer one or two broad searches over many narrow retries.","- Only if you hit a genuine blocker a human must clear (see above) may you call `user_ask` \u2014 otherwise keep going and finish the task.","",`(task id: ${$.id})`].join(`
2864
2864
  `)}async function Jr4($,Z,X){let Y=(await $.storage.taskBoard.listPrs(Z.id,Z.organizationId).catch(()=>[])).find((G)=>G.number===X);if(!Y)return null;return tv8($,Z.organizationId,Y).catch(()=>null)}async function Kr4($,Z){let X=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId).catch(()=>[]);return $B8(X)}function Wr4($){return $!=="closed"}async function Hr4($,Z){let X=await $.storage.taskBoard.listPrs(Z.id,Z.organizationId).catch(()=>[]);for(let Q of X){let{state:Y}=await vu(Z.organizationId,Q);if(Wr4(Y))return{number:Q.number,url:Q.url}}return}async function NF($,Z,X){let Q=await YB8($,Z,X?.userInitiated?Rh():void 0),Y="decopilot";try{let G=o0().taskBoardRerunReusesPrBranch,J=X?.pr??(G?await Hr4($,Z):void 0),K=G&&J?await Jr4($,Z,J.number):null,W=!X?.feedback&&!X?.resolveConflict,H=J&&W?await Kr4($,Z):null,N=J&&J!==X?.pr||H?{...X,...J?{pr:J}:{},...H?{feedback:H}:{}}:X,U=await aA0($,Z.organizationId);if(U){Y="claude-code";let F="repo"in U?U.repo:null;await Va($,Z,{title:`Super Agent: ${Z.title}`,...X?.runClass?{runClass:X.runClass}:{},...K?{pinnedRef:K}:{},prompt:kv8(Z,F,{...N,..."choices"in U?{repoChoices:U.choices}:{}}),temperature:0.5,harnessId:"claude-code",...F?{repo:F}:{}})}else await Va($,Z,{title:`Super Agent: ${Z.title}`,...X?.runClass?{runClass:X.runClass}:{},prompt:Gr4(Z,N),temperature:0.5,...K?{pinnedRef:K}:{}})}catch(G){throw await GB8($.storage.organizationBilling,Z.organizationId,Z.id,Q),G}await $.storage.taskBoard.supersedeFailedThreads(Z.id,Z.organizationId).catch((G)=>console.error("[task-board] superseding failed threads failed",G)),UG({event:"task_run_enqueued",organizationId:Z.organizationId,properties:{task_id:Z.id,reports_task:KY(Z),claim:Q,harness:Y,...X?.runClass?{run_class:X.runClass}:{}}})}var JF=w(()=>{g9();DK();g9();h4();C8();K71();yH();Sa();W71()});import{z as UF}from"zod";var I71;var ov8=w(()=>{n0();CK();D51();JF();RQ();Z9();I71=m({name:"TASK_BOARD_ITEM_CREATE",description:"Create a new task board item for the organization.",annotations:{title:"Create Task Board Item",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:UF.object({title:UF.string().min(1),description:UF.string().nullable().optional(),status:SK.optional(),priority:o_.optional(),assigneeId:UF.string().nullable().optional(),repo:UF.string().nullable().optional(),dueDate:UF.string().datetime().nullable().optional(),tagIds:UF.array(UF.string()).optional()}),outputSchema:UF.object({item:Wu}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");if($.assigneeId)await OP0(Z,X,$.assigneeId);let Q=$.assigneeId===G4;if($.tagIds?.length){let G=await Z.storage.tags.listOrgTags(X),J=new Set(G.map((K)=>K.id));for(let K of $.tagIds)if(!J.has(K))throw Error(`Tag not found: ${K}`)}let Y=await Z.storage.taskBoard.create({organizationId:X,title:$.title,description:$.description??null,status:Q?"todo":$.status,priority:$.priority,assigneeId:$.assigneeId??null,assignedBy:$.assigneeId?D1(Z):null,repo:$.repo??null,dueDate:$.dueDate??null,by:D1(Z)});if($.tagIds?.length)await Z.storage.taskBoard.setItemTags(Y.id,$.tagIds,D1(Z)),Y=await Z.storage.taskBoard.getById(Y.id,X);return await i$(Z,{taskBoardItemId:Y.id,action:"created",actorId:D1(Z)}),P6(X,Y),await NL(Z,Y),{item:Y}}})});function Nr4($){if($.status==="completed")return"advance";if($.status==="failed"&&$.messageStorageVersion===2&&Q_8($))return"nudge";return"none"}function Ur4($){return["This task is still In Progress on the board and your last run ended without finishing it.","","Look at what you already did (`git log`, `git status`, and the messages above), then either:","- finish the remaining work (and open the PR, if it needed code changes),","- or, if it's actually done, say so in one line \u2014 the board moves the card for you,",$==="decopilot"?"- or, if you're blocked on something only a human knows, call the `user_ask` tool.":"- or, if you're blocked on something only a human knows, say what you need and stop.","","Don't start over and don't redo work you already committed or pushed. You are on the same branch as before \u2014 push to it and update your existing pull request rather than opening a second one."].join(`
2865
- `)}async function Fr4($,Z,X){let Q=Z.organizationId,Y=await RX($,"smart"),G=X.virtual_mcp_id??eE(Q),J={id:`stall-nudge-${Z.id}-${X.id}`,role:"user",parts:[{type:"text",text:Ur4(X.harness_id)}]};await new kX({storage:$.storage.threads.messageParts(),orgId:Q,threadId:X.id,runId:X.id}).emitRequestMessage(J),await KF({threadId:X.id,source:"background-tool",request:{messages:[J],models:{credentialId:Y.credentialId,thinking:{id:Y.modelId,title:Y.modelMeta.title}},agent:{id:G},temperature:0.5,toolApprovalLevel:"auto",mode:"default",organizationId:Q,userId:Z.assignedBy??Z.createdBy,harnessId:X.harness_id==="claude-code"?"claude-code":"decopilot",sandboxProviderKind:"agent-sandbox",...X.branch?{branch:X.branch}:{},taskId:X.id,runMetadata:wP0(Z)}},{workflowID:`stall-nudge:${Z.id}:${X.id}`})}async function Br4($,Z){let X=await $.storage.threads.get(Z);if(!X)return{action:"none",thread:null};return{action:Nr4({status:X.status,messageStorageVersion:X.message_storage_version,harnessId:X.harness_id,sandboxProviderKind:X.sandbox_provider_kind}),thread:X}}function Or4($,Z=Date.now()){if($.status!=="in_progress")return!1;if($.run_started_at)return!1;return Oa($,Z)}async function wr4($,Z){let X=[];for(let Q of Z.threads){if(Q.status!=="in_progress")continue;let Y=await $.storage.threads.get(Q.threadId);if(!Y||!Or4(Y))continue;if(await $.storage.threads.markRunFailed(Q.threadId,q71,"abandoned"))X.push(Q.threadId),console.warn(`[task-board] failed never-started thread ${Q.threadId} on ${Z.id}`)}return X}async function rv8($,Z){let X=$.organization?.id;if(!X)return;for(let Q of Z){if(Q.status==="in_progress")try{if((await wr4($,Q)).length>0)continue}catch(J){console.error(`[task-board] reaping threads for ${Q.id} failed`,J)}let Y=Q.repo!=null&&(await $.storage.taskBoard.listPrs(Q.id,X)).length>0;if(!a91(Q,Y))continue;let G=Q.threads.find((J)=>J.hasMessages);if(!G)continue;try{let{action:J,thread:K}=await Br4($,G.threadId);if(J==="none"||!K)continue;if(J==="advance")await Tu($.storage.taskBoard,G.threadId,X,$.storage.organizationBilling);else await Fr4($,Q,K)}catch(J){console.error(`[task-board] stall recovery failed for ${Q.id}`,J)}}}var q71="Run never started \u2014 no pod picked it up before the idle window elapsed";var M71=w(()=>{pr();UL();$L();WF();vH();T6();Z9()});import{z as xa}from"zod";var V71;var av8=w(()=>{n0();XY();CK();M71();V71=m({name:"TASK_BOARD_ITEM_LIST",description:"List all task board items for the organization, plus the `owner/name` repos this organization has imported (the valid values for a task's `repo` field).",annotations:{title:"List Task Board Items",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:xa.object({}),outputSchema:xa.object({items:xa.array(Wu),repos:xa.array(xa.string())}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.list(X),{items:Y}=await Z.storage.connections.list(X,{slug:"mcp-github"}),G=JF8(Y);return rv8(Z,Q),{items:Q,repos:G}}})});import{z as p3}from"zod";function Dr4($,Z){let X=[];for(let{field:G,action:J}of Lr4){if(Z[G]===$[G])continue;X.push({action:J,data:{from:$[G],to:Z[G]}})}if(Z.description!==$.description)X.push({action:"description_changed"});let Q=new Set($.tags.map((G)=>G.id));if(Z.tags.length!==$.tags.length||Z.tags.some((G)=>!Q.has(G.id)))X.push({action:"tags_changed",data:{from:$.tags,to:Z.tags}});return X}function Er4($,Z){if($!==G4)return!1;if(!Z)return!1;return Z.assigneeId!==G4?!0:Z.status==="todo"}function jr4($,Z,X){return X&&$==="done"&&Z==="in_review"}var Lr4,k71;var sv8=w(()=>{n0();CK();D51();JF();RQ();Ku();Z9();DK();Lr4=[{field:"status",action:"status_changed"},{field:"assigneeId",action:"assignee_changed"},{field:"priority",action:"priority_changed"},{field:"dueDate",action:"due_date_changed"},{field:"title",action:"title_changed"}];k71=m({name:"TASK_BOARD_ITEM_UPDATE",description:"Update a task board item's fields (title, description, status, priority, assignee), and/or link a chat thread to it.",annotations:{title:"Update Task Board Item",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:p3.object({id:p3.string(),title:p3.string().min(1).optional(),description:p3.string().nullable().optional(),status:SK.optional(),priority:o_.optional(),assigneeId:p3.string().nullable().optional(),repo:p3.string().nullable().optional(),dueDate:p3.string().datetime().nullable().optional(),sortOrder:p3.number().optional(),tagIds:p3.array(p3.string()).optional(),linkThreadId:p3.string().optional()}),outputSchema:p3.object({item:Wu}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");if($.assigneeId)await OP0(Z,X,$.assigneeId);if($.linkThreadId){if(!await Z.storage.taskBoard.getById($.id,X))throw Error(`Task board item not found: ${$.id}`);if(!await Z.storage.threads.get($.linkThreadId))throw Error(`Thread not found: ${$.linkThreadId}`);await Z.storage.taskBoard.linkThread($.id,$.linkThreadId,X)}let Q=$.title!==void 0||$.description!==void 0||$.status!==void 0||$.priority!==void 0||$.assigneeId!==void 0||$.repo!==void 0||$.dueDate!==void 0||$.sortOrder!==void 0||$.tagIds!==void 0,Y=Q?await Z.storage.taskBoard.getById($.id,X):null;if(Q&&!Y)throw Error(`Task board item not found: ${$.id}`);let G=t_.getStore()!==void 0;if(jr4($.status,Y?.status,G))throw Error("This task is In Review \u2014 a run can't move it to Done. Leave it in "+"in_review for the reviewer; only a person, or TASK_BOARD_REVIEW_DECISION on a reviewer's own run, completes a task under review.");let J=$.assigneeId!==void 0&&$.assigneeId!==(Y?.assigneeId??null),K=Er4($.assigneeId,Y);if(Y&&KY(Y)){if($.title!==void 0||$.description!==void 0||$.priority!==void 0)throw Error("This task was generated from your report and can't be edited \u2014 create your own task instead.");if(K)await h30(Z,Y,Rh())}if($.tagIds!==void 0){let H=await Z.storage.tags.listOrgTags(X),N=new Set(H.map((U)=>U.id));for(let U of $.tagIds)if(!N.has(U))throw Error(`Tag not found: ${U}`);await Z.storage.taskBoard.setItemTags($.id,$.tagIds,D1(Z))}let W;if(Q)W=await Z.storage.taskBoard.update($.id,X,{title:$.title,description:$.description,status:K?"todo":$.status,priority:$.priority,assigneeId:$.assigneeId,assignedBy:J?$.assigneeId?D1(Z):null:void 0,repo:$.repo,dueDate:$.dueDate,sortOrder:$.sortOrder},D1(Z));else{let H=await Z.storage.taskBoard.getById($.id,X);if(!H)throw Error(`Task board item not found: ${$.id}`);W=H}if(Y){let H=D1(Z),N=Dr4(Y,W);if(N.length>0)await JC8(Z,N.map((U)=>({taskBoardItemId:W.id,actorId:H,...U})))}if(Q||$.linkThreadId)P6(X,W);if(K)await NL(Z,W,{userInitiated:!0});return{item:W}}})});import{z as JT0}from"zod";var S71;var ev8=w(()=>{n0();Z9();S71=m({name:"TASK_BOARD_ITEM_DELETE",description:"Delete a task board item. A reports-pushed task also dismisses its finding, so the next diagnostic import won't re-create the card.",annotations:{title:"Delete Task Board Item",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:JT0.object({id:JT0.string()}),outputSchema:JT0.object({success:JT0.boolean()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");if(!await Z.storage.taskBoard.delete($.id,X,D1(Z)??"system"))throw Error(`Task board item not found: ${$.id}`);return LC8(X,$.id),{success:!0}}})});import{z as Av}from"zod";var C71;var $x8=w(()=>{n0();s91();Z9();Ku();C71=m({name:"TASK_BOARD_ITEM_PR_LINK",description:"Link the pull request you just opened to this run's task board item. Call this right after `gh pr create` succeeds, with the PR URL it printed. Reviewers (QA, code review) are dispatched from the linked PR, so a task whose PR is not linked never gets reviewed.",annotations:{title:"Link Pull Request to Task",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Av.object({url:Av.string().describe("The pull request URL, e.g. https://github.com/owner/repo/pull/123")}),outputSchema:Av.object({url:Av.string(),prNumber:Av.number(),taskBoardItemIds:Av.array(Av.string())}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z).id,{threadId:Q}=BP0(),Y=UA0($.url);if(!Y)throw Error(`Not a GitHub pull request URL: ${$.url} (expected https://github.com/<owner>/<repo>/pull/<number>)`);let G=await zA0(Z,X,Q);for(let J of G)await Z.storage.taskBoard.linkPr({taskBoardItemId:J,organizationId:X,url:Y.url,prNumber:Y.number,repoOwner:Y.owner,repoName:Y.repo}),await Z.storage.taskBoard.clearSweepBudget(J,X);return{url:Y.url,prNumber:Y.number,taskBoardItemIds:G}}})});function Xx8($){Zx8=$}function KT0($){Zx8?.broadcast($)}var Zx8=null;import{DBOS as WT0}from"@dbos-inc/dbos-sdk";function zr4($,Z){let X=`thread-run:${Z}:`;if(!$.workflowID.startsWith(X))return null;let Q=$.input?.[0],Y=Q?.request;return{workflowId:$.workflowID,messageId:Y?.messageId??$.workflowID.slice(X.length),status:$.status==="PENDING"?"running":"queued",enqueuedAt:$.createdAt,...Q?.source!==void 0?{source:Q.source}:{}}}async function _71($){return(await WT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING","ENQUEUED"],loadInput:!0,loadOutput:!1})).map((X)=>zr4(X,$)).filter((X)=>X!==null).sort((X,Q)=>X.enqueuedAt-Q.enqueuedAt)}async function Qx8($,Z){if(!Z.startsWith(`thread-run:${$}:`))return!1;return await WT0.cancelWorkflows([Z]),!0}async function fu($){let Z=await WT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING"],loadInput:!1,loadOutput:!1});if(Z.length===0)return;await WT0.cancelWorkflows(Z.map((X)=>X.workflowID))}var HT0=()=>{};function Tr4($){return/\b405\b/.test($)&&/not allowed on this repository/i.test($)}function Ir4($,Z={}){if($==="failing")return!0;if($==="pending")return!Z.allowPendingChecks;return!1}async function qr4($,Z,X,Q,Y){if(Rr4.has(Q))return;let J=(await $.storage.taskBoard.listActivity(X,Z).catch(()=>[])).at(-1);if(J?.action==="merge_failed"&&J.data?.reason===Q)return;await i$($,{taskBoardItemId:X,action:"merge_failed",actorId:null,data:{reason:Q,...Y?{detail:Y}:{}}})}function Mr4($){if(!$?.isError)return{kind:"merged"};let Z=JSON.stringify($?.content)??"";if(Tr4(Z))return{kind:"method_not_allowed",detail:Z};if(QT0(Z))return{kind:"rate_limited",detail:Z};return{kind:"refused",detail:Z}}async function Vr4($,Z,X){let Q=await $.callTool({name:"merge_pull_request",arguments:{owner:Z.repoOwner,repo:Z.repoName,pullNumber:Z.number,merge_method:X}},void 0,{timeout:Pr4});return Mr4(Q)}async function fa($,Z,X,Q={}){let Y=async(U,F)=>{return await qr4($,Z,X,U,F),{merged:!1,reason:U,...F?{detail:F}:{}}},G=await $.storage.taskBoard.listPrs(X,Z),J=await wL($,Z,G);if(!J)return console.warn(`[task-board] merge skipped \u2014 no linked PR on ${X}`),Y("no_pr");let K=await iv8($,Z,J);if(Ir4(K,Q))return console.warn(`[task-board] merge blocked \u2014 checks ${K} on PR #${J.number}`),Y(K==="failing"?"checks_failing":"checks_pending");let W=`${J.repoOwner}/${J.repoName}`,H=await Pv($,Z,J.connectionId,{owner:J.repoOwner,name:J.repoName});if(!H)return console.warn("[task-board] merge blocked \u2014 no active GitHub connection for "+`${W} (PR #${J.number})`),Y("no_connection",W);let N=await I5(H,$,!0);try{let U=null;for(let F of Ar4){let B=await Vr4(N,J,F);if(B.kind==="merged")return hv8(H.id),{merged:!0};if(B.kind==="rate_limited")return console.warn(`[task-board] merge rate-limited on PR #${J.number} \u2014 sweep retries`),Y("rate_limited",B.detail.slice(0,500));if(B.kind==="method_not_allowed"){console.warn(`[task-board] merge method '${F}' not allowed on ${W} \u2014 trying next`),U=B.detail;continue}return console.error(`[task-board] merge refused by GitHub on PR #${J.number}:`,B.detail),Y("refused",B.detail.slice(0,500))}return console.error(`[task-board] no merge method allowed on ${W} (PR #${J.number})`,U),Y("refused",U?.slice(0,500))}catch(U){let F=U instanceof Error?U.message:String(U);if(QT0(U))return Y("rate_limited",F);return console.error("[task-board] merge PR failed",U),Y("error",F)}finally{await N.close().catch(()=>{})}}async function ba($,Z,X){let Q=await $.storage.organizationSettings.get(Z),Y=fU(Q?.flags),G=await $.storage.taskBoard.listActivity(X,Z);return Pw(G,Y,{verifiedOnly:!0})}async function kr4($,Z){let X=await $.storage.organizationSettings.get(Z.organizationId),Q=fU(X?.flags),Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId);if(!eF8(Y,Q))return;await fH($,Z,"every reviewer approved, but an approval could not be verified \u2014 "+"auto-merge is blocked and no reviewer can be re-dispatched this cycle")}function Yx8($){return!$.merged&&$.reason==="refused"}function v71($,Z){if($!==null)return $;if(Z===null||!Yx8(Z))return null;return(Z.detail??"").toLowerCase().includes("merge conflict")?!0:null}async function Sr4($,Z,X){if(!Yx8(X))return;let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q),G=await wL($,Q,Y);if(!G)return;await _u($,Q,Z,{pr:{number:G.number,url:G.url},conflict:v71(await xu($,Q,G),X)}).catch((J)=>{console.error("[task-board] sweep conflict auto-resolve failed",J)})}async function Gx8($,Z){let X=Z.organizationId;if(Z.status!=="in_review")return!1;if((await $.storage.organizationSettings.get(X))?.flags?.auto_merge!==!0)return!1;if(await $.storage.taskBoard.hasHumanRejectedDone(Z.id,X))return!1;if(!await ba($,X,Z.id))return await kr4($,Z),!1;let Y=await fa($,X,Z.id);if(!Y.merged)return await Sr4($,Z,Y),!1;let G=await $.storage.taskBoard.update(Z.id,X,{status:"done"},Z.updatedBy);return await i$($,{taskBoardItemId:Z.id,action:"status_changed",actorId:null,data:{from:Z.status,to:"done"}}),P6(X,G),!0}var Pr4=15000,Ar4,Rr4;var ya=w(()=>{VU();g9();RQ();ka();yH();Z9();Ar4=["merge","squash","rebase"];Rr4=new Set(["checks_pending"])});import{z as bu}from"zod";function _r4($){return $.threads.filter((Z)=>Z.status!==null&&!Ea.has(Z.status)).map((Z)=>Z.threadId)}async function vr4($,Z,X){let Q=(G)=>(J)=>console.error("[task-board] rerun takeover step failed",{threadId:Z,step:G,err:J});await $.storage.threads.setCancelRequested(Z,X).catch(Q("cancel-flag")),await qu(Z).catch(Q("background-jobs")),await fu(Z).catch(Q("gate-head"));let Y=await $.storage.threads.getRunFence(Z).catch(()=>null);if(Y)await zv(Z,Y).catch(Q("hosted-harness"));KT0(Z)}function xr4($,Z){return $===!0&&w71(Z)}async function fr4($,Z,X){let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q).catch(()=>[]),G=await wL($,Q,Y).catch(()=>{return});if(!G)return!1;let J=await xu($,Q,G).catch(()=>null);return xr4(J,X)}function yr4($,Z){let X=bU($),Q=0;for(let Y of $){if(Y.action!=="review_approved")continue;let G=new Date(Y.occurredAt).getTime();if(G>=X)Q=Math.max(Q,G)}return Z-Q>=br4}async function gr4($,Z){if(Z.status!=="in_review")return;if((await $.storage.organizationSettings.get(Z.organizationId))?.flags?.auto_merge!==!0)return;if(!await ba($,Z.organizationId,Z.id))return;let Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId).catch(()=>[]);if(yr4(Y,Date.now()))return;if(await fr4($,Z,Y))return;throw Error("Every reviewer approved this task and its merge is retrying \u2014 re-running "+"would throw that away and start a new review cycle. Wait for the merge, or use the ship button if the PR needs a nudge.")}var Cr4="Superseded by a manual re-run of this task",br4=900000,x71;var Jx8=w(()=>{n0();g9();vH();WF();HT0();Mu();RQ();Z9();JF();ya();yH();ka();DK();x71=m({name:"TASK_BOARD_ITEM_RERUN",description:"Re-run a task board item with the Super Agent, whatever lane it is in. Use this to retry a task that stalled, finished without doing the job, or is already assigned to the Super Agent (in which case re-assigning it does nothing). Fails any run still holding the task open, moves it to In Progress, and queues a fresh run.",annotations:{title:"Re-run Task",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:bu.object({id:bu.string().describe("The task board item to re-run.")}),outputSchema:bu.object({status:bu.string().describe("The task's lane after the re-run was queued."),supersededThreadIds:bu.array(bu.string()).describe("Runs that were failed to make room for this one.")}),handler:async({id:$},Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);if(Q.assigneeId!==G4)throw Error("Only a task assigned to the Super Agent can be re-run. Assign it to "+"the Super Agent instead \u2014 that queues a run by itself.");await gr4(Z,Q),await h30(Z,Q,Rh());let Y=[];for(let J of _r4(Q)){if(!await Z.storage.threads.failIfNotTerminal(J,Cr4,"superseded"))continue;Y.push(J),await vr4(Z,J,X)}let G=await Z.storage.taskBoard.update($,X,{status:"in_progress"},D1(Z));return await i$(Z,{taskBoardItemId:$,action:"status_changed",actorId:D1(Z),data:{from:Q.status,to:"in_progress",reason:"rerun"}}),P6(X,G),await NF(Z,G,{userInitiated:!0}),{status:G.status,supersededThreadIds:Y}}})});import{z as LL}from"zod";function hr4($,Z,X){return $!==null&&$.reviewer===Z&&$.cycleAt.getTime()===X}function ur4($,Z){return P81($).get(Z)==="changes_requested"}var f71;var Kx8=w(()=>{n0();g9();CK();RQ();Z9();JF();ya();yH();N71();ka();DK();f71=m({name:"TASK_BOARD_REVIEW_DECISION",description:"Record a reviewer's decision for a task under review. `approve` marks the pull request approved by that reviewer (and, once EVERY enabled reviewer has approved, merges it when the org enabled auto-merge, advancing the task to Done); `request_changes` hands the task back to the Super Agent with your notes so it can fix the PR.",annotations:{title:"Review Decision",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:LL.object({taskBoardItemId:LL.string(),reviewer:LL.enum(["qa","code_review"]).describe("Which reviewer you are: `qa` (QA Agent) or `code_review` (Code Reviewer)."),reviewToken:LL.string().optional().describe("The reviewToken from your prompt \u2014 proves you are this reviewer. "+"Pass it through exactly; an approval without a valid token is recorded but does NOT count toward an automatic merge."),decision:LL.enum(["approve","request_changes"]),notes:LL.string().min(1).describe("For approve: a short summary of what you verified. For request_changes: specific, actionable feedback the Super Agent must address.")}),outputSchema:LL.object({status:SK,merged:LL.boolean().describe("True when this approval completed the review and merged the PR.")}),handler:async({taskBoardItemId:$,reviewer:Z,reviewToken:X,decision:Q,notes:Y},G)=>{G0(G),await G.access.check();let J=G.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let K=await G.storage.taskBoard.getById($,J);if(!K)throw Error(`Task board item not found: ${$}`);let W=X?bU(await G.storage.taskBoard.listActivity($,J)):0,H=!!X&&(Sv8(X,$,Z,new Date(W))||hr4(await G.storage.taskBoard.resolveReviewClaimByToken($,X),Z,W));if(Q==="request_changes"){let j=await G.storage.taskBoard.listActivity($,J);if(ur4(j,Z))return{status:K.status,merged:!1};if(ZB8(j))return await i$(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H,bounceLimitReached:!0}}),await fH(G,K,`${A81} review bounces reached \u2014 the reviewer and the `+"Super Agent are not converging"),{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};let z=await G.storage.taskBoard.claimReviewChangesBounce($,J,K.updatedBy);if(await i$(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!z)return{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};P6(J,z);let P=await G.storage.taskBoard.listPrs($,J),A=await wL(G,J,P);return await NF(G,z,{feedback:`${Th[Z]}: ${Y}`,pr:A?{number:A.number,url:A.url}:void 0}).catch(async(I)=>{if(await AA0(G,z,I)){await G.storage.taskBoard.update(z.id,J,{status:"in_review"},"system").then((q)=>P6(J,q)).catch((q)=>console.error("[task-board] runs-exhausted status revert failed",q));return}if(I instanceof DX)throw I;console.error("[task-board] request_changes re-enqueue failed",I)}),{status:z.status,merged:!1}}if(await i$(G,{taskBoardItemId:$,action:"review_approved",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!await ba(G,J,$)){let j=await G.storage.taskBoard.getById($,J)??K;return P6(J,j),{status:j.status,merged:!1}}let F=(await G.storage.organizationSettings.get(J))?.flags?.auto_merge===!0,B=await G.storage.taskBoard.hasHumanRejectedDone($,J),O=F&&!B,L=O?await fa(G,J,$):null;if(L?.merged===!0){let j=await G.storage.taskBoard.update($,J,{status:"done"},K.updatedBy);return await i$(G,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:K.status,to:"done"}}),P6(J,j),{status:j.status,merged:!0}}let E=await G.storage.taskBoard.getById($,J)??K;if(O){let j=await G.storage.taskBoard.listPrs($,J),z=await wL(G,J,j);if(z?await _u(G,J,E,{pr:{number:z.number,url:z.url},conflict:v71(await xu(G,J,z),L)}).catch((A)=>{if(A instanceof DX)throw A;return console.error("[task-board] conflict auto-resolve failed",A),!1}):!1)return{status:(await G.storage.taskBoard.getById($,J)??E).status,merged:!1}}return P6(J,E),{status:E.status,merged:!1}}})});import{z as NT0}from"zod";function cr4($,Z,X){if($!=="in_review")return!1;return X.length===0||Pw(Z,X)}var b71;var Wx8=w(()=>{n0();g9();CK();RQ();Z9();ya();b71=m({name:"TASK_BOARD_PROMOTE_TO_PRODUCTION",description:"Ship a reviewed task: merge its open pull request and move the task to Done. Used by the board's 'Ship to production' button after the enabled reviewers approved, when auto-merge is off (a human does the final merge).",annotations:{title:"Ship to Production",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:NT0.object({taskBoardItemId:NT0.string()}),outputSchema:NT0.object({status:SK,merged:NT0.boolean().describe("True when the PR was merged.")}),handler:async({taskBoardItemId:$},Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);let Y=await Z.storage.organizationSettings.get(X),G=fU(Y?.flags),J=await Z.storage.taskBoard.listActivity($,X);if(!cr4(Q.status,J,G))throw Error("Task is not ready to ship: it must be In Review with every enabled reviewer approved");if(!(await fa(Z,X,$,{allowPendingChecks:!0})).merged){let H=await Z.storage.taskBoard.getById($,X)??Q;return P6(X,H),{status:Q.status,merged:!1}}let W=await Z.storage.taskBoard.update($,X,{status:"done"},Q.updatedBy);if(Q.status!=="done")await i$(Z,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:Q.status,to:"done"}});return P6(X,W),{status:W.status,merged:!0}}})});import{z as t3}from"zod";function Hx8($){if(!$)throw Error("Organization ID required (no active organization in context)");return $}var lr4,y71,g71;var Nx8=w(()=>{n0();lr4=t3.object({externalKey:t3.string(),dismissedBy:t3.string(),dismissedAt:t3.string()});y71=m({name:"TASK_BOARD_DISMISSED_LIST",description:"List the diagnostic findings this organization has dismissed by deleting their task board cards. The import skips these until they're restored.",annotations:{title:"List Dismissed Findings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:t3.object({}),outputSchema:t3.object({findings:t3.array(lr4)}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Hx8(Z.organization?.id);return{findings:await Z.storage.taskBoard.listDismissedFindings(X)}}}),g71=m({name:"TASK_BOARD_DISMISSED_RESTORE",description:"Un-dismiss diagnostic findings, returning their cards to the board. Omit externalKeys to restore every dismissed finding.",annotations:{title:"Restore Dismissed Findings",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:t3.object({externalKeys:t3.array(t3.string()).optional()}),outputSchema:t3.object({restored:t3.number()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Hx8(Z.organization?.id);return{restored:await Z.storage.taskBoard.restoreDismissedFindings(X,$.externalKeys)}}})});import{z as Q5}from"zod";function UT0($){let Z=$.organization?.id;if(!Z)throw Error("Organization ID required (no active organization in context)");return Z}function mr4($,Z,X){return $.replace(dr4,(Q,Y,G,J)=>{let K=encodeURIComponent(`${Z}/${G}`);return`${Y}/api/${encodeURIComponent(X)}/fs/outputs/read?path=${K}${J}`})}var h71,u71,dr4,c71,l71,d71;var Ux8=w(()=>{n0();g9();EA0();Ku();h71=Q5.object({id:Q5.string(),taskBoardItemId:Q5.string(),parentId:Q5.string().nullable(),authorId:Q5.string(),body:Q5.string(),resolved:Q5.boolean(),createdAt:Q5.string(),updatedAt:Q5.string()});u71=m({name:"TASK_BOARD_COMMENT_LIST",description:"List a task board item's comments (flat, oldest first; replies carry parentId).",annotations:{title:"List Task Comments",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Q5.object({taskBoardItemId:Q5.string()}),outputSchema:Q5.object({comments:Q5.array(h71)}),handler:async($,Z)=>{return G0(Z),await Z.access.check(),{comments:await Z.storage.taskBoard.listComments($.taskBoardItemId,UT0(Z))}}}),dr4=/(!\[[^\]]*\]\()org\/output\/([^)\s]+)(\))/g;c71=m({name:"TASK_BOARD_COMMENT_CREATE",description:"Post a comment on a task board item, or a reply to one.",annotations:{title:"Create Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:Q5.object({taskBoardItemId:Q5.string(),body:Q5.string().trim().min(1),parentId:Q5.string().nullish()}),outputSchema:Q5.object({comment:h71}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=UT0(Z),Q=t_.getStore(),Y=Z.organization?.slug,G=Q?.threadId&&Y?mr4($.body,Q.threadId,Y):$.body,J=await Z.storage.taskBoard.createComment({taskBoardItemId:$.taskBoardItemId,organizationId:X,parentId:$.parentId??null,authorId:Q?G4:D1(Z),body:G});if(!J)throw Error("Task board item not found");return await HZ1(Z,{commentId:J.id,taskBoardItemId:J.taskBoardItemId,organizationId:X,authorLabel:Q?"Super Agent":Z.auth?.user?.name??Z.auth?.user?.email??"Studio",body:J.body}),{comment:J}}}),l71=m({name:"TASK_BOARD_COMMENT_UPDATE",description:"Edit your own comment's body, or resolve/unresolve a comment thread (root only, any org member may toggle it).",annotations:{title:"Update Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Q5.object({id:Q5.string(),body:Q5.string().trim().min(1).optional(),resolved:Q5.boolean().optional()}),outputSchema:Q5.object({comment:h71}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=await Z.storage.taskBoard.updateComment({id:$.id,organizationId:UT0(Z),callerId:D1(Z),body:$.body,resolved:$.resolved});if(!X)throw Error("Comment not found, or you can only edit your own comments");return{comment:X}}}),d71=m({name:"TASK_BOARD_COMMENT_DELETE",description:"Delete your own comment. Deleting a thread root deletes its replies too.",annotations:{title:"Delete Task Comment",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Q5.object({id:Q5.string()}),outputSchema:Q5.object({success:Q5.boolean()}),handler:async($,Z)=>{return G0(Z),await Z.access.check(),{success:await Z.storage.taskBoard.deleteComment($.id,UT0(Z),D1(Z))}}})});var Fx8=w(()=>{wq8();ov8();av8();sv8();ev8();yH();$x8();Jx8();Kx8();Wx8();RQ();Nx8();Ux8()});import{z as FF}from"zod";var m71;var Bx8=w(()=>{n0();m71=m({name:"TAGS_LIST",description:"List all tags available in the organization.",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:FF.object({}),outputSchema:FF.object({tags:FF.array(FF.object({id:FF.string(),organizationId:FF.string(),name:FF.string(),color:FF.string().nullable(),createdAt:FF.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z);return{tags:(await Z.storage.tags.listOrgTags(X.id)).map((Y)=>({...Y,createdAt:Y.createdAt instanceof Date?Y.createdAt.toISOString():String(Y.createdAt)}))}}})});import{z as gH}from"zod";var i71;var Ox8=w(()=>{n0();i71=m({name:"TAGS_CREATE",description:"Create a new tag, usable on organization members and task board items.",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:gH.object({name:gH.string().min(1).max(50).describe("Tag name"),color:gH.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional().describe('Hex color the tag renders its dot with, e.g. "#3b82f6"')}),outputSchema:gH.object({tag:gH.object({id:gH.string(),organizationId:gH.string(),name:gH.string(),color:gH.string().nullable(),createdAt:gH.string().describe("ISO 8601 timestamp")})}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z),Q=await Z.storage.tags.createTag(X.id,$.name,$.color);return{tag:{...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}}}})});import{z as FT0}from"zod";var n71;var wx8=w(()=>{n0();n71=m({name:"TAGS_DELETE",description:"Delete a tag and automatically remove it from all assigned members.",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:FT0.object({tagId:FT0.string().describe("Tag ID to delete")}),outputSchema:FT0.object({success:FT0.boolean()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z),Q=await Z.storage.tags.getTag($.tagId);if(!Q)throw Error("Tag not found");if(Q.organizationId!==X.id)throw Error("Tag does not belong to this organization");return await Z.storage.tags.deleteTag($.tagId),{success:!0}}})});import{z as hH}from"zod";var p71;var Lx8=w(()=>{n0();p71=m({name:"MEMBER_TAGS_GET",description:"Get all tags currently assigned to a specific member.",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:hH.object({memberId:hH.string().describe("Member ID")}),outputSchema:hH.object({tags:hH.array(hH.object({id:hH.string(),organizationId:hH.string(),name:hH.string(),color:hH.string().nullable(),createdAt:hH.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);return{tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});import{z as o3}from"zod";var t71;var Dx8=w(()=>{n0();t71=m({name:"MEMBER_TAGS_SET",description:"Replace all tags on a member with the given set. Pass empty array to clear.",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:o3.object({memberId:o3.string().describe("Member ID"),tagIds:o3.array(o3.string()).describe("Array of tag IDs to assign")}),outputSchema:o3.object({success:o3.boolean(),tags:o3.array(o3.object({id:o3.string(),organizationId:o3.string(),name:o3.string(),createdAt:o3.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);for(let G of $.tagIds){let J=await Z.storage.tags.getTag(G);if(!J)throw Error(`Tag not found: ${G}`);if(J.organizationId!==X.id)throw Error(`Tag does not belong to this organization: ${G}`)}return await Z.storage.tags.setMemberTags($.memberId,$.tagIds),{success:!0,tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var Ex8=w(()=>{Bx8();Ox8();wx8();Lx8();Dx8()});import{z as jx8}from"zod";function or4($,Z){let X=$?.[Z];if(!X)return;return Object.entries(X).sort(([,Y],[,G])=>{let J=Math.max(0,...Object.values(Y).map((W)=>W.createdAt??0));return Math.max(0,...Object.values(G).map((W)=>W.createdAt??0))-J})[0]?.[0]}var pr4,tr4,o71;var zx8=w(()=>{h4();n0();Hv();GQ();pr4=jx8.object({data:SS8.describe("Data for the new thread (id is auto-generated if not provided)")}),tr4=jx8.object({item:CH.describe("The created thread entity")});o71=m({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread for organizing messages and conversations.",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:pr4,outputSchema:tr4,handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=D1(Z);if(!Q)throw Error("User ID required to create thread");let{data:Y}=$,G=Y.id??Q4("thrd"),K=(await XA0(Z.storage.virtualMcps,Y.virtual_mcp_id,X.id)).metadata,W=K?.githubRepo,H=null;if(W)H=Y.branch??or4(K?.sandboxMap,Q)??KP0(JP0(Z.auth.user));let N=await Z.storage.threads.create({id:G,organization_id:X.id,title:Y.title,description:Y.description,virtual_mcp_id:Y.virtual_mcp_id,branch:H,created_by:Q,...Y.runtime?{metadata:{runtime:Y.runtime}}:{}});if(N.isNew)n1.capture({distinctId:Q,event:"chat_started",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:G,has_title:!!$.data.title,created_via:"tool"}});return{item:m3(N)}}})});import{z as r71}from"zod";var rr4,ar4,a71;var Px8=w(()=>{h4();n0();Hv();GA0();rr4=r71.object({id:r71.string().describe("ID of the thread to update"),data:CS8.describe("Partial thread data to update")}),ar4=r71.object({item:CH.describe("The updated thread entity")}),a71=m({name:"COLLECTION_THREADS_UPDATE",description:"Update a thread's title, description, or visibility.",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:rr4,outputSchema:ar4,handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=D1(Z);if(!Q)throw Error("User ID required to update thread");let{id:Y,data:G}=$,J=await Z.storage.threads.get(Y);if(!J)throw Error("Thread not found in organization");if(G.virtual_mcp_id!==void 0)await XA0(Z.storage.virtualMcps,G.virtual_mcp_id,X.id);if(G.branch===null&&J.virtual_mcp_id){if((await Z.storage.virtualMcps.findById(J.virtual_mcp_id,X.id))?.metadata?.githubRepo)throw Error("Cannot set branch=null on a github-linked thread (vMCP has githubRepo)")}let K={title:G.title,description:G.description,hidden:G.hidden,updated_by:Q};if(G.status)K.status=G.status;if(G.metadata!==void 0){let H=g91(J.metadata?.runtime);K.metadata=H?{...G.metadata,runtime:H}:G.metadata}if(G.branch!==void 0)K.branch=G.branch;if(G.virtual_mcp_id!==void 0)K.virtual_mcp_id=G.virtual_mcp_id;let W=await Z.storage.threads.update(Y,K);if(G.hidden!==void 0&&G.hidden!==J.hidden)n1.capture({distinctId:Q,event:G.hidden?"chat_archived":"chat_unarchived",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:Y}});return{item:m3(W)}}})});var s71;var Ax8=w(()=>{V3();Hv();h4();n0();WF();HT0();Mu();s71=m({name:"COLLECTION_THREADS_DELETE",description:"Permanently delete a thread and all its messages.",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Do,outputSchema:Eo(CH),handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=await Z.storage.threads.get($.id);if(!Q)throw Error(`Thread not found: ${$.id}`);if(Q.status==="in_progress"){let G=(K)=>(W)=>console.error("[thread] delete-time run cancel step failed",{threadId:$.id,step:K,err:W});await qu($.id).catch(G("background-jobs")),await fu($.id).catch(G("gate-head"));let J=await Z.storage.threads.getRunFence($.id).catch(()=>null);if(J)await zv($.id,J).catch(G("hosted-harness"));KT0($.id)}await Z.storage.threads.delete($.id);let Y=D1(Z);if(Y)n1.capture({distinctId:Y,event:"chat_deleted",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:$.id}});return{item:m3(Q)}}})});var Tx8=w(()=>{zx8();h91();u91();Px8();Ax8();c91()});function er4($){return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:$}]}]}}function $a4($){return $.map((Z)=>{let X=Z.metadata;if(X?.tiptapDoc)return Z;let Q=Z.parts.find((Y)=>Y.type==="text"&&typeof Y.text==="string");if(!Q?.text||typeof Q.text!=="string")return Z;return{...Z,metadata:{...X,tiptapDoc:er4(Q.text)}}})}function BT0($){let Z;if(typeof $==="string")try{let X=JSON.parse($);if(Array.isArray(X)&&X.length>0&&X[0]?.role&&Array.isArray(X[0]?.parts))Z=X;else Z=[{role:"user",parts:[{type:"text",text:$}]}]}catch{Z=[{role:"user",parts:[{type:"text",text:$}]}]}else Z=$;return $a4(Z)}import{z as Y5}from"zod";var e71;var Rx8=w(()=>{h4();n0();YY();e71=m({name:"AUTOMATION_CREATE",description:"Create an automation that runs an agent thread on trigger fire. Requires virtual_mcp_id + messages.",annotations:{title:"Create Automation",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:Y5.object({name:Y5.string().min(1).max(255),virtual_mcp_id:Y5.string(),messages:Y5.union([Y5.string(),Y5.array(Y5.looseObject({id:Y5.string().optional(),role:Y5.enum(["user","assistant","system"]),parts:Y5.array(Y5.record(Y5.string(),Y5.unknown())),metadata:Y5.unknown().optional()}))]),models:Y5.object({tier:Dw,modelId:Y5.string().optional(),credentialId:Y5.string().optional()}).loose().default({tier:"smart"}),tools:Y5.array(Y5.string()).nullable().optional(),maxAgentSteps:Y5.number().int().min(1).max(100).nullable().optional(),temperature:Y5.number().default(0.5),active:Y5.boolean().default(!0)}),outputSchema:Y5.object({id:Y5.string(),name:Y5.string(),active:Y5.boolean(),created_at:Y5.string()}),handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=D1(Z);if(!Q)throw Error("Unable to determine user identity");let Y=BT0($.messages),G=await Z.storage.automations.create({organization_id:X.id,created_by:Q,name:$.name,messages:JSON.stringify(Y),models:JSON.stringify($.models),tools:$.tools===void 0||$.tools===null?null:JSON.stringify($.tools),max_agent_steps:$.maxAgentSteps??null,temperature:$.temperature,active:$.active,virtual_mcp_id:$.virtual_mcp_id});return n1.capture({distinctId:Q,event:"automation_created",groups:{organization:X.id},properties:{organization_id:X.id,automation_id:G.id,virtual_mcp_id:$.virtual_mcp_id,active:G.active,tier:$.models.tier}}),{id:G.id,name:G.name,active:G.active,created_at:G.created_at}}})});import{z as n$}from"zod";var $X1;var Ix8=w(()=>{n0();$X1=m({name:"AUTOMATION_GET",description:"Get an automation's full configuration and triggers by ID.",annotations:{title:"Get Automation",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:n$.object({id:n$.string()}),outputSchema:n$.object({automation:n$.object({id:n$.string(),name:n$.string(),active:n$.boolean(),created_by:n$.string(),created_at:n$.string(),updated_at:n$.string(),virtual_mcp_id:n$.string(),messages:n$.unknown(),models:n$.unknown(),tools:n$.array(n$.string()).nullable(),maxAgentSteps:n$.number().nullable(),temperature:n$.number(),triggers:n$.array(n$.object({id:n$.string(),type:n$.enum(["cron","event","webhook"]),cron_expression:n$.string().nullable(),connection_id:n$.string().nullable(),event_type:n$.string().nullable(),params:n$.unknown().nullable(),last_run_at:n$.string().nullable(),api_key_id:n$.string().nullable(),created_at:n$.string()}))}).nullable()}),handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=await Z.storage.automations.findById($.id,X.id);if(!Q)return{automation:null};let Y=await Z.storage.automations.listTriggers(Q.id);return{automation:{id:Q.id,name:Q.name,active:Q.active,created_by:Q.created_by,created_at:Q.created_at,updated_at:Q.updated_at,virtual_mcp_id:Q.virtual_mcp_id,messages:JSON.parse(Q.messages),models:JSON.parse(Q.models),tools:Q.tools?JSON.parse(Q.tools):null,maxAgentSteps:Q.max_agent_steps,temperature:Q.temperature,triggers:Y.map((G)=>({id:G.id,type:G.type,cron_expression:G.cron_expression,connection_id:G.connection_id,event_type:G.event_type,params:G.params?JSON.parse(G.params):null,last_run_at:G.last_run_at,api_key_id:G.api_key_id,created_at:G.created_at}))}}}})});import{z as SG}from"zod";var ZX1;var qx8=w(()=>{n0();ZX1=m({name:"AUTOMATION_LIST",description:"List automations with their status, triggers, and configuration.",annotations:{title:"List Automations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:SG.object({virtual_mcp_id:SG.string().optional().nullable()}),outputSchema:SG.object({automations:SG.array(SG.object({id:SG.string(),name:SG.string(),active:SG.boolean(),created_by:SG.string(),created_at:SG.string(),trigger_count:SG.number(),nearest_next_run_at:SG.string().nullable(),virtual_mcp_id:SG.string()}))}),handler:async($,Z)=>{G0(Z);let X=X0(Z);return await Z.access.check(),{automations:(await Z.storage.automations.listWithTriggerCounts(X.id,$.virtual_mcp_id)).map((G)=>({id:G.id,name:G.name,active:G.active,created_by:G.created_by,created_at:G.created_at,trigger_count:G.trigger_count,nearest_next_run_at:G.nearest_next_run_at,virtual_mcp_id:G.virtual_mcp_id}))}}})});function Xa4($){if(!$)return null;try{let Z=JSON.parse($);if(Array.isArray(Z)&&Z.every((X)=>typeof X==="string"))return Z.length>0?Z:null}catch{}return null}function Mx8($){return`${$}:context`}function Vx8($,Z,X,Q,Y){let J=JSON.parse($.messages).map((H,N)=>({...H,id:`${X}:${N}`})),K=Z?{...Y,[LP0]:Za4}:Y;return{messages:J,models:{credentialId:Q.credentialId,thinking:Q.thinking,...Q.image?{image:Q.image}:{},...Q.webSearch?{webSearch:Q.webSearch}:{},...Q.deepResearch?{deepResearch:Q.deepResearch}:{}},agent:{id:$.virtual_mcp_id},toolAllowlist:Xa4($.tools),maxAgentSteps:$.max_agent_steps??void 0,temperature:$.temperature??0.5,toolApprovalLevel:"auto",mode:"default",organizationId:$.organization_id,userId:$.created_by,harnessId:"decopilot",sandboxProviderKind:"agent-sandbox",triggerId:Z??void 0,...K?{runMetadata:K}:{},taskId:X}}var Za4="new_task";var kx8=w(()=>{tr()});function SX($,Z,X,Q,Y,G,J,K){return SX.fromTZ(SX.tp($,Z,X,Q,Y,G,J),K)}function XX1($,Z=new Date){let X=Z.toLocaleString("en-US",{timeZone:$,timeZoneName:"shortOffset"}).split(" ").slice(-1)[0],Q=Z.toLocaleString("en-US").replace(/[\u202f]/," ");return Date.parse(`${Q} GMT`)-Date.parse(`${Q} ${X}`)}function Qa4($,Z){let X=new Date(Date.parse($));if(isNaN(X))throw Error("minitz: Invalid ISO8601 passed to parser.");let Q=$.substring(9);return $.includes("Z")||Q.includes("-")||Q.includes("+")?SX.tp(X.getUTCFullYear(),X.getUTCMonth()+1,X.getUTCDate(),X.getUTCHours(),X.getUTCMinutes(),X.getUTCSeconds(),"Etc/UTC"):SX.tp(X.getFullYear(),X.getMonth()+1,X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),Z)}function Ya4($){if($===void 0&&($={}),delete $.name,$.legacyMode=$.legacyMode===void 0?!0:$.legacyMode,$.paused=$.paused===void 0?!1:$.paused,$.maxRuns=$.maxRuns===void 0?1/0:$.maxRuns,$.catch=$.catch===void 0?!1:$.catch,$.interval=$.interval===void 0?0:parseInt($.interval.toString(),10),$.utcOffset=$.utcOffset===void 0?void 0:parseInt($.utcOffset.toString(),10),$.unref=$.unref===void 0?!1:$.unref,$.startAt&&($.startAt=new r3($.startAt,$.timezone)),$.stopAt&&($.stopAt=new r3($.stopAt,$.timezone)),$.interval!==null){if(isNaN($.interval))throw Error("CronOptions: Supplied value for interval is not a number");if($.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if($.utcOffset!==void 0){if(isNaN($.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if($.utcOffset<-870||$.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if($.utcOffset!==void 0&&$.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if($.unref!==!0&&$.unref!==!1)throw Error("CronOptions: Unref should be either true, false or undefined(false).");return $}function ga($){return Object.prototype.toString.call($)==="[object Function]"||typeof $=="function"||$ instanceof Function}function Ga4($){return ga($)}function Ja4($){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer($):$&&typeof $.unref<"u"&&$.unref()}var QX1=32,ha,vx8,Sx8=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor($,Z){this.pattern=$,this.timezone=Z,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let $=this.pattern.replace(/\s+/g," ").split(" ");if($.length<5||$.length>6)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five or six space separated parts are required.");if($.length===5&&$.unshift("0"),$[3].indexOf("L")>=0&&($[3]=$[3].replace("L",""),this.lastDayOfMonth=!0),$[3]=="*"&&(this.starDOM=!0),$[4].length>=3&&($[4]=this.replaceAlphaMonths($[4])),$[5].length>=3&&($[5]=this.replaceAlphaDays($[5])),$[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0){let Z=new r3(new Date,this.timezone).getDate(!0);$[0]=$[0].replace("?",Z.getSeconds().toString()),$[1]=$[1].replace("?",Z.getMinutes().toString()),$[2]=$[2].replace("?",Z.getHours().toString()),this.starDOM||($[3]=$[3].replace("?",Z.getDate().toString())),$[4]=$[4].replace("?",(Z.getMonth()+1).toString()),this.starDOW||($[5]=$[5].replace("?",Z.getDay().toString()))}this.throwAtIllegalCharacters($),this.partToArray("second",$[0],0,1),this.partToArray("minute",$[1],0,1),this.partToArray("hour",$[2],0,1),this.partToArray("day",$[3],-1,1),this.partToArray("month",$[4],-1,1),this.partToArray("dayOfWeek",$[5],0,ha),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray($,Z,X,Q){let Y=this[$],G=$==="day"&&this.lastDayOfMonth;if(Z===""&&!G)throw TypeError("CronPattern: configuration entry "+$+" ("+Z+") is empty, check for trailing spaces.");if(Z==="*")return Y.fill(Q);let J=Z.split(",");if(J.length>1)for(let K=0;K<J.length;K++)this.partToArray($,J[K],X,Q);else Z.indexOf("-")!==-1&&Z.indexOf("/")!==-1?this.handleRangeWithStepping(Z,$,X,Q):Z.indexOf("-")!==-1?this.handleRange(Z,$,X,Q):Z.indexOf("/")!==-1?this.handleStepping(Z,$,X,Q):Z!==""&&this.handleNumber(Z,$,X,Q)}throwAtIllegalCharacters($){for(let Z=0;Z<$.length;Z++)if((Z===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test($[Z]))throw TypeError("CronPattern: configuration entry "+Z+" ("+$[Z]+") contains illegal characters.")}handleNumber($,Z,X,Q){let Y=this.extractNth($,Z),G=parseInt(Y[0],10)+X;if(isNaN(G))throw TypeError("CronPattern: "+Z+" is not a number: '"+$+"'");this.setPart(Z,G,Y[1]||Q)}setPart($,Z,X){if(!Object.prototype.hasOwnProperty.call(this,$))throw TypeError("CronPattern: Invalid part specified: "+$);if($==="dayOfWeek"){if(Z===7&&(Z=0),Z<0||Z>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+Z);this.setNthWeekdayOfMonth(Z,X);return}if($==="second"||$==="minute"){if(Z<0||Z>=60)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="hour"){if(Z<0||Z>=24)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="day"){if(Z<0||Z>=31)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="month"&&(Z<0||Z>=12))throw RangeError("CronPattern: Invalid value for "+$+": "+Z);this[$][Z]=X}handleRangeWithStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(G===null)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+$+"'");let[,J,K,W]=G,H=parseInt(J,10)+X,N=parseInt(K,10)+X,U=parseInt(W,10);if(isNaN(H))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(N))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(U))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(U===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(U>this[Z].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[Z].length+")");if(H>N)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let F=H;F<=N;F+=U)this.setPart(Z,F,Y[1]||Q)}extractNth($,Z){let X=$,Q;if(X.includes("#")){if(Z!=="dayOfWeek")throw Error("CronPattern: nth (#) only allowed in day-of-week field");Q=X.split("#")[1],X=X.split("#")[0]}return[X,Q]}handleRange($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("-");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal range: '"+$+"'");let J=parseInt(G[0],10)+X,K=parseInt(G[1],10)+X;if(isNaN(J))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(J>K)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let W=J;W<=K;W++)this.setPart(Z,W,Y[1]||Q)}handleStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("/");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+$+"'");G[0]===""&&(G[0]="*");let J=0;G[0]!=="*"&&(J=parseInt(G[0],10)+X);let K=parseInt(G[1],10);if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(K===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(K>this[Z].length)throw TypeError("CronPattern: Syntax error, max steps for part is ("+this[Z].length+")");for(let W=J;W<this[Z].length;W+=K)this.setPart(Z,W,Y[1]||Q)}replaceAlphaDays($){return $.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths($){return $.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames($){let Z=$.trim().toLowerCase();return Z==="@yearly"||Z==="@annually"?"0 0 1 1 *":Z==="@monthly"?"0 0 1 * *":Z==="@weekly"?"0 0 * * 0":Z==="@daily"?"0 0 * * *":Z==="@hourly"?"0 * * * *":$}setNthWeekdayOfMonth($,Z){if(typeof Z!="number"&&Z==="L")this.dayOfWeek[$]=this.dayOfWeek[$]|QX1;else if(Z===ha)this.dayOfWeek[$]=ha;else if(Z<6&&Z>0)this.dayOfWeek[$]=this.dayOfWeek[$]|vx8[Z-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${Z}, Type: ${typeof Z}`)}},Cx8,BF,r3=class ${tz;ms;second;minute;hour;day;month;year;constructor(Z,X){if(this.tz=X,Z&&Z instanceof Date)if(!isNaN(Z))this.fromDate(Z);else throw TypeError("CronDate: Invalid date passed to CronDate constructor");else if(Z===void 0)this.fromDate(new Date);else if(Z&&typeof Z=="string")this.fromString(Z);else if(Z instanceof $)this.fromCronDate(Z);else throw TypeError("CronDate: Invalid type ("+typeof Z+") passed to CronDate constructor")}isNthWeekdayOfMonth(Z,X,Q,Y){let G=new Date(Date.UTC(Z,X,Q)).getUTCDay(),J=0;for(let K=1;K<=Q;K++)new Date(Date.UTC(Z,X,K)).getUTCDay()===G&&J++;if(Y&ha&&vx8[J-1]&Y)return!0;if(Y&QX1){let K=new Date(Date.UTC(Z,X+1,0)).getUTCDate();for(let W=Q+1;W<=K;W++)if(new Date(Date.UTC(Z,X,W)).getUTCDay()===G)return!1;return!0}return!1}fromDate(Z){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes()+this.tz,this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),this.apply();else{let X=SX.toTZ(Z,this.tz);this.ms=Z.getMilliseconds(),this.second=X.s,this.minute=X.i,this.hour=X.h,this.day=X.d,this.month=X.m-1,this.year=X.y}else this.ms=Z.getMilliseconds(),this.second=Z.getSeconds(),this.minute=Z.getMinutes(),this.hour=Z.getHours(),this.day=Z.getDate(),this.month=Z.getMonth(),this.year=Z.getFullYear()}fromCronDate(Z){this.tz=Z.tz,this.year=Z.year,this.month=Z.month,this.day=Z.day,this.hour=Z.hour,this.minute=Z.minute,this.second=Z.second,this.ms=Z.ms}apply(){if(this.month>11||this.day>Cx8[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let Z=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes(),this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),!0}else return!1}fromString(Z){if(typeof this.tz=="number"){let X=SX.fromTZISO(Z);this.ms=X.getUTCMilliseconds(),this.second=X.getUTCSeconds(),this.minute=X.getUTCMinutes(),this.hour=X.getUTCHours(),this.day=X.getUTCDate(),this.month=X.getUTCMonth(),this.year=X.getUTCFullYear(),this.apply()}else return this.fromDate(SX.fromTZISO(Z,this.tz))}findNext(Z,X,Q,Y){let G=this[X],J;Q.lastDayOfMonth&&(this.month!==1?J=Cx8[this.month]:J=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let K=!Q.starDOW&&X=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let W=this[X]+Y;W<Q[X].length;W++){let H=Q[X][W];if(X==="day"&&Q.lastDayOfMonth&&W-Y==J&&(H=1),X==="day"&&!Q.starDOW){let N=Q.dayOfWeek[(K+(W-Y-1))%7];if(N&&N&ha)N=this.isNthWeekdayOfMonth(this.year,this.month,W-Y,N)?1:0;else if(N)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${N}`);Z.legacyMode&&!Q.starDOM?H=H||N:H=H&&N}if(H)return this[X]=W-Y,G!==this[X]?2:1}return 3}recurse(Z,X,Q){let Y=this.findNext(X,BF[Q][0],Z,BF[Q][2]);if(Y>1){let G=Q+1;for(;G<BF.length;)this[BF[G][0]]=-BF[G][2],G++;if(Y===3)return this[BF[Q][1]]++,this[BF[Q][0]]=-BF[Q][2],this.apply(),this.recurse(Z,X,0);if(this.apply())return this.recurse(Z,X,Q-1)}return Q+=1,Q>=BF.length?this:this.year>=3000?null:this.recurse(Z,X,Q)}increment(Z,X,Q){return this.second+=X.interval!==void 0&&X.interval>1&&Q?X.interval:1,this.ms=0,this.apply(),this.recurse(Z,X,0)}getDate(Z){return Z||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):SX.fromTZ(SX.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}},_x8=30000,OT0,wT0=class{name;options;_states;fn;constructor($,Z,X){let Q,Y;if(ga(Z))Y=Z;else if(typeof Z=="object")Q=Z;else if(Z!==void 0)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(ga(X))Y=X;else if(typeof X=="object")Q=X;else if(X!==void 0)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=Q?.name,this.options=Ya4(Q),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:Q?Q.maxRuns:void 0,paused:Q?Q.paused:!1,pattern:new Sx8("* * * * *")},$&&($ instanceof Date||typeof $=="string"&&$.indexOf(":")>0)?this._states.once=new r3($,this.options.timezone||this.options.utcOffset):this._states.pattern=new Sx8($,this.options.timezone),this.name){if(OT0.find((G)=>G.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");OT0.push(this)}return Y!==void 0&&Ga4(Y)&&(this.fn=Y,this.schedule()),this}nextRun($){let Z=this._next($);return Z?Z.getDate(!1):null}nextRuns($,Z){this._states.maxRuns!==void 0&&$>this._states.maxRuns&&($=this._states.maxRuns);let X=[],Q=Z||this._states.currentRun||void 0;for(;$--&&(Q=this.nextRun(Q));)X.push(Q);return X}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let $=this.nextRun(this._states.currentRun),Z=!this._states.paused,X=this.fn!==void 0,Q=!this._states.kill;return Z&&X&&Q&&$!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext($){let Z=this._next($);return Z?$ instanceof r3||$ instanceof Date?Z.getTime()-$.getTime():Z.getTime()-new r3($).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let $=OT0.indexOf(this);$>=0&&OT0.splice($,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule($){if($&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");$&&(this.fn=$);let Z=this.msToNext(),X=this.nextRun(this._states.currentRun);return Z==null||isNaN(Z)||X===null?this:(Z>_x8&&(Z=_x8),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(X),Z),this._states.currentTimeout&&this.options.unref&&Ja4(this._states.currentTimeout),this)}async _trigger($){if(this._states.blocking=!0,this._states.currentRun=new r3(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(Z){ga(this.options.catch)&&this.options.catch(Z,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new r3($,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger($){let Z=new Date,X=!this._states.paused&&Z.getTime()>=$.getTime(),Q=this._states.blocking&&this.options.protect;X&&!Q?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):X&&Q&&ga(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next($){let Z=!!($||this._states.currentRun),X=!1;!$&&this.options.startAt&&this.options.interval&&([$,Z]=this._calculatePreviousRun($,Z),X=!$),$=new r3($,this.options.timezone||this.options.utcOffset),this.options.startAt&&$&&$.getTime()<this.options.startAt.getTime()&&($=this.options.startAt);let Q=this._states.once||new r3($,this.options.timezone||this.options.utcOffset);return!X&&Q!==this._states.once&&(Q=Q.increment(this._states.pattern,this.options,Z)),this._states.once&&this._states.once.getTime()<=$.getTime()||Q===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&Q.getTime()>=this.options.stopAt.getTime()?null:Q}_calculatePreviousRun($,Z){let X=new r3(void 0,this.options.timezone||this.options.utcOffset),Q=$;if(this.options.startAt.getTime()<=X.getTime()){Q=this.options.startAt;let Y=Q.getTime()+this.options.interval*1000;for(;Y<=X.getTime();)Q=new r3(Q,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),Y=Q.getTime()+this.options.interval*1000;Z=!0}return Q===null&&(Q=void 0),[Q,Z]}};var YX1=w(()=>{SX.fromTZISO=($,Z,X)=>SX.fromTZ(Qa4($,Z),X);SX.fromTZ=function($,Z){let X=new Date(Date.UTC($.y,$.m-1,$.d,$.h,$.i,$.s)),Q=XX1($.tz,X),Y=new Date(X.getTime()-Q),G=XX1($.tz,Y);if(G-Q===0)return Y;{let J=new Date(X.getTime()-G),K=XX1($.tz,J);if(K-G===0)return J;if(!Z&&K-G>0)return J;if(Z)throw Error("Invalid date passed to fromTZ()");return Y}};SX.toTZ=function($,Z){let X=$.toLocaleString("en-US",{timeZone:Z}).replace(/[\u202f]/," "),Q=new Date(X);return{y:Q.getFullYear(),m:Q.getMonth()+1,d:Q.getDate(),h:Q.getHours(),i:Q.getMinutes(),s:Q.getSeconds(),tz:Z}};SX.tp=($,Z,X,Q,Y,G,J)=>({y:$,m:Z,d:X,h:Q,i:Y,s:G,tz:J});SX.minitz=SX;ha=31|QX1,vx8=[1,2,4,8,16],Cx8=[31,28,31,30,31,30,31,31,30,31,30,31],BF=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]];OT0=[]});function LT0($,Z){try{return new wT0($,{timezone:"UTC"}).nextRun(Z)??null}catch{return null}}var GX1=w(()=>{YX1()});import{DBOS as _7,SchedulerMode as Ka4}from"@dbos-inc/dbos-sdk";async function NX1($){try{let{rows:Z}=await $.query(`SELECT q.name FROM dbos.queues q
2865
+ `)}async function Fr4($,Z,X){let Q=Z.organizationId,Y=await RX($,"smart"),G=X.virtual_mcp_id??eE(Q),J={id:`stall-nudge-${Z.id}-${X.id}`,role:"user",parts:[{type:"text",text:Ur4(X.harness_id)}]};await new kX({storage:$.storage.threads.messageParts(),orgId:Q,threadId:X.id,runId:X.id}).emitRequestMessage(J),await KF({threadId:X.id,source:"background-tool",request:{messages:[J],models:{credentialId:Y.credentialId,thinking:{id:Y.modelId,title:Y.modelMeta.title}},agent:{id:G},temperature:0.5,toolApprovalLevel:"auto",mode:"default",organizationId:Q,userId:Z.assignedBy??Z.createdBy,harnessId:X.harness_id==="claude-code"?"claude-code":"decopilot",sandboxProviderKind:"agent-sandbox",...X.branch?{branch:X.branch}:{},taskId:X.id,runMetadata:wP0(Z)}},{workflowID:`stall-nudge:${Z.id}:${X.id}`})}async function Br4($,Z){let X=await $.storage.threads.get(Z);if(!X)return{action:"none",thread:null};return{action:Nr4({status:X.status,messageStorageVersion:X.message_storage_version,harnessId:X.harness_id,sandboxProviderKind:X.sandbox_provider_kind}),thread:X}}function Or4($,Z=Date.now()){if($.status!=="in_progress")return!1;if($.run_started_at)return!1;return Oa($,Z)}async function wr4($,Z){let X=[];for(let Q of Z.threads){if(Q.status!=="in_progress")continue;let Y=await $.storage.threads.get(Q.threadId);if(!Y||!Or4(Y))continue;if(await $.storage.threads.markRunFailed(Q.threadId,q71,"abandoned"))X.push(Q.threadId),console.warn(`[task-board] failed never-started thread ${Q.threadId} on ${Z.id}`)}return X}async function rv8($,Z){let X=$.organization?.id;if(!X)return;for(let Q of Z){if(Q.status==="in_progress")try{if((await wr4($,Q)).length>0)continue}catch(J){console.error(`[task-board] reaping threads for ${Q.id} failed`,J)}let Y;try{Y=Q.repo!=null&&(await $.storage.taskBoard.listPrs(Q.id,X)).length>0}catch(J){console.error(`[task-board] listPrs for ${Q.id} failed`,J);continue}if(!a91(Q,Y))continue;let G=Q.threads.find((J)=>J.hasMessages);if(!G)continue;try{let{action:J,thread:K}=await Br4($,G.threadId);if(J==="none"||!K)continue;if(J==="advance")await Tu($.storage.taskBoard,G.threadId,X,$.storage.organizationBilling);else await Fr4($,Q,K)}catch(J){console.error(`[task-board] stall recovery failed for ${Q.id}`,J)}}}var q71="Run never started \u2014 no pod picked it up before the idle window elapsed";var M71=w(()=>{pr();UL();$L();WF();vH();T6();Z9()});import{z as xa}from"zod";var V71;var av8=w(()=>{n0();XY();CK();M71();V71=m({name:"TASK_BOARD_ITEM_LIST",description:"List all task board items for the organization, plus the `owner/name` repos this organization has imported (the valid values for a task's `repo` field).",annotations:{title:"List Task Board Items",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:xa.object({}),outputSchema:xa.object({items:xa.array(Wu),repos:xa.array(xa.string())}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.list(X),{items:Y}=await Z.storage.connections.list(X,{slug:"mcp-github"}),G=JF8(Y);return rv8(Z,Q),{items:Q,repos:G}}})});import{z as p3}from"zod";function Dr4($,Z){let X=[];for(let{field:G,action:J}of Lr4){if(Z[G]===$[G])continue;X.push({action:J,data:{from:$[G],to:Z[G]}})}if(Z.description!==$.description)X.push({action:"description_changed"});let Q=new Set($.tags.map((G)=>G.id));if(Z.tags.length!==$.tags.length||Z.tags.some((G)=>!Q.has(G.id)))X.push({action:"tags_changed",data:{from:$.tags,to:Z.tags}});return X}function Er4($,Z){if($!==G4)return!1;if(!Z)return!1;return Z.assigneeId!==G4?!0:Z.status==="todo"}function jr4($,Z,X){return X&&$==="done"&&Z==="in_review"}var Lr4,k71;var sv8=w(()=>{n0();CK();D51();JF();RQ();Ku();Z9();DK();Lr4=[{field:"status",action:"status_changed"},{field:"assigneeId",action:"assignee_changed"},{field:"priority",action:"priority_changed"},{field:"dueDate",action:"due_date_changed"},{field:"title",action:"title_changed"}];k71=m({name:"TASK_BOARD_ITEM_UPDATE",description:"Update a task board item's fields (title, description, status, priority, assignee), and/or link a chat thread to it.",annotations:{title:"Update Task Board Item",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:p3.object({id:p3.string(),title:p3.string().min(1).optional(),description:p3.string().nullable().optional(),status:SK.optional(),priority:o_.optional(),assigneeId:p3.string().nullable().optional(),repo:p3.string().nullable().optional(),dueDate:p3.string().datetime().nullable().optional(),sortOrder:p3.number().optional(),tagIds:p3.array(p3.string()).optional(),linkThreadId:p3.string().optional()}),outputSchema:p3.object({item:Wu}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");if($.assigneeId)await OP0(Z,X,$.assigneeId);if($.linkThreadId){if(!await Z.storage.taskBoard.getById($.id,X))throw Error(`Task board item not found: ${$.id}`);if(!await Z.storage.threads.get($.linkThreadId))throw Error(`Thread not found: ${$.linkThreadId}`);await Z.storage.taskBoard.linkThread($.id,$.linkThreadId,X)}let Q=$.title!==void 0||$.description!==void 0||$.status!==void 0||$.priority!==void 0||$.assigneeId!==void 0||$.repo!==void 0||$.dueDate!==void 0||$.sortOrder!==void 0||$.tagIds!==void 0,Y=Q?await Z.storage.taskBoard.getById($.id,X):null;if(Q&&!Y)throw Error(`Task board item not found: ${$.id}`);let G=t_.getStore()!==void 0;if(jr4($.status,Y?.status,G))throw Error("This task is In Review \u2014 a run can't move it to Done. Leave it in "+"in_review for the reviewer; only a person, or TASK_BOARD_REVIEW_DECISION on a reviewer's own run, completes a task under review.");let J=$.assigneeId!==void 0&&$.assigneeId!==(Y?.assigneeId??null),K=Er4($.assigneeId,Y);if(Y&&KY(Y)){if($.title!==void 0||$.description!==void 0||$.priority!==void 0)throw Error("This task was generated from your report and can't be edited \u2014 create your own task instead.");if(K)await h30(Z,Y,Rh())}if($.tagIds!==void 0){let H=await Z.storage.tags.listOrgTags(X),N=new Set(H.map((U)=>U.id));for(let U of $.tagIds)if(!N.has(U))throw Error(`Tag not found: ${U}`);await Z.storage.taskBoard.setItemTags($.id,$.tagIds,D1(Z))}let W;if(Q)W=await Z.storage.taskBoard.update($.id,X,{title:$.title,description:$.description,status:K?"todo":$.status,priority:$.priority,assigneeId:$.assigneeId,assignedBy:J?$.assigneeId?D1(Z):null:void 0,repo:$.repo,dueDate:$.dueDate,sortOrder:$.sortOrder},D1(Z));else{let H=await Z.storage.taskBoard.getById($.id,X);if(!H)throw Error(`Task board item not found: ${$.id}`);W=H}if(Y){let H=D1(Z),N=Dr4(Y,W);if(N.length>0)await JC8(Z,N.map((U)=>({taskBoardItemId:W.id,actorId:H,...U})))}if(Q||$.linkThreadId)P6(X,W);if(K)await NL(Z,W,{userInitiated:!0});return{item:W}}})});import{z as JT0}from"zod";var S71;var ev8=w(()=>{n0();Z9();S71=m({name:"TASK_BOARD_ITEM_DELETE",description:"Delete a task board item. A reports-pushed task also dismisses its finding, so the next diagnostic import won't re-create the card.",annotations:{title:"Delete Task Board Item",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:JT0.object({id:JT0.string()}),outputSchema:JT0.object({success:JT0.boolean()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");if(!await Z.storage.taskBoard.delete($.id,X,D1(Z)??"system"))throw Error(`Task board item not found: ${$.id}`);return LC8(X,$.id),{success:!0}}})});import{z as Av}from"zod";var C71;var $x8=w(()=>{n0();s91();Z9();Ku();C71=m({name:"TASK_BOARD_ITEM_PR_LINK",description:"Link the pull request you just opened to this run's task board item. Call this right after `gh pr create` succeeds, with the PR URL it printed. Reviewers (QA, code review) are dispatched from the linked PR, so a task whose PR is not linked never gets reviewed.",annotations:{title:"Link Pull Request to Task",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Av.object({url:Av.string().describe("The pull request URL, e.g. https://github.com/owner/repo/pull/123")}),outputSchema:Av.object({url:Av.string(),prNumber:Av.number(),taskBoardItemIds:Av.array(Av.string())}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z).id,{threadId:Q}=BP0(),Y=UA0($.url);if(!Y)throw Error(`Not a GitHub pull request URL: ${$.url} (expected https://github.com/<owner>/<repo>/pull/<number>)`);let G=await zA0(Z,X,Q);for(let J of G)await Z.storage.taskBoard.linkPr({taskBoardItemId:J,organizationId:X,url:Y.url,prNumber:Y.number,repoOwner:Y.owner,repoName:Y.repo}),await Z.storage.taskBoard.clearSweepBudget(J,X);return{url:Y.url,prNumber:Y.number,taskBoardItemIds:G}}})});function Xx8($){Zx8=$}function KT0($){Zx8?.broadcast($)}var Zx8=null;import{DBOS as WT0}from"@dbos-inc/dbos-sdk";function zr4($,Z){let X=`thread-run:${Z}:`;if(!$.workflowID.startsWith(X))return null;let Q=$.input?.[0],Y=Q?.request;return{workflowId:$.workflowID,messageId:Y?.messageId??$.workflowID.slice(X.length),status:$.status==="PENDING"?"running":"queued",enqueuedAt:$.createdAt,...Q?.source!==void 0?{source:Q.source}:{}}}async function _71($){return(await WT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING","ENQUEUED"],loadInput:!0,loadOutput:!1})).map((X)=>zr4(X,$)).filter((X)=>X!==null).sort((X,Q)=>X.enqueuedAt-Q.enqueuedAt)}async function Qx8($,Z){if(!Z.startsWith(`thread-run:${$}:`))return!1;return await WT0.cancelWorkflows([Z]),!0}async function fu($){let Z=await WT0.listWorkflows({workflow_id_prefix:`thread-run:${$}:`,status:["PENDING"],loadInput:!1,loadOutput:!1});if(Z.length===0)return;await WT0.cancelWorkflows(Z.map((X)=>X.workflowID))}var HT0=()=>{};function Tr4($){return/\b405\b/.test($)&&/not allowed on this repository/i.test($)}function Ir4($,Z={}){if($==="failing")return!0;if($==="pending")return!Z.allowPendingChecks;return!1}async function qr4($,Z,X,Q,Y){if(Rr4.has(Q))return;let J=(await $.storage.taskBoard.listActivity(X,Z).catch(()=>[])).at(-1);if(J?.action==="merge_failed"&&J.data?.reason===Q)return;await i$($,{taskBoardItemId:X,action:"merge_failed",actorId:null,data:{reason:Q,...Y?{detail:Y}:{}}})}function Mr4($){if(!$?.isError)return{kind:"merged"};let Z=JSON.stringify($?.content)??"";if(Tr4(Z))return{kind:"method_not_allowed",detail:Z};if(QT0(Z))return{kind:"rate_limited",detail:Z};return{kind:"refused",detail:Z}}async function Vr4($,Z,X){let Q=await $.callTool({name:"merge_pull_request",arguments:{owner:Z.repoOwner,repo:Z.repoName,pullNumber:Z.number,merge_method:X}},void 0,{timeout:Pr4});return Mr4(Q)}async function fa($,Z,X,Q={}){let Y=async(U,F)=>{return await qr4($,Z,X,U,F),{merged:!1,reason:U,...F?{detail:F}:{}}},G=await $.storage.taskBoard.listPrs(X,Z),J=await wL($,Z,G);if(!J)return console.warn(`[task-board] merge skipped \u2014 no linked PR on ${X}`),Y("no_pr");let K=await iv8($,Z,J);if(Ir4(K,Q))return console.warn(`[task-board] merge blocked \u2014 checks ${K} on PR #${J.number}`),Y(K==="failing"?"checks_failing":"checks_pending");let W=`${J.repoOwner}/${J.repoName}`,H=await Pv($,Z,J.connectionId,{owner:J.repoOwner,name:J.repoName});if(!H)return console.warn("[task-board] merge blocked \u2014 no active GitHub connection for "+`${W} (PR #${J.number})`),Y("no_connection",W);let N=await I5(H,$,!0);try{let U=null;for(let F of Ar4){let B=await Vr4(N,J,F);if(B.kind==="merged")return hv8(H.id),{merged:!0};if(B.kind==="rate_limited")return console.warn(`[task-board] merge rate-limited on PR #${J.number} \u2014 sweep retries`),Y("rate_limited",B.detail.slice(0,500));if(B.kind==="method_not_allowed"){console.warn(`[task-board] merge method '${F}' not allowed on ${W} \u2014 trying next`),U=B.detail;continue}return console.error(`[task-board] merge refused by GitHub on PR #${J.number}:`,B.detail),Y("refused",B.detail.slice(0,500))}return console.error(`[task-board] no merge method allowed on ${W} (PR #${J.number})`,U),Y("refused",U?.slice(0,500))}catch(U){let F=U instanceof Error?U.message:String(U);if(QT0(U))return Y("rate_limited",F);return console.error("[task-board] merge PR failed",U),Y("error",F)}finally{await N.close().catch(()=>{})}}async function ba($,Z,X){let Q=await $.storage.organizationSettings.get(Z),Y=fU(Q?.flags),G=await $.storage.taskBoard.listActivity(X,Z);return Pw(G,Y,{verifiedOnly:!0})}async function kr4($,Z){let X=await $.storage.organizationSettings.get(Z.organizationId),Q=fU(X?.flags),Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId);if(!eF8(Y,Q))return;await fH($,Z,"every reviewer approved, but an approval could not be verified \u2014 "+"auto-merge is blocked and no reviewer can be re-dispatched this cycle")}function Yx8($){return!$.merged&&$.reason==="refused"}function v71($,Z){if($!==null)return $;if(Z===null||!Yx8(Z))return null;return(Z.detail??"").toLowerCase().includes("merge conflict")?!0:null}async function Sr4($,Z,X){if(!Yx8(X))return;let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q),G=await wL($,Q,Y);if(!G)return;await _u($,Q,Z,{pr:{number:G.number,url:G.url},conflict:v71(await xu($,Q,G),X)}).catch((J)=>{console.error("[task-board] sweep conflict auto-resolve failed",J)})}async function Gx8($,Z){let X=Z.organizationId;if(Z.status!=="in_review")return!1;if((await $.storage.organizationSettings.get(X))?.flags?.auto_merge!==!0)return!1;if(await $.storage.taskBoard.hasHumanRejectedDone(Z.id,X))return!1;if(!await ba($,X,Z.id))return await kr4($,Z),!1;let Y=await fa($,X,Z.id);if(!Y.merged)return await Sr4($,Z,Y),!1;let G=await $.storage.taskBoard.update(Z.id,X,{status:"done"},Z.updatedBy);return await i$($,{taskBoardItemId:Z.id,action:"status_changed",actorId:null,data:{from:Z.status,to:"done"}}),P6(X,G),!0}var Pr4=15000,Ar4,Rr4;var ya=w(()=>{VU();g9();RQ();ka();yH();Z9();Ar4=["merge","squash","rebase"];Rr4=new Set(["checks_pending"])});import{z as bu}from"zod";function _r4($){return $.threads.filter((Z)=>Z.status!==null&&!Ea.has(Z.status)).map((Z)=>Z.threadId)}async function vr4($,Z,X){let Q=(G)=>(J)=>console.error("[task-board] rerun takeover step failed",{threadId:Z,step:G,err:J});await $.storage.threads.setCancelRequested(Z,X).catch(Q("cancel-flag")),await qu(Z).catch(Q("background-jobs")),await fu(Z).catch(Q("gate-head"));let Y=await $.storage.threads.getRunFence(Z).catch(()=>null);if(Y)await zv(Z,Y).catch(Q("hosted-harness"));KT0(Z)}function xr4($,Z){return $===!0&&w71(Z)}async function fr4($,Z,X){let Q=Z.organizationId,Y=await $.storage.taskBoard.listPrs(Z.id,Q).catch(()=>[]),G=await wL($,Q,Y).catch(()=>{return});if(!G)return!1;let J=await xu($,Q,G).catch(()=>null);return xr4(J,X)}function yr4($,Z){let X=bU($),Q=0;for(let Y of $){if(Y.action!=="review_approved")continue;let G=new Date(Y.occurredAt).getTime();if(G>=X)Q=Math.max(Q,G)}return Z-Q>=br4}async function gr4($,Z){if(Z.status!=="in_review")return;if((await $.storage.organizationSettings.get(Z.organizationId))?.flags?.auto_merge!==!0)return;if(!await ba($,Z.organizationId,Z.id))return;let Y=await $.storage.taskBoard.listActivity(Z.id,Z.organizationId).catch(()=>[]);if(yr4(Y,Date.now()))return;if(await fr4($,Z,Y))return;throw Error("Every reviewer approved this task and its merge is retrying \u2014 re-running "+"would throw that away and start a new review cycle. Wait for the merge, or use the ship button if the PR needs a nudge.")}var Cr4="Superseded by a manual re-run of this task",br4=900000,x71;var Jx8=w(()=>{n0();g9();vH();WF();HT0();Mu();RQ();Z9();JF();ya();yH();ka();DK();x71=m({name:"TASK_BOARD_ITEM_RERUN",description:"Re-run a task board item with the Super Agent, whatever lane it is in. Use this to retry a task that stalled, finished without doing the job, or is already assigned to the Super Agent (in which case re-assigning it does nothing). Fails any run still holding the task open, moves it to In Progress, and queues a fresh run.",annotations:{title:"Re-run Task",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:bu.object({id:bu.string().describe("The task board item to re-run.")}),outputSchema:bu.object({status:bu.string().describe("The task's lane after the re-run was queued."),supersededThreadIds:bu.array(bu.string()).describe("Runs that were failed to make room for this one.")}),handler:async({id:$},Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);if(Q.assigneeId!==G4)throw Error("Only a task assigned to the Super Agent can be re-run. Assign it to "+"the Super Agent instead \u2014 that queues a run by itself.");await gr4(Z,Q),await h30(Z,Q,Rh());let Y=[];for(let J of _r4(Q)){if(!await Z.storage.threads.failIfNotTerminal(J,Cr4,"superseded"))continue;Y.push(J),await vr4(Z,J,X)}let G=await Z.storage.taskBoard.update($,X,{status:"in_progress"},D1(Z));return await i$(Z,{taskBoardItemId:$,action:"status_changed",actorId:D1(Z),data:{from:Q.status,to:"in_progress",reason:"rerun"}}),P6(X,G),await NF(Z,G,{userInitiated:!0}),{status:G.status,supersededThreadIds:Y}}})});import{z as LL}from"zod";function hr4($,Z,X){return $!==null&&$.reviewer===Z&&$.cycleAt.getTime()===X}function ur4($,Z){return P81($).get(Z)==="changes_requested"}var f71;var Kx8=w(()=>{n0();g9();CK();RQ();Z9();JF();ya();yH();N71();ka();DK();f71=m({name:"TASK_BOARD_REVIEW_DECISION",description:"Record a reviewer's decision for a task under review. `approve` marks the pull request approved by that reviewer (and, once EVERY enabled reviewer has approved, merges it when the org enabled auto-merge, advancing the task to Done); `request_changes` hands the task back to the Super Agent with your notes so it can fix the PR.",annotations:{title:"Review Decision",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:LL.object({taskBoardItemId:LL.string(),reviewer:LL.enum(["qa","code_review"]).describe("Which reviewer you are: `qa` (QA Agent) or `code_review` (Code Reviewer)."),reviewToken:LL.string().optional().describe("The reviewToken from your prompt \u2014 proves you are this reviewer. "+"Pass it through exactly; an approval without a valid token is recorded but does NOT count toward an automatic merge."),decision:LL.enum(["approve","request_changes"]),notes:LL.string().min(1).describe("For approve: a short summary of what you verified. For request_changes: specific, actionable feedback the Super Agent must address.")}),outputSchema:LL.object({status:SK,merged:LL.boolean().describe("True when this approval completed the review and merged the PR.")}),handler:async({taskBoardItemId:$,reviewer:Z,reviewToken:X,decision:Q,notes:Y},G)=>{G0(G),await G.access.check();let J=G.organization?.id;if(!J)throw Error("Organization ID required (no active organization in context)");let K=await G.storage.taskBoard.getById($,J);if(!K)throw Error(`Task board item not found: ${$}`);let W=X?bU(await G.storage.taskBoard.listActivity($,J)):0,H=!!X&&(Sv8(X,$,Z,new Date(W))||hr4(await G.storage.taskBoard.resolveReviewClaimByToken($,X),Z,W));if(Q==="request_changes"){let j=await G.storage.taskBoard.listActivity($,J);if(ur4(j,Z))return{status:K.status,merged:!1};if(ZB8(j))return await i$(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H,bounceLimitReached:!0}}),await fH(G,K,`${A81} review bounces reached \u2014 the reviewer and the `+"Super Agent are not converging"),{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};let z=await G.storage.taskBoard.claimReviewChangesBounce($,J,K.updatedBy);if(await i$(G,{taskBoardItemId:$,action:"review_changes_requested",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!z)return{status:(await G.storage.taskBoard.getById($,J)??K).status,merged:!1};P6(J,z);let P=await G.storage.taskBoard.listPrs($,J),A=await wL(G,J,P);return await NF(G,z,{feedback:`${Th[Z]}: ${Y}`,pr:A?{number:A.number,url:A.url}:void 0}).catch(async(I)=>{if(await AA0(G,z,I)){await G.storage.taskBoard.update(z.id,J,{status:"in_review"},"system").then((q)=>P6(J,q)).catch((q)=>console.error("[task-board] runs-exhausted status revert failed",q));return}if(I instanceof DX)throw I;console.error("[task-board] request_changes re-enqueue failed",I)}),{status:z.status,merged:!1}}if(await i$(G,{taskBoardItemId:$,action:"review_approved",actorId:null,data:{reviewer:Z,notes:Y,verified:H}}),!await ba(G,J,$)){let j=await G.storage.taskBoard.getById($,J)??K;return P6(J,j),{status:j.status,merged:!1}}let F=(await G.storage.organizationSettings.get(J))?.flags?.auto_merge===!0,B=await G.storage.taskBoard.hasHumanRejectedDone($,J),O=F&&!B,L=O?await fa(G,J,$):null;if(L?.merged===!0){let j=await G.storage.taskBoard.update($,J,{status:"done"},K.updatedBy);return await i$(G,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:K.status,to:"done"}}),P6(J,j),{status:j.status,merged:!0}}let E=await G.storage.taskBoard.getById($,J)??K;if(O){let j=await G.storage.taskBoard.listPrs($,J),z=await wL(G,J,j);if(z?await _u(G,J,E,{pr:{number:z.number,url:z.url},conflict:v71(await xu(G,J,z),L)}).catch((A)=>{if(A instanceof DX)throw A;return console.error("[task-board] conflict auto-resolve failed",A),!1}):!1)return{status:(await G.storage.taskBoard.getById($,J)??E).status,merged:!1}}return P6(J,E),{status:E.status,merged:!1}}})});import{z as NT0}from"zod";function cr4($,Z,X){if($!=="in_review")return!1;return X.length===0||Pw(Z,X)}var b71;var Wx8=w(()=>{n0();g9();CK();RQ();Z9();ya();b71=m({name:"TASK_BOARD_PROMOTE_TO_PRODUCTION",description:"Ship a reviewed task: merge its open pull request and move the task to Done. Used by the board's 'Ship to production' button after the enabled reviewers approved, when auto-merge is off (a human does the final merge).",annotations:{title:"Ship to Production",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},inputSchema:NT0.object({taskBoardItemId:NT0.string()}),outputSchema:NT0.object({status:SK,merged:NT0.boolean().describe("True when the PR was merged.")}),handler:async({taskBoardItemId:$},Z)=>{G0(Z),await Z.access.check();let X=Z.organization?.id;if(!X)throw Error("Organization ID required (no active organization in context)");let Q=await Z.storage.taskBoard.getById($,X);if(!Q)throw Error(`Task board item not found: ${$}`);let Y=await Z.storage.organizationSettings.get(X),G=fU(Y?.flags),J=await Z.storage.taskBoard.listActivity($,X);if(!cr4(Q.status,J,G))throw Error("Task is not ready to ship: it must be In Review with every enabled reviewer approved");if(!(await fa(Z,X,$,{allowPendingChecks:!0})).merged){let H=await Z.storage.taskBoard.getById($,X)??Q;return P6(X,H),{status:Q.status,merged:!1}}let W=await Z.storage.taskBoard.update($,X,{status:"done"},Q.updatedBy);if(Q.status!=="done")await i$(Z,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:Q.status,to:"done"}});return P6(X,W),{status:W.status,merged:!0}}})});import{z as t3}from"zod";function Hx8($){if(!$)throw Error("Organization ID required (no active organization in context)");return $}var lr4,y71,g71;var Nx8=w(()=>{n0();lr4=t3.object({externalKey:t3.string(),dismissedBy:t3.string(),dismissedAt:t3.string()});y71=m({name:"TASK_BOARD_DISMISSED_LIST",description:"List the diagnostic findings this organization has dismissed by deleting their task board cards. The import skips these until they're restored.",annotations:{title:"List Dismissed Findings",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:t3.object({}),outputSchema:t3.object({findings:t3.array(lr4)}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Hx8(Z.organization?.id);return{findings:await Z.storage.taskBoard.listDismissedFindings(X)}}}),g71=m({name:"TASK_BOARD_DISMISSED_RESTORE",description:"Un-dismiss diagnostic findings, returning their cards to the board. Omit externalKeys to restore every dismissed finding.",annotations:{title:"Restore Dismissed Findings",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:t3.object({externalKeys:t3.array(t3.string()).optional()}),outputSchema:t3.object({restored:t3.number()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=Hx8(Z.organization?.id);return{restored:await Z.storage.taskBoard.restoreDismissedFindings(X,$.externalKeys)}}})});import{z as Q5}from"zod";function UT0($){let Z=$.organization?.id;if(!Z)throw Error("Organization ID required (no active organization in context)");return Z}function mr4($,Z,X){return $.replace(dr4,(Q,Y,G,J)=>{let K=encodeURIComponent(`${Z}/${G}`);return`${Y}/api/${encodeURIComponent(X)}/fs/outputs/read?path=${K}${J}`})}var h71,u71,dr4,c71,l71,d71;var Ux8=w(()=>{n0();g9();EA0();Ku();h71=Q5.object({id:Q5.string(),taskBoardItemId:Q5.string(),parentId:Q5.string().nullable(),authorId:Q5.string(),body:Q5.string(),resolved:Q5.boolean(),createdAt:Q5.string(),updatedAt:Q5.string()});u71=m({name:"TASK_BOARD_COMMENT_LIST",description:"List a task board item's comments (flat, oldest first; replies carry parentId).",annotations:{title:"List Task Comments",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Q5.object({taskBoardItemId:Q5.string()}),outputSchema:Q5.object({comments:Q5.array(h71)}),handler:async($,Z)=>{return G0(Z),await Z.access.check(),{comments:await Z.storage.taskBoard.listComments($.taskBoardItemId,UT0(Z))}}}),dr4=/(!\[[^\]]*\]\()org\/output\/([^)\s]+)(\))/g;c71=m({name:"TASK_BOARD_COMMENT_CREATE",description:"Post a comment on a task board item, or a reply to one.",annotations:{title:"Create Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:Q5.object({taskBoardItemId:Q5.string(),body:Q5.string().trim().min(1),parentId:Q5.string().nullish()}),outputSchema:Q5.object({comment:h71}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=UT0(Z),Q=t_.getStore(),Y=Z.organization?.slug,G=Q?.threadId&&Y?mr4($.body,Q.threadId,Y):$.body,J=await Z.storage.taskBoard.createComment({taskBoardItemId:$.taskBoardItemId,organizationId:X,parentId:$.parentId??null,authorId:Q?G4:D1(Z),body:G});if(!J)throw Error("Task board item not found");return await HZ1(Z,{commentId:J.id,taskBoardItemId:J.taskBoardItemId,organizationId:X,authorLabel:Q?"Super Agent":Z.auth?.user?.name??Z.auth?.user?.email??"Studio",body:J.body}),{comment:J}}}),l71=m({name:"TASK_BOARD_COMMENT_UPDATE",description:"Edit your own comment's body, or resolve/unresolve a comment thread (root only, any org member may toggle it).",annotations:{title:"Update Task Comment",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:Q5.object({id:Q5.string(),body:Q5.string().trim().min(1).optional(),resolved:Q5.boolean().optional()}),outputSchema:Q5.object({comment:h71}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=await Z.storage.taskBoard.updateComment({id:$.id,organizationId:UT0(Z),callerId:D1(Z),body:$.body,resolved:$.resolved});if(!X)throw Error("Comment not found, or you can only edit your own comments");return{comment:X}}}),d71=m({name:"TASK_BOARD_COMMENT_DELETE",description:"Delete your own comment. Deleting a thread root deletes its replies too.",annotations:{title:"Delete Task Comment",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Q5.object({id:Q5.string()}),outputSchema:Q5.object({success:Q5.boolean()}),handler:async($,Z)=>{return G0(Z),await Z.access.check(),{success:await Z.storage.taskBoard.deleteComment($.id,UT0(Z),D1(Z))}}})});var Fx8=w(()=>{wq8();ov8();av8();sv8();ev8();yH();$x8();Jx8();Kx8();Wx8();RQ();Nx8();Ux8()});import{z as FF}from"zod";var m71;var Bx8=w(()=>{n0();m71=m({name:"TAGS_LIST",description:"List all tags available in the organization.",annotations:{title:"List Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:FF.object({}),outputSchema:FF.object({tags:FF.array(FF.object({id:FF.string(),organizationId:FF.string(),name:FF.string(),color:FF.string().nullable(),createdAt:FF.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z);return{tags:(await Z.storage.tags.listOrgTags(X.id)).map((Y)=>({...Y,createdAt:Y.createdAt instanceof Date?Y.createdAt.toISOString():String(Y.createdAt)}))}}})});import{z as gH}from"zod";var i71;var Ox8=w(()=>{n0();i71=m({name:"TAGS_CREATE",description:"Create a new tag, usable on organization members and task board items.",annotations:{title:"Create Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!1},inputSchema:gH.object({name:gH.string().min(1).max(50).describe("Tag name"),color:gH.string().regex(/^#[0-9a-fA-F]{6}$/).nullable().optional().describe('Hex color the tag renders its dot with, e.g. "#3b82f6"')}),outputSchema:gH.object({tag:gH.object({id:gH.string(),organizationId:gH.string(),name:gH.string(),color:gH.string().nullable(),createdAt:gH.string().describe("ISO 8601 timestamp")})}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z),Q=await Z.storage.tags.createTag(X.id,$.name,$.color);return{tag:{...Q,createdAt:Q.createdAt instanceof Date?Q.createdAt.toISOString():String(Q.createdAt)}}}})});import{z as FT0}from"zod";var n71;var wx8=w(()=>{n0();n71=m({name:"TAGS_DELETE",description:"Delete a tag and automatically remove it from all assigned members.",annotations:{title:"Delete Tag",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:FT0.object({tagId:FT0.string().describe("Tag ID to delete")}),outputSchema:FT0.object({success:FT0.boolean()}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z),Q=await Z.storage.tags.getTag($.tagId);if(!Q)throw Error("Tag not found");if(Q.organizationId!==X.id)throw Error("Tag does not belong to this organization");return await Z.storage.tags.deleteTag($.tagId),{success:!0}}})});import{z as hH}from"zod";var p71;var Lx8=w(()=>{n0();p71=m({name:"MEMBER_TAGS_GET",description:"Get all tags currently assigned to a specific member.",annotations:{title:"Get Member Tags",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:hH.object({memberId:hH.string().describe("Member ID")}),outputSchema:hH.object({tags:hH.array(hH.object({id:hH.string(),organizationId:hH.string(),name:hH.string(),color:hH.string().nullable(),createdAt:hH.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);return{tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});import{z as o3}from"zod";var t71;var Dx8=w(()=>{n0();t71=m({name:"MEMBER_TAGS_SET",description:"Replace all tags on a member with the given set. Pass empty array to clear.",annotations:{title:"Set Member Tags",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:o3.object({memberId:o3.string().describe("Member ID"),tagIds:o3.array(o3.string()).describe("Array of tag IDs to assign")}),outputSchema:o3.object({success:o3.boolean(),tags:o3.array(o3.object({id:o3.string(),organizationId:o3.string(),name:o3.string(),createdAt:o3.string().describe("ISO 8601 timestamp")}))}),handler:async($,Z)=>{G0(Z),await Z.access.check();let X=X0(Z);if(!await Z.storage.tags.verifyMemberOrg($.memberId,X.id))throw Error(`Member not found in this organization: ${$.memberId}`);for(let G of $.tagIds){let J=await Z.storage.tags.getTag(G);if(!J)throw Error(`Tag not found: ${G}`);if(J.organizationId!==X.id)throw Error(`Tag does not belong to this organization: ${G}`)}return await Z.storage.tags.setMemberTags($.memberId,$.tagIds),{success:!0,tags:(await Z.storage.tags.getMemberTags($.memberId)).map((G)=>({...G,createdAt:G.createdAt instanceof Date?G.createdAt.toISOString():String(G.createdAt)}))}}})});var Ex8=w(()=>{Bx8();Ox8();wx8();Lx8();Dx8()});import{z as jx8}from"zod";function or4($,Z){let X=$?.[Z];if(!X)return;return Object.entries(X).sort(([,Y],[,G])=>{let J=Math.max(0,...Object.values(Y).map((W)=>W.createdAt??0));return Math.max(0,...Object.values(G).map((W)=>W.createdAt??0))-J})[0]?.[0]}var pr4,tr4,o71;var zx8=w(()=>{h4();n0();Hv();GQ();pr4=jx8.object({data:SS8.describe("Data for the new thread (id is auto-generated if not provided)")}),tr4=jx8.object({item:CH.describe("The created thread entity")});o71=m({name:"COLLECTION_THREADS_CREATE",description:"Create a new thread for organizing messages and conversations.",annotations:{title:"Create Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:pr4,outputSchema:tr4,handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=D1(Z);if(!Q)throw Error("User ID required to create thread");let{data:Y}=$,G=Y.id??Q4("thrd"),K=(await XA0(Z.storage.virtualMcps,Y.virtual_mcp_id,X.id)).metadata,W=K?.githubRepo,H=null;if(W)H=Y.branch??or4(K?.sandboxMap,Q)??KP0(JP0(Z.auth.user));let N=await Z.storage.threads.create({id:G,organization_id:X.id,title:Y.title,description:Y.description,virtual_mcp_id:Y.virtual_mcp_id,branch:H,created_by:Q,...Y.runtime?{metadata:{runtime:Y.runtime}}:{}});if(N.isNew)n1.capture({distinctId:Q,event:"chat_started",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:G,has_title:!!$.data.title,created_via:"tool"}});return{item:m3(N)}}})});import{z as r71}from"zod";var rr4,ar4,a71;var Px8=w(()=>{h4();n0();Hv();GA0();rr4=r71.object({id:r71.string().describe("ID of the thread to update"),data:CS8.describe("Partial thread data to update")}),ar4=r71.object({item:CH.describe("The updated thread entity")}),a71=m({name:"COLLECTION_THREADS_UPDATE",description:"Update a thread's title, description, or visibility.",annotations:{title:"Update Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:rr4,outputSchema:ar4,handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=D1(Z);if(!Q)throw Error("User ID required to update thread");let{id:Y,data:G}=$,J=await Z.storage.threads.get(Y);if(!J)throw Error("Thread not found in organization");if(G.virtual_mcp_id!==void 0)await XA0(Z.storage.virtualMcps,G.virtual_mcp_id,X.id);if(G.branch===null&&J.virtual_mcp_id){if((await Z.storage.virtualMcps.findById(J.virtual_mcp_id,X.id))?.metadata?.githubRepo)throw Error("Cannot set branch=null on a github-linked thread (vMCP has githubRepo)")}let K={title:G.title,description:G.description,hidden:G.hidden,updated_by:Q};if(G.status)K.status=G.status;if(G.metadata!==void 0){let H=g91(J.metadata?.runtime);K.metadata=H?{...G.metadata,runtime:H}:G.metadata}if(G.branch!==void 0)K.branch=G.branch;if(G.virtual_mcp_id!==void 0)K.virtual_mcp_id=G.virtual_mcp_id;let W=await Z.storage.threads.update(Y,K);if(G.hidden!==void 0&&G.hidden!==J.hidden)n1.capture({distinctId:Q,event:G.hidden?"chat_archived":"chat_unarchived",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:Y}});return{item:m3(W)}}})});var s71;var Ax8=w(()=>{V3();Hv();h4();n0();WF();HT0();Mu();s71=m({name:"COLLECTION_THREADS_DELETE",description:"Permanently delete a thread and all its messages.",annotations:{title:"Delete Thread",readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},inputSchema:Do,outputSchema:Eo(CH),handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=await Z.storage.threads.get($.id);if(!Q)throw Error(`Thread not found: ${$.id}`);if(Q.status==="in_progress"){let G=(K)=>(W)=>console.error("[thread] delete-time run cancel step failed",{threadId:$.id,step:K,err:W});await qu($.id).catch(G("background-jobs")),await fu($.id).catch(G("gate-head"));let J=await Z.storage.threads.getRunFence($.id).catch(()=>null);if(J)await zv($.id,J).catch(G("hosted-harness"));KT0($.id)}await Z.storage.threads.delete($.id);let Y=D1(Z);if(Y)n1.capture({distinctId:Y,event:"chat_deleted",groups:{organization:X.id},properties:{organization_id:X.id,thread_id:$.id}});return{item:m3(Q)}}})});var Tx8=w(()=>{zx8();h91();u91();Px8();Ax8();c91()});function er4($){return{type:"doc",content:[{type:"paragraph",content:[{type:"text",text:$}]}]}}function $a4($){return $.map((Z)=>{let X=Z.metadata;if(X?.tiptapDoc)return Z;let Q=Z.parts.find((Y)=>Y.type==="text"&&typeof Y.text==="string");if(!Q?.text||typeof Q.text!=="string")return Z;return{...Z,metadata:{...X,tiptapDoc:er4(Q.text)}}})}function BT0($){let Z;if(typeof $==="string")try{let X=JSON.parse($);if(Array.isArray(X)&&X.length>0&&X[0]?.role&&Array.isArray(X[0]?.parts))Z=X;else Z=[{role:"user",parts:[{type:"text",text:$}]}]}catch{Z=[{role:"user",parts:[{type:"text",text:$}]}]}else Z=$;return $a4(Z)}import{z as Y5}from"zod";var e71;var Rx8=w(()=>{h4();n0();YY();e71=m({name:"AUTOMATION_CREATE",description:"Create an automation that runs an agent thread on trigger fire. Requires virtual_mcp_id + messages.",annotations:{title:"Create Automation",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},inputSchema:Y5.object({name:Y5.string().min(1).max(255),virtual_mcp_id:Y5.string(),messages:Y5.union([Y5.string(),Y5.array(Y5.looseObject({id:Y5.string().optional(),role:Y5.enum(["user","assistant","system"]),parts:Y5.array(Y5.record(Y5.string(),Y5.unknown())),metadata:Y5.unknown().optional()}))]),models:Y5.object({tier:Dw,modelId:Y5.string().optional(),credentialId:Y5.string().optional()}).loose().default({tier:"smart"}),tools:Y5.array(Y5.string()).nullable().optional(),maxAgentSteps:Y5.number().int().min(1).max(100).nullable().optional(),temperature:Y5.number().default(0.5),active:Y5.boolean().default(!0)}),outputSchema:Y5.object({id:Y5.string(),name:Y5.string(),active:Y5.boolean(),created_at:Y5.string()}),handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=D1(Z);if(!Q)throw Error("Unable to determine user identity");let Y=BT0($.messages),G=await Z.storage.automations.create({organization_id:X.id,created_by:Q,name:$.name,messages:JSON.stringify(Y),models:JSON.stringify($.models),tools:$.tools===void 0||$.tools===null?null:JSON.stringify($.tools),max_agent_steps:$.maxAgentSteps??null,temperature:$.temperature,active:$.active,virtual_mcp_id:$.virtual_mcp_id});return n1.capture({distinctId:Q,event:"automation_created",groups:{organization:X.id},properties:{organization_id:X.id,automation_id:G.id,virtual_mcp_id:$.virtual_mcp_id,active:G.active,tier:$.models.tier}}),{id:G.id,name:G.name,active:G.active,created_at:G.created_at}}})});import{z as n$}from"zod";var $X1;var Ix8=w(()=>{n0();$X1=m({name:"AUTOMATION_GET",description:"Get an automation's full configuration and triggers by ID.",annotations:{title:"Get Automation",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:n$.object({id:n$.string()}),outputSchema:n$.object({automation:n$.object({id:n$.string(),name:n$.string(),active:n$.boolean(),created_by:n$.string(),created_at:n$.string(),updated_at:n$.string(),virtual_mcp_id:n$.string(),messages:n$.unknown(),models:n$.unknown(),tools:n$.array(n$.string()).nullable(),maxAgentSteps:n$.number().nullable(),temperature:n$.number(),triggers:n$.array(n$.object({id:n$.string(),type:n$.enum(["cron","event","webhook"]),cron_expression:n$.string().nullable(),connection_id:n$.string().nullable(),event_type:n$.string().nullable(),params:n$.unknown().nullable(),last_run_at:n$.string().nullable(),api_key_id:n$.string().nullable(),created_at:n$.string()}))}).nullable()}),handler:async($,Z)=>{G0(Z);let X=X0(Z);await Z.access.check();let Q=await Z.storage.automations.findById($.id,X.id);if(!Q)return{automation:null};let Y=await Z.storage.automations.listTriggers(Q.id);return{automation:{id:Q.id,name:Q.name,active:Q.active,created_by:Q.created_by,created_at:Q.created_at,updated_at:Q.updated_at,virtual_mcp_id:Q.virtual_mcp_id,messages:JSON.parse(Q.messages),models:JSON.parse(Q.models),tools:Q.tools?JSON.parse(Q.tools):null,maxAgentSteps:Q.max_agent_steps,temperature:Q.temperature,triggers:Y.map((G)=>({id:G.id,type:G.type,cron_expression:G.cron_expression,connection_id:G.connection_id,event_type:G.event_type,params:G.params?JSON.parse(G.params):null,last_run_at:G.last_run_at,api_key_id:G.api_key_id,created_at:G.created_at}))}}}})});import{z as SG}from"zod";var ZX1;var qx8=w(()=>{n0();ZX1=m({name:"AUTOMATION_LIST",description:"List automations with their status, triggers, and configuration.",annotations:{title:"List Automations",readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},inputSchema:SG.object({virtual_mcp_id:SG.string().optional().nullable()}),outputSchema:SG.object({automations:SG.array(SG.object({id:SG.string(),name:SG.string(),active:SG.boolean(),created_by:SG.string(),created_at:SG.string(),trigger_count:SG.number(),nearest_next_run_at:SG.string().nullable(),virtual_mcp_id:SG.string()}))}),handler:async($,Z)=>{G0(Z);let X=X0(Z);return await Z.access.check(),{automations:(await Z.storage.automations.listWithTriggerCounts(X.id,$.virtual_mcp_id)).map((G)=>({id:G.id,name:G.name,active:G.active,created_by:G.created_by,created_at:G.created_at,trigger_count:G.trigger_count,nearest_next_run_at:G.nearest_next_run_at,virtual_mcp_id:G.virtual_mcp_id}))}}})});function Xa4($){if(!$)return null;try{let Z=JSON.parse($);if(Array.isArray(Z)&&Z.every((X)=>typeof X==="string"))return Z.length>0?Z:null}catch{}return null}function Mx8($){return`${$}:context`}function Vx8($,Z,X,Q,Y){let J=JSON.parse($.messages).map((H,N)=>({...H,id:`${X}:${N}`})),K=Z?{...Y,[LP0]:Za4}:Y;return{messages:J,models:{credentialId:Q.credentialId,thinking:Q.thinking,...Q.image?{image:Q.image}:{},...Q.webSearch?{webSearch:Q.webSearch}:{},...Q.deepResearch?{deepResearch:Q.deepResearch}:{}},agent:{id:$.virtual_mcp_id},toolAllowlist:Xa4($.tools),maxAgentSteps:$.max_agent_steps??void 0,temperature:$.temperature??0.5,toolApprovalLevel:"auto",mode:"default",organizationId:$.organization_id,userId:$.created_by,harnessId:"decopilot",sandboxProviderKind:"agent-sandbox",triggerId:Z??void 0,...K?{runMetadata:K}:{},taskId:X}}var Za4="new_task";var kx8=w(()=>{tr()});function SX($,Z,X,Q,Y,G,J,K){return SX.fromTZ(SX.tp($,Z,X,Q,Y,G,J),K)}function XX1($,Z=new Date){let X=Z.toLocaleString("en-US",{timeZone:$,timeZoneName:"shortOffset"}).split(" ").slice(-1)[0],Q=Z.toLocaleString("en-US").replace(/[\u202f]/," ");return Date.parse(`${Q} GMT`)-Date.parse(`${Q} ${X}`)}function Qa4($,Z){let X=new Date(Date.parse($));if(isNaN(X))throw Error("minitz: Invalid ISO8601 passed to parser.");let Q=$.substring(9);return $.includes("Z")||Q.includes("-")||Q.includes("+")?SX.tp(X.getUTCFullYear(),X.getUTCMonth()+1,X.getUTCDate(),X.getUTCHours(),X.getUTCMinutes(),X.getUTCSeconds(),"Etc/UTC"):SX.tp(X.getFullYear(),X.getMonth()+1,X.getDate(),X.getHours(),X.getMinutes(),X.getSeconds(),Z)}function Ya4($){if($===void 0&&($={}),delete $.name,$.legacyMode=$.legacyMode===void 0?!0:$.legacyMode,$.paused=$.paused===void 0?!1:$.paused,$.maxRuns=$.maxRuns===void 0?1/0:$.maxRuns,$.catch=$.catch===void 0?!1:$.catch,$.interval=$.interval===void 0?0:parseInt($.interval.toString(),10),$.utcOffset=$.utcOffset===void 0?void 0:parseInt($.utcOffset.toString(),10),$.unref=$.unref===void 0?!1:$.unref,$.startAt&&($.startAt=new r3($.startAt,$.timezone)),$.stopAt&&($.stopAt=new r3($.stopAt,$.timezone)),$.interval!==null){if(isNaN($.interval))throw Error("CronOptions: Supplied value for interval is not a number");if($.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if($.utcOffset!==void 0){if(isNaN($.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if($.utcOffset<-870||$.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if($.utcOffset!==void 0&&$.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if($.unref!==!0&&$.unref!==!1)throw Error("CronOptions: Unref should be either true, false or undefined(false).");return $}function ga($){return Object.prototype.toString.call($)==="[object Function]"||typeof $=="function"||$ instanceof Function}function Ga4($){return ga($)}function Ja4($){typeof Deno<"u"&&typeof Deno.unrefTimer<"u"?Deno.unrefTimer($):$&&typeof $.unref<"u"&&$.unref()}var QX1=32,ha,vx8,Sx8=class{pattern;timezone;second;minute;hour;day;month;dayOfWeek;lastDayOfMonth;starDOM;starDOW;constructor($,Z){this.pattern=$,this.timezone=Z,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.lastDayOfMonth=!1,this.starDOM=!1,this.starDOW=!1,this.parse()}parse(){if(!(typeof this.pattern=="string"||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let $=this.pattern.replace(/\s+/g," ").split(" ");if($.length<5||$.length>6)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five or six space separated parts are required.");if($.length===5&&$.unshift("0"),$[3].indexOf("L")>=0&&($[3]=$[3].replace("L",""),this.lastDayOfMonth=!0),$[3]=="*"&&(this.starDOM=!0),$[4].length>=3&&($[4]=this.replaceAlphaMonths($[4])),$[5].length>=3&&($[5]=this.replaceAlphaDays($[5])),$[5]=="*"&&(this.starDOW=!0),this.pattern.indexOf("?")>=0){let Z=new r3(new Date,this.timezone).getDate(!0);$[0]=$[0].replace("?",Z.getSeconds().toString()),$[1]=$[1].replace("?",Z.getMinutes().toString()),$[2]=$[2].replace("?",Z.getHours().toString()),this.starDOM||($[3]=$[3].replace("?",Z.getDate().toString())),$[4]=$[4].replace("?",(Z.getMonth()+1).toString()),this.starDOW||($[5]=$[5].replace("?",Z.getDay().toString()))}this.throwAtIllegalCharacters($),this.partToArray("second",$[0],0,1),this.partToArray("minute",$[1],0,1),this.partToArray("hour",$[2],0,1),this.partToArray("day",$[3],-1,1),this.partToArray("month",$[4],-1,1),this.partToArray("dayOfWeek",$[5],0,ha),this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray($,Z,X,Q){let Y=this[$],G=$==="day"&&this.lastDayOfMonth;if(Z===""&&!G)throw TypeError("CronPattern: configuration entry "+$+" ("+Z+") is empty, check for trailing spaces.");if(Z==="*")return Y.fill(Q);let J=Z.split(",");if(J.length>1)for(let K=0;K<J.length;K++)this.partToArray($,J[K],X,Q);else Z.indexOf("-")!==-1&&Z.indexOf("/")!==-1?this.handleRangeWithStepping(Z,$,X,Q):Z.indexOf("-")!==-1?this.handleRange(Z,$,X,Q):Z.indexOf("/")!==-1?this.handleStepping(Z,$,X,Q):Z!==""&&this.handleNumber(Z,$,X,Q)}throwAtIllegalCharacters($){for(let Z=0;Z<$.length;Z++)if((Z===5?/[^/*0-9,\-#L]+/:/[^/*0-9,-]+/).test($[Z]))throw TypeError("CronPattern: configuration entry "+Z+" ("+$[Z]+") contains illegal characters.")}handleNumber($,Z,X,Q){let Y=this.extractNth($,Z),G=parseInt(Y[0],10)+X;if(isNaN(G))throw TypeError("CronPattern: "+Z+" is not a number: '"+$+"'");this.setPart(Z,G,Y[1]||Q)}setPart($,Z,X){if(!Object.prototype.hasOwnProperty.call(this,$))throw TypeError("CronPattern: Invalid part specified: "+$);if($==="dayOfWeek"){if(Z===7&&(Z=0),Z<0||Z>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+Z);this.setNthWeekdayOfMonth(Z,X);return}if($==="second"||$==="minute"){if(Z<0||Z>=60)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="hour"){if(Z<0||Z>=24)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="day"){if(Z<0||Z>=31)throw RangeError("CronPattern: Invalid value for "+$+": "+Z)}else if($==="month"&&(Z<0||Z>=12))throw RangeError("CronPattern: Invalid value for "+$+": "+Z);this[$][Z]=X}handleRangeWithStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(G===null)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+$+"'");let[,J,K,W]=G,H=parseInt(J,10)+X,N=parseInt(K,10)+X,U=parseInt(W,10);if(isNaN(H))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(N))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(isNaN(U))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(U===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(U>this[Z].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[Z].length+")");if(H>N)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let F=H;F<=N;F+=U)this.setPart(Z,F,Y[1]||Q)}extractNth($,Z){let X=$,Q;if(X.includes("#")){if(Z!=="dayOfWeek")throw Error("CronPattern: nth (#) only allowed in day-of-week field");Q=X.split("#")[1],X=X.split("#")[0]}return[X,Q]}handleRange($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("-");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal range: '"+$+"'");let J=parseInt(G[0],10)+X,K=parseInt(G[1],10)+X;if(isNaN(J))throw TypeError("CronPattern: Syntax error, illegal lower range (NaN)");if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal upper range (NaN)");if(J>K)throw TypeError("CronPattern: From value is larger than to value: '"+$+"'");for(let W=J;W<=K;W++)this.setPart(Z,W,Y[1]||Q)}handleStepping($,Z,X,Q){let Y=this.extractNth($,Z),G=Y[0].split("/");if(G.length!==2)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+$+"'");G[0]===""&&(G[0]="*");let J=0;G[0]!=="*"&&(J=parseInt(G[0],10)+X);let K=parseInt(G[1],10);if(isNaN(K))throw TypeError("CronPattern: Syntax error, illegal stepping: (NaN)");if(K===0)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(K>this[Z].length)throw TypeError("CronPattern: Syntax error, max steps for part is ("+this[Z].length+")");for(let W=J;W<this[Z].length;W+=K)this.setPart(Z,W,Y[1]||Q)}replaceAlphaDays($){return $.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaMonths($){return $.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames($){let Z=$.trim().toLowerCase();return Z==="@yearly"||Z==="@annually"?"0 0 1 1 *":Z==="@monthly"?"0 0 1 * *":Z==="@weekly"?"0 0 * * 0":Z==="@daily"?"0 0 * * *":Z==="@hourly"?"0 * * * *":$}setNthWeekdayOfMonth($,Z){if(typeof Z!="number"&&Z==="L")this.dayOfWeek[$]=this.dayOfWeek[$]|QX1;else if(Z===ha)this.dayOfWeek[$]=ha;else if(Z<6&&Z>0)this.dayOfWeek[$]=this.dayOfWeek[$]|vx8[Z-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${Z}, Type: ${typeof Z}`)}},Cx8,BF,r3=class ${tz;ms;second;minute;hour;day;month;year;constructor(Z,X){if(this.tz=X,Z&&Z instanceof Date)if(!isNaN(Z))this.fromDate(Z);else throw TypeError("CronDate: Invalid date passed to CronDate constructor");else if(Z===void 0)this.fromDate(new Date);else if(Z&&typeof Z=="string")this.fromString(Z);else if(Z instanceof $)this.fromCronDate(Z);else throw TypeError("CronDate: Invalid type ("+typeof Z+") passed to CronDate constructor")}isNthWeekdayOfMonth(Z,X,Q,Y){let G=new Date(Date.UTC(Z,X,Q)).getUTCDay(),J=0;for(let K=1;K<=Q;K++)new Date(Date.UTC(Z,X,K)).getUTCDay()===G&&J++;if(Y&ha&&vx8[J-1]&Y)return!0;if(Y&QX1){let K=new Date(Date.UTC(Z,X+1,0)).getUTCDate();for(let W=Q+1;W<=K;W++)if(new Date(Date.UTC(Z,X,W)).getUTCDay()===G)return!1;return!0}return!1}fromDate(Z){if(this.tz!==void 0)if(typeof this.tz=="number")this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes()+this.tz,this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),this.apply();else{let X=SX.toTZ(Z,this.tz);this.ms=Z.getMilliseconds(),this.second=X.s,this.minute=X.i,this.hour=X.h,this.day=X.d,this.month=X.m-1,this.year=X.y}else this.ms=Z.getMilliseconds(),this.second=Z.getSeconds(),this.minute=Z.getMinutes(),this.hour=Z.getHours(),this.day=Z.getDate(),this.month=Z.getMonth(),this.year=Z.getFullYear()}fromCronDate(Z){this.tz=Z.tz,this.year=Z.year,this.month=Z.month,this.day=Z.day,this.hour=Z.hour,this.minute=Z.minute,this.second=Z.second,this.ms=Z.ms}apply(){if(this.month>11||this.day>Cx8[this.month]||this.hour>59||this.minute>59||this.second>59||this.hour<0||this.minute<0||this.second<0){let Z=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=Z.getUTCMilliseconds(),this.second=Z.getUTCSeconds(),this.minute=Z.getUTCMinutes(),this.hour=Z.getUTCHours(),this.day=Z.getUTCDate(),this.month=Z.getUTCMonth(),this.year=Z.getUTCFullYear(),!0}else return!1}fromString(Z){if(typeof this.tz=="number"){let X=SX.fromTZISO(Z);this.ms=X.getUTCMilliseconds(),this.second=X.getUTCSeconds(),this.minute=X.getUTCMinutes(),this.hour=X.getUTCHours(),this.day=X.getUTCDate(),this.month=X.getUTCMonth(),this.year=X.getUTCFullYear(),this.apply()}else return this.fromDate(SX.fromTZISO(Z,this.tz))}findNext(Z,X,Q,Y){let G=this[X],J;Q.lastDayOfMonth&&(this.month!==1?J=Cx8[this.month]:J=new Date(Date.UTC(this.year,this.month+1,0,0,0,0,0)).getUTCDate());let K=!Q.starDOW&&X=="day"?new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay():void 0;for(let W=this[X]+Y;W<Q[X].length;W++){let H=Q[X][W];if(X==="day"&&Q.lastDayOfMonth&&W-Y==J&&(H=1),X==="day"&&!Q.starDOW){let N=Q.dayOfWeek[(K+(W-Y-1))%7];if(N&&N&ha)N=this.isNthWeekdayOfMonth(this.year,this.month,W-Y,N)?1:0;else if(N)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${N}`);Z.legacyMode&&!Q.starDOM?H=H||N:H=H&&N}if(H)return this[X]=W-Y,G!==this[X]?2:1}return 3}recurse(Z,X,Q){let Y=this.findNext(X,BF[Q][0],Z,BF[Q][2]);if(Y>1){let G=Q+1;for(;G<BF.length;)this[BF[G][0]]=-BF[G][2],G++;if(Y===3)return this[BF[Q][1]]++,this[BF[Q][0]]=-BF[Q][2],this.apply(),this.recurse(Z,X,0);if(this.apply())return this.recurse(Z,X,Q-1)}return Q+=1,Q>=BF.length?this:this.year>=3000?null:this.recurse(Z,X,Q)}increment(Z,X,Q){return this.second+=X.interval!==void 0&&X.interval>1&&Q?X.interval:1,this.ms=0,this.apply(),this.recurse(Z,X,0)}getDate(Z){return Z||this.tz===void 0?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):typeof this.tz=="number"?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):SX.fromTZ(SX.tp(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}},_x8=30000,OT0,wT0=class{name;options;_states;fn;constructor($,Z,X){let Q,Y;if(ga(Z))Y=Z;else if(typeof Z=="object")Q=Z;else if(Z!==void 0)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(ga(X))Y=X;else if(typeof X=="object")Q=X;else if(X!==void 0)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=Q?.name,this.options=Ya4(Q),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:Q?Q.maxRuns:void 0,paused:Q?Q.paused:!1,pattern:new Sx8("* * * * *")},$&&($ instanceof Date||typeof $=="string"&&$.indexOf(":")>0)?this._states.once=new r3($,this.options.timezone||this.options.utcOffset):this._states.pattern=new Sx8($,this.options.timezone),this.name){if(OT0.find((G)=>G.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");OT0.push(this)}return Y!==void 0&&Ga4(Y)&&(this.fn=Y,this.schedule()),this}nextRun($){let Z=this._next($);return Z?Z.getDate(!1):null}nextRuns($,Z){this._states.maxRuns!==void 0&&$>this._states.maxRuns&&($=this._states.maxRuns);let X=[],Q=Z||this._states.currentRun||void 0;for(;$--&&(Q=this.nextRun(Q));)X.push(Q);return X}getPattern(){return this._states.pattern?this._states.pattern.pattern:void 0}isRunning(){let $=this.nextRun(this._states.currentRun),Z=!this._states.paused,X=this.fn!==void 0,Q=!this._states.kill;return Z&&X&&Q&&$!==null}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext($){let Z=this._next($);return Z?$ instanceof r3||$ instanceof Date?Z.getTime()-$.getTime():Z.getTime()-new r3($).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let $=OT0.indexOf(this);$>=0&&OT0.splice($,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule($){if($&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");$&&(this.fn=$);let Z=this.msToNext(),X=this.nextRun(this._states.currentRun);return Z==null||isNaN(Z)||X===null?this:(Z>_x8&&(Z=_x8),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(X),Z),this._states.currentTimeout&&this.options.unref&&Ja4(this._states.currentTimeout),this)}async _trigger($){if(this._states.blocking=!0,this._states.currentRun=new r3(void 0,this.options.timezone||this.options.utcOffset),this.options.catch)try{this.fn!==void 0&&await this.fn(this,this.options.context)}catch(Z){ga(this.options.catch)&&this.options.catch(Z,this)}else this.fn!==void 0&&await this.fn(this,this.options.context);this._states.previousRun=new r3($,this.options.timezone||this.options.utcOffset),this._states.blocking=!1}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger($){let Z=new Date,X=!this._states.paused&&Z.getTime()>=$.getTime(),Q=this._states.blocking&&this.options.protect;X&&!Q?(this._states.maxRuns!==void 0&&this._states.maxRuns--,this._trigger()):X&&Q&&ga(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next($){let Z=!!($||this._states.currentRun),X=!1;!$&&this.options.startAt&&this.options.interval&&([$,Z]=this._calculatePreviousRun($,Z),X=!$),$=new r3($,this.options.timezone||this.options.utcOffset),this.options.startAt&&$&&$.getTime()<this.options.startAt.getTime()&&($=this.options.startAt);let Q=this._states.once||new r3($,this.options.timezone||this.options.utcOffset);return!X&&Q!==this._states.once&&(Q=Q.increment(this._states.pattern,this.options,Z)),this._states.once&&this._states.once.getTime()<=$.getTime()||Q===null||this._states.maxRuns!==void 0&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&Q.getTime()>=this.options.stopAt.getTime()?null:Q}_calculatePreviousRun($,Z){let X=new r3(void 0,this.options.timezone||this.options.utcOffset),Q=$;if(this.options.startAt.getTime()<=X.getTime()){Q=this.options.startAt;let Y=Q.getTime()+this.options.interval*1000;for(;Y<=X.getTime();)Q=new r3(Q,this.options.timezone||this.options.utcOffset).increment(this._states.pattern,this.options,!0),Y=Q.getTime()+this.options.interval*1000;Z=!0}return Q===null&&(Q=void 0),[Q,Z]}};var YX1=w(()=>{SX.fromTZISO=($,Z,X)=>SX.fromTZ(Qa4($,Z),X);SX.fromTZ=function($,Z){let X=new Date(Date.UTC($.y,$.m-1,$.d,$.h,$.i,$.s)),Q=XX1($.tz,X),Y=new Date(X.getTime()-Q),G=XX1($.tz,Y);if(G-Q===0)return Y;{let J=new Date(X.getTime()-G),K=XX1($.tz,J);if(K-G===0)return J;if(!Z&&K-G>0)return J;if(Z)throw Error("Invalid date passed to fromTZ()");return Y}};SX.toTZ=function($,Z){let X=$.toLocaleString("en-US",{timeZone:Z}).replace(/[\u202f]/," "),Q=new Date(X);return{y:Q.getFullYear(),m:Q.getMonth()+1,d:Q.getDate(),h:Q.getHours(),i:Q.getMinutes(),s:Q.getSeconds(),tz:Z}};SX.tp=($,Z,X,Q,Y,G,J)=>({y:$,m:Z,d:X,h:Q,i:Y,s:G,tz:J});SX.minitz=SX;ha=31|QX1,vx8=[1,2,4,8,16],Cx8=[31,28,31,30,31,30,31,31,30,31,30,31],BF=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]];OT0=[]});function LT0($,Z){try{return new wT0($,{timezone:"UTC"}).nextRun(Z)??null}catch{return null}}var GX1=w(()=>{YX1()});import{DBOS as _7,SchedulerMode as Ka4}from"@dbos-inc/dbos-sdk";async function NX1($){try{let{rows:Z}=await $.query(`SELECT q.name FROM dbos.queues q
2866
2866
  WHERE q.name LIKE $1
2867
2867
  AND NOT EXISTS (
2868
2868
  SELECT 1 FROM dbos.workflow_status w