decocms 4.329.5 → 4.329.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/dist/client/assets/{AlertCircle-mN_-o_mQ.js → AlertCircle-DA1cEHVG.js} +1 -1
  2. package/dist/client/assets/{AreaChart-Bvt1hsm0.js → AreaChart-CXRdv0xx.js} +1 -1
  3. package/dist/client/assets/{ArrowLeft-TOd2y5eQ.js → ArrowLeft-Br9KqDZP.js} +1 -1
  4. package/dist/client/assets/{ArrowUp-D9BmQW3y.js → ArrowUp-TsmTWJjN.js} +1 -1
  5. package/dist/client/assets/{Check-DHPj8hLS.js → Check-grvRnT6d.js} +1 -1
  6. package/dist/client/assets/{CheckCircle-Bape6EQJ.js → CheckCircle-W70-Hp-u.js} +1 -1
  7. package/dist/client/assets/{ChevronRight-CNf6Y7s8.js → ChevronRight-gw9dm0MJ.js} +1 -1
  8. package/dist/client/assets/{ChevronSelectorVertical-BGG06THN.js → ChevronSelectorVertical-CZ_XnnrO.js} +1 -1
  9. package/dist/client/assets/{ChevronUp-DhEp0EVP.js → ChevronUp-DbYyUJ2c.js} +1 -1
  10. package/dist/client/assets/{Copy01-BM0WPlp9.js → Copy01-DC15dYeZ.js} +1 -1
  11. package/dist/client/assets/{CreditCard01-BcxIFS9C.js → CreditCard01-BQ448v1L.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-Bbr6RMTH.js → DotsVertical-DuImY45F.js} +1 -1
  13. package/dist/client/assets/{Download01-BP8_5nMI.js → Download01-C92aqGYG.js} +1 -1
  14. package/dist/client/assets/{ErrorBarContext-D1mkTlU7.js → ErrorBarContext-VF7KGcUm.js} +1 -1
  15. package/dist/client/assets/{Eye-B0Pd_ezn.js → Eye-BHvUcvRj.js} +1 -1
  16. package/dist/client/assets/{GitBranch01-ITA5wAsb.js → GitBranch01-5KhVbuOf.js} +1 -1
  17. package/dist/client/assets/{Globe01-CxD9oJyC.js → Globe01-B1lfl4nW.js} +1 -1
  18. package/dist/client/assets/{HardDrive-Bx3SgLl5.js → HardDrive-Bl2sm0P3.js} +1 -1
  19. package/dist/client/assets/{Image01-DkeWoTxv.js → Image01-BmysQdds.js} +1 -1
  20. package/dist/client/assets/{Key01-3XmA_FLZ.js → Key01-BHRixQVB.js} +1 -1
  21. package/dist/client/assets/{Link01-DBqTW3qG.js → Link01-pXyMJR2J.js} +1 -1
  22. package/dist/client/assets/{LinkExternal01-CDbttyHT.js → LinkExternal01-CqwZLC94.js} +1 -1
  23. package/dist/client/assets/{Monitor01-DxoPQwl_.js → Monitor01-VQD1wr6O.js} +1 -1
  24. package/dist/client/assets/{Package-BmmKpgLP.js → Package-D8xZrFk4.js} +1 -1
  25. package/dist/client/assets/{Palette-PDnTmDZk.js → Palette-Bo_A8ldC.js} +1 -1
  26. package/dist/client/assets/{Play-67XUCyKd.js → Play-CyYcbqou.js} +1 -1
  27. package/dist/client/assets/{Plus-BiE4uFsT.js → Plus-BIAtk7db.js} +1 -1
  28. package/dist/client/assets/{SearchMd-D9B5PGY2.js → SearchMd-D6yqdaba.js} +1 -1
  29. package/dist/client/assets/{Sector-Bx8Rm7Bx.js → Sector-CsxyX7hI.js} +1 -1
  30. package/dist/client/assets/{Settings02-D20k8vab.js → Settings02-Dmn9Uagb.js} +1 -1
  31. package/dist/client/assets/{Share07-mTYGTjnX.js → Share07-BUu5_15N.js} +1 -1
  32. package/dist/client/assets/{Shield01-Dh1KVvty.js → Shield01-B9JGpaTp.js} +1 -1
  33. package/dist/client/assets/{Stars01-PXW__m1z.js → Stars01-CWhfbfaB.js} +1 -1
  34. package/dist/client/assets/{Sun-CPXNGo67.js → Sun-DWLAV3m1.js} +1 -1
  35. package/dist/client/assets/{Tool01-DO3tFwrT.js → Tool01-Cy0ZGCil.js} +1 -1
  36. package/dist/client/assets/{Tool02-BsbxtGm_.js → Tool02-CSZTEjDX.js} +1 -1
  37. package/dist/client/assets/{Trash01-Dp51yqnn.js → Trash01-D1GpJcjK.js} +1 -1
  38. package/dist/client/assets/{TrendUp01-B5AMHutg.js → TrendUp01-CYPVBoFc.js} +1 -1
  39. package/dist/client/assets/{Upload01-BNUtlGr4.js → Upload01-BCzsausn.js} +1 -1
  40. package/dist/client/assets/{User01-Ct3vu-8e.js → User01-DpOHQvBN.js} +1 -1
  41. package/dist/client/assets/{UserSquare-BMU7ptkw.js → UserSquare-BncQsikh.js} +1 -1
  42. package/dist/client/assets/{Users01-BiGPt9OV.js → Users01-Di41qDP0.js} +1 -1
  43. package/dist/client/assets/{Users03-CtT9PMQy.js → Users03-DTortZ69.js} +1 -1
  44. package/dist/client/assets/{XCircle-CPujy2uw.js → XCircle-waBvJxuW.js} +1 -1
  45. package/dist/client/assets/{XClose-ydonzdQx.js → XClose-D87Tx9wT.js} +1 -1
  46. package/dist/client/assets/{Zap-Cff3TLsZ.js → Zap-Bz0lnET7.js} +1 -1
  47. package/dist/client/assets/{ZoomOut-Cyr7GMp8.js → ZoomOut-NYNe_Z4v.js} +1 -1
  48. package/dist/client/assets/{access-gate-CxbXElgc.js → access-gate-CrQA8sIX.js} +1 -1
  49. package/dist/client/assets/{agent-icon-D0nFNhxK.js → agent-icon-CUm4oB7y.js} +1 -1
  50. package/dist/client/assets/{agents-list-CWgCuNdA.js → agents-list-dztbB-Cw.js} +1 -1
  51. package/dist/client/assets/{ai-providers-B_1c2MUZ.js → ai-providers-B_bOEKQb.js} +1 -1
  52. package/dist/client/assets/{alert-DXRS4LlD.js → alert-6mjnov6H.js} +1 -1
  53. package/dist/client/assets/{alert-dialog-P0CuRl4b.js → alert-dialog-C51iVTPN.js} +1 -1
  54. package/dist/client/assets/{analytics-tab-C8Ml9hnf.js → analytics-tab-BncFpj4z.js} +1 -1
  55. package/dist/client/assets/{api-keys-BlbK2ztb.js → api-keys-BAAWPoda.js} +1 -1
  56. package/dist/client/assets/api-keys-HdPFDyhU.js +1 -0
  57. package/dist/client/assets/{app-editor-DNnqs-BT.js → app-editor-DR0tLRro.js} +1 -1
  58. package/dist/client/assets/{auth-BVp2xy53.js → auth-Bbv_i1Jo.js} +1 -1
  59. package/dist/client/assets/{auth-catchall-DNlKODhS.js → auth-catchall-C4qKgNYY.js} +1 -1
  60. package/dist/client/assets/{auth-entry-DBaEHAB5.js → auth-entry-DRIlfsP_.js} +1 -1
  61. package/dist/client/assets/{auth-split-layout-BhgIfBec.js → auth-split-layout-CC36faDL.js} +1 -1
  62. package/dist/client/assets/{authenticate-and-persist-oauth-BAd7rGHc.js → authenticate-and-persist-oauth-sBYdDIRi.js} +1 -1
  63. package/dist/client/assets/{automation-list-row-DlvHKPyj.js → automation-list-row-Hqe9OUun.js} +1 -1
  64. package/dist/client/assets/{automation-runs-CCVcrtR2.js → automation-runs-DLjirUtq.js} +1 -1
  65. package/dist/client/assets/automations-BDc7sMoE.js +1 -0
  66. package/dist/client/assets/{avatar-b8hndRPx.js → avatar-Cqr4rNtI.js} +1 -1
  67. package/dist/client/assets/{badge-BStsm_lg.js → badge-CdD_S6_J.js} +1 -1
  68. package/dist/client/assets/{block-document-CgPj5a7q.js → block-document-CwU9JWtH.js} +1 -1
  69. package/dist/client/assets/{breadcrumb-Bcg6Ab2L.js → breadcrumb-CGLwazRA.js} +1 -1
  70. package/dist/client/assets/{buckets-C0rDB5Al.js → buckets-CJn89MHy.js} +1 -1
  71. package/dist/client/assets/{bulk-category-panel-DN63hkby.js → bulk-category-panel-3QzafbMh.js} +1 -1
  72. package/dist/client/assets/{capability-load-error-DJ7cUT9Z.js → capability-load-error-DXzCDpxj.js} +1 -1
  73. package/dist/client/assets/{cards-DaQEzixK.js → cards-De2Tofte.js} +1 -1
  74. package/dist/client/assets/{category-editor-vpz2dWAT.js → category-editor-COqxAE1f.js} +1 -1
  75. package/dist/client/assets/{cdn-tab-BbmlviYg.js → cdn-tab-D_pbGC7l.js} +1 -1
  76. package/dist/client/assets/{chart-DHv_Afvm.js → chart-7R5tmwSB.js} +1 -1
  77. package/dist/client/assets/{chat-context-CsVVImtr.js → chat-context-CTC6stWi.js} +1 -1
  78. package/dist/client/assets/{checkbox-BSJHTjoV.js → checkbox-DtN6Dr54.js} +1 -1
  79. package/dist/client/assets/{choose-editor-CJmqYzFT.js → choose-editor-Blhw32Ri.js} +1 -1
  80. package/dist/client/assets/{cli-auth-success-BsTXHwdh.js → cli-auth-success-CeAzdEYA.js} +1 -1
  81. package/dist/client/assets/{client-icons-Dbh16KTh.js → client-icons-C1w3IsHJ.js} +1 -1
  82. package/dist/client/assets/{collection-detail-YcEc9PSs.js → collection-detail-BFl9ZukZ.js} +1 -1
  83. package/dist/client/assets/{collection-display-button-Dlv2uRSO.js → collection-display-button-Bzjk0jzF.js} +1 -1
  84. package/dist/client/assets/{collection-search-Nx8I1VWD.js → collection-search-CO09NGkg.js} +1 -1
  85. package/dist/client/assets/{collection-table-wrapper-DEUvwrm7.js → collection-table-wrapper-eg9oZGZn.js} +1 -1
  86. package/dist/client/assets/{collection-tabs-DkuVrlwj.js → collection-tabs-cr1701fJ.js} +1 -1
  87. package/dist/client/assets/{command-BQZNWnLl.js → command-A0s0uPHt.js} +1 -1
  88. package/dist/client/assets/{commerce-onboarding-D2RPtK_d.js → commerce-onboarding-DtsFghjm.js} +1 -1
  89. package/dist/client/assets/{connect-CqMi0Kj6.js → connect-DrXaw1w8.js} +1 -1
  90. package/dist/client/assets/{connect-layout-LGbISPTt.js → connect-layout-CrHWsBPn.js} +1 -1
  91. package/dist/client/assets/{connection-BKjGbuRp.js → connection-DFFOswZj.js} +1 -1
  92. package/dist/client/assets/{connection-card-CUDq88xM.js → connection-card-TaYo6pYl.js} +1 -1
  93. package/dist/client/assets/{connection-detail-PQGXGzTQ.js → connection-detail-BFvYx2p3.js} +1 -1
  94. package/dist/client/assets/{connection-form-helpers-j54kv39E.js → connection-form-helpers-CoIQo1Gb.js} +1 -1
  95. package/dist/client/assets/{connections-BIa_J0_x.js → connections-DW0Ud7Ns.js} +1 -1
  96. package/dist/client/assets/{create-organization-dialog-C0dAeHRr.js → create-organization-dialog-CY527eHC.js} +1 -1
  97. package/dist/client/assets/{decopilot-sse-pool-BJt1WWih.js → decopilot-sse-pool-DU0j98RE.js} +1 -1
  98. package/dist/client/assets/{dialog-CwR2ZkB1.js → dialog-1xIvEVWS.js} +1 -1
  99. package/dist/client/assets/{domain-settings-Ck9aohMU.js → domain-settings-CiOIlCwE.js} +1 -1
  100. package/dist/client/assets/{download-app-dialog-BSTfXNDN.js → download-app-dialog-CsPmnO0q.js} +1 -1
  101. package/dist/client/assets/{drawer-C4eE6wVo.js → drawer-C-pTdfTV.js} +1 -1
  102. package/dist/client/assets/{dropdown-menu-D1Dyu0Ie.js → dropdown-menu-Dm9zz_PI.js} +1 -1
  103. package/dist/client/assets/{e2e-tab-BKa3vgG1.js → e2e-tab-DAWapk18.js} +1 -1
  104. package/dist/client/assets/{editor-X_GwLxUe.js → editor-DuZZHVnS.js} +1 -1
  105. package/dist/client/assets/{empty-state-DweMZJTW.js → empty-state-CaQCn5yY.js} +1 -1
  106. package/dist/client/assets/{empty-state-BObNah86.js → empty-state-Z33ir3je.js} +1 -1
  107. package/dist/client/assets/{extract-connection-data-TVNJHOmc.js → extract-connection-data-C44EqyQK.js} +1 -1
  108. package/dist/client/assets/{file-explorer-BVlXTJHP.js → file-explorer-DQ8njhcM.js} +1 -1
  109. package/dist/client/assets/{file-type-icon-DFeVbUcK.js → file-type-icon-Dl9zrC0W.js} +1 -1
  110. package/dist/client/assets/{folder-icon-fliliFSE.js → folder-icon-DXofXja-.js} +1 -1
  111. package/dist/client/assets/{form-R-ND42yQ.js → form-DLHM0IAy.js} +1 -1
  112. package/dist/client/assets/{general-CbsMwCUF.js → general-D6rHAjlN.js} +1 -1
  113. package/dist/client/assets/{github-repo-picker-VVXQm56m.js → github-repo-picker-BIbCpUFZ.js} +1 -1
  114. package/dist/client/assets/{hooks-Chtya12g.js → hooks-Cv_l36vR.js} +1 -1
  115. package/dist/client/assets/{hosting-tab-yCo5MFnA.js → hosting-tab-DtuFDGvE.js} +1 -1
  116. package/dist/client/assets/{index-F3C6ps0B.js → index-BVvpVlYL.js} +1 -1
  117. package/dist/client/assets/{index-BPoFiAxf.js → index-BkljfHxy.js} +2 -2
  118. package/dist/client/assets/{index-T5aBTzrV.js → index-CRSJpMzc.js} +1 -1
  119. package/dist/client/assets/{index-EMRlgytw.js → index-CUyq5xp-.js} +1 -1
  120. package/dist/client/assets/{index-C9r1r2iD.js → index-Dh_lhfEM.js} +1 -1
  121. package/dist/client/assets/{index-C-iRRri3.js → index-Dm5mbx-j.js} +1 -1
  122. package/dist/client/assets/{index-B4S5w1-x.js → index-Dmu_jFDN.js} +1 -1
  123. package/dist/client/assets/{index-DFO8Hy2x.js → index-TRl02mXS.js} +6 -6
  124. package/dist/client/assets/{index-CZG_2YcM.js → index-fcQmErZ3.js} +1 -1
  125. package/dist/client/assets/{index-94aQRAaT.js → index-ldx_aeXw.js} +1 -1
  126. package/dist/client/assets/{index-redirect-wsAas5g2.js → index-redirect-B4WcqrST.js} +1 -1
  127. package/dist/client/assets/{infra-billing-DmphYAUU.js → infra-billing-CT4isBll.js} +1 -1
  128. package/dist/client/assets/{input-LsHd3z5Z.js → input-CYJ7J22n.js} +1 -1
  129. package/dist/client/assets/{integration-icon-BukX17Ja.js → integration-icon-kfJeGcu4.js} +1 -1
  130. package/dist/client/assets/{invite-member-dialog-CnDi6qyS.js → invite-member-dialog-CcDGSu2c.js} +1 -1
  131. package/dist/client/assets/{label-fGGyQxp5.js → label-BSeVlzkX.js} +1 -1
  132. package/dist/client/assets/{layout-CHbCwmYb.js → layout--aonA48-.js} +1 -1
  133. package/dist/client/assets/{login-C8TvcwaD.js → login-DbVueJaI.js} +1 -1
  134. package/dist/client/assets/{markdown-BKbOmMip.js → markdown-D7QuNT69.js} +1 -1
  135. package/dist/client/assets/{mcp-oauth-DTP_bedh.js → mcp-oauth-dGHhlLy0.js} +1 -1
  136. package/dist/client/assets/{members-m278wo7-.js → members-Bf8lcWZe.js} +1 -1
  137. package/dist/client/assets/{monaco-editor-BpbvUJwi.js → monaco-editor-CC-Sqg8F.js} +1 -1
  138. package/dist/client/assets/{monitoring-stats-row-BIfVwwYm.js → monitoring-stats-row-vacc3BYl.js} +1 -1
  139. package/dist/client/assets/{multi-select-BGEhYv6Q.js → multi-select-nRNpGGJY.js} +1 -1
  140. package/dist/client/assets/{oauth-callback-DNm5e3t4.js → oauth-callback-Ce0X_vqm.js} +1 -1
  141. package/dist/client/assets/{oauth-callback-ai-provider-C6wR7YHk.js → oauth-callback-ai-provider-BdyUwN3J.js} +1 -1
  142. package/dist/client/assets/{onboarding-D7MAN9sh.js → onboarding-SmWY9lBA.js} +1 -1
  143. package/dist/client/assets/org-layout-D0H1iAiF.js +1 -0
  144. package/dist/client/assets/{organization-choice-yFaS2KYn.js → organization-choice-C49clKoP.js} +1 -1
  145. package/dist/client/assets/{orgs-GzeWzw6o.js → orgs-CAjirR3W.js} +1 -1
  146. package/dist/client/assets/{page-seo-form-BlVNkW7I.js → page-seo-form-BGqqc2Gj.js} +1 -1
  147. package/dist/client/assets/{popover-Q1deFKgp.js → popover-mZ_x_ILZ.js} +1 -1
  148. package/dist/client/assets/{post-calendar-B09pnMW9.js → post-calendar-DM4--jD1.js} +1 -1
  149. package/dist/client/assets/{post-editor-DH3cc2rR.js → post-editor-GHkZtflO.js} +1 -1
  150. package/dist/client/assets/{primitives-0K9NGeUu.js → primitives-Bp0pnH9F.js} +1 -1
  151. package/dist/client/assets/{profile-BpvIbEub.js → profile-Dvj2Ky_G.js} +1 -1
  152. package/dist/client/assets/{project-app-view-BW8nEgoK.js → project-app-view-C5a0S8VK.js} +1 -1
  153. package/dist/client/assets/{project-icon-CW7lG0f-.js → project-icon-BBqdk5OE.js} +1 -1
  154. package/dist/client/assets/{prompts-BJn-p95i.js → prompts-Dr4JAnH0.js} +1 -1
  155. package/dist/client/assets/record-editor-2DwNqvUy.js +1 -0
  156. package/dist/client/assets/{redirect-editor-BI-Kllix.js → redirect-editor-Bat0o4y3.js} +1 -1
  157. package/dist/client/assets/registry--J_j_Iy0.js +2 -0
  158. package/dist/client/assets/{registry-layout-BP7gmPI-.js → registry-layout-DIey2mbB.js} +1 -1
  159. package/dist/client/assets/{reports-CAV2Cslk.js → reports-Bev3cmDf.js} +1 -1
  160. package/dist/client/assets/{require-capability-C5rDfjFm.js → require-capability-DOJ4tTFn.js} +1 -1
  161. package/dist/client/assets/{required-auth-layout-Geu1OAEe.js → required-auth-layout-B2tIP5k3.js} +1 -1
  162. package/dist/client/assets/{reset-password-DUIDurfe.js → reset-password-C4gYW7se.js} +1 -1
  163. package/dist/client/assets/{review-settings-CsiIDmFA.js → review-settings-BOZEVIl7.js} +1 -1
  164. package/dist/client/assets/{roles-BAD7kH_t.js → roles-cRWL1Za5.js} +1 -1
  165. package/dist/client/assets/{schema-D2aEo9_j.js → schema-BgSBbsw7.js} +1 -1
  166. package/dist/client/assets/{scroll-area-D_zmdKz7.js → scroll-area-0nfzfnAs.js} +1 -1
  167. package/dist/client/assets/{search-input-BizsLhvX.js → search-input-CIki-uxf.js} +1 -1
  168. package/dist/client/assets/{secrets-G0v2X3oa.js → secrets-D2e6phy9.js} +1 -1
  169. package/dist/client/assets/{sections-editor-CWq03Vnp.js → sections-editor-D-QRzAnK.js} +1 -1
  170. package/dist/client/assets/{select-BPlqzUpB.js → select-DqJyZyIQ.js} +1 -1
  171. package/dist/client/assets/{select-model-D5-IXAsH.js → select-model-BsGv2vyu.js} +1 -1
  172. package/dist/client/assets/{self-tool-result-CTIc9xGS.js → self-tool-result-BoZ6MFRP.js} +1 -1
  173. package/dist/client/assets/{seo-editor-O_gPOD8y.js → seo-editor-g6APT0uI.js} +1 -1
  174. package/dist/client/assets/settings-layout-CkbSimBL.js +1 -0
  175. package/dist/client/assets/{settings-sidebar-B8AwNjia.js → settings-sidebar-jSd5MSjq.js} +1 -1
  176. package/dist/client/assets/{shell-controls-DnZgBbdN.js → shell-controls-C4MO7deC.js} +1 -1
  177. package/dist/client/assets/{shell-layout-OBmJcmOt.js → shell-layout-tPdz54xh.js} +1 -1
  178. package/dist/client/assets/{skill-preview-mwAW0EFc.js → skill-preview-C-lpKGFK.js} +1 -1
  179. package/dist/client/assets/{skills-B4jG1i-v.js → skills-C_OSw6ZN.js} +1 -1
  180. package/dist/client/assets/{sso-DEIlxpGO.js → sso-BsFPpeYe.js} +1 -1
  181. package/dist/client/assets/{store-dJDoMR5j.js → store-qwASLyWC.js} +1 -1
  182. package/dist/client/assets/store-registry-cT643_3i.js +2 -0
  183. package/dist/client/assets/{switch-DbWQok_U.js → switch-CZqeYbje.js} +1 -1
  184. package/dist/client/assets/{synced-repos-BN345C03.js → synced-repos-ByBUacaY.js} +1 -1
  185. package/dist/client/assets/{table-DOif7xTO.js → table-DbdXafHS.js} +1 -1
  186. package/dist/client/assets/{tabs-B_MhFzq8.js → tabs-C9EAqZz9.js} +1 -1
  187. package/dist/client/assets/{task-board-CcPCmS8T.js → task-board-7HRng9a2.js} +1 -1
  188. package/dist/client/assets/{task-route-C4sr5u2Y.js → task-route-_ESOOTZi.js} +1 -1
  189. package/dist/client/assets/{tasks-DUn9MzS1.js → tasks-CxA4gPZJ.js} +1 -1
  190. package/dist/client/assets/{textarea-Cg093qVK.js → textarea-90AQXVh4.js} +1 -1
  191. package/dist/client/assets/{toggle-group-DR2FN9bK.js → toggle-group-Diuss92s.js} +1 -1
  192. package/dist/client/assets/{toolbar-BMJtXOZ8.js → toolbar-BWOWuYdi.js} +1 -1
  193. package/dist/client/assets/{toolbar-icon-button-j89gz31d.js → toolbar-icon-button-DnenepzG.js} +1 -1
  194. package/dist/client/assets/{track-CEYIUg92.js → track-Qcawd54k.js} +1 -1
  195. package/dist/client/assets/{types-CvaupNP5.js → types-B-HpXlbf.js} +1 -1
  196. package/dist/client/assets/{use-ai-providers-qSmDdlV5.js → use-ai-providers-CWtvyrT-.js} +1 -1
  197. package/dist/client/assets/{use-automations-BHUwCHCu.js → use-automations-D9Y9jZ0Z.js} +1 -1
  198. package/dist/client/assets/{use-autosave-B6xJm16y.js → use-autosave-DIT9IDbg.js} +1 -1
  199. package/dist/client/assets/{use-connection-DssDxszT.js → use-connection-Uyph_H8d.js} +1 -1
  200. package/dist/client/assets/{use-copy-DElZsO5o.js → use-copy-Cuzq782M.js} +1 -1
  201. package/dist/client/assets/{use-create-virtual-mcp-fX5KRaaa.js → use-create-virtual-mcp-D24xpy0o.js} +1 -1
  202. package/dist/client/assets/{use-debounced-autosave-MHpLopBx.js → use-debounced-autosave-DS1yKwxh.js} +1 -1
  203. package/dist/client/assets/{use-debounced-value-CfUze3fk.js → use-debounced-value-DJ0hN8gB.js} +1 -1
  204. package/dist/client/assets/{use-decopilot-events-BCTeDl9d.js → use-decopilot-events-Cm5dzSwF.js} +1 -1
  205. package/dist/client/assets/{use-delete-connection-CjblC6Ap.js → use-delete-connection-BKcL-J29.js} +1 -1
  206. package/dist/client/assets/{use-deployment-admin-i2vFl9gf.js → use-deployment-admin-BE2hLNuR.js} +1 -1
  207. package/dist/client/assets/{use-destination-route-BnzyxZK-.js → use-destination-route-DLsn9uXe.js} +1 -1
  208. package/dist/client/assets/{use-file-configs-DbhqGRsz.js → use-file-configs-CHDaFO85.js} +1 -1
  209. package/dist/client/assets/{use-infinite-scroll--JAy1jrF.js → use-infinite-scroll-Bj-_fMYw.js} +1 -1
  210. package/dist/client/assets/{use-join-requests-BmM24zP-.js → use-join-requests-Cu_2S_W2.js} +1 -1
  211. package/dist/client/assets/{use-mcp-auth-status-BWBUcCX_.js → use-mcp-auth-status-HMnG1EUf.js} +1 -1
  212. package/dist/client/assets/{use-mcp-client-r4Xv9xDe.js → use-mcp-client-Deaem8WO.js} +1 -1
  213. package/dist/client/assets/{use-mcp-prompts-BDT2dqpH.js → use-mcp-prompts-C5IrmXgS.js} +1 -1
  214. package/dist/client/assets/{use-members-BB0dVjBb.js → use-members-Cv__v2oz.js} +1 -1
  215. package/dist/client/assets/{use-navigate-to-agent-BAFEWvwz.js → use-navigate-to-agent-B-P_VAZF.js} +1 -1
  216. package/dist/client/assets/{use-org-auth-client-BhrDbDSV.js → use-org-auth-client-DWweu3ja.js} +1 -1
  217. package/dist/client/assets/{use-org-sso-CxgCZrTk.js → use-org-sso-CMfMnqpv.js} +1 -1
  218. package/dist/client/assets/{use-organization-roles-CDQDzA2S.js → use-organization-roles-BQmWc6DN.js} +1 -1
  219. package/dist/client/assets/{use-organization-settings-BZpxVSP5.js → use-organization-settings-CwdP6bUS.js} +1 -1
  220. package/dist/client/assets/{use-panel-navigate-Bqzu-m4-.js → use-panel-navigate-BRmpjsHj.js} +1 -1
  221. package/dist/client/assets/{use-registry-connections-BZ-aHAcc.js → use-registry-connections-CU4AWQn4.js} +1 -1
  222. package/dist/client/assets/{use-secrets-Bh_QiR6h.js → use-secrets--00GbFn8.js} +1 -1
  223. package/dist/client/assets/{use-section-preview-base-D_r7iT64.js → use-section-preview-base-CTx7wzR-.js} +1 -1
  224. package/dist/client/assets/{use-status-sounds-CNPhXYst.js → use-status-sounds-CkzzANKj.js} +1 -1
  225. package/dist/client/assets/{use-tags-CQrzK6kW.js → use-tags-k_sYBsNz.js} +1 -1
  226. package/dist/client/assets/{use-view-mode-PLD7Z8Gt.js → use-view-mode-3y5HyEBP.js} +1 -1
  227. package/dist/client/assets/{use-virtual-mcp-zpAtwz7v.js → use-virtual-mcp-12aBqy7V.js} +1 -1
  228. package/dist/client/assets/useInfiniteQuery-DiQVH8QR.js +1 -0
  229. package/dist/client/assets/useSuspenseInfiniteQuery-BMUPA2Dd.js +1 -0
  230. package/dist/client/assets/{users-BZQPvMd3.js → users-DjB8KCBh.js} +1 -1
  231. package/dist/client/assets/{variant-calendar-BGv44m4Q.js → variant-calendar-DaQkdUZ_.js} +1 -1
  232. package/dist/client/assets/{view-mode-toggle-CC6x-V9J.js → view-mode-toggle-WcHFJdKB.js} +1 -1
  233. package/dist/client/index.html +1 -1
  234. package/dist/server/cli.js +2 -2
  235. package/dist/server/server.js +2 -2
  236. package/package.json +1 -1
  237. package/dist/client/assets/api-keys-CwBd9UBU.js +0 -1
  238. package/dist/client/assets/automations-D0z1_feX.js +0 -1
  239. package/dist/client/assets/org-layout-D5JilW3M.js +0 -1
  240. package/dist/client/assets/record-editor-DNyePUjb.js +0 -1
  241. package/dist/client/assets/registry-Ft8pANng.js +0 -2
  242. package/dist/client/assets/settings-layout-CB8wJ9KB.js +0 -1
  243. package/dist/client/assets/store-registry-oLwveuwU.js +0 -2
  244. package/dist/client/assets/useInfiniteQuery-BkZl1y7Z.js +0 -1
  245. package/dist/client/assets/useSuspenseInfiniteQuery-w4-apbuy.js +0 -1
@@ -1545,7 +1545,7 @@ Usage: deco services <up|down|status>`),process.exit(1)}}var mn1=L(()=>{Eb()});f
1545
1545
  `.execute($);if(Number(W.rows[0]?.cnt)===0){console.warn(`Failed to migrate ${J}/${K}, keeping in old table`);continue}}await dy`
1546
1546
  DELETE FROM kysely_migration WHERE name = ${Q}
1547
1547
  `.execute($)}}async function ts1($){await I04($),await q04($);let Z=new ps1({db:$,provider:{getMigrations:()=>Promise.resolve(vn0)}}),{error:Q,results:X}=await Z.migrateToLatest(),Y=0;if(X?.forEach((G)=>{if(G.status==="Success")Y++;else if(G.status==="Error")console.error(`Failed to execute migration "${G.migrationName}"`)}),Q)throw console.error("Failed to migrate"),console.error(Q),Q;return Y}async function M04($){let{keepOpen:Z=!1,database:Q,skipBetterAuth:X=!1}=$??{},Y="skipped";if(!X&&!Q)Y=await zm0();let G=Q??c$(),J=async()=>{if(!Z&&!Q)await NO(G).catch((K)=>{console.warn("Warning: Error closing database:",K)})};try{let K=await ts1(G.db);return await J(),{betterAuth:Y,kysely:K}}catch(K){throw await J(),K}}async function V04(){let $=c$(),Z=new ps1({db:$.db,provider:{getMigrations:()=>Promise.resolve(vn0)}}),{error:Q,results:X}=await Z.migrateDown();if(X?.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}"`)}),Q)throw console.error("Failed to rollback migration"),console.error(Q),Q}var rs1=L(()=>{is1();Pm0();WQ()});async function h70($){let Z={...process.env},Q=C80($,Z);console.log(iE1(Q.settings.encryptionKey));let X=Q.settings.betterAuthSecret||(Q.settings.localMode?Po1(Q.settings.dataDir):""),{ensureServices:Y}=await Promise.resolve().then(() => (mZ0(),lZ0)),{outputs:G,services:J}=await Y({home:Q.settings.dataDir,externalDatabaseUrl:Q.externalDatabaseUrl,externalNatsUrl:Q.externalNatsUrl});if(!Q.skipMigrations){let{migrateBetterAuth:W}=await Promise.resolve().then(() => (Pm0(),To1));await W(G.databaseUrl);let{createDatabase:H}=await Promise.resolve().then(() => (WQ(),ht1)),{migrateToLatest:F}=await Promise.resolve().then(() => (rs1(),os1)),U=H(G.databaseUrl);await F({keepOpen:!0,database:U,skipBetterAuth:!0})}let K={...Q.settings,betterAuthSecret:X,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}:{}};return dn1(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 xn0=L(()=>{Eb();Ao1();j$()});var $e1={};s($e1,{updateService:()=>Yj,subscribeCliState:()=>yn0,setTuiConsoleIntercepted:()=>u70,setServerUrl:()=>yp,setMigrationsDone:()=>bp,setDevMode:()=>S04,resetCliStateForTests:()=>k04,isTuiConsoleIntercepted:()=>c70,getCliState:()=>bn0,addLogEntry:()=>jO});function as1(){return[{name:"Postgres",status:"pending",port:0},{name:"NATS",status:"pending",port:0}]}function ss1(){return{services:as1(),migrationsStatus:"pending",serverUrl:null,logs:[]}}function k04(){oX=ss1()}function fp(){for(let $ of fn0)$()}function bn0(){return oX}function yn0($){return fn0.add($),()=>fn0.delete($)}function Yj($){oX={...oX,services:oX.services.map((Z)=>Z.name===$.name?$:Z)},fp()}function bp(){oX={...oX,migrationsStatus:"done"},fp()}function yp($){oX={...oX,serverUrl:$},fp()}function jO($){let Z=[...oX.logs,$];oX={...oX,logs:Z.length>500?Z.slice(-500):Z},fp()}function S04(){oX={...oX,services:[...as1(),{name:"API",status:"pending",port:0},{name:"Vite",status:"pending",port:0}]},fp()}function u70($){es1=$}function c70(){return es1}var oX,fn0,es1=!1;var Gj=L(()=>{oX=ss1();fn0=new Set});import{createServer as Ze1}from"net";function C04($){return new Promise((Z)=>{let Q=Ze1();Q.once("error",()=>Z(!1)),Q.listen($,"0.0.0.0",()=>{Q.close(()=>Z(!0))})})}async function gp($){if(await C04($))return $;let Z=await new Promise((Q,X)=>{let Y=Ze1();Y.once("error",X),Y.listen(0,"0.0.0.0",()=>{let G=Y.address(),J=typeof G==="object"&&G?G.port:0;Y.close(()=>Q(J))})});return console.warn(`Port ${$} is in use, using port ${Z} instead.`),Z}var gn0=()=>{};var un0={};s(un0,{startDevServer:()=>v04,pipeToLogStore:()=>hn0});import{join as _04}from"path";function hn0($){let Z=$.getReader(),Q=new TextDecoder,X="";function Y(){let G=X.split(`
1548
- `);X=G.pop()??"";for(let J of G){let K=Bun.stripANSI(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;jO({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{try{for(;;){let{done:G,value:J}=await Z.read();if(G)break;X+=Q.decode(J,{stream:!0}),Y()}}catch{}if(X.trim()){let G=Bun.stripANSI(X).replace(/^\[\d+\]\s*/,"").trim();if(G)jO({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function v04($){let{baseUrl:Z,noTui:Q}=$,X=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=X?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=X?await gp(Number(Y)+1):await gp(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await h70({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let D of W)Yj({name:D.name,status:"ready",port:D.port});bp();let F=_04(import.meta.dir,"..","..","..","..",".."),U=Q===!0,N=Bun.spawn(["bun","run","dev:servers"],{cwd:F,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.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}},stdio:["inherit",U?"inherit":"pipe",U?"inherit":"pipe"]});if(!U)hn0(N.stdout),hn0(N.stderr);yp(G),Yj({name:"Vite",status:"ready",port:Number(Y)}),Yj({name:"API",status:"ready",port:Number(K.port)});let O=async(D)=>{if(N.kill(D),await N.exited,H.length>0){let{stopServices:w}=await Promise.resolve().then(() => (mZ0(),lZ0));await w(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:N}}var cn0=L(()=>{xn0();Gj();gn0()});var l70;var ln0=L(()=>{l70={name:"decocms",version:"4.329.5",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","@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 f04,Text as Qe1}from"ink";import{jsx as b04,jsxs as Xe1}from"react/jsx-runtime";function Ye1({version:$}){return Xe1(f04,{flexDirection:"column",marginTop:1,children:[N70.map((Z,Q)=>b04(Qe1,{color:B70[Q],children:Z},Q)),Xe1(Qe1,{dimColor:!0,children:[" v",$]})]})}var Ge1=L(()=>{Tp()});import{Box as Jj,Text as zO}from"ink";import{Spinner as y04}from"@inkjs/ui";import{jsx as UG,jsxs as iy}from"react/jsx-runtime";function Je1({status:$}){if($==="pending")return UG(y04,{label:""});return UG(zO,{color:"green",children:"\u2713"})}function g04($){return`${$.name}: ${$.port||"...."}`}function Ke1({services:$,migrationsStatus:Z,home:Q,serverUrl:X}){return iy(Jj,{flexDirection:"column",paddingBottom:1,children:[UG(Ye1,{version:l70.version}),UG(Jj,{marginBottom:1,children:UG(zO,{dimColor:!0,children:"\u2500".repeat(80)})}),UG(Jj,{children:iy(zO,{dimColor:!0,children:["Home: ",Q]})}),iy(Jj,{gap:2,children:[$.map((Y)=>iy(Jj,{gap:1,children:[UG(zO,{children:g04(Y)}),UG(Je1,{status:Y.status})]},Y.name)),iy(Jj,{gap:1,children:[UG(zO,{children:"Migrations"}),UG(Je1,{status:Z})]})]}),UG(Jj,{children:X?iy(zO,{children:["Open in browser: ",UG(zO,{color:"cyan",children:X})]}):UG(zO,{dimColor:!0,children:"Starting..."})})]})}var We1=L(()=>{ln0();Ge1()});import{Box as h04,Text as hp}from"ink";import{jsx as mn0,jsxs as dn0}from"react/jsx-runtime";function u04($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function He1({logs:$}){return mn0(h04,{flexDirection:"column",children:$.map((Z,Q)=>{if(Z.rawLine)return mn0(hp,{dimColor:!0,children:Z.rawLine},Q);let X=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return dn0(hp,{children:[dn0(hp,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),mn0(hp,{color:u04(Z.status),children:Z.status}),dn0(hp,{dimColor:!0,children:[" ",X.padStart(8)]})]},Q)})})}var Fe1=()=>{};var in0={};s(in0,{App:()=>m04});import{Box as c04}from"ink";import{useSyncExternalStore as l04}from"react";import{jsx as Ue1,jsxs as d04}from"react/jsx-runtime";function m04({home:$}){let Z=l04(yn0,bn0);return d04(c04,{flexDirection:"column",children:[Ue1(Ke1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),Ue1(He1,{logs:Z.logs})]})}var pn0=L(()=>{We1();Fe1();Gj()});var a3="thread-gate",RU="decopilot-hosted-harness",IU="decopilot-hosted-harness-sandboxed",MJ="automations",PO="background-tools",Kj="task-board-github-reads";var Ne1="11";function Be1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:Ne1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var Oe1=()=>{};import i04 from"pg";async function De1($,Z){let{databaseUrl:Q,lockTimeoutMs:X=p04}=$,Y=$.log??((W)=>console.log(W)),G=new i04.Client({connectionString:Q});await G.connect();let J=Date.now(),K=!1;try{while(!K){if(K=(await G.query("SELECT pg_try_advisory_lock($1) AS locked",[Le1.toString()])).rows[0]?.locked===!0,K)break;if(Date.now()-J>=X)throw Error(`Timed out after ${X}ms waiting for the DBOS migration lock. Another process is still migrating the dbos schema; this pod will restart and retry.`);await F$(n04)}let W=Date.now()-J;if(W>1000)Y(`[dbos] waited ${W}ms for the migration lock; another process migrated first`);return await Z()}finally{if(K)try{await G.query("SELECT pg_advisory_unlock($1)",[Le1.toString()])}catch{}await G.end().catch(()=>{})}}var Le1=8314027461559302n,p04=600000,n04=500;var we1=L(()=>{t8()});function t04(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function nn0($,Z){for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X===void 0)continue;if(X===Z)return $[Q+1];if(X.startsWith(`${Z}=`))return X.slice(Z.length+1)}return}function Ee1(){let $=t04();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:nn0($,"--cpu-prof-dir")??process.cwd(),name:nn0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(nn0($,"--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 je1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let Q=$j();if(!Q)return;let X={};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);X={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:Q.rss,heapUsed:Q.heapUsed,heapTotal:Q.heapTotal,external:Q.external,arrayBuffers:Q.arrayBuffers,...X}))};return Z().catch(()=>{}),m70=setInterval(()=>void Z().catch(()=>{}),$),m70.unref?.(),process.on("SIGUSR2",()=>{try{let Q=Bun.generateHeapSnapshot("v8"),X=typeof Q==="string"?Q:JSON.stringify(Q),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,X),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(Q){console.error("[heap-watch] snapshot failed:",Q)}}),()=>{if(m70)clearInterval(m70)}}var m70;var ze1=()=>{};import*as o04 from"bun:jsc";function Pe1(){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{r04()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let Q,X=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-X;X=G+Z;let K=[];try{K=a04()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let F of K){let U=F.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??F.frames[0];if(!U)continue;let N=(U.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${U.name??"?"} @ ${N}:${U.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((F,U)=>U[1]-F[1]).slice(0,8).map(([F,U])=>({frame:F,count:U}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}Q=setTimeout(Y,Z),Q.unref?.()};return Q=setTimeout(Y,Z),Q.unref?.(),()=>{if(Q)clearTimeout(Q)}}var r04,a04;var Ae1=L(()=>{({startSamplingProfiler:r04,samplingProfilerStackTraces:a04}=o04)});function Te1(){Ee1();let $=[je1(),Ct1(),Pe1()];return()=>{for(let Z of $)Z()}}var Re1=L(()=>{Um0();ze1();Ae1()});var Wj=v((Ie1)=>{Object.defineProperty(Ie1,"__esModule",{value:!0});Ie1.RepublishHeaders=Ie1.DirectMsgHeaders=Ie1.JsHeaders=Ie1.AdvisoryKind=void 0;Ie1.isOrderedPushConsumerOptions=s04;Ie1.isPullConsumer=e04;Ie1.isPushConsumer=$14;Ie1.isBoundPushConsumerOptions=Z14;function s04($){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 e04($){return $.isPullConsumer()}function $14($){return $.isPushConsumer()}function Z14($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}Ie1.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"};Ie1.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"};Ie1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};Ie1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var NG=v((Me1)=>{Object.defineProperty(Me1,"__esModule",{value:!0});Me1.TD=Me1.TE=Me1.Empty=void 0;Me1.encode=F14;Me1.decode=U14;Me1.Empty=new Uint8Array(0);Me1.TE=new TextEncoder;Me1.TD=new TextDecoder;function H14(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let Q=new Uint8Array(Z),X=0;for(let Y=0;Y<$.length;Y++)Q.set($[Y],X),X+=$[Y].length;return Q}function F14(...$){let Z=[];for(let Q=0;Q<$.length;Q++)Z.push(Me1.TE.encode($[Q]));if(Z.length===0)return Me1.Empty;if(Z.length===1)return Z[0];return H14(...Z)}function U14($){if(!$||$.length===0)return"";return Me1.TD.decode($)}});var BG=v((Se1)=>{Object.defineProperty(Se1,"__esModule",{value:!0});Se1.errors=Se1.PermissionViolationError=Se1.NoRespondersError=Se1.TimeoutError=Se1.RequestError=Se1.ProtocolError=Se1.ConnectionError=Se1.DrainingConnectionError=Se1.ClosedConnectionError=Se1.AuthorizationError=Se1.UserAuthenticationExpiredError=Se1.InvalidOperationError=Se1.InvalidArgumentError=Se1.InvalidSubjectError=void 0;class on0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}Se1.InvalidSubjectError=on0;class d70 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,Q){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((X)=>`'${X}'`),$=$.join(",");else $=`'${$}'`;return new d70(`${$} ${Z}`,Q)}}Se1.InvalidArgumentError=d70;class rn0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}Se1.InvalidOperationError=rn0;class i70 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new i70($);return null}}Se1.UserAuthenticationExpiredError=i70;class p70 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],Q=$.toLowerCase();for(let X=0;X<Z.length;X++)if(Q.indexOf(Z[X])!==-1)return new p70($);return null}}Se1.AuthorizationError=p70;class an0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}Se1.ClosedConnectionError=an0;class sn0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}Se1.DrainingConnectionError=sn0;class en0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}Se1.ConnectionError=en0;class $t0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}Se1.ProtocolError=$t0;class Zt0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof n70}}Se1.RequestError=Zt0;class Qt0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}Se1.TimeoutError=Qt0;class n70 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}Se1.NoRespondersError=n70;class t70 extends Error{operation;subject;queue;constructor($,Z,Q,X,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=Q,this.queue=X}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let Q="publish",X="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(Q=G[1].toLowerCase(),X=G[2],Q==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new t70($,Q,X,Y)}}Se1.PermissionViolationError=t70;Se1.errors={AuthorizationError:p70,ClosedConnectionError:an0,ConnectionError:en0,DrainingConnectionError:sn0,InvalidArgumentError:d70,InvalidOperationError:rn0,InvalidSubjectError:on0,NoRespondersError:n70,PermissionViolationError:t70,ProtocolError:$t0,RequestError:Zt0,TimeoutError:Qt0,UserAuthenticationExpiredError:i70}});var s3=v((fe1)=>{Object.defineProperty(fe1,"__esModule",{value:!0});fe1.SimpleMutex=fe1.Perf=void 0;fe1.extend=V14;fe1.render=k14;fe1.timeout=S14;fe1.delay=C14;fe1.deadline=_14;fe1.deferred=Yt0;fe1.debugDeferred=v14;fe1.shuffle=x14;fe1.collect=f14;fe1.jitter=xe1;fe1.backoff=b14;fe1.nanos=y14;fe1.millis=g14;fe1.randomToken=c14;var M14=NG(),Xt0=BG();function V14($,...Z){for(let Q=0;Q<Z.length;Q++){let X=Z[Q];Object.keys(X).forEach(function(Y){$[Y]=X[Y]})}return $}function k14($){return M14.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function S14($,Z=!0){let Q=Z?new Xt0.TimeoutError:null,X,Y,G=new Promise((J,K)=>{X={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(Q===null)K(new Xt0.TimeoutError);else K(Q)},$)});return Object.assign(G,X)}function C14($=0){let Z,Q=new Promise((X)=>{let Y=setTimeout(()=>{X()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),X()}}});return Object.assign(Q,Z)}async function _14($,Z=1000){let Q=Yt0(),X=setTimeout(()=>{Q.reject(new Xt0.TimeoutError)},Z);try{return await Promise.race([$,Q])}finally{clearTimeout(X)}}function Yt0(){let $={},Z=new Promise((Q,X)=>{$={resolve:Q,reject:X}});return Object.assign(Z,$)}function v14(){let $={},Z=new Promise((Q,X)=>{$={resolve:(Y)=>{console.trace("resolve",Y),Q(Y)},reject:(Y)=>{console.trace("reject"),X(Y)}}});return Object.assign(Z,$)}function x14($){for(let Z=$.length-1;Z>0;Z--){let Q=Math.floor(Math.random()*(Z+1));[$[Z],$[Q]]=[$[Q],$[Z]]}return $}async function f14($){let Z=[];for await(let Q of $)Z.push(Q);return Z}class _e1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,Q){let X=this.timers.get(Z);if(X===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(Q);if(Y===void 0)throw Error(`${Q} is not defined`);this.measures.set($,Y-X)}getEntries(){let $=[];return this.measures.forEach((Z,Q)=>{$.push({name:Q,duration:Z})}),$}}fe1.Perf=_e1;class ve1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=Yt0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}fe1.SimpleMutex=ve1;function xe1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function b14($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(Q){return xe1(Q>Z?$[Z]:$[Q])}}}function y14($){return $*1e6}function g14($){return Math.floor($/1e6)}var h14="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",qU=new Uint8Array(62);for(let $=0;$<62;$++)qU[$]=h14.charCodeAt($);var u14=218340105584896;function c14(){let $=Math.floor(Math.random()*u14),Z=$%62,Q=qU[Z];$=($-Z)/62,Z=$%62;let X=qU[Z];$=($-Z)/62,Z=$%62;let Y=qU[Z];$=($-Z)/62,Z=$%62;let G=qU[Z];$=($-Z)/62,Z=$%62;let J=qU[Z];$=($-Z)/62,Z=$%62;let K=qU[Z];$=($-Z)/62,Z=$%62;let W=qU[Z];$=($-Z)/62;let H=qU[$];return String.fromCharCode(Q,X,Y,G,J,K,W,H)}});var me1=v((ce1)=>{Object.defineProperty(ce1,"__esModule",{value:!0});ce1.nuid=ce1.NuidImpl=void 0;var X$4="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",AO=62,r70=12,he1=10,ye1=33,Y$4=333,ge1=r70+he1,Jt0=new Uint8Array(AO);for(let $=0;$<AO;$++)Jt0[$]=X$4.charCodeAt($);var o70=4294967296,ue1=BigInt(AO)**BigInt(he1),up=Number(ue1/(1n<<32n)),Gt0=Number(ue1%(1n<<32n));function G$4($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function J$4($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else G$4($)}class Kt0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(ge1),this.cbuf=new Uint8Array(r70),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(up+1)),this.seqLo=Math.floor(Math.random()*o70);while($++<8&&this.seqHi===up&&this.seqLo>=Gt0);if(this.seqHi===up&&this.seqLo>=Gt0)this.seqLo=0;this.inc=Math.random()*(Y$4-ye1)+ye1|0}setPre(){J$4(this.cbuf);for(let $=0;$<r70;$++)this.buf[$]=Jt0[this.cbuf[$]%AO]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let Q=ge1-1;Q>=r70;Q--){let X=Math.floor($/AO),G=($-X*AO)*o70+Z,J=Math.floor(G/AO),K=G-J*AO;this.buf[Q]=Jt0[K],$=X,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=o70)this.seqLo-=o70,this.seqHi+=1;if(this.seqHi>up||this.seqHi===up&&this.seqLo>=Gt0)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()}}ce1.NuidImpl=Kt0;ce1.nuid=new Kt0});var ne1=v((ie1)=>{Object.defineProperty(ie1,"__esModule",{value:!0});ie1.nuid=ie1.Nuid=void 0;var de1=me1();ie1.Nuid=de1.NuidImpl;ie1.nuid=de1.nuid});var s70=v((a70)=>{Object.defineProperty(a70,"__esModule",{value:!0});a70.nuid=a70.Nuid=void 0;var te1=ne1();Object.defineProperty(a70,"Nuid",{enumerable:!0,get:function(){return te1.Nuid}});Object.defineProperty(a70,"nuid",{enumerable:!0,get:function(){return te1.nuid}})});var TO=v((oe1)=>{Object.defineProperty(oe1,"__esModule",{value:!0});oe1.DEFAULT_HOST=oe1.DEFAULT_PORT=oe1.Match=void 0;oe1.syncIterator=N$4;oe1.createInbox=B$4;var F$4=s70(),U$4=BG();oe1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function N$4($){let Z=$[Symbol.asyncIterator]();return{async next(){let Q=await Z.next();if(Q.done)return Promise.resolve(null);return Promise.resolve(Q.value)}}}function B$4($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw U$4.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${F$4.nuid.next()}`}oe1.DEFAULT_PORT=4222;oe1.DEFAULT_HOST="127.0.0.1"});var cp=v((ee1)=>{Object.defineProperty(ee1,"__esModule",{value:!0});ee1.DataBuffer=void 0;var ae1=NG();class se1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let Q=new Uint8Array(Z),X=0;for(let Y=0;Y<$.length;Y++)Q.set($[Y],X),X+=$[Y].length;return Q}static fromAscii($){if(!$)$="";return ae1.TE.encode($)}static toAscii($){return ae1.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 Q=0;Q<this.buffers.length;Q++)$.set(this.buffers[Q],Z),Z+=this.buffers[Q].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 Q=this.byteLength;if($===void 0||$>Q)$=Q;let X=Z.subarray(0,$);if(Q>$)this.buffers.push(Z.subarray($));return this.byteLength=Q-$,X}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let Q=0;Q<Z.length;Q++)if(Z[Q]&&Z[Q].length)this.buffers.push(Z[Q]),this.byteLength+=Z[Q].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}}ee1.DataBuffer=se1});var Hj=v((Q0$)=>{Object.defineProperty(Q0$,"__esModule",{value:!0});Q0$.LF=Q0$.CR=Q0$.CRLF=Q0$.CR_LF_LEN=Q0$.CR_LF=void 0;Q0$.setTransportFactory=P$4;Q0$.defaultPort=A$4;Q0$.getUrlParseFn=T$4;Q0$.newTransport=R$4;Q0$.getResolveFn=I$4;Q0$.protoLen=Z0$;Q0$.extractProtocolMessage=q$4;var E$4=NG(),j$4=TO(),z$4=cp(),OG;function P$4($){OG=$}function A$4(){return OG!==void 0&&OG.defaultPort!==void 0?OG.defaultPort:j$4.DEFAULT_PORT}function T$4(){return OG!==void 0&&OG.urlParseFn?OG.urlParseFn:void 0}function R$4(){if(!OG||typeof OG.factory!=="function")throw Error("transport fn is not set");return OG.factory()}function I$4(){return OG!==void 0&&OG.dnsResolveFn?OG.dnsResolveFn:void 0}Q0$.CR_LF=`\r
1548
+ `);X=G.pop()??"";for(let J of G){let K=Bun.stripANSI(J).replace(/^\[\d+\]\s*/,"").trim();if(!K)continue;jO({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:K})}}(async()=>{try{for(;;){let{done:G,value:J}=await Z.read();if(G)break;X+=Q.decode(J,{stream:!0}),Y()}}catch{}if(X.trim()){let G=Bun.stripANSI(X).replace(/^\[\d+\]\s*/,"").trim();if(G)jO({method:"",path:"",status:0,duration:0,timestamp:new Date,rawLine:G})}})()}async function v04($){let{baseUrl:Z,noTui:Q}=$,X=process.env.HOST==="0.0.0.0"&&Boolean(process.env.PORT),Y=X?process.env.PORT:$.vitePort,G=Z||`http://localhost:${Y}`,J=X?await gp(Number(Y)+1):await gp(Number($.port)),{settings:K,services:W,managedServiceNames:H}=await h70({port:String(J),home:$.home,baseUrl:$.baseUrl,localMode:$.localMode,skipMigrations:$.skipMigrations,noTui:$.noTui,vitePort:$.vitePort});for(let D of W)Yj({name:D.name,status:"ready",port:D.port});bp();let F=_04(import.meta.dir,"..","..","..","..",".."),U=Q===!0,N=Bun.spawn(["bun","run","dev:servers"],{cwd:F,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.natsCredsPath?{NATS_CREDS:K.natsCredsPath}:{}},stdio:["inherit",U?"inherit":"pipe",U?"inherit":"pipe"]});if(!U)hn0(N.stdout),hn0(N.stderr);yp(G),Yj({name:"Vite",status:"ready",port:Number(Y)}),Yj({name:"API",status:"ready",port:Number(K.port)});let O=async(D)=>{if(N.kill(D),await N.exited,H.length>0){let{stopServices:w}=await Promise.resolve().then(() => (mZ0(),lZ0));await w(K.dataDir)}};return process.on("SIGINT",()=>O("SIGINT")),process.on("SIGTERM",()=>O("SIGTERM")),{port:Number(Y),process:N}}var cn0=L(()=>{xn0();Gj();gn0()});var l70;var ln0=L(()=>{l70={name:"decocms",version:"4.329.6",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","@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 f04,Text as Qe1}from"ink";import{jsx as b04,jsxs as Xe1}from"react/jsx-runtime";function Ye1({version:$}){return Xe1(f04,{flexDirection:"column",marginTop:1,children:[N70.map((Z,Q)=>b04(Qe1,{color:B70[Q],children:Z},Q)),Xe1(Qe1,{dimColor:!0,children:[" v",$]})]})}var Ge1=L(()=>{Tp()});import{Box as Jj,Text as zO}from"ink";import{Spinner as y04}from"@inkjs/ui";import{jsx as UG,jsxs as iy}from"react/jsx-runtime";function Je1({status:$}){if($==="pending")return UG(y04,{label:""});return UG(zO,{color:"green",children:"\u2713"})}function g04($){return`${$.name}: ${$.port||"...."}`}function Ke1({services:$,migrationsStatus:Z,home:Q,serverUrl:X}){return iy(Jj,{flexDirection:"column",paddingBottom:1,children:[UG(Ye1,{version:l70.version}),UG(Jj,{marginBottom:1,children:UG(zO,{dimColor:!0,children:"\u2500".repeat(80)})}),UG(Jj,{children:iy(zO,{dimColor:!0,children:["Home: ",Q]})}),iy(Jj,{gap:2,children:[$.map((Y)=>iy(Jj,{gap:1,children:[UG(zO,{children:g04(Y)}),UG(Je1,{status:Y.status})]},Y.name)),iy(Jj,{gap:1,children:[UG(zO,{children:"Migrations"}),UG(Je1,{status:Z})]})]}),UG(Jj,{children:X?iy(zO,{children:["Open in browser: ",UG(zO,{color:"cyan",children:X})]}):UG(zO,{dimColor:!0,children:"Starting..."})})]})}var We1=L(()=>{ln0();Ge1()});import{Box as h04,Text as hp}from"ink";import{jsx as mn0,jsxs as dn0}from"react/jsx-runtime";function u04($){if($>=500)return"red";if($>=400)return"yellow";if($>=300)return"cyan";return"green"}function He1({logs:$}){return mn0(h04,{flexDirection:"column",children:$.map((Z,Q)=>{if(Z.rawLine)return mn0(hp,{dimColor:!0,children:Z.rawLine},Q);let X=Z.duration<1000?`${Z.duration}ms`:`${(Z.duration/1000).toFixed(1)}s`;return dn0(hp,{children:[dn0(hp,{dimColor:!0,children:[Z.method.padEnd(6)," ",Z.path.padEnd(30)," "]}),mn0(hp,{color:u04(Z.status),children:Z.status}),dn0(hp,{dimColor:!0,children:[" ",X.padStart(8)]})]},Q)})})}var Fe1=()=>{};var in0={};s(in0,{App:()=>m04});import{Box as c04}from"ink";import{useSyncExternalStore as l04}from"react";import{jsx as Ue1,jsxs as d04}from"react/jsx-runtime";function m04({home:$}){let Z=l04(yn0,bn0);return d04(c04,{flexDirection:"column",children:[Ue1(Ke1,{services:Z.services,migrationsStatus:Z.migrationsStatus,home:$,serverUrl:Z.serverUrl}),Ue1(He1,{logs:Z.logs})]})}var pn0=L(()=>{We1();Fe1();Gj()});var a3="thread-gate",RU="decopilot-hosted-harness",IU="decopilot-hosted-harness-sandboxed",MJ="automations",PO="background-tools",Kj="task-board-github-reads";var Ne1="11";function Be1($){return{name:"decocms",systemDatabaseUrl:$.systemDatabaseUrl,systemDatabaseSchemaName:"dbos",systemDatabasePoolSize:$.poolSize,runAdminServer:!1,executorID:$.executorID,applicationVersion:Ne1,...$.listenQueues!==void 0?{listenQueues:$.listenQueues}:{}}}var Oe1=()=>{};import i04 from"pg";async function De1($,Z){let{databaseUrl:Q,lockTimeoutMs:X=p04}=$,Y=$.log??((W)=>console.log(W)),G=new i04.Client({connectionString:Q});await G.connect();let J=Date.now(),K=!1;try{while(!K){if(K=(await G.query("SELECT pg_try_advisory_lock($1) AS locked",[Le1.toString()])).rows[0]?.locked===!0,K)break;if(Date.now()-J>=X)throw Error(`Timed out after ${X}ms waiting for the DBOS migration lock. Another process is still migrating the dbos schema; this pod will restart and retry.`);await F$(n04)}let W=Date.now()-J;if(W>1000)Y(`[dbos] waited ${W}ms for the migration lock; another process migrated first`);return await Z()}finally{if(K)try{await G.query("SELECT pg_advisory_unlock($1)",[Le1.toString()])}catch{}await G.end().catch(()=>{})}}var Le1=8314027461559302n,p04=600000,n04=500;var we1=L(()=>{t8()});function t04(){let $=(process.env.BUN_OPTIONS??"").split(/\s+/).filter(Boolean);return[...process.argv.slice(1),...$]}function nn0($,Z){for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X===void 0)continue;if(X===Z)return $[Q+1];if(X.startsWith(`${Z}=`))return X.slice(Z.length+1)}return}function Ee1(){let $=t04();if($.includes("--cpu-prof")){console.log(JSON.stringify({msg:"cpu-profiling-active",dir:nn0($,"--cpu-prof-dir")??process.cwd(),name:nn0($,"--cpu-prof-name"),markdown:$.includes("--cpu-prof-md"),intervalUs:Number(nn0($,"--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 je1(){if(process.env.HEAP_WATCH!=="1")return()=>{};let $=Number(process.env.HEAP_WATCH_INTERVAL_MS??60000),Z=async()=>{let Q=$j();if(!Q)return;let X={};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);X={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:Q.rss,heapUsed:Q.heapUsed,heapTotal:Q.heapTotal,external:Q.external,arrayBuffers:Q.arrayBuffers,...X}))};return Z().catch(()=>{}),m70=setInterval(()=>void Z().catch(()=>{}),$),m70.unref?.(),process.on("SIGUSR2",()=>{try{let Q=Bun.generateHeapSnapshot("v8"),X=typeof Q==="string"?Q:JSON.stringify(Q),Y=`/tmp/heap-${process.pid}-${Date.now()}.heapsnapshot`;Bun.write(Y,X),console.log(JSON.stringify({msg:"heap-snapshot-written",path:Y}))}catch(Q){console.error("[heap-watch] snapshot failed:",Q)}}),()=>{if(m70)clearInterval(m70)}}var m70;var ze1=()=>{};import*as o04 from"bun:jsc";function Pe1(){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{r04()}catch(G){return console.error("[stall-watchdog] failed to start sampling profiler:",G),()=>{}}let Q,X=performance.now()+Z,Y=()=>{let G=performance.now(),J=G-X;X=G+Z;let K=[];try{K=a04()?.traces??[]}catch{}if(J>$&&K.length>0){let W=new Map;for(let F of K){let U=F.frames.find((O)=>O.sourceURL&&!/Unknown Executable/.test(O.category??""))??F.frames[0];if(!U)continue;let N=(U.sourceURL??"?").replace(/^.*\/node_modules\//,"node_modules/"),B=`${U.name??"?"} @ ${N}:${U.line??"?"}`;W.set(B,(W.get(B)??0)+1)}let H=[...W.entries()].sort((F,U)=>U[1]-F[1]).slice(0,8).map(([F,U])=>({frame:F,count:U}));console.warn(JSON.stringify({msg:"stall-stack",ts:new Date().toISOString(),lagMs:Math.round(J),samplesInWindow:K.length,top:H}))}Q=setTimeout(Y,Z),Q.unref?.()};return Q=setTimeout(Y,Z),Q.unref?.(),()=>{if(Q)clearTimeout(Q)}}var r04,a04;var Ae1=L(()=>{({startSamplingProfiler:r04,samplingProfilerStackTraces:a04}=o04)});function Te1(){Ee1();let $=[je1(),Ct1(),Pe1()];return()=>{for(let Z of $)Z()}}var Re1=L(()=>{Um0();ze1();Ae1()});var Wj=v((Ie1)=>{Object.defineProperty(Ie1,"__esModule",{value:!0});Ie1.RepublishHeaders=Ie1.DirectMsgHeaders=Ie1.JsHeaders=Ie1.AdvisoryKind=void 0;Ie1.isOrderedPushConsumerOptions=s04;Ie1.isPullConsumer=e04;Ie1.isPushConsumer=$14;Ie1.isBoundPushConsumerOptions=Z14;function s04($){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 e04($){return $.isPullConsumer()}function $14($){return $.isPushConsumer()}function Z14($){if($&&typeof $==="object")return"deliver_subject"in $||"deliver_group"in $||"idle_heartbeat"in $;return!1}Ie1.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"};Ie1.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"};Ie1.DirectMsgHeaders={Stream:"Nats-Stream",Sequence:"Nats-Sequence",TimeStamp:"Nats-Time-Stamp",Subject:"Nats-Subject",LastSequence:"Nats-Last-Sequence",NumPending:"Nats-Num-Pending"};Ie1.RepublishHeaders={Stream:"Nats-Stream",Subject:"Nats-Subject",Sequence:"Nats-Sequence",LastSequence:"Nats-Last-Sequence",Size:"Nats-Msg-Size"}});var NG=v((Me1)=>{Object.defineProperty(Me1,"__esModule",{value:!0});Me1.TD=Me1.TE=Me1.Empty=void 0;Me1.encode=F14;Me1.decode=U14;Me1.Empty=new Uint8Array(0);Me1.TE=new TextEncoder;Me1.TD=new TextDecoder;function H14(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let Q=new Uint8Array(Z),X=0;for(let Y=0;Y<$.length;Y++)Q.set($[Y],X),X+=$[Y].length;return Q}function F14(...$){let Z=[];for(let Q=0;Q<$.length;Q++)Z.push(Me1.TE.encode($[Q]));if(Z.length===0)return Me1.Empty;if(Z.length===1)return Z[0];return H14(...Z)}function U14($){if(!$||$.length===0)return"";return Me1.TD.decode($)}});var BG=v((Se1)=>{Object.defineProperty(Se1,"__esModule",{value:!0});Se1.errors=Se1.PermissionViolationError=Se1.NoRespondersError=Se1.TimeoutError=Se1.RequestError=Se1.ProtocolError=Se1.ConnectionError=Se1.DrainingConnectionError=Se1.ClosedConnectionError=Se1.AuthorizationError=Se1.UserAuthenticationExpiredError=Se1.InvalidOperationError=Se1.InvalidArgumentError=Se1.InvalidSubjectError=void 0;class on0 extends Error{constructor($,Z){super(`illegal subject: '${$}'`,Z);this.name="InvalidSubjectError"}}Se1.InvalidSubjectError=on0;class d70 extends Error{constructor($,Z){super($,Z);this.name="InvalidArgumentError"}static format($,Z,Q){if(Array.isArray(Z)&&Z.length>1)Z=Z[0];if(Array.isArray($))$=$.map((X)=>`'${X}'`),$=$.join(",");else $=`'${$}'`;return new d70(`${$} ${Z}`,Q)}}Se1.InvalidArgumentError=d70;class rn0 extends Error{constructor($,Z){super($,Z);this.name="InvalidOperationError"}}Se1.InvalidOperationError=rn0;class i70 extends Error{constructor($,Z){super($,Z);this.name="UserAuthenticationExpiredError"}static parse($){if($.toLowerCase().indexOf("user authentication expired")!==-1)return new i70($);return null}}Se1.UserAuthenticationExpiredError=i70;class p70 extends Error{constructor($,Z){super($,Z);this.name="AuthorizationError"}static parse($){let Z=["authorization violation","account authentication expired","authentication timeout"],Q=$.toLowerCase();for(let X=0;X<Z.length;X++)if(Q.indexOf(Z[X])!==-1)return new p70($);return null}}Se1.AuthorizationError=p70;class an0 extends Error{constructor(){super("closed connection");this.name="ClosedConnectionError"}}Se1.ClosedConnectionError=an0;class sn0 extends Error{constructor(){super("connection draining");this.name="DrainingConnectionError"}}Se1.DrainingConnectionError=sn0;class en0 extends Error{constructor($,Z){super($,Z);this.name="ConnectionError"}}Se1.ConnectionError=en0;class $t0 extends Error{constructor($,Z){super($,Z);this.name="ProtocolError"}}Se1.ProtocolError=$t0;class Zt0 extends Error{constructor($="",Z){super($,Z);this.name="RequestError"}isNoResponders(){return this.cause instanceof n70}}Se1.RequestError=Zt0;class Qt0 extends Error{constructor($){super("timeout",$);this.name="TimeoutError"}}Se1.TimeoutError=Qt0;class n70 extends Error{subject;constructor($,Z){super(`no responders: '${$}'`,Z);this.subject=$,this.name="NoResponders"}}Se1.NoRespondersError=n70;class t70 extends Error{operation;subject;queue;constructor($,Z,Q,X,Y){super($,Y);this.name="PermissionViolationError",this.operation=Z,this.subject=Q,this.queue=X}static parse($){if(($?$.toLowerCase():"").indexOf("permissions violation")===-1)return null;let Q="publish",X="",Y=void 0,G=$.match(/(Publish|Subscription) to "(\S+)"/);if(G){if(Q=G[1].toLowerCase(),X=G[2],Q==="subscription"){let J=$.match(/using queue "(\S+)"/);if(J)Y=J[1]}}return new t70($,Q,X,Y)}}Se1.PermissionViolationError=t70;Se1.errors={AuthorizationError:p70,ClosedConnectionError:an0,ConnectionError:en0,DrainingConnectionError:sn0,InvalidArgumentError:d70,InvalidOperationError:rn0,InvalidSubjectError:on0,NoRespondersError:n70,PermissionViolationError:t70,ProtocolError:$t0,RequestError:Zt0,TimeoutError:Qt0,UserAuthenticationExpiredError:i70}});var s3=v((fe1)=>{Object.defineProperty(fe1,"__esModule",{value:!0});fe1.SimpleMutex=fe1.Perf=void 0;fe1.extend=V14;fe1.render=k14;fe1.timeout=S14;fe1.delay=C14;fe1.deadline=_14;fe1.deferred=Yt0;fe1.debugDeferred=v14;fe1.shuffle=x14;fe1.collect=f14;fe1.jitter=xe1;fe1.backoff=b14;fe1.nanos=y14;fe1.millis=g14;fe1.randomToken=c14;var M14=NG(),Xt0=BG();function V14($,...Z){for(let Q=0;Q<Z.length;Q++){let X=Z[Q];Object.keys(X).forEach(function(Y){$[Y]=X[Y]})}return $}function k14($){return M14.TD.decode($).replace(/\n/g,"\u240A").replace(/\r/g,"\u240D")}function S14($,Z=!0){let Q=Z?new Xt0.TimeoutError:null,X,Y,G=new Promise((J,K)=>{X={cancel:()=>{if(Y)clearTimeout(Y)}},Y=setTimeout(()=>{if(Q===null)K(new Xt0.TimeoutError);else K(Q)},$)});return Object.assign(G,X)}function C14($=0){let Z,Q=new Promise((X)=>{let Y=setTimeout(()=>{X()},$);Z={cancel:()=>{if(Y)clearTimeout(Y),X()}}});return Object.assign(Q,Z)}async function _14($,Z=1000){let Q=Yt0(),X=setTimeout(()=>{Q.reject(new Xt0.TimeoutError)},Z);try{return await Promise.race([$,Q])}finally{clearTimeout(X)}}function Yt0(){let $={},Z=new Promise((Q,X)=>{$={resolve:Q,reject:X}});return Object.assign(Z,$)}function v14(){let $={},Z=new Promise((Q,X)=>{$={resolve:(Y)=>{console.trace("resolve",Y),Q(Y)},reject:(Y)=>{console.trace("reject"),X(Y)}}});return Object.assign(Z,$)}function x14($){for(let Z=$.length-1;Z>0;Z--){let Q=Math.floor(Math.random()*(Z+1));[$[Z],$[Q]]=[$[Q],$[Z]]}return $}async function f14($){let Z=[];for await(let Q of $)Z.push(Q);return Z}class _e1{timers;measures;constructor(){this.timers=new Map,this.measures=new Map}mark($){this.timers.set($,performance.now())}measure($,Z,Q){let X=this.timers.get(Z);if(X===void 0)throw Error(`${Z} is not defined`);let Y=this.timers.get(Q);if(Y===void 0)throw Error(`${Q} is not defined`);this.measures.set($,Y-X)}getEntries(){let $=[];return this.measures.forEach((Z,Q)=>{$.push({name:Q,duration:Z})}),$}}fe1.Perf=_e1;class ve1{max;current;waiting;constructor($=1){this.max=$,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();let $=Yt0();return this.waiting.push($),$}unlock(){this.current--,this.waiting.pop()?.resolve()}}fe1.SimpleMutex=ve1;function xe1($){if($===0)return 0;return Math.floor($/2+Math.random()*$)}function b14($=[0,250,250,500,500,3000,5000]){if(!Array.isArray($))$=[0,250,250,500,500,3000,5000];let Z=$.length-1;return{backoff(Q){return xe1(Q>Z?$[Z]:$[Q])}}}function y14($){return $*1e6}function g14($){return Math.floor($/1e6)}var h14="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",qU=new Uint8Array(62);for(let $=0;$<62;$++)qU[$]=h14.charCodeAt($);var u14=218340105584896;function c14(){let $=Math.floor(Math.random()*u14),Z=$%62,Q=qU[Z];$=($-Z)/62,Z=$%62;let X=qU[Z];$=($-Z)/62,Z=$%62;let Y=qU[Z];$=($-Z)/62,Z=$%62;let G=qU[Z];$=($-Z)/62,Z=$%62;let J=qU[Z];$=($-Z)/62,Z=$%62;let K=qU[Z];$=($-Z)/62,Z=$%62;let W=qU[Z];$=($-Z)/62;let H=qU[$];return String.fromCharCode(Q,X,Y,G,J,K,W,H)}});var me1=v((ce1)=>{Object.defineProperty(ce1,"__esModule",{value:!0});ce1.nuid=ce1.NuidImpl=void 0;var X$4="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",AO=62,r70=12,he1=10,ye1=33,Y$4=333,ge1=r70+he1,Jt0=new Uint8Array(AO);for(let $=0;$<AO;$++)Jt0[$]=X$4.charCodeAt($);var o70=4294967296,ue1=BigInt(AO)**BigInt(he1),up=Number(ue1/(1n<<32n)),Gt0=Number(ue1%(1n<<32n));function G$4($){for(let Z=0;Z<$.length;Z++)$[Z]=Math.floor(Math.random()*256)}function J$4($){if(globalThis?.crypto?.getRandomValues)globalThis.crypto.getRandomValues($);else G$4($)}class Kt0{buf;cbuf;seqHi;seqLo;inc;inited;constructor(){this.buf=new Uint8Array(ge1),this.cbuf=new Uint8Array(r70),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){let $=0;do this.seqHi=Math.floor(Math.random()*(up+1)),this.seqLo=Math.floor(Math.random()*o70);while($++<8&&this.seqHi===up&&this.seqLo>=Gt0);if(this.seqHi===up&&this.seqLo>=Gt0)this.seqLo=0;this.inc=Math.random()*(Y$4-ye1)+ye1|0}setPre(){J$4(this.cbuf);for(let $=0;$<r70;$++)this.buf[$]=Jt0[this.cbuf[$]%AO]}fillSeq(){let $=this.seqHi,Z=this.seqLo;for(let Q=ge1-1;Q>=r70;Q--){let X=Math.floor($/AO),G=($-X*AO)*o70+Z,J=Math.floor(G/AO),K=G-J*AO;this.buf[Q]=Jt0[K],$=X,Z=J}}next(){if(!this.inited)this.init();if(this.seqLo+=this.inc,this.seqLo>=o70)this.seqLo-=o70,this.seqHi+=1;if(this.seqHi>up||this.seqHi===up&&this.seqLo>=Gt0)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()}}ce1.NuidImpl=Kt0;ce1.nuid=new Kt0});var ne1=v((ie1)=>{Object.defineProperty(ie1,"__esModule",{value:!0});ie1.nuid=ie1.Nuid=void 0;var de1=me1();ie1.Nuid=de1.NuidImpl;ie1.nuid=de1.nuid});var s70=v((a70)=>{Object.defineProperty(a70,"__esModule",{value:!0});a70.nuid=a70.Nuid=void 0;var te1=ne1();Object.defineProperty(a70,"Nuid",{enumerable:!0,get:function(){return te1.Nuid}});Object.defineProperty(a70,"nuid",{enumerable:!0,get:function(){return te1.nuid}})});var TO=v((oe1)=>{Object.defineProperty(oe1,"__esModule",{value:!0});oe1.DEFAULT_HOST=oe1.DEFAULT_PORT=oe1.Match=void 0;oe1.syncIterator=N$4;oe1.createInbox=B$4;var F$4=s70(),U$4=BG();oe1.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function N$4($){let Z=$[Symbol.asyncIterator]();return{async next(){let Q=await Z.next();if(Q.done)return Promise.resolve(null);return Promise.resolve(Q.value)}}}function B$4($=""){if($=$||"_INBOX",typeof $!=="string")throw TypeError("prefix must be a string");return $.split(".").forEach((Z)=>{if(Z==="*"||Z===">")throw U$4.InvalidArgumentError.format("prefix",`cannot have wildcards ('${$}')`)}),`${$}.${F$4.nuid.next()}`}oe1.DEFAULT_PORT=4222;oe1.DEFAULT_HOST="127.0.0.1"});var cp=v((ee1)=>{Object.defineProperty(ee1,"__esModule",{value:!0});ee1.DataBuffer=void 0;var ae1=NG();class se1{buffers;byteLength;constructor(){this.buffers=[],this.byteLength=0}static concat(...$){let Z=0;for(let Y=0;Y<$.length;Y++)Z+=$[Y].length;let Q=new Uint8Array(Z),X=0;for(let Y=0;Y<$.length;Y++)Q.set($[Y],X),X+=$[Y].length;return Q}static fromAscii($){if(!$)$="";return ae1.TE.encode($)}static toAscii($){return ae1.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 Q=0;Q<this.buffers.length;Q++)$.set(this.buffers[Q],Z),Z+=this.buffers[Q].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 Q=this.byteLength;if($===void 0||$>Q)$=Q;let X=Z.subarray(0,$);if(Q>$)this.buffers.push(Z.subarray($));return this.byteLength=Q-$,X}}return new Uint8Array(0)}fill($,...Z){if($)this.buffers.push($),this.byteLength+=$.length;for(let Q=0;Q<Z.length;Q++)if(Z[Q]&&Z[Q].length)this.buffers.push(Z[Q]),this.byteLength+=Z[Q].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}}ee1.DataBuffer=se1});var Hj=v((Q0$)=>{Object.defineProperty(Q0$,"__esModule",{value:!0});Q0$.LF=Q0$.CR=Q0$.CRLF=Q0$.CR_LF_LEN=Q0$.CR_LF=void 0;Q0$.setTransportFactory=P$4;Q0$.defaultPort=A$4;Q0$.getUrlParseFn=T$4;Q0$.newTransport=R$4;Q0$.getResolveFn=I$4;Q0$.protoLen=Z0$;Q0$.extractProtocolMessage=q$4;var E$4=NG(),j$4=TO(),z$4=cp(),OG;function P$4($){OG=$}function A$4(){return OG!==void 0&&OG.defaultPort!==void 0?OG.defaultPort:j$4.DEFAULT_PORT}function T$4(){return OG!==void 0&&OG.urlParseFn?OG.urlParseFn:void 0}function R$4(){if(!OG||typeof OG.factory!=="function")throw Error("transport fn is not set");return OG.factory()}function I$4(){return OG!==void 0&&OG.dnsResolveFn?OG.dnsResolveFn:void 0}Q0$.CR_LF=`\r
1549
1549
  `;Q0$.CR_LF_LEN=Q0$.CR_LF.length;Q0$.CRLF=z$4.DataBuffer.fromAscii(Q0$.CR_LF);Q0$.CR=new Uint8Array(Q0$.CRLF)[0];Q0$.LF=new Uint8Array(Q0$.CRLF)[1];function Z0$($){for(let Z=0;Z<$.length;Z++){let Q=Z+1;if($.byteLength>Q&&$[Z]===Q0$.CR&&$[Q]===Q0$.LF)return Q+1}return 0}function q$4($){let Z=Z0$($);if(Z>0){let X=new Uint8Array($).slice(0,Z);return E$4.TD.decode(X)}return""}});var Nt0=v((F0$)=>{Object.defineProperty(F0$,"__esModule",{value:!0});F0$.ipV4=K0$;F0$.isIP=y$4;F0$.parseIP=W0$;var lp=4,Fj=16,e70=48,J0$=57,Y0$=65,f$4=70,G0$=97,b$4=102,Ut0=16777215;function K0$($,Z,Q,X){let Y=new Uint8Array(Fj);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]=Q,Y[15]=X,Y}function y$4($){return W0$($)!==void 0}function W0$($){for(let Z=0;Z<$.length;Z++)switch($[Z]){case".":return H0$($);case":":return g$4($)}return}function H0$($){let Z=new Uint8Array(lp);for(let Q=0;Q<lp;Q++){if($.length===0)return;if(Q>0){if($[0]!==".")return;$=$.substring(1)}let{n:X,c:Y,ok:G}=h$4($);if(!G||X>255)return;$=$.substring(Y),Z[Q]=X}return K0$(Z[0],Z[1],Z[2],Z[3])}function g$4($){let Z=new Uint8Array(Fj),Q=-1;if($.length>=2&&$[0]===":"&&$[1]===":"){if(Q=0,$=$.substring(2),$.length===0)return Z}let X=0;while(X<Fj){let{n:Y,c:G,ok:J}=u$4($);if(!J||Y>65535)return;if(G<$.length&&$[G]==="."){if(Q<0&&X!=Fj-lp)return;if(X+lp>Fj)return;let K=H0$($);if(K===void 0)return;Z[X]=K[12],Z[X+1]=K[13],Z[X+2]=K[14],Z[X+3]=K[15],$="",X+=lp;break}if(Z[X]=Y>>8,Z[X+1]=Y,X+=2,$=$.substring(G),$.length===0)break;if($[0]!==":"||$.length==1)return;if($=$.substring(1),$[0]===":"){if(Q>=0)return;if(Q=X,$=$.substring(1),$.length===0)break}}if($.length!==0)return;if(X<Fj){if(Q<0)return;let Y=Fj-X;for(let G=X-1;G>=Q;G--)Z[G+Y]=Z[G];for(let G=Q+Y-1;G>=Q;G--)Z[G]=0}else if(Q>=0)return;return Z}function h$4($){let Z=0,Q=0;for(Z=0;Z<$.length&&e70<=$.charCodeAt(Z)&&$.charCodeAt(Z)<=J0$;Z++)if(Q=Q*10+($.charCodeAt(Z)-e70),Q>=Ut0)return{n:Ut0,c:Z,ok:!1};if(Z===0)return{n:0,c:0,ok:!1};return{n:Q,c:Z,ok:!0}}function u$4($){let Z=0,Q=0;for(Q=0;Q<$.length;Q++){if(e70<=$.charCodeAt(Q)&&$.charCodeAt(Q)<=J0$)Z*=16,Z+=$.charCodeAt(Q)-e70;else if(G0$<=$.charCodeAt(Q)&&$.charCodeAt(Q)<=b$4)Z*=16,Z+=$.charCodeAt(Q)-G0$+10;else if(Y0$<=$.charCodeAt(Q)&&$.charCodeAt(Q)<=f$4)Z*=16,Z+=$.charCodeAt(Q)-Y0$+10;else break;if(Z>=Ut0)return{n:0,c:Q,ok:!1}}if(Q===0)return{n:0,c:Q,ok:!1};return{n:Z,c:Q,ok:!0}}});var Et0=v((N0$)=>{Object.defineProperty(N0$,"__esModule",{value:!0});N0$.Servers=N0$.ServerImpl=void 0;N0$.isIPV4OrHostname=U0$;N0$.hostPort=wt0;var Bt0=Hj(),Ot0=s3(),Lt0=Nt0(),d$4=TO(),i$4=BG();function U0$($){if($.indexOf("[")!==-1||$.indexOf("::")!==-1)return!1;if($.indexOf(".")!==-1)return!0;if($.split(":").length<=2)return!0;return!1}function Dt0($){return!U0$($)}function p$4($){let Q=$.toUpperCase().indexOf("::FFFF:");if(Q!==-1&&$.indexOf(".")!==-1){let X=$.substring(Q+7);return X=X.replace("[",""),X.replace("]","")}return $}function wt0($){if($=$.trim(),$.match(/^(.*:\/\/)(.*)/m))$=$.replace(/^(.*:\/\/)(.*)/gm,"$2");if($=p$4($),Dt0($)&&$.indexOf("[")===-1)$=`[${$}]`;let Z=Dt0($)?$.match(/(]:)(\d+)/):$.match(/(:)(\d+)/),Q=Z&&Z.length===3&&Z[1]&&Z[2]?parseInt(Z[2]):d$4.DEFAULT_PORT,Y=new URL(`${Q===80?"https":"http"}://${$}`);Y.port=`${Q}`;let G=Y.hostname;if(G.charAt(0)==="[")G=G.substring(1,G.length-1);return{listen:Y.host,hostname:G,port:Q}}class py{src;listen;hostname;port;didConnect;reconnects;lastConnect;gossiped;tlsName;resolves;constructor($,Z=!1){this.src=$,this.tlsName="";let Q=wt0($);this.listen=Q.listen,this.hostname=Q.hostname,this.port=Q.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,Lt0.isIP)(this.hostname))return[this];else{let Q=await $.fn(this.hostname);if($.debug)console.log(`resolve ${this.hostname} = ${Q.join(",")}`);for(let X of Q){let Y=this.port===80?"https":"http",G=new URL(`${Y}://${Dt0(X)?"["+X+"]":X}`);G.port=`${this.port}`;let J=new py(G.host,!1);J.tlsName=this.hostname,Z.push(J)}}if($.randomize)(0,Ot0.shuffle)(Z);return this.resolves=Z,Z}}N0$.ServerImpl=py;class $Q0{firstSelect;servers;currentServer;tlsName;randomize;constructor($={}){this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=$.randomize||!1}setServers($){if(!Array.isArray($)||$.length===0)throw i$4.InvalidArgumentError.format("servers","cannot be empty");let Z=(0,Bt0.getUrlParseFn)(),Q=new Map;for(let Y of this.servers)Q.set(Y.listen,Y);let X=[];for(let Y of $){Y=Z?Z(Y):Y;let{listen:G}=wt0(Y),J=Q.get(G);if(J)J.gossiped=!1,X.push(J);else X.push(new py(Y))}if(this.randomize)(0,Ot0.shuffle)(X);if(this.servers=X,this.currentServer===void 0||!X.includes(this.currentServer))this.currentServer=X[0],this.firstSelect=!0}clear(){this.servers.length=0}updateTLSName(){let $=this.getCurrentServer();if(!(0,Lt0.isIP)($.hostname))this.tlsName=$.hostname,this.servers.forEach((Z)=>{if(Z.gossiped)Z.tlsName=this.tlsName})}getCurrentServer(){return this.currentServer}addServer($,Z=!1){let Q=(0,Bt0.getUrlParseFn)();$=Q?Q($):$;let X=new py($,Z);if((0,Lt0.isIP)(X.hostname))X.tlsName=this.tlsName;this.servers.push(X)}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 $Q0.freezeAll(this.servers)}snapshotForHandler(){let $=this.currentServer;if(!$)return this.snapshot();let Z=this.servers.indexOf($);if(Z<=0)return this.snapshot();return $Q0.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 Q=[],X=[],Y=(0,Bt0.getUrlParseFn)(),G=new Map;if($.connect_urls&&$.connect_urls.length>0)$.connect_urls.forEach((K)=>{K=Y?Y(K,Z):K;let W=new py(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);X=X.concat(W[0].listen)}),G.forEach((K,W)=>{this.servers.push(K),Q.push(W)}),this.randomize&&Q.length>0){let K=this.currentServer,W=this.servers.filter((H)=>H!==K);(0,Ot0.shuffle)(W),this.servers=K?[K,...W]:W}return{added:Q,deleted:X}}}N0$.Servers=$Q0});var ZQ0=v((D0$)=>{Object.defineProperty(D0$,"__esModule",{value:!0});D0$.QueuedIteratorImpl=void 0;var jt0=s3(),O0$=BG();class L0${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,jt0.deferred)(),this.yields=[],this.iterClosed=(0,jt0.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(Q){}}return}if(typeof $==="function")this.pendingFiltered++;this.yields.push($),this.signal.resolve()}async*iterate(){if(this.noIterator)throw new O0$.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new O0$.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 X=$[Z];try{X()}catch(Y){throw Y}if(this.err)throw this.err;continue}this.processed++,this.inflight--;let Q=this.profile?Date.now():0;yield $[Z],this.time=this.profile?Date.now()-Q:0}if(this.done)break;else if(this.yields.length===0)$.length=0,this.yields=$,this.signal=(0,jt0.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}}D0$.QueuedIteratorImpl=L0$});var zt0=v((z0$)=>{Object.defineProperty(z0$,"__esModule",{value:!0});z0$.MuxSubscription=void 0;var r$4=TO(),E0$=BG();class j0${baseInbox;reqs;constructor(){this.reqs=new Map}size(){return this.reqs.size}init($){return this.baseInbox=`${(0,r$4.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((Q)=>{Q.resolver(Z,{})}),!0;if(Z.operation==="publish"){let Q=this.all().find((X)=>{return X.requestSubject===Z.subject});if(Q)return Q.resolver(Z,{}),!0}return!1}dispatcher(){return($,Z)=>{let Q=this.getToken(Z);if(Q){let X=this.get(Q);if(X){if($===null)$=Z?.data?.length===0&&Z.headers?.code===503?new E0$.NoRespondersError(X.requestSubject):null;X.resolver($,Z)}}}}close(){let $=new E0$.RequestError("connection closed");this.reqs.forEach((Z)=>{Z.resolver($,{})})}}z0$.MuxSubscription=j0$});var Pt0=v((T0$)=>{Object.defineProperty(T0$,"__esModule",{value:!0});T0$.Heartbeat=void 0;var a$4=s3();class A0${ph;interval;maxOut;timer;pendings;constructor($,Z,Q){this.ph=$,this.interval=Z,this.maxOut=Q,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,a$4.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})}}T0$.Heartbeat=A0$});var Rt0=v((V0$)=>{Object.defineProperty(V0$,"__esModule",{value:!0});V0$.DenoBuffer=V0$.MAX_SIZE=V0$.AssertionError=void 0;V0$.assert=q0$;V0$.concat=M0$;V0$.append=e$4;V0$.readAll=$84;V0$.writeAll=Z84;var s$4=NG();class At0 extends Error{constructor($){super($);this.name="AssertionError"}}V0$.AssertionError=At0;function q0$($,Z="Assertion failed."){if(!$)throw new At0(Z)}var I0$=32768;V0$.MAX_SIZE=4294967294;function QQ0($,Z,Q=0){let X=Z.byteLength-Q;if($.byteLength>X)$=$.subarray(0,X);return Z.set($,Q),$.byteLength}function M0$($,Z){if($===void 0&&Z===void 0)return new Uint8Array(0);if($===void 0)return Z;if(Z===void 0)return $;let Q=new Uint8Array($.length+Z.length);return Q.set($,0),Q.set(Z,$.length),Q}function e$4($,Z){return M0$($,Uint8Array.of(Z))}class Tt0{_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($){q0$($<=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=QQ0(this._buf.subarray(this._off),$);return this._off+=Z,Z}writeByte($){return this.write(Uint8Array.of($))}writeString($){return this.write(s$4.TE.encode($))}write($){let Z=this._grow($.byteLength);return QQ0($,this._buf,Z)}_grow($){let Z=this.length;if(Z===0&&this._off!==0)this.reset();let Q=this._tryGrowByReslice($);if(Q>=0)return Q;let X=this.capacity;if($<=Math.floor(X/2)-Z)QQ0(this._buf.subarray(this._off),this._buf);else if(X+$>V0$.MAX_SIZE)throw Error("The buffer cannot be grown beyond the maximum size.");else{let Y=new Uint8Array(Math.min(2*X+$,V0$.MAX_SIZE));QQ0(this._buf.subarray(this._off),Y),this._buf=Y}return this._off=0,this._reslice(Math.min(Z+$,V0$.MAX_SIZE)),Z}grow($){if($<0)throw Error("Buffer._grow: negative count");let Z=this._grow($);this._reslice(Z)}readFrom($){let Z=0,Q=new Uint8Array(I0$);while(!0){let X=this.capacity-this.length<I0$,Y=X?Q:new Uint8Array(this._buf.buffer,this.length),G=$.read(Y);if(G===null)return Z;if(X)this.write(Y.subarray(0,G));else this._reslice(this.length+G);Z+=G}}}V0$.DenoBuffer=Tt0;function $84($){let Z=new Tt0;return Z.readFrom($),Z.bytes()}function Z84($,Z){let Q=0;while(Q<Z.length)Q+=$.write(Z.subarray(Q))}});var Mt0=v((v0$)=>{Object.defineProperty(v0$,"__esModule",{value:!0});v0$.cc=v0$.State=v0$.Parser=v0$.Kind=void 0;v0$.describe=W84;var It0=Rt0(),qt0=NG();v0$.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function W84($){let Z,Q="";switch($.kind){case v0$.Kind.MSG:Z="MSG";break;case v0$.Kind.OK:Z="OK";break;case v0$.Kind.ERR:Z="ERR",Q=qt0.TD.decode($.data);break;case v0$.Kind.PING:Z="PING";break;case v0$.Kind.PONG:Z="PONG";break;case v0$.Kind.INFO:Z="INFO",Q=qt0.TD.decode($.data)}return`${Z}: ${Q}`}function S0$(){let $={};return $.sid=-1,$.hdr=-1,$.size=-1,$}var C0$=48,H84=57,ny=67108864;class _0${dispatcher;state;as;drop;hdr;ma;argBuf;msgBuf;constructor($){this.dispatcher=$,this.state=v0$.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse($){let Z;for(Z=0;Z<$.length;Z++){let Q=$[Z];switch(this.state){case v0$.State.OP_START:switch(Q){case v0$.cc.M:case v0$.cc.m:this.state=v0$.State.OP_M,this.hdr=-1,this.ma=S0$();break;case v0$.cc.H:case v0$.cc.h:this.state=v0$.State.OP_H,this.hdr=0,this.ma=S0$();break;case v0$.cc.P:case v0$.cc.p:this.state=v0$.State.OP_P;break;case v0$.cc.PLUS:this.state=v0$.State.OP_PLUS;break;case v0$.cc.MINUS:this.state=v0$.State.OP_MINUS;break;case v0$.cc.I:case v0$.cc.i:this.state=v0$.State.OP_I;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_H:switch(Q){case v0$.cc.M:case v0$.cc.m:this.state=v0$.State.OP_M;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_M:switch(Q){case v0$.cc.S:case v0$.cc.s:this.state=v0$.State.OP_MS;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_MS:switch(Q){case v0$.cc.G:case v0$.cc.g:this.state=v0$.State.OP_MSG;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_MSG:switch(Q){case v0$.cc.SPACE:case v0$.cc.TAB:this.state=v0$.State.OP_MSG_SPC;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_MSG_SPC:switch(Q){case v0$.cc.SPACE:case v0$.cc.TAB:continue;default:this.state=v0$.State.MSG_ARG,this.as=Z}break;case v0$.State.MSG_ARG:switch(Q){case v0$.cc.CR:this.drop=1;break;case v0$.cc.NL:{let X=this.argBuf?this.argBuf.bytes():$.subarray(this.as,Z-this.drop);this.processMsgArgs(X),this.drop=0,this.as=Z+1,this.state=v0$.State.MSG_PAYLOAD,Z=this.as+this.ma.size-1;break}default:if(this.argBuf)this.argBuf.writeByte(Q)}break;case v0$.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){let X=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:v0$.Kind.MSG,msg:this.ma,data:X}),this.argBuf=void 0,this.msgBuf=void 0,this.state=v0$.State.MSG_END}else{let X=this.ma.size-this.msgBuf.length,Y=$.length-Z;if(Y<X)X=Y;if(X>0)this.msgBuf.write($.subarray(Z,Z+X)),Z=Z+X-1;else this.msgBuf.writeByte(Q)}else if(Z-this.as>=this.ma.size)this.dispatcher.push({kind:v0$.Kind.MSG,msg:this.ma,data:$.subarray(this.as,Z)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=v0$.State.MSG_END;break;case v0$.State.MSG_END:switch(Q){case v0$.cc.NL:this.drop=0,this.as=Z+1,this.state=v0$.State.OP_START;break;default:continue}break;case v0$.State.OP_PLUS:switch(Q){case v0$.cc.O:case v0$.cc.o:this.state=v0$.State.OP_PLUS_O;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_PLUS_O:switch(Q){case v0$.cc.K:case v0$.cc.k:this.state=v0$.State.OP_PLUS_OK;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_PLUS_OK:switch(Q){case v0$.cc.NL:this.dispatcher.push({kind:v0$.Kind.OK}),this.drop=0,this.state=v0$.State.OP_START;break}break;case v0$.State.OP_MINUS:switch(Q){case v0$.cc.E:case v0$.cc.e:this.state=v0$.State.OP_MINUS_E;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_MINUS_E:switch(Q){case v0$.cc.R:case v0$.cc.r:this.state=v0$.State.OP_MINUS_ER;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_MINUS_ER:switch(Q){case v0$.cc.R:case v0$.cc.r:this.state=v0$.State.OP_MINUS_ERR;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_MINUS_ERR:switch(Q){case v0$.cc.SPACE:case v0$.cc.TAB:this.state=v0$.State.OP_MINUS_ERR_SPC;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_MINUS_ERR_SPC:switch(Q){case v0$.cc.SPACE:case v0$.cc.TAB:continue;default:this.state=v0$.State.MINUS_ERR_ARG,this.as=Z}break;case v0$.State.MINUS_ERR_ARG:switch(Q){case v0$.cc.CR:this.drop=1;break;case v0$.cc.NL:{let X;if(this.argBuf)X=this.argBuf.bytes(),this.argBuf=void 0;else X=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:v0$.Kind.ERR,data:X}),this.drop=0,this.as=Z+1,this.state=v0$.State.OP_START;break}default:if(this.argBuf)this.argBuf.write(Uint8Array.of(Q))}break;case v0$.State.OP_P:switch(Q){case v0$.cc.I:case v0$.cc.i:this.state=v0$.State.OP_PI;break;case v0$.cc.O:case v0$.cc.o:this.state=v0$.State.OP_PO;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_PO:switch(Q){case v0$.cc.N:case v0$.cc.n:this.state=v0$.State.OP_PON;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_PON:switch(Q){case v0$.cc.G:case v0$.cc.g:this.state=v0$.State.OP_PONG;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_PONG:switch(Q){case v0$.cc.NL:this.dispatcher.push({kind:v0$.Kind.PONG}),this.drop=0,this.state=v0$.State.OP_START;break}break;case v0$.State.OP_PI:switch(Q){case v0$.cc.N:case v0$.cc.n:this.state=v0$.State.OP_PIN;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_PIN:switch(Q){case v0$.cc.G:case v0$.cc.g:this.state=v0$.State.OP_PING;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_PING:switch(Q){case v0$.cc.NL:this.dispatcher.push({kind:v0$.Kind.PING}),this.drop=0,this.state=v0$.State.OP_START;break}break;case v0$.State.OP_I:switch(Q){case v0$.cc.N:case v0$.cc.n:this.state=v0$.State.OP_IN;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_IN:switch(Q){case v0$.cc.F:case v0$.cc.f:this.state=v0$.State.OP_INF;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_INF:switch(Q){case v0$.cc.O:case v0$.cc.o:this.state=v0$.State.OP_INFO;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_INFO:switch(Q){case v0$.cc.SPACE:case v0$.cc.TAB:this.state=v0$.State.OP_INFO_SPC;break;default:throw this.fail($.subarray(Z))}break;case v0$.State.OP_INFO_SPC:switch(Q){case v0$.cc.SPACE:case v0$.cc.TAB:continue;default:this.state=v0$.State.INFO_ARG,this.as=Z}break;case v0$.State.INFO_ARG:switch(Q){case v0$.cc.CR:this.drop=1;break;case v0$.cc.NL:{let X;if(this.argBuf)X=this.argBuf.bytes(),this.argBuf=void 0;else X=$.subarray(this.as,Z-this.drop);this.dispatcher.push({kind:v0$.Kind.INFO,data:X}),this.drop=0,this.as=Z+1,this.state=v0$.State.OP_START;break}default:if(this.argBuf)this.argBuf.writeByte(Q)}break;default:throw this.fail($.subarray(Z))}}if((this.state===v0$.State.MSG_ARG||this.state===v0$.State.MINUS_ERR_ARG||this.state===v0$.State.INFO_ARG)&&!this.argBuf)this.argBuf=new It0.DenoBuffer($.subarray(this.as,Z-this.drop));if(this.state===v0$.State.MSG_PAYLOAD&&!this.msgBuf){if(!this.argBuf)this.cloneMsgArg();this.msgBuf=new It0.DenoBuffer($.subarray(this.as))}}cloneMsgArg(){let $=this.ma.subject.length,Z=this.ma.reply?this.ma.reply.length:0,Q=new Uint8Array($+Z);if(Q.set(this.ma.subject),this.ma.reply)Q.set(this.ma.reply,$);if(this.argBuf=new It0.DenoBuffer(Q),this.ma.subject=Q.subarray(0,$),this.ma.reply)this.ma.reply=Q.subarray($)}processMsgArgs($){if(this.hdr>=0)return this.processHeaderMsgArgs($);let Z=[],Q=-1;for(let X=0;X<$.length;X++)switch($[X]){case v0$.cc.SPACE:case v0$.cc.TAB:case v0$.cc.CR:case v0$.cc.NL:if(Q>=0)Z.push($.subarray(Q,X)),Q=-1;break;default:if(Q<0)Q=X}if(Q>=0)Z.push($.subarray(Q));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],ny);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],ny);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}: ${qt0.TD.decode($)}`)}processHeaderMsgArgs($){let Z=[],Q=-1;for(let X=0;X<$.length;X++)switch($[X]){case v0$.cc.SPACE:case v0$.cc.TAB:case v0$.cc.CR:case v0$.cc.NL:if(Q>=0)Z.push($.subarray(Q,X)),Q=-1;break;default:if(Q<0)Q=X}if(Q>=0)Z.push($.subarray(Q));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],ny),this.ma.size=this.protoParseInt(Z[3],ny);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],ny),this.ma.size=this.protoParseInt(Z[4],ny);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 Q=0;for(let X=0;X<$.length;X++){if($[X]<C0$||$[X]>H84)return-1;Q=Q*10+($[X]-C0$)}return Z!==void 0&&Q>Z?-1:Q}}v0$.Parser=_0$;v0$.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};v0$.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 GQ0=v((f0$)=>{Object.defineProperty(f0$,"__esModule",{value:!0});f0$.MsgHdrsImpl=void 0;f0$.canonicalMIMEHeaderKey=kt0;f0$.headers=N84;var x0$=NG(),e3=TO(),YQ0=BG();function kt0($){let F=!0,U=Array($.length);for(let N=0;N<$.length;N++){let B=$.charCodeAt(N);if(B===58||B<33||B>126)throw YQ0.InvalidArgumentError.format("header",`'${$[N]}' is not a valid character in a header name`);if(F&&97<=B&&B<=122)B-=32;else if(!F&&65<=B&&B<=90)B+=32;U[N]=B,F=B==45}return String.fromCharCode(...U)}function N84($=0,Z=""){if($===0&&Z!=="")throw YQ0.InvalidArgumentError.format("code","is required");else if($>0&&Z==="")throw YQ0.InvalidArgumentError.format("description","is required");return new ty($,Z)}var Vt0="NATS/1.0";class ty{_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,Q]of this.headers){let X=$.values(Z);if(Q.length!==X.length)return!1;let Y=[...Q].sort(),G=[...X].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 ty,X=x0$.TD.decode($).split(`\r
1550
1550
  `),Y=X[0];if(Y!==Vt0){let G=Y.replace(Vt0,"").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(X.length>=1)X.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 $=Vt0;if(this._code>0&&this._description!=="")$+=` ${this._code} ${this._description}`;for(let[Z,Q]of this.headers)for(let X=0;X<Q.length;X++)$=`${$}\r
1551
1551
  ${Z}: ${Q[X]}`;return`${$}\r
@@ -2892,7 +2892,7 @@ Studio renders those as real images in the comment.`,`- End the run by calling \
2892
2892
  3. EXERCISE the change on the PR's deploy preview, AFTER your push, on the `+"preview of the commit you actually pushed \u2014 the earlier preview is a "+"different build and a verdict on it is a verdict on bytes that will not ship. Wait for it if it is still building. Deep-link to the specific page/route the task affects (not just its root), check the acceptance criteria implied by the title and description, and look for regressions "+"in the affected flow. Judge OUTCOMES, not the diff \u2014 NEVER approve on "+"inspection alone. For any VISUAL change capture the affected view BEFORE (the current production / base-branch site) and AFTER (the preview), and for a responsive change capture BOTH a desktop and a real mobile view (a "+"phone viewport AND a mobile user-agent \u2014 not a narrowed desktop). The "+`How-to steps below name the exact screenshot tool for your run.
2893
2893
  If the preview will not render (303s, hangs, blank) or you otherwise cannot exercise the change, do NOT approve: request changes stating what is blocking and what is needed to unblock. An unverified preview is not a pass.
2894
2894
  `+"4. RECORD the whole pass as a task comment BEFORE the decision \u2014 a "+"durable record, separate from the short decision summary, and REQUIRED: a verdict with no comment is an incomplete run and you will be asked for one. Structure it: what you read and the concrete issues with file/line references, WHICH of them you fixed (with the commits), the acceptance criteria / scenarios you exercised with a pass/fail on each, a "+"before\u2192after pointer to the screenshots, the exact URL(s) and viewport, "+`and anything you did not review or could not verify and why.
2895
- That comment must ALWAYS carry the visual change: embed the before/after screenshots in it whenever the change has any visual surface. If it has none, write the exact words \`${ur}\` in the comment and `+"name why (backend-only, config, test-only) \u2014 that literal is what a "+"machine check looks for, so no paraphrase of it counts, and silence about screenshots is not an acceptable answer either way.\n5. DECIDE. Approve once the pull request is in the state you would approve. Only `request_changes` for something you genuinely cannot settle here (a product decision, a missing credential, an approach that needs "+"rethinking) \u2014 that hands the card to a human, it does not start another "+"agent round. NEVER end your run without having called `TASK_BOARD_REVIEW_DECISION`: a run that stops to wait on a background task, or that runs low on room, must decide on what it knows first. An unrecorded verdict strands the card and is the one failure this run cannot leave behind."}});function ar4($,Z){return $.status===T$.review&&$.assigneeId===o$&&Z===!0}function DQ1($){return $.filter((Q)=>Q.action==="merge_conflict_resolution").length>=sv$}async function dD($,Z,Q,X){if(!ar4(Q,X.conflict))return!1;let G=(await $.storage.organizationSettings.get(Z))?.flags??{};if(!zD$(G))return!1;let J=JN(G),K=await $.storage.taskBoard.listActivity(Q.id,Z);if(!YD(K,J,{cycleStartedAt:Q.reviewCycleStartedAt,verifiedOnly:!0}))return!1;if(DQ1(K))return console.warn(`[task-board] conflict auto-resolve cap (${sv$}) reached on task ${Q.id} \u2014 leaving the PR for a human`),!1;let W=X.pr,H=await $.storage.taskBoard.claimConflictResolution(Q.id,Z,Q.updatedBy);if(!H)return!1;F8(Z,H);try{await sK($,H,{pr:{number:W.number,url:W.url},resolveConflict:!0})}catch(F){throw await ev$($,H,F).catch(()=>!1),await $.storage.taskBoard.update(H.id,Z,{status:T$.review},"system").then((U)=>F8(Z,U)).catch((U)=>console.error("[task-board] conflict-resolution status revert failed",U)),F}return await C6($,{taskBoardItemId:Q.id,action:"merge_conflict_resolution",actorId:null,data:{prNumber:W.number}}),!0}var sv$=3;var Rc=L(()=>{z4();ZZ();SQ();n5();$F()});async function ZF($,Z){let Q=await $.selectFrom("organization").select(["id","slug","name"]).where("id","=",Z).executeTakeFirst();if(!Q)return null;let X=await K3.create();return X.organization={id:Q.id,slug:Q.slug,name:Q.name},iD(X,{id:Q.id,slug:Q.slug}),X}var Ic=L(()=>{pD()});import{DBOS as jQ1}from"@dbos-inc/dbos-sdk";function Zx$($){wQ1=$}async function Za4($,Z){if(!wQ1)throw Error("[task-board-github-read] runtime not initialized \u2014 setTaskBoardGithubReadRuntime() must run before the workflow fires");let Q=await ZF(wQ1.db,$);if(!Q)return EQ1;return await Xx$(Q,$,Z)}async function Qa4($,Z){return await jQ1.runStep(()=>Za4($,Z),{name:"readPrState"})}function Qx$(){if(uT0)return;uT0=jQ1.registerWorkflow(Qa4,{name:"taskBoardGithubReadWorkflow"})}async function qc($,Z){if(!uT0)return EQ1;try{return await(await jQ1.startWorkflow(uT0,{queueName:Kj,timeoutMS:$a4})($,Z)).getResult()}catch(Q){return console.error("[task-board-github-read] throttled PR read failed",Q),EQ1}}var sr4=20,er4=4,$a4=60000,$x$,wQ1=null,EQ1,uT0=null;var ws=L(()=>{Ic();kZ();$x$={concurrency:er4,rateLimit:{limitPerPeriod:sr4,periodSec:60}};EQ1={state:null,merged:null,checksStatus:null,conflict:null}});import{createHash as Xa4}from"crypto";class Zx{config;options;now;kv=null;codec=iL();revalidating=new Set;fallback;placeholderFallback=new Map;static MAX_PLACEHOLDER_FALLBACK_ENTRIES=1000;constructor($,Z,Q=()=>Date.now()){this.config=$;this.options=Z;this.now=Q;let X={revalidateAfterMs:$.revalidateAfterMs,maxStaleMs:$.maxStaleMs,maxValueBytes:Yx$};this.fallback=new f30({"tools/call":X,"resources/read":X,"prompts/get":X})}async init($){if($){this.kv=$;return}let Z=this.options.getJetStream();if(!Z)return;this.kv=await new Jx$.Kvm(Z).create(this.config.bucket,{storage:Gx$.StorageType.Memory,ttl:this.config.maxStaleMs,maxValueSize:Yx$})}storageKey($,Z){let Q=Xa4("sha256").update(Z).digest("hex").slice(0,32);return`${$}.${Q}`}async fetch($){let{namespace:Z,key:Q,fetchLive:X,onRevalidation:Y}=$,{cache:G,revalidateAfterMs:J,maxStaleMs:K}=this.config;if(!this.kv)return this.fallback.fetch({type:"tools/call",connectionId:Z,scope:{kind:"org"},params:{key:Q},fetchLive:X,onRevalidation:Y});let W=this.storageKey(Z,Q),H=await this.read(W),F=H?this.now()-H.storedAt:Number.POSITIVE_INFINITY;if(!H||F>K){nD.add(1,{cache:G,outcome:"miss"});let U=await X();return await this.write(W,U,G),U}if(F>J&&!this.revalidating.has(W))nD.add(1,{cache:G,outcome:"stale"}),this.revalidating.add(W),Y(X().then((U)=>this.write(W,U,G)).catch(()=>{nD.add(1,{cache:G,outcome:"error"})}).finally(()=>this.revalidating.delete(W)));else nD.add(1,{cache:G,outcome:"hit"});return H.value}async fetchOrPlaceholder($){let{namespace:Z,key:Q,fetchLive:X,placeholder:Y}=$,{cache:G,revalidateAfterMs:J,maxStaleMs:K}=this.config,W=this.storageKey(Z,Q),H=await this.read(W),F=H?this.now()-H.storedAt:Number.POSITIVE_INFINITY,U=H!=null&&F<=K;if(U&&F<=J)return nD.add(1,{cache:G,outcome:"hit"}),{value:H.value,live:!0};if(nD.add(1,{cache:G,outcome:U?"stale":"placeholder"}),!this.revalidating.has(W))this.revalidating.add(W),X().then((N)=>this.write(W,N,G)).catch(()=>{nD.add(1,{cache:G,outcome:"error"})}).finally(()=>this.revalidating.delete(W));return U?{value:H.value,live:!0}:{value:Y,live:!1}}async read($){if(!this.kv)return this.placeholderFallback.get($)??null;try{let Z=await this.kv?.get($);if(!Z?.value?.length)return null;if(Z.operation==="DEL"||Z.operation==="PURGE")return null;return this.codec.decode(Z.value)}catch{return null}}async write($,Z,Q){if(!this.kv){if(this.placeholderFallback.size>=Zx.MAX_PLACEHOLDER_FALLBACK_ENTRIES){let X=this.placeholderFallback.keys().next().value;if(X!==void 0)this.placeholderFallback.delete(X)}this.placeholderFallback.set($,{storedAt:this.now(),value:Z});return}try{await this.kv?.put($,this.codec.encode({storedAt:this.now(),value:Z}))}catch{nD.add(1,{cache:Q,outcome:"store_rejected"})}}async invalidate($){if(this.fallback.invalidate($),!this.kv)return;try{let Z=await this.kv.keys(`${$}.*`);for await(let Q of Z)await this.kv.delete(Q).catch(()=>{})}catch{}}teardown(){this.kv=null}}function AQ1($){Kx$=$?.reads??null,Wx$=$?.cards??null}function TQ1(){return Kx$??Ya4}function RQ1(){return Wx$??Ga4}var Gx$,Jx$,nD,Yx$=524288,zQ1,PQ1,Kx$=null,Wx$=null,Ya4,Ga4;var IQ1=L(()=>{Mr();H6();Gx$=k(_U(),1),Jx$=k(Fr(),1),nD=X$.createCounter("pr_read_cache.fetches",{description:"Task board PR cache outcomes (hit, stale, miss, placeholder, error, store_rejected)",unit:"{fetches}"}),zQ1={bucket:"DECOCMS_PR_READS",revalidateAfterMs:55000,maxStaleMs:1800000,cache:"reads"},PQ1={bucket:"DECOCMS_PR_CARDS",revalidateAfterMs:30000,maxStaleMs:86400000,cache:"cards"};Ya4=new Zx(zQ1,{getJetStream:()=>null}),Ga4=new Zx(PQ1,{getJetStream:()=>null})});import{z as cT0}from"zod";function dT0($){let Q=($ instanceof Error?$.message:String($)).replace(/https?:\/\/\S+/gi," ");return/too many requests|rate limit|\b429\b/i.test(Q)}function Hx$($){return TQ1().invalidate($)}function W3($){return RQ1().invalidate($)}function Ja4($){let Z=null,Q=null;return{get:()=>{return Q??=$().then((X)=>{return Z=X,X}).catch((X)=>{throw Q=null,X}),Q},current:()=>Z}}function Fx$($,Z){let{get:Q,current:X}=Ja4(()=>c5($,Z,!0));return{get:Q,closeWhenIdle:(Y)=>{Promise.allSettled(Y).then(()=>X()?.close().catch(()=>{}))}}}async function js($,Z,Q,X,Y,G){try{let J=await TQ1().fetch({namespace:Z,key:JSON.stringify({name:Q,args:X}),fetchLive:()=>o4(async()=>{let K=await(await $()).callTool({name:Q,arguments:X},void 0,{timeout:mT0});if(K&&typeof K==="object"&&K.isError)throw Error(K.content?.[0]?.text??`${Q} returned isError`);return K},{maxAttempts:3,minTimeout:300,maxTimeout:3000,jitter:1,isRetriable:(K)=>!dT0(K)}),onRevalidation:(K)=>G.push(K)});return iT0(J)}catch(J){let K=J instanceof tQ?J.cause:J;return console.error(`[task-board] ${Q} failed for ${Y}:`,K),null}}async function xN($,Z,Q,X){if(Q){let G=await $.storage.connections.findById(Q,Z);if(G&&G.status==="active")return G}let{items:Y}=await $.storage.connections.list(Z,{slug:"mcp-github"});return Ka4(Y.filter((G)=>G.status==="active"),X)}function Ka4($,Z){let Q=$.find((Y)=>l5(Y)===null)??null;if(!Z)return Q??$[0]??null;return $.find((Y)=>{let G=l5(Y);return G?.owner===Z.owner&&G?.repo===Z.name})??Q}function iT0($){if(!$||typeof $!=="object")return null;let Z=$;if(Z.isError)return null;if(Z.structuredContent&&typeof Z.structuredContent==="object"&&Object.keys(Z.structuredContent).length>0)return Z.structuredContent;let Q=Z.content?.find((X)=>X.type==="text")?.text;if(!Q)return null;try{return JSON.parse(Q)}catch{return null}}function Qx($){let Z;try{Z=new URL($).hostname.toLowerCase()}catch{return!1}return Z==="deco.site"||Z.endsWith(".decocdn.com")||Z.endsWith(".deco-cx.workers.dev")||Z.endsWith(".deco.site")||Z.endsWith(".vercel.app")||Z.endsWith(".preview.vtex.app")}function Wa4($){if(!$||!Array.isArray($.statuses))return null;let Z=$.statuses.map((Q)=>Q&&typeof Q==="object"?Q:null).filter((Q)=>!!Q&&typeof Q.target_url==="string"&&Qx(Q.target_url));if(Z.length===0)return null;return Z.find((Q)=>Q.state==="success")?.target_url??Z[0].target_url}function Fa4($){let Z=Array.isArray($)?$:Array.isArray($?.check_runs)?$.check_runs:[];for(let Q of Z){if(!Q||typeof Q!=="object")continue;let X=Q,Y=typeof X.name==="string"?/^Workers Builds:\s*([a-z0-9][a-z0-9-]*)\s*$/i.exec(X.name)?.[1]:null;if(!Y)continue;let G=X.output?.summary;if(typeof G!=="string")continue;let J=/Version ID:\s*([0-9a-f]{8})/i.exec(G)?.[1];if(!J)continue;let K=`https://${J}-${Y}.${Ha4}.workers.dev`;if(Qx(K))return K}return null}function Ua4($){let Z=Array.isArray($)?$:Array.isArray($?.comments)?$.comments:Array.isArray($?.items)?$.items:[],Q=(Y)=>{let G=Y;return Date.parse(G?.updated_at)||Date.parse(G?.created_at)},X=Z.map((Y,G)=>({c:Y,index:G})).sort((Y,G)=>{let J=Q(Y.c),K=Q(G.c);if(Number.isNaN(J)||Number.isNaN(K))return Y.index-G.index;return K-J}).map(({c:Y})=>Y);for(let Y of X){let G=Y&&typeof Y.body==="string"?Y.body:"";if(!G)continue;let J=G.match(/href=['"]([^'"]+)['"][^>]*>\s*Branch Preview/i);if(J?.[1]&&Qx(J[1]))return J[1];let K=(G.match(/https?:\/\/[^\s"'<>)\]]+/g)??[]).find((W)=>Qx(W));if(K)return K}return null}function Na4($){let Z=$&&typeof $.environmentUrl==="string"?$.environmentUrl:null;return Z&&Qx(Z)?Z:null}function Ux$($){return typeof $==="string"&&/^[0-9a-fA-F]{7,40}$/.test($)?$:null}function Ba4($){let Z=$?.head;return Ux$(Z?.sha)}function Oa4($){return Ux$($?.sha)}function Nx$($){if(!$)return null;if((typeof $.total_count==="number"?$.total_count:null)===0)return null;switch($.state){case"success":return"passing";case"failure":case"error":return"failing";case"pending":return"pending";default:return null}}function Ox$($){let Z=Array.isArray($)?$:Array.isArray($?.check_runs)?$.check_runs:[];if(Z.length===0)return null;let Q=!1,X=!1;for(let Y of Z){if(!Y||typeof Y!=="object")continue;let{status:G,conclusion:J}=Y;if(G!=="completed")X=!0;else if(typeof J==="string"&&Bx$.has(J))Q=!0}if(Q)return"failing";if(X)return"pending";return"passing"}function Lx$($,Z){if($==="failing"||Z==="failing")return"failing";if($==="pending"||Z==="pending")return"pending";if($==="passing"||Z==="passing")return"passing";return null}function La4($){let Z=Array.isArray($)?$:Array.isArray($?.check_runs)?$.check_runs:[],Q=[];for(let X of Z){if(!X||typeof X!=="object")continue;let Y=X;Q.push({id:typeof Y.id==="number"?Y.id:null,name:typeof Y.name==="string"?Y.name:"",status:typeof Y.status==="string"?Y.status:"completed",conclusion:typeof Y.conclusion==="string"?Y.conclusion:null,detailsUrl:typeof Y.html_url==="string"?Y.html_url:typeof Y.details_url==="string"?Y.details_url:null})}return Q}function Da4($){return $.status==="completed"&&$.conclusion!=null&&Bx$.has($.conclusion)}async function wa4($,Z,Q,X,Y){let J=(await js($,Z,"GET_CHECK_RUN",{owner:Q.repoOwner,repo:Q.repoName,checkRunId:X},`${Es(Q)} check-run ${X}`,Y))?.output,K=typeof J?.summary==="string"?J.summary:null,W=typeof J?.text==="string"?J.text:null;return K??W??null}async function Dx$($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return null;let Y=await c5(X,$,!0),G=async(J)=>iT0(await Y.callTool({name:"pull_request_read",arguments:{method:J,owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number}},void 0,{timeout:mT0}));try{let J=null;try{J=Nx$(await G("get_status"))}catch{}try{J=Lx$(J,Ox$(await G("get_check_runs")))}catch{}return J}finally{await Y.close().catch(()=>{})}}function pT0($){if(!$)return null;if($.state!=="open")return!1;if(typeof $.mergeable==="boolean")return!$.mergeable;let Z=$.mergeable_state;if(typeof Z!=="string"||Z===""||Z==="unknown")return null;return Z==="dirty"}async function tD($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return null;let Y=await c5(X,$,!0);try{return pT0(iT0(await Y.callTool({name:"pull_request_read",arguments:{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number}},void 0,{timeout:mT0})))}catch{return null}finally{await Y.close().catch(()=>{})}}async function Ea4($,Z,Q,X,Y){let G=(N)=>js($,Z,"pull_request_read",{method:N,owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number},`${Es(Q)} (${N})`,X),[J,K,W]=await Promise.all([G("get_status"),G("get_check_runs"),G("get_comments")]),H=Lx$(Nx$(J),Ox$(K)),F=Fa4(K)??Wa4(J)??Ua4(W);if(!F){let N=Ba4(await Y)??Oa4(J);if(N)F=Na4(await js($,Z,"GET_PREVIEW_DEPLOYMENT",{owner:Q.repoOwner,repo:Q.repoName,sha:N},`${Es(Q)} (deployment preview)`,X))}let U=await Promise.all(La4(K).map(async(N)=>({name:N.name,status:N.status,conclusion:N.conclusion,detailsUrl:N.detailsUrl,summary:Da4(N)&&N.id!=null?await wa4($,Z,Q,N.id,X):null})));return{checksStatus:H,checks:U,previewUrl:F}}function MQ1($){return wx$($).every((Z)=>Z.checksStatus!=="failing"&&Z.checksStatus!=="pending")}async function ja4($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return lT0;let{get:Y,closeWhenIdle:G}=Fx$(X,$),J=[];try{let K=js(Y,X.id,"pull_request_read",{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number},`${Es(Q)} (get)`,J),[W,H]=await Promise.all([K,Ea4(Y,X.id,Q,J,K)]);if(!W)return lT0;let F=W.state,U=F==="open",N=pT0(W);return{title:typeof W.title==="string"?W.title:null,body:typeof W.body==="string"?W.body:null,state:F==="closed"?"closed":U?"open":null,draft:typeof W.draft==="boolean"?W.draft:null,merged:typeof W.merged==="boolean"?W.merged:null,mergeable:U&&N!==null?!N:null,checksStatus:U?H.checksStatus:null,checks:U?H.checks:[],previewUrl:U?H.previewUrl:null}}catch{return lT0}finally{G(J)}}async function Ex$($,Z,Q,X){let Y=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!Y)return null;let{get:G,closeWhenIdle:J}=Fx$(Y,$),K=[];try{return await js(G,Y.id,"pull_request_read",{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number},`${Es(Q)} (${X})`,K)}catch{return null}finally{J(K)}}async function vT0($,Z,Q){let X=await Ex$($,Z,Q,"landing");return{state:X?.state==="closed"?"closed":X?.state==="open"?"open":null,merged:typeof X?.merged==="boolean"?X.merged:null}}async function Xx$($,Z,Q){let X=await Ex$($,Z,Q,"candidate");return{state:X?.state==="closed"?"closed":X?.state==="open"?"open":null,merged:typeof X?.merged==="boolean"?X.merged:null,checksStatus:za4(X?.mergeable_state),conflict:pT0(X)}}function za4($){if($==="clean")return"passing";if($==="unstable")return"failing";return null}function Pa4($){let Z=$.findIndex((Q)=>Q!=="closed");return Z===-1?0:Z}async function Xx($,Z,Q){if(Q.length<=1)return Q[0];let X=[];for(let Y of Q){let{state:G}=await qc(Z,Y);if(X.push(G),G!=="closed")break}return Q[Pa4(X)]}async function jx$($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return null;let Y=await c5(X,$,!0);try{let G=iT0(await Y.callTool({name:"pull_request_read",arguments:{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number}},void 0,{timeout:mT0}));if(!G||G.state!=="open")return null;let J=G.head?.ref;return typeof J==="string"&&J.length>0?J:null}catch{return null}finally{await Y.close().catch(()=>{})}}var mT0=8000,Es=($)=>`${$.repoOwner}/${$.repoName}#${$.number}`,lT0,Ha4="deco-cx",Bx$,qQ1=($)=>wx$($).length>0,wx$=($)=>$.filter((Z)=>Z.state!=="closed"&&Z.merged!==!0),Yx;var kZ=L(()=>{V0();sU();BY();z4();t8();Q3();Tc();SQ();aK();n5();OQ1();Rc();ws();IQ1();lT0={title:null,body:null,state:null,draft:null,merged:null,mergeable:null,checksStatus:null,checks:[],previewUrl:null};Bx$=new Set(["failure","cancelled","timed_out","action_required","startup_failure","stale"]);Yx=h({name:"TASK_BOARD_ITEM_PRS_GET",description:"Get the GitHub pull requests linked to a task board item, each enriched with live state (title, open/closed, draft, merged) fetched from GitHub.",annotations:{title:"Get Task Board Item Pull Requests",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},inputSchema:cT0.object({taskBoardItemId:cT0.string()}),outputSchema:cT0.object({prs:cT0.array(zS$)}),handler:async({taskBoardItemId:$},Z)=>{r(Z),await Z.access.check();let Q=Z.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let X=await Z.storage.taskBoard.getById($,Q),Y=await Z.storage.taskBoard.listPrs($,Q),G=()=>Promise.all(Y.map(async(U)=>{let N=await ja4(Z,Q,U);return{url:U.url,number:U.number,repoOwner:U.repoOwner,repoName:U.repoName,createdAt:U.createdAt,...N}})),{value:J,live:K}=await RQ1().fetchOrPlaceholder({namespace:Q,key:$,fetchLive:G,placeholder:Y.map((U)=>({url:U.url,number:U.number,repoOwner:U.repoOwner,repoName:U.repoName,createdAt:U.createdAt,...lT0}))});if(!K)return{prs:J};let W=T$.review,H=J.find((U)=>U.state==="open"&&!U.merged);if(X&&_Y(X)&&X.assigneeId===o$&&qQ1(J))await hT0(Z,X,{previewMatchesHead:MQ1(J)}).catch((U)=>{console.error("[task-board] reviewer auto-handoff failed",U)});let F=H?pT0({state:H.state,mergeable:H.mergeable}):null;if(X&&X.status===W&&X.assigneeId===o$&&H&&F===!0)await dD(Z,Q,X,{pr:{number:H.number,url:H.url},conflict:!0}).catch((U)=>{console.error("[task-board] conflict auto-resolve failed",U)});if(ev(J))try{let U=await Z.storage.organizationSettings.get(Q),N=_H(U?.flags);if(X&&dv$(X.status,N)&&!await Z.storage.taskBoard.hasHumanRejectedDone($,Q)){let B=await Z.storage.taskBoard.update($,Q,{status:N},X.updatedBy);await C6(Z,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:X.status,to:N}}),F8(Q,B)}}catch(U){console.error("[task-board] merged-PR reconcile failed",U)}return{prs:J}}})});function Px$($){if(zx$.has($.kind??""))return 0;return qa4($)?Ra4:Ia4}function qa4($){let Z=$.kind??"";if(zx$.has(Z))return!1;if(Aa4.has(Z))return!0;let Q=$.errorText??"";if(!Q)return!1;if(Q.includes(uA0))return!0;let X=Q.replace(/https?:\/\/\S+/gi," ");return Ta4.some((Y)=>Y.test(X))}var Aa4,zx$,Ta4,Ra4=3,Ia4=1;var Ax$=L(()=>{KT0();Aa4=new Set(["stall","liveness","projection","abandoned"]),zx$=new Set(["cancelled",...Hs]),Ta4=[/sandbox did not become ready/i,/sandbox (?:provisioning|claim) failed/i,/mcp is unusable/i,/harness_crashed: unexpected eof/i,/too many clients already|timeout exceeded when trying to connect/i,/\b(?:429|503)\b|too many requests|service unavailable/i]});function nT0($,Z,Q,X){AG({event:$,organizationId:Z,properties:{task_id:Q.id,reports_task:DY(Q),...X}})}function F8($,Z){p5.emit($,{id:crypto.randomUUID(),type:sD$,source:"task-board",subject:Z.id,data:Z,time:new Date().toISOString()})}function Tx$($,Z){p5.emit($,{id:crypto.randomUUID(),type:eD$,source:"task-board",subject:Z,data:{id:Z},time:new Date().toISOString()})}function Ma4($,Z){return $?[$]:Z}async function Gx($,Z,Q){let X=$.metadata?.runMetadata?.taskBoardItemId,Y=!X&&Q?await $.storage.taskBoard.linkedTaskIds(Q,Z):[];return Ma4(X,Y)}async function Rx$($,Z,Q){let X=$.organization?.id;if(!X)return;try{let Y=T$[Z];for(let G of await Gx($,X,Q)){let J=await $.storage.taskBoard.getById(G,X);if(!J)continue;if(J.status===Y||!fT0(J.status,Y))continue;let K=await $.storage.taskBoard.update(G,X,{status:Y},$.auth?.user?.id??J.updatedBy);if(await $.storage.taskBoard.recordActivity({taskBoardItemId:G,action:"status_changed",actorId:null,data:{from:J.status,to:Y}}).catch((W)=>console.error("[task-board] activity log write failed",W)),F8(X,K),Z==="progress")nT0("task_run_started",X,K,{from:J.status})}}catch(Y){console.error("[task-board] run transition failed",Y)}}async function tT0($,Z){let Q=$.organization?.id;if(!Q)return;try{for(let X of await Gx($,Q,Z)){let Y=await $.storage.taskBoard.openReviewCycleIfInProgress(X,Q);if(!Y)continue;F8(Q,Y),nT0("task_run_completed",Q,Y,{from:"in_progress",via:"pr_open"})}}catch(X){console.error("[task-board] review-cycle open failed",X)}}async function oT0($,Z,Q,X){let Y=$.organization?.id;if(!Y)return;try{let G=ST0(Z);if(!G)return;let J=await Gx($,Y,X);for(let K of J)await $.storage.taskBoard.linkPr({taskBoardItemId:K,organizationId:Y,url:G.url,prNumber:G.number,repoOwner:G.owner,repoName:G.repo,connectionId:Q??null});if(J.length>0)await W3(Y)}catch(G){console.error("[task-board] PR capture failed",G)}}async function Mc($,Z,Q,X){try{let Y=await $.advanceLinkedTasksToReviewOnThreadFinish(Z,Q);for(let G of Y)F8(Q,G),nT0("task_run_completed",Q,G,{from:"in_progress",via:"thread_finish"});for(let G of Y)await $.clearRunRetry(G.id,Q).catch(()=>{})}catch(Y){console.error("[task-board] thread-finish transition failed",Y)}await VQ1($,Z,Q),await kQ1($,X,Z,Q)}function Ix$($){return($x($.status)??-1)>=xT0.in_review||Boolean($.reviewCycleStartedAt)}async function VQ1($,Z,Q){try{let X=await $.failedRunInfo(Z,Q);if(!X)return;let Y=Px$(X);for(let G of await $.linkedTaskIds(Z,Q)){let J=await $.getById(G,Q);if(!J)continue;if(Ix$(J))await $.relabelDeliveredFailure(Z,Q,Sa4).catch(()=>{});if(J.status!==T$.progress)continue;if(J.reviewCycleStartedAt)continue;if(J.threads.some((H)=>H.hasMessages&&H.status==="in_progress"))continue;let K=J.retryAttempts;if(K<Y){let H=D7(ka4,Va4,K,2,0.5);if(!await $.scheduleRunRetry(G,Q,K+1,new Date(Date.now()+H)))continue;await $.recordActivity({taskBoardItemId:G,action:"status_changed",actorId:null,data:{from:T$.progress,to:T$.progress,retry:K+1,of:Y,reason:X.errorText??X.kind}}).catch(()=>{});continue}let W=await $.returnToTodoAfterFailure(G,Q,J.updatedBy);if(!W)continue;await $.recordActivity({taskBoardItemId:G,action:"status_changed",actorId:null,data:{from:T$.progress,to:T$.queue,reason:X.errorText??X.kind,retriesSpent:K}}).catch(()=>{}),F8(Q,W),nT0("task_run_failed",Q,J,{reason:X.kind??"error",retries_spent:K})}}catch(X){console.error("[task-board] failed-run reaction failed",X)}}async function kQ1($,Z,Q,X){try{for(let Y of await $.linkedTaskIds(Q,X)){let G=await $.getById(Y,X);if(!G)continue;if(Ix$(G))continue;if(G.threads.some((K)=>K.hasMessages&&(K.status===null||!Os.has(K.status))))continue;if((await $.listPrs(Y,X)).length>0)continue;await Yw$(Z,X,Y)}}catch(Y){console.error("[task-board] quota refund pass failed",Y)}}async function SQ1($,Z){if(Z.status!==T$.progress||!_Y(Z))return;try{let Q=await $.storage.taskBoard.update(Z.id,Z.organizationId,{status:T$.review},Z.updatedBy);await $.storage.taskBoard.recordActivity({taskBoardItemId:Z.id,action:"status_changed",actorId:null,data:{from:Z.status,to:T$.review}}).catch(()=>{}),F8(Z.organizationId,Q)}catch(Q){console.error(`[task-board] parking ${Z.id} for review failed`,Q)}}async function eH($,Z,Q){let X=Z.organizationId;if(Z.assigneeId!==o$)return!1;try{await SQ1($,Z).catch((G)=>console.warn(`[task-board] parking ${Z.id} before hand-off failed`,G));let Y=await $.storage.taskBoard.unassignSuperAgent(Z.id,X,Z.updatedBy);if(!Y)return!1;return await C6($,{taskBoardItemId:Z.id,action:"assignee_changed",actorId:null,data:{from:Z.assigneeId,to:null,reason:Q}}),console.warn(`[task-board] ${Z.id} handed to a human: ${Q}`),F8(X,Y),!0}catch(Y){return console.error(`[task-board] handing ${Z.id} to a human failed`,Y),!1}}async function ev$($,Z,Q){if(!(Q instanceof IX))return!1;if(Q.reason!=="runs_exhausted")return!1;return await eH($,Z,"per-task run limit reached \u2014 the Super Agent can no longer re-dispatch "+"itself on this task. Re-run it manually to continue."),!0}async function qx$($,Z){let Q=$.organization?.id;if(!Q)return;try{let X=await $.storage.taskBoard.reopenLinkedTasksOnThreadRun(Z,Q);for(let Y of X)F8(Q,Y)}catch(X){console.error("[task-board] thread-run reopen failed",X)}}function Mx$($){return $.includes("create_pull_request")||$.includes("createPullRequest")}function Vx$($){if(Ca4.test($))return!0;return _a4.test($)&&va4.test($)}var Va4=30000,ka4=120000,Sa4="Run ended after it had already delivered \u2014 the task moved on without it",Ca4,_a4,va4;var n5=L(()=>{nJ();y4();vN();Ac();kZ();Ax$();t8();Ns();z4();SQ();aK();Ca4=/\bgh\s+pr\s+create\b/,_a4=/api\.github\.com\/repos\/[^\s"']+\/pulls\b/,va4=/(?:-X|--request)\s+POST/});function xa4($){if($.status==="completed")return"advance";if($.status==="failed"&&$.messageStorageVersion===2&&($.harnessId==="decopilot"||$.harnessId==="claude-code"))return"nudge";return"none"}function fa4($){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(`
2895
+ That comment must ALWAYS carry the visual change: embed the before/after screenshots in it whenever the change has any visual surface. If it has none, write the exact words \`${ur}\` in the comment and `+"name why (backend-only, config, test-only) \u2014 that literal is what a "+"machine check looks for, so no paraphrase of it counts, and silence about screenshots is not an acceptable answer either way.\n5. DECIDE. Approve once the pull request is in the state you would approve. Only `request_changes` for something you genuinely cannot settle here (a product decision, a missing credential, an approach that needs "+"rethinking) \u2014 that hands the card to a human, it does not start another "+"agent round. NEVER end your run without having called `TASK_BOARD_REVIEW_DECISION`: a run that stops to wait on a background task, or that runs low on room, must decide on what it knows first. An unrecorded verdict strands the card and is the one failure this run cannot leave behind."}});function ar4($,Z){return $.status===T$.review&&$.assigneeId===o$&&Z===!0}function DQ1($){return $.filter((Q)=>Q.action==="merge_conflict_resolution").length>=sv$}async function dD($,Z,Q,X){if(!ar4(Q,X.conflict))return!1;let G=(await $.storage.organizationSettings.get(Z))?.flags??{};if(!zD$(G))return!1;let J=JN(G),K=await $.storage.taskBoard.listActivity(Q.id,Z);if(!YD(K,J,{cycleStartedAt:Q.reviewCycleStartedAt,verifiedOnly:!0}))return!1;if(DQ1(K))return console.warn(`[task-board] conflict auto-resolve cap (${sv$}) reached on task ${Q.id} \u2014 leaving the PR for a human`),!1;let W=X.pr,H=await $.storage.taskBoard.claimConflictResolution(Q.id,Z,Q.updatedBy);if(!H)return!1;F8(Z,H);try{await sK($,H,{pr:{number:W.number,url:W.url},resolveConflict:!0})}catch(F){throw await ev$($,H,F).catch(()=>!1),await $.storage.taskBoard.update(H.id,Z,{status:T$.review},"system").then((U)=>F8(Z,U)).catch((U)=>console.error("[task-board] conflict-resolution status revert failed",U)),F}return await C6($,{taskBoardItemId:Q.id,action:"merge_conflict_resolution",actorId:null,data:{prNumber:W.number}}),!0}var sv$=3;var Rc=L(()=>{z4();ZZ();SQ();n5();$F()});async function ZF($,Z){let Q=await $.selectFrom("organization").select(["id","slug","name"]).where("id","=",Z).executeTakeFirst();if(!Q)return null;let X=await K3.create();return X.organization={id:Q.id,slug:Q.slug,name:Q.name},iD(X,{id:Q.id,slug:Q.slug}),X}var Ic=L(()=>{pD()});import{DBOS as jQ1}from"@dbos-inc/dbos-sdk";function Zx$($){wQ1=$}async function Za4($,Z){if(!wQ1)throw Error("[task-board-github-read] runtime not initialized \u2014 setTaskBoardGithubReadRuntime() must run before the workflow fires");let Q=await ZF(wQ1.db,$);if(!Q)return EQ1;return await Xx$(Q,$,Z)}async function Qa4($,Z){return await jQ1.runStep(()=>Za4($,Z),{name:"readPrState"})}function Qx$(){if(uT0)return;uT0=jQ1.registerWorkflow(Qa4,{name:"taskBoardGithubReadWorkflow"})}async function qc($,Z){if(!uT0)return EQ1;try{return await(await jQ1.startWorkflow(uT0,{queueName:Kj,timeoutMS:$a4})($,Z)).getResult()}catch(Q){return console.error("[task-board-github-read] throttled PR read failed",Q),EQ1}}var sr4=20,er4=4,$a4=60000,$x$,wQ1=null,EQ1,uT0=null;var ws=L(()=>{Ic();kZ();$x$={concurrency:er4,rateLimit:{limitPerPeriod:sr4,periodSec:60}};EQ1={state:null,merged:null,checksStatus:null,conflict:null}});import{createHash as Xa4}from"crypto";class Zx{config;options;now;kv=null;codec=iL();revalidating=new Set;fallback;placeholderFallback=new Map;static MAX_PLACEHOLDER_FALLBACK_ENTRIES=1000;constructor($,Z,Q=()=>Date.now()){this.config=$;this.options=Z;this.now=Q;let X={revalidateAfterMs:$.revalidateAfterMs,maxStaleMs:$.maxStaleMs,maxValueBytes:Yx$};this.fallback=new f30({"tools/call":X,"resources/read":X,"prompts/get":X})}async init($){if($){this.kv=$;return}let Z=this.options.getJetStream();if(!Z)return;this.kv=await new Jx$.Kvm(Z).create(this.config.bucket,{storage:Gx$.StorageType.Memory,ttl:this.config.maxStaleMs,maxValueSize:Yx$})}storageKey($,Z){let Q=Xa4("sha256").update(Z).digest("hex").slice(0,32);return`${$}.${Q}`}async fetch($){let{namespace:Z,key:Q,fetchLive:X,onRevalidation:Y}=$,{cache:G,revalidateAfterMs:J,maxStaleMs:K}=this.config;if(!this.kv)return this.fallback.fetch({type:"tools/call",connectionId:Z,scope:{kind:"org"},params:{key:Q},fetchLive:X,onRevalidation:Y});let W=this.storageKey(Z,Q),H=await this.read(W),F=H?this.now()-H.storedAt:Number.POSITIVE_INFINITY;if(!H||F>K){nD.add(1,{cache:G,outcome:"miss"});let U=await X();return await this.write(W,U,G),U}if(F>J&&!this.revalidating.has(W))nD.add(1,{cache:G,outcome:"stale"}),this.revalidating.add(W),Y(X().then((U)=>this.write(W,U,G)).catch(()=>{nD.add(1,{cache:G,outcome:"error"})}).finally(()=>this.revalidating.delete(W)));else nD.add(1,{cache:G,outcome:"hit"});return H.value}async fetchOrPlaceholder($){let{namespace:Z,key:Q,fetchLive:X,placeholder:Y}=$,{cache:G,revalidateAfterMs:J,maxStaleMs:K}=this.config,W=this.storageKey(Z,Q),H=await this.read(W),F=H?this.now()-H.storedAt:Number.POSITIVE_INFINITY,U=H!=null&&F<=K;if(U&&F<=J)return nD.add(1,{cache:G,outcome:"hit"}),{value:H.value,live:!0};if(nD.add(1,{cache:G,outcome:U?"stale":"placeholder"}),!this.revalidating.has(W))this.revalidating.add(W),X().then((N)=>this.write(W,N,G)).catch(()=>{nD.add(1,{cache:G,outcome:"error"})}).finally(()=>this.revalidating.delete(W));return U?{value:H.value,live:!0}:{value:Y,live:!1}}async read($){if(!this.kv)return this.placeholderFallback.get($)??null;try{let Z=await this.kv?.get($);if(!Z?.value?.length)return null;if(Z.operation==="DEL"||Z.operation==="PURGE")return null;return this.codec.decode(Z.value)}catch{return null}}async write($,Z,Q){if(!this.kv){if(this.placeholderFallback.size>=Zx.MAX_PLACEHOLDER_FALLBACK_ENTRIES){let X=this.placeholderFallback.keys().next().value;if(X!==void 0)this.placeholderFallback.delete(X)}this.placeholderFallback.set($,{storedAt:this.now(),value:Z});return}try{await this.kv?.put($,this.codec.encode({storedAt:this.now(),value:Z}))}catch{nD.add(1,{cache:Q,outcome:"store_rejected"})}}async invalidate($){if(this.fallback.invalidate($),!this.kv)return;try{let Z=await this.kv.keys(`${$}.*`);for await(let Q of Z)await this.kv.delete(Q).catch(()=>{})}catch{}}teardown(){this.kv=null}}function AQ1($){Kx$=$?.reads??null,Wx$=$?.cards??null}function TQ1(){return Kx$??Ya4}function RQ1(){return Wx$??Ga4}var Gx$,Jx$,nD,Yx$=524288,zQ1,PQ1,Kx$=null,Wx$=null,Ya4,Ga4;var IQ1=L(()=>{Mr();H6();Gx$=k(_U(),1),Jx$=k(Fr(),1),nD=X$.createCounter("pr_read_cache.fetches",{description:"Task board PR cache outcomes (hit, stale, miss, placeholder, error, store_rejected)",unit:"{fetches}"}),zQ1={bucket:"DECOCMS_PR_READS",revalidateAfterMs:55000,maxStaleMs:1800000,cache:"reads"},PQ1={bucket:"DECOCMS_PR_CARDS",revalidateAfterMs:30000,maxStaleMs:86400000,cache:"cards"};Ya4=new Zx(zQ1,{getJetStream:()=>null}),Ga4=new Zx(PQ1,{getJetStream:()=>null})});import{z as cT0}from"zod";function dT0($){let Q=($ instanceof Error?$.message:String($)).replace(/https?:\/\/\S+/gi," ");return/too many requests|rate limit|\b429\b/i.test(Q)}function Hx$($){return TQ1().invalidate($)}function W3($){return RQ1().invalidate($)}function Ja4($){let Z=null,Q=null;return{get:()=>{return Q??=$().then((X)=>{return Z=X,X}).catch((X)=>{throw Q=null,X}),Q},current:()=>Z}}function Fx$($,Z){let{get:Q,current:X}=Ja4(()=>c5($,Z,!0));return{get:Q,closeWhenIdle:(Y)=>{Promise.allSettled(Y).then(()=>X()?.close().catch(()=>{}))}}}async function js($,Z,Q,X,Y,G){try{let J=await TQ1().fetch({namespace:Z,key:JSON.stringify({name:Q,args:X}),fetchLive:()=>o4(async()=>{let K=await(await $()).callTool({name:Q,arguments:X},void 0,{timeout:mT0});if(K&&typeof K==="object"&&K.isError)throw Error(K.content?.[0]?.text??`${Q} returned isError`);return K},{maxAttempts:3,minTimeout:300,maxTimeout:3000,jitter:1,isRetriable:(K)=>!dT0(K)}),onRevalidation:(K)=>G.push(K)});return iT0(J)}catch(J){let K=J instanceof tQ?J.cause:J;return console.error(`[task-board] ${Q} failed for ${Y}:`,K),null}}async function xN($,Z,Q,X){if(Q){let G=await $.storage.connections.findById(Q,Z);if(G&&G.status==="active")return G}let{items:Y}=await $.storage.connections.list(Z,{slug:"mcp-github"});return Ka4(Y.filter((G)=>G.status==="active"),X)}function Ka4($,Z){let Q=$.find((Y)=>l5(Y)===null)??null;if(!Z)return Q??$[0]??null;return $.find((Y)=>{let G=l5(Y);return G?.owner===Z.owner&&G?.repo===Z.name})??Q}function iT0($){if(!$||typeof $!=="object")return null;let Z=$;if(Z.isError)return null;if(Z.structuredContent&&typeof Z.structuredContent==="object"&&Object.keys(Z.structuredContent).length>0)return Z.structuredContent;let Q=Z.content?.find((X)=>X.type==="text")?.text;if(!Q)return null;try{return JSON.parse(Q)}catch{return null}}function Qx($){let Z;try{Z=new URL($).hostname.toLowerCase()}catch{return!1}return Z==="deco.site"||Z.endsWith(".decocdn.com")||Z.endsWith(".deco-cx.workers.dev")||Z.endsWith(".deco.site")||Z.endsWith(".vercel.app")||Z.endsWith(".vtex.app")}function Wa4($){if(!$||!Array.isArray($.statuses))return null;let Z=$.statuses.map((Q)=>Q&&typeof Q==="object"?Q:null).filter((Q)=>!!Q&&typeof Q.target_url==="string"&&Qx(Q.target_url));if(Z.length===0)return null;return Z.find((Q)=>Q.state==="success")?.target_url??Z[0].target_url}function Fa4($){let Z=Array.isArray($)?$:Array.isArray($?.check_runs)?$.check_runs:[];for(let Q of Z){if(!Q||typeof Q!=="object")continue;let X=Q,Y=typeof X.name==="string"?/^Workers Builds:\s*([a-z0-9][a-z0-9-]*)\s*$/i.exec(X.name)?.[1]:null;if(!Y)continue;let G=X.output?.summary;if(typeof G!=="string")continue;let J=/Version ID:\s*([0-9a-f]{8})/i.exec(G)?.[1];if(!J)continue;let K=`https://${J}-${Y}.${Ha4}.workers.dev`;if(Qx(K))return K}return null}function Ua4($){let Z=Array.isArray($)?$:Array.isArray($?.comments)?$.comments:Array.isArray($?.items)?$.items:[],Q=(Y)=>{let G=Y;return Date.parse(G?.updated_at)||Date.parse(G?.created_at)},X=Z.map((Y,G)=>({c:Y,index:G})).sort((Y,G)=>{let J=Q(Y.c),K=Q(G.c);if(Number.isNaN(J)||Number.isNaN(K))return Y.index-G.index;return K-J}).map(({c:Y})=>Y);for(let Y of X){let G=Y&&typeof Y.body==="string"?Y.body:"";if(!G)continue;let J=G.match(/href=['"]([^'"]+)['"][^>]*>\s*Branch Preview/i);if(J?.[1]&&Qx(J[1]))return J[1];let K=(G.match(/https?:\/\/[^\s"'<>)\]]+/g)??[]).find((W)=>Qx(W));if(K)return K}return null}function Na4($){let Z=$&&typeof $.environmentUrl==="string"?$.environmentUrl:null;return Z&&Qx(Z)?Z:null}function Ux$($){return typeof $==="string"&&/^[0-9a-fA-F]{7,40}$/.test($)?$:null}function Ba4($){let Z=$?.head;return Ux$(Z?.sha)}function Oa4($){return Ux$($?.sha)}function Nx$($){if(!$)return null;if((typeof $.total_count==="number"?$.total_count:null)===0)return null;switch($.state){case"success":return"passing";case"failure":case"error":return"failing";case"pending":return"pending";default:return null}}function Ox$($){let Z=Array.isArray($)?$:Array.isArray($?.check_runs)?$.check_runs:[];if(Z.length===0)return null;let Q=!1,X=!1;for(let Y of Z){if(!Y||typeof Y!=="object")continue;let{status:G,conclusion:J}=Y;if(G!=="completed")X=!0;else if(typeof J==="string"&&Bx$.has(J))Q=!0}if(Q)return"failing";if(X)return"pending";return"passing"}function Lx$($,Z){if($==="failing"||Z==="failing")return"failing";if($==="pending"||Z==="pending")return"pending";if($==="passing"||Z==="passing")return"passing";return null}function La4($){let Z=Array.isArray($)?$:Array.isArray($?.check_runs)?$.check_runs:[],Q=[];for(let X of Z){if(!X||typeof X!=="object")continue;let Y=X;Q.push({id:typeof Y.id==="number"?Y.id:null,name:typeof Y.name==="string"?Y.name:"",status:typeof Y.status==="string"?Y.status:"completed",conclusion:typeof Y.conclusion==="string"?Y.conclusion:null,detailsUrl:typeof Y.html_url==="string"?Y.html_url:typeof Y.details_url==="string"?Y.details_url:null})}return Q}function Da4($){return $.status==="completed"&&$.conclusion!=null&&Bx$.has($.conclusion)}async function wa4($,Z,Q,X,Y){let J=(await js($,Z,"GET_CHECK_RUN",{owner:Q.repoOwner,repo:Q.repoName,checkRunId:X},`${Es(Q)} check-run ${X}`,Y))?.output,K=typeof J?.summary==="string"?J.summary:null,W=typeof J?.text==="string"?J.text:null;return K??W??null}async function Dx$($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return null;let Y=await c5(X,$,!0),G=async(J)=>iT0(await Y.callTool({name:"pull_request_read",arguments:{method:J,owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number}},void 0,{timeout:mT0}));try{let J=null;try{J=Nx$(await G("get_status"))}catch{}try{J=Lx$(J,Ox$(await G("get_check_runs")))}catch{}return J}finally{await Y.close().catch(()=>{})}}function pT0($){if(!$)return null;if($.state!=="open")return!1;if(typeof $.mergeable==="boolean")return!$.mergeable;let Z=$.mergeable_state;if(typeof Z!=="string"||Z===""||Z==="unknown")return null;return Z==="dirty"}async function tD($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return null;let Y=await c5(X,$,!0);try{return pT0(iT0(await Y.callTool({name:"pull_request_read",arguments:{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number}},void 0,{timeout:mT0})))}catch{return null}finally{await Y.close().catch(()=>{})}}async function Ea4($,Z,Q,X,Y){let G=(N)=>js($,Z,"pull_request_read",{method:N,owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number},`${Es(Q)} (${N})`,X),[J,K,W]=await Promise.all([G("get_status"),G("get_check_runs"),G("get_comments")]),H=Lx$(Nx$(J),Ox$(K)),F=Fa4(K)??Wa4(J)??Ua4(W);if(!F){let N=Ba4(await Y)??Oa4(J);if(N)F=Na4(await js($,Z,"GET_PREVIEW_DEPLOYMENT",{owner:Q.repoOwner,repo:Q.repoName,sha:N},`${Es(Q)} (deployment preview)`,X))}let U=await Promise.all(La4(K).map(async(N)=>({name:N.name,status:N.status,conclusion:N.conclusion,detailsUrl:N.detailsUrl,summary:Da4(N)&&N.id!=null?await wa4($,Z,Q,N.id,X):null})));return{checksStatus:H,checks:U,previewUrl:F}}function MQ1($){return wx$($).every((Z)=>Z.checksStatus!=="failing"&&Z.checksStatus!=="pending")}async function ja4($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return lT0;let{get:Y,closeWhenIdle:G}=Fx$(X,$),J=[];try{let K=js(Y,X.id,"pull_request_read",{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number},`${Es(Q)} (get)`,J),[W,H]=await Promise.all([K,Ea4(Y,X.id,Q,J,K)]);if(!W)return lT0;let F=W.state,U=F==="open",N=pT0(W);return{title:typeof W.title==="string"?W.title:null,body:typeof W.body==="string"?W.body:null,state:F==="closed"?"closed":U?"open":null,draft:typeof W.draft==="boolean"?W.draft:null,merged:typeof W.merged==="boolean"?W.merged:null,mergeable:U&&N!==null?!N:null,checksStatus:U?H.checksStatus:null,checks:U?H.checks:[],previewUrl:U?H.previewUrl:null}}catch{return lT0}finally{G(J)}}async function Ex$($,Z,Q,X){let Y=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!Y)return null;let{get:G,closeWhenIdle:J}=Fx$(Y,$),K=[];try{return await js(G,Y.id,"pull_request_read",{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number},`${Es(Q)} (${X})`,K)}catch{return null}finally{J(K)}}async function vT0($,Z,Q){let X=await Ex$($,Z,Q,"landing");return{state:X?.state==="closed"?"closed":X?.state==="open"?"open":null,merged:typeof X?.merged==="boolean"?X.merged:null}}async function Xx$($,Z,Q){let X=await Ex$($,Z,Q,"candidate");return{state:X?.state==="closed"?"closed":X?.state==="open"?"open":null,merged:typeof X?.merged==="boolean"?X.merged:null,checksStatus:za4(X?.mergeable_state),conflict:pT0(X)}}function za4($){if($==="clean")return"passing";if($==="unstable")return"failing";return null}function Pa4($){let Z=$.findIndex((Q)=>Q!=="closed");return Z===-1?0:Z}async function Xx($,Z,Q){if(Q.length<=1)return Q[0];let X=[];for(let Y of Q){let{state:G}=await qc(Z,Y);if(X.push(G),G!=="closed")break}return Q[Pa4(X)]}async function jx$($,Z,Q){let X=await xN($,Z,Q.connectionId,{owner:Q.repoOwner,name:Q.repoName});if(!X)return null;let Y=await c5(X,$,!0);try{let G=iT0(await Y.callTool({name:"pull_request_read",arguments:{method:"get",owner:Q.repoOwner,repo:Q.repoName,pullNumber:Q.number}},void 0,{timeout:mT0}));if(!G||G.state!=="open")return null;let J=G.head?.ref;return typeof J==="string"&&J.length>0?J:null}catch{return null}finally{await Y.close().catch(()=>{})}}var mT0=8000,Es=($)=>`${$.repoOwner}/${$.repoName}#${$.number}`,lT0,Ha4="deco-cx",Bx$,qQ1=($)=>wx$($).length>0,wx$=($)=>$.filter((Z)=>Z.state!=="closed"&&Z.merged!==!0),Yx;var kZ=L(()=>{V0();sU();BY();z4();t8();Q3();Tc();SQ();aK();n5();OQ1();Rc();ws();IQ1();lT0={title:null,body:null,state:null,draft:null,merged:null,mergeable:null,checksStatus:null,checks:[],previewUrl:null};Bx$=new Set(["failure","cancelled","timed_out","action_required","startup_failure","stale"]);Yx=h({name:"TASK_BOARD_ITEM_PRS_GET",description:"Get the GitHub pull requests linked to a task board item, each enriched with live state (title, open/closed, draft, merged) fetched from GitHub.",annotations:{title:"Get Task Board Item Pull Requests",readOnlyHint:!1,destructiveHint:!1,idempotentHint:!0,openWorldHint:!0},inputSchema:cT0.object({taskBoardItemId:cT0.string()}),outputSchema:cT0.object({prs:cT0.array(zS$)}),handler:async({taskBoardItemId:$},Z)=>{r(Z),await Z.access.check();let Q=Z.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let X=await Z.storage.taskBoard.getById($,Q),Y=await Z.storage.taskBoard.listPrs($,Q),G=()=>Promise.all(Y.map(async(U)=>{let N=await ja4(Z,Q,U);return{url:U.url,number:U.number,repoOwner:U.repoOwner,repoName:U.repoName,createdAt:U.createdAt,...N}})),{value:J,live:K}=await RQ1().fetchOrPlaceholder({namespace:Q,key:$,fetchLive:G,placeholder:Y.map((U)=>({url:U.url,number:U.number,repoOwner:U.repoOwner,repoName:U.repoName,createdAt:U.createdAt,...lT0}))});if(!K)return{prs:J};let W=T$.review,H=J.find((U)=>U.state==="open"&&!U.merged);if(X&&_Y(X)&&X.assigneeId===o$&&qQ1(J))await hT0(Z,X,{previewMatchesHead:MQ1(J)}).catch((U)=>{console.error("[task-board] reviewer auto-handoff failed",U)});let F=H?pT0({state:H.state,mergeable:H.mergeable}):null;if(X&&X.status===W&&X.assigneeId===o$&&H&&F===!0)await dD(Z,Q,X,{pr:{number:H.number,url:H.url},conflict:!0}).catch((U)=>{console.error("[task-board] conflict auto-resolve failed",U)});if(ev(J))try{let U=await Z.storage.organizationSettings.get(Q),N=_H(U?.flags);if(X&&dv$(X.status,N)&&!await Z.storage.taskBoard.hasHumanRejectedDone($,Q)){let B=await Z.storage.taskBoard.update($,Q,{status:N},X.updatedBy);await C6(Z,{taskBoardItemId:$,action:"status_changed",actorId:null,data:{from:X.status,to:N}}),F8(Q,B)}}catch(U){console.error("[task-board] merged-PR reconcile failed",U)}return{prs:J}}})});function Px$($){if(zx$.has($.kind??""))return 0;return qa4($)?Ra4:Ia4}function qa4($){let Z=$.kind??"";if(zx$.has(Z))return!1;if(Aa4.has(Z))return!0;let Q=$.errorText??"";if(!Q)return!1;if(Q.includes(uA0))return!0;let X=Q.replace(/https?:\/\/\S+/gi," ");return Ta4.some((Y)=>Y.test(X))}var Aa4,zx$,Ta4,Ra4=3,Ia4=1;var Ax$=L(()=>{KT0();Aa4=new Set(["stall","liveness","projection","abandoned"]),zx$=new Set(["cancelled",...Hs]),Ta4=[/sandbox did not become ready/i,/sandbox (?:provisioning|claim) failed/i,/mcp is unusable/i,/harness_crashed: unexpected eof/i,/too many clients already|timeout exceeded when trying to connect/i,/\b(?:429|503)\b|too many requests|service unavailable/i]});function nT0($,Z,Q,X){AG({event:$,organizationId:Z,properties:{task_id:Q.id,reports_task:DY(Q),...X}})}function F8($,Z){p5.emit($,{id:crypto.randomUUID(),type:sD$,source:"task-board",subject:Z.id,data:Z,time:new Date().toISOString()})}function Tx$($,Z){p5.emit($,{id:crypto.randomUUID(),type:eD$,source:"task-board",subject:Z,data:{id:Z},time:new Date().toISOString()})}function Ma4($,Z){return $?[$]:Z}async function Gx($,Z,Q){let X=$.metadata?.runMetadata?.taskBoardItemId,Y=!X&&Q?await $.storage.taskBoard.linkedTaskIds(Q,Z):[];return Ma4(X,Y)}async function Rx$($,Z,Q){let X=$.organization?.id;if(!X)return;try{let Y=T$[Z];for(let G of await Gx($,X,Q)){let J=await $.storage.taskBoard.getById(G,X);if(!J)continue;if(J.status===Y||!fT0(J.status,Y))continue;let K=await $.storage.taskBoard.update(G,X,{status:Y},$.auth?.user?.id??J.updatedBy);if(await $.storage.taskBoard.recordActivity({taskBoardItemId:G,action:"status_changed",actorId:null,data:{from:J.status,to:Y}}).catch((W)=>console.error("[task-board] activity log write failed",W)),F8(X,K),Z==="progress")nT0("task_run_started",X,K,{from:J.status})}}catch(Y){console.error("[task-board] run transition failed",Y)}}async function tT0($,Z){let Q=$.organization?.id;if(!Q)return;try{for(let X of await Gx($,Q,Z)){let Y=await $.storage.taskBoard.openReviewCycleIfInProgress(X,Q);if(!Y)continue;F8(Q,Y),nT0("task_run_completed",Q,Y,{from:"in_progress",via:"pr_open"})}}catch(X){console.error("[task-board] review-cycle open failed",X)}}async function oT0($,Z,Q,X){let Y=$.organization?.id;if(!Y)return;try{let G=ST0(Z);if(!G)return;let J=await Gx($,Y,X);for(let K of J)await $.storage.taskBoard.linkPr({taskBoardItemId:K,organizationId:Y,url:G.url,prNumber:G.number,repoOwner:G.owner,repoName:G.repo,connectionId:Q??null});if(J.length>0)await W3(Y)}catch(G){console.error("[task-board] PR capture failed",G)}}async function Mc($,Z,Q,X){try{let Y=await $.advanceLinkedTasksToReviewOnThreadFinish(Z,Q);for(let G of Y)F8(Q,G),nT0("task_run_completed",Q,G,{from:"in_progress",via:"thread_finish"});for(let G of Y)await $.clearRunRetry(G.id,Q).catch(()=>{})}catch(Y){console.error("[task-board] thread-finish transition failed",Y)}await VQ1($,Z,Q),await kQ1($,X,Z,Q)}function Ix$($){return($x($.status)??-1)>=xT0.in_review||Boolean($.reviewCycleStartedAt)}async function VQ1($,Z,Q){try{let X=await $.failedRunInfo(Z,Q);if(!X)return;let Y=Px$(X);for(let G of await $.linkedTaskIds(Z,Q)){let J=await $.getById(G,Q);if(!J)continue;if(Ix$(J))await $.relabelDeliveredFailure(Z,Q,Sa4).catch(()=>{});if(J.status!==T$.progress)continue;if(J.reviewCycleStartedAt)continue;if(J.threads.some((H)=>H.hasMessages&&H.status==="in_progress"))continue;let K=J.retryAttempts;if(K<Y){let H=D7(ka4,Va4,K,2,0.5);if(!await $.scheduleRunRetry(G,Q,K+1,new Date(Date.now()+H)))continue;await $.recordActivity({taskBoardItemId:G,action:"status_changed",actorId:null,data:{from:T$.progress,to:T$.progress,retry:K+1,of:Y,reason:X.errorText??X.kind}}).catch(()=>{});continue}let W=await $.returnToTodoAfterFailure(G,Q,J.updatedBy);if(!W)continue;await $.recordActivity({taskBoardItemId:G,action:"status_changed",actorId:null,data:{from:T$.progress,to:T$.queue,reason:X.errorText??X.kind,retriesSpent:K}}).catch(()=>{}),F8(Q,W),nT0("task_run_failed",Q,J,{reason:X.kind??"error",retries_spent:K})}}catch(X){console.error("[task-board] failed-run reaction failed",X)}}async function kQ1($,Z,Q,X){try{for(let Y of await $.linkedTaskIds(Q,X)){let G=await $.getById(Y,X);if(!G)continue;if(Ix$(G))continue;if(G.threads.some((K)=>K.hasMessages&&(K.status===null||!Os.has(K.status))))continue;if((await $.listPrs(Y,X)).length>0)continue;await Yw$(Z,X,Y)}}catch(Y){console.error("[task-board] quota refund pass failed",Y)}}async function SQ1($,Z){if(Z.status!==T$.progress||!_Y(Z))return;try{let Q=await $.storage.taskBoard.update(Z.id,Z.organizationId,{status:T$.review},Z.updatedBy);await $.storage.taskBoard.recordActivity({taskBoardItemId:Z.id,action:"status_changed",actorId:null,data:{from:Z.status,to:T$.review}}).catch(()=>{}),F8(Z.organizationId,Q)}catch(Q){console.error(`[task-board] parking ${Z.id} for review failed`,Q)}}async function eH($,Z,Q){let X=Z.organizationId;if(Z.assigneeId!==o$)return!1;try{await SQ1($,Z).catch((G)=>console.warn(`[task-board] parking ${Z.id} before hand-off failed`,G));let Y=await $.storage.taskBoard.unassignSuperAgent(Z.id,X,Z.updatedBy);if(!Y)return!1;return await C6($,{taskBoardItemId:Z.id,action:"assignee_changed",actorId:null,data:{from:Z.assigneeId,to:null,reason:Q}}),console.warn(`[task-board] ${Z.id} handed to a human: ${Q}`),F8(X,Y),!0}catch(Y){return console.error(`[task-board] handing ${Z.id} to a human failed`,Y),!1}}async function ev$($,Z,Q){if(!(Q instanceof IX))return!1;if(Q.reason!=="runs_exhausted")return!1;return await eH($,Z,"per-task run limit reached \u2014 the Super Agent can no longer re-dispatch "+"itself on this task. Re-run it manually to continue."),!0}async function qx$($,Z){let Q=$.organization?.id;if(!Q)return;try{let X=await $.storage.taskBoard.reopenLinkedTasksOnThreadRun(Z,Q);for(let Y of X)F8(Q,Y)}catch(X){console.error("[task-board] thread-run reopen failed",X)}}function Mx$($){return $.includes("create_pull_request")||$.includes("createPullRequest")}function Vx$($){if(Ca4.test($))return!0;return _a4.test($)&&va4.test($)}var Va4=30000,ka4=120000,Sa4="Run ended after it had already delivered \u2014 the task moved on without it",Ca4,_a4,va4;var n5=L(()=>{nJ();y4();vN();Ac();kZ();Ax$();t8();Ns();z4();SQ();aK();Ca4=/\bgh\s+pr\s+create\b/,_a4=/api\.github\.com\/repos\/[^\s"']+\/pulls\b/,va4=/(?:-X|--request)\s+POST/});function xa4($){if($.status==="completed")return"advance";if($.status==="failed"&&$.messageStorageVersion===2&&($.harnessId==="decopilot"||$.harnessId==="claude-code"))return"nudge";return"none"}function fa4($){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(`
2896
2896
  `)}async function ba4($,Z,Q){await Ec($,Z,Q,{messageId:`stall-nudge-${Z.id}-${Q.id}`,prompt:fa4(Q.harness_id),workflowID:`stall-nudge:${Z.id}:${Q.id}`})}async function ya4($,Z){let Q=await $.storage.threads.get(Z);if(!Q)return{action:"none",thread:null};return{action:xa4({status:Q.status,messageStorageVersion:Q.message_storage_version,harnessId:Q.harness_id}),thread:Q}}function ga4($,Z=Date.now()){if($.status!=="in_progress")return!1;if($.run_started_at)return!1;return Ws($,Z)}async function ha4($,Z){let Q=[];for(let X of Z.threads){if(X.status!=="in_progress")continue;let Y=await $.storage.threads.get(X.threadId);if(!Y||!ga4(Y))continue;if(await $.storage.threads.markRunFailed(X.threadId,CQ1,"abandoned"))Q.push(X.threadId),console.warn(`[task-board] failed never-started thread ${X.threadId} on ${Z.id}`)}return Q}async function kx$($,Z){let Q=$.organization?.id;if(!Q)return;for(let X of Z){if(X.status==="in_progress")try{if((await ha4($,X)).length>0)continue}catch(J){console.error(`[task-board] reaping threads for ${X.id} failed`,J)}let Y;try{Y=X.repo!=null&&(await $.storage.taskBoard.listPrs(X.id,Q)).length>0}catch(J){console.error(`[task-board] listPrs for ${X.id} failed`,J);continue}if(!GQ1(X,Y))continue;let G=X.threads.find((J)=>J.hasMessages);if(!G)continue;try{let{action:J,thread:K}=await ya4($,G.threadId);if(J==="none"||!K)continue;if(J==="advance")await Mc($.storage.taskBoard,G.threadId,Q,$.storage.organizationBilling);else await ba4($,X,K)}catch(J){console.error(`[task-board] stall recovery failed for ${X.id}`,J)}}}var CQ1="Run never started \u2014 no pod picked it up before the idle window elapsed";var _Q1=L(()=>{PT0();vN();n5()});import{z as QF}from"zod";var ua4,Jx;var vQ1=L(()=>{z4();V0();BY();Q3();_Q1();ua4=QF.object({key:QF.string(),title:QF.string(),position:QF.number()}),Jx=h({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:QF.object({}),outputSchema:QF.object({items:QF.array(Fc),repos:QF.array(QF.string()),columns:QF.array(ua4)}),handler:async($,Z)=>{r(Z),await Z.access.check();let Q=Z.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let[X,{items:Y}]=await Promise.all([Z.storage.taskBoard.list(Q),Z.storage.connections.list(Q,{slug:"mcp-github"})]),G=sL$(Y);return kx$(Z,X),{items:X,repos:G,columns:oD$}}})});async function Sx$($,Z,Q){if(Z.assigneeId)return Z;let X=Z.organizationId,Y=await $.storage.columnAutomations.get(X,Z.status);if(!Y)return Z;let G=await $.storage.taskBoard.claimUnassignedForSuperAgent(Z.id,X,Q.assignedBy,Q.actor,Z.status);if(!G)return Z;await $.storage.taskBoard.recordActivity({taskBoardItemId:Z.id,action:"assignee_changed",actorId:null,data:{from:null,to:o$}});try{await oD($,G,{instruction:Y.prompt??void 0})}catch(J){return console.warn(`[task-board] column rule on ${Z.status} rejected for ${Z.id}, un-delegating:`,J instanceof Error?J.message:J),await $.storage.taskBoard.unassignSuperAgent(Z.id,X,Q.actor)??await $.storage.taskBoard.getById(Z.id,X)??G}return G}var Cx$=L(()=>{z4();$F()});import{z as cG}from"zod";function ma4($){return la4.some((Z)=>$[Z]!==void 0)}function da4($,Z){let Q=[];for(let{field:G,action:J}of ca4){if(Z[G]===$[G])continue;Q.push({action:J,data:{from:$[G],to:Z[G]}})}if(Z.description!==$.description)Q.push({action:"description_changed"});let X=new Set($.tags.map((G)=>G.id));if(Z.tags.length!==$.tags.length||Z.tags.some((G)=>!X.has(G.id)))Q.push({action:"tags_changed",data:{from:$.tags,to:Z.tags}});return Q}function ia4($,Z){if($!==o$)return!1;if(!Z)return!1;return Z.assigneeId!==o$?!0:Z.status===T$.queue}function na4($,Z,Q){let X=$!==void 0&&pa4.has($),Y=Z!==void 0&&_Y(Z);return Q&&X&&Y}function xQ1($,Z){return $!==void 0&&KQ1($)&&!Z}var ca4,la4,pa4,Kx;var rT0=L(()=>{z4();V0();ZZ();Q3();aK();fZ1();$F();SQ();tH();n5();Cx$();Ac();kZ();nJ();ca4=[{field:"status",action:"status_changed"},{field:"assigneeId",action:"assignee_changed"},{field:"priority",action:"priority_changed"},{field:"type",action:"type_changed"},{field:"dueDate",action:"due_date_changed"},{field:"title",action:"title_changed"}],la4=["title","description","status","priority","type","assigneeId","repo","dueDate","sortOrder","tagIds"];pa4=new Set(["approved","merged","post_deploy_validation","done","archived"]);Kx=h({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:cG.object({id:cG.string(),title:cG.string().min(1).max(_A0).optional(),description:cG.string().max(CA0).nullable().optional(),status:RN.optional(),priority:yv.optional(),type:na.optional(),assigneeId:cG.string().nullable().optional(),repo:cG.string().max(vA0).nullable().optional(),dueDate:cG.string().datetime().nullable().optional(),sortOrder:cG.number().optional(),tagIds:cG.array(cG.string()).max(1000).optional(),linkThreadId:cG.string().optional(),prUrl:cG.string().nullable().optional().describe("GitHub pull request URL to link to this task, e.g. https://github.com/owner/repo/pull/123. Pass it after opening a PR for an existing card; linking one is what starts its review.")}),outputSchema:cG.object({item:Fc}),handler:async($,Z)=>{r(Z),await Z.access.check();let Q=Z.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");let X=$.prUrl?mD($.prUrl):null;if($.prUrl&&!X)throw Error(`Not a GitHub pull request URL: ${$.prUrl} (expected https://github.com/<owner>/<repo>/pull/<number>)`);if($.assigneeId)await fA0(Z,Q,$.assigneeId);if($.linkThreadId){if(!await Z.storage.taskBoard.getById($.id,Q))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,Q)}let Y=ma4($),G=Y?await Z.storage.taskBoard.getById($.id,Q):null;if(Y&&!G)throw Error(`Task board item not found: ${$.id}`);if($.status!==void 0&&KQ1($.status)){let N=await Z.storage.organizationSettings.get(Q);if(xQ1($.status,RX(N?.flags,"delivery_lanes_enabled")))throw Error("Delivery lanes are not enabled for this organization \u2014 enable "+"them in Settings before moving a task to Approved, Merged, or Post-deploy Validation.")}let J=tK.getStore()!==void 0;if(na4($.status,G??void 0,J))throw Error("This task is under review \u2014 a run can't move it to Done or Archived. "+"Leave it for the reviewer; only a person, or TASK_BOARD_REVIEW_DECISION on a reviewer's own run, closes out a task under review.");let K=$.assigneeId!==void 0&&$.assigneeId!==(G?.assigneeId??null),W=ia4($.assigneeId,G),F=(W?T$.queue:void 0)??$.status;if(G&&DY(G)){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(W)await Iu(Z,G,KD())}if($.tagIds!==void 0){let N=await Z.storage.tags.listOrgTags(Q),B=new Set(N.map((O)=>O.id));for(let O of $.tagIds)if(!B.has(O))throw Error(`Tag not found: ${O}`);await Z.storage.taskBoard.setItemTags($.id,$.tagIds,r0(Z))}let U;if(Y)U=await Z.storage.taskBoard.update($.id,Q,{title:$.title,description:$.description,status:F,priority:$.priority,type:$.type,assigneeId:$.assigneeId,assignedBy:K?$.assigneeId?r0(Z):null:void 0,repo:$.repo,dueDate:$.dueDate,sortOrder:$.sortOrder},r0(Z));else{let N=await Z.storage.taskBoard.getById($.id,Q);if(!N)throw Error(`Task board item not found: ${$.id}`);U=N}if(X)await Z.storage.taskBoard.linkPr({taskBoardItemId:U.id,organizationId:Q,url:X.url,prNumber:X.number,repoOwner:X.owner,repoName:X.repo,connectionId:null}),await W3(Q).catch((N)=>{console.error("[task-board] PR card cache invalidation failed",N)});if(G){let N=r0(Z),B=da4(G,U);if(B.length>0)await cv$(Z,B.map((O)=>({taskBoardItemId:U.id,actorId:N,...O,alsoSubscribe:O.action==="assignee_changed"&&U.assigneeId!==o$?[U.assigneeId]:void 0})))}if(G&&U.description!==G.description)await Z.storage.notifications.notifyMentions({taskBoardItemId:U.id,organizationId:Q,actorId:r0(Z),body:U.description??"",previousBody:G.description});if(Y||$.linkThreadId||X)F8(Q,U);if(W)return await oD(Z,U,{userInitiated:!0}),{item:U};if($.status!==void 0&&G!==null&&G.status!==U.status)U=await Sx$(Z,U,{assignedBy:r0(Z),actor:r0(Z)});return{item:U}}})});import{z as aT0}from"zod";var Wx;var fQ1=L(()=>{V0();n5();Wx=h({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:aT0.object({id:aT0.string()}),outputSchema:aT0.object({success:aT0.boolean()}),handler:async($,Z)=>{r(Z),await Z.access.check();let Q=Z.organization?.id;if(!Q)throw Error("Organization ID required (no active organization in context)");if(!await Z.storage.taskBoard.delete($.id,Q,r0(Z)??"system"))throw Error(`Task board item not found: ${$.id}`);return Tx$(Q,$.id),{success:!0}}})});function _x$($){return{TASK_BOARD_ITEM_LIST:v$({description:Jx.description,inputSchema:Q0(Jx.inputSchema),execute:(Z)=>Jx.execute(Z,$)}),TASK_BOARD_ITEM_CREATE:v$({description:Hx.description,inputSchema:Q0(Hx.inputSchema),execute:(Z)=>Hx.execute(Z,$)}),TASK_BOARD_ITEM_UPDATE:v$({description:Kx.description,inputSchema:Q0(Kx.inputSchema),execute:(Z)=>Kx.execute(Z,$)}),TASK_BOARD_ITEM_DELETE:v$({description:Wx.description,inputSchema:Q0(Wx.inputSchema),execute:(Z)=>Wx.execute(Z,$)}),TASK_BOARD_ITEM_PRS_GET:v$({description:Yx.description,inputSchema:Q0(Yx.inputSchema),execute:(Z)=>Yx.execute(Z,$)})}}var vx$=L(()=>{l4();bQ1();vQ1();rT0();fQ1();kZ()});async function oa4($,Z,Q){let{provider:X,imageProvider:Y,webSearchProvider:G,deepResearchProvider:J,organization:K,models:W,toolApprovalLevel:H="auto",isPlanMode:F=!1,toolOutputMap:U,pendingImages:N,passthroughClient:B,vmContext:O,htmlArtifactBuffer:D,taskId:w,agentId:E,onChildUsage:j,backgroundDispatcher:z}=Z,P={isPlanMode:F},A=Q.auth?.user?.id,I=q_$({writer:$,toolOutputMap:U,passthroughClient:B,toolApprovalLevel:H,isPlanMode:F,objectStorage:Q.objectStorage});if(A)I.update_interests=U_$({write:async(S)=>{await Q.storage.interests.setForAgent(S.orgId,S.agentId,S.userId,{interests:S.interests})},orgId:K.id,agentId:E,userId:A});Object.assign(I,v_$(Q)),Object.assign(I,await aa4(Q,w)?jv$(Q,w):_x$(Q));let V=$s(H,!1,P)!==!1,q;if(O){let S=await Kc(Q,{virtualMcpId:O.virtualMcpId,branch:O.branch,userId:O.userId,syncTools:O.syncTools,threadId:O.threadId}),i=H_$(S);q=K_$({fs:i.fs,htmlArtifactBuffer:D,toolOutputMap:U,needsApproval:V,pendingImages:N}),Object.assign(I,q);let f=await US$({ctx:Q,orgId:K.id,virtualMcpId:O.virtualMcpId,userId:O.userId,threadId:O.threadId,writer:$,rebindFs:async(b)=>{i.swap(await Kc(Q,{virtualMcpId:O.virtualMcpId,branch:b,userId:O.userId,syncTools:O.syncTools,threadId:O.threadId}))}});if(f)I.load_repo=f}if(X)I.subtask=Js("subtask",gQ1,hQ1($,{provider:X,organization:K,models:W,self:{id:E},currentThreadId:w,needsApproval:$s(H,!1,P)!==!1,onChildUsage:j,vmTools:q,parentBuiltInParams:Z},Q),z,(S)=>z_$(w,S));if(Y&&W.image&&Q.objectStorage)I.generate_image=Js("generate_image",Ys,w_$($,{provider:Y,imageModelInfo:W.image,objectStorage:Q.objectStorage,allowHttpExternalUrls:C0().localMode}),z);if(G&&W.webSearch){let S=w71({provider:G,modelInfo:W.webSearch,ctx:Q,mode:"quick",toolName:"web_search"});I.web_search=O71($,{researchJob:S,toolOutputMap:U,taskId:w})}if(J&&W.deepResearch){let S=w71({provider:J,modelInfo:W.deepResearch,ctx:Q,mode:"deep",toolName:"deep_research"});I.deep_research=O71($,{researchJob:S,toolOutputMap:U,taskId:w,description:"Run in-depth, multi-source research and synthesize a comprehensive, cited report. Use this when the user needs thorough analysis, a literature/market review, or a question that warrants exploring many "+"sources \u2014 accuracy and depth matter more than latency. For quick "+"lookups or fact-checks, use `web_search` instead."})}return I}function ra4($,Z,Q){let X=Z.organization.id,Y=Q.auth?.user?.id,G={};for(let[J,K]of Object.entries($)){let W=K,H=W.execute;if(typeof H!=="function"){G[J]=K;continue}let F=ta4[J],U=H.constructor?.name==="AsyncGeneratorFunction",N=(O,D)=>{if(!X||!Y)return;f1.capture({distinctId:Y,event:"tool_called",groups:{organization:X},properties:{organization_id:X,tool_source:"builtin",tool_name:J,tool_safe_name:J,read_only:F?.readOnly??null,destructive:F?.destructive??null,idempotent:null,open_world:null,latency_ms:Math.round(O),is_error:D}})},B=U?async function*(O,D){let w=performance.now(),E=!1;try{yield*H.call(W,O,D)}catch(j){throw E=!0,j}finally{N(performance.now()-w,E)}}:async(O,D)=>{let w=performance.now(),E=!1;try{return await H.call(W,O,D)}catch(j){throw E=!0,j}finally{N(performance.now()-w,E)}};G[J]={...W,execute:B}}return G}async function sT0($,Z,Q){let X=await oa4($,Z,Q),Y=ra4(X,Z,Q);if(!Z.isPlanMode){let{propose_plan:G,...J}=Y;return J}return Y}function xx$($){let{ctx:Z,writer:Q,toolOutputMap:X,subtaskParams:Y,planMode:G}=$,J={user_ask:eA0,todo_write:$T0,read_tool_output:rA0({toolOutputMap:X})};if(G)J.propose_plan=QT0;if(Y.provider)J.subtask=hQ1(Q,Y,Z);return J}async function aa4($,Z){try{return(await $.storage.threads.get(Z))?.metadata?.source==="jira"}catch{return!1}}var ta4;var yQ1=L(()=>{y4();Zs();VN();W_$();kA0();SA0();uQ1();J71();K71();N_$();W71();E_$();U71();B71();Gs();A_$();I_$();M_$();x_$();zv$();vx$();j$();ta4={read_tool_output:{readOnly:!0,destructive:!1},read_resource:{readOnly:!0,destructive:!1},read_prompt:{readOnly:!0,destructive:!1},web_search:{readOnly:!0,destructive:!1},deep_research:{readOnly:!0,destructive:!1},generate_image:{readOnly:!1,destructive:!1},open_in_agent:{readOnly:!1,destructive:!1},subtask:{readOnly:!1,destructive:!1},user_ask:{readOnly:!0,destructive:!1},propose_plan:{readOnly:!0,destructive:!1},enable_tool:{readOnly:!0,destructive:!1},todo_write:{readOnly:!1,destructive:!1},update_interests:{readOnly:!1,destructive:!1},load_repo:{readOnly:!1,destructive:!0},search_threads:{readOnly:!0,destructive:!1},get_thread:{readOnly:!0,destructive:!1},list_thread_messages:{readOnly:!0,destructive:!1},TASK_BOARD_ITEM_LIST:{readOnly:!0,destructive:!1},TASK_BOARD_ITEM_CREATE:{readOnly:!1,destructive:!1},TASK_BOARD_ITEM_UPDATE:{readOnly:!1,destructive:!1},TASK_BOARD_ITEM_DELETE:{readOnly:!1,destructive:!0},TASK_BOARD_ITEM_PRS_GET:{readOnly:!0,destructive:!1}}});async function fx$($){let Z=$.toolOutputMap??oA0(),{tools:Q,nameMap:X}=await sA0($.mcpClient,Z,$.writer,$.toolApprovalLevel,{disableOutputTruncation:!1,isPlanMode:$.planMode,timeoutMs:tA0,resolveArgs:$.resolveArgs,onToolCalled:$.onToolCalled,onPrOpened:$.onPrOpened}),Y=$.fullBuiltInParams?await sT0($.writer,{...$.fullBuiltInParams,toolOutputMap:Z},$.ctx):xx$({ctx:$.ctx,writer:$.writer,toolOutputMap:Z,subtaskParams:$.subtaskParams,planMode:$.planMode}),G=$.kind==="subagent"?Object.fromEntries(Object.entries(Y).filter(([K])=>!sa4.includes(K))):Y;return{tools:{...Q,...G},toolOutputMap:Z,nameMap:X}}var sa4;var bx$=L(()=>{Zs();VN();yQ1();sa4=["subtask","user_ask","propose_plan"]});var $20={};s($20,{waitForSeed:()=>Ws4,seedLocalMode:()=>Gs4,pruneUndecryptableJwks:()=>hx$,markSeedComplete:()=>Ks4,isLocalMode:()=>fN,healLocalJwks:()=>Qs4,getLocalAdminUser:()=>cQ1,getLocalAdminPassword:()=>eT0});import{symmetricDecrypt as ea4}from"better-auth/crypto";import{sql as yx$}from"kysely";import{userInfo as $s4}from"os";async function Qs4(){let $=C0();if(!$.localMode)return 0;if(!$.betterAuthSecret)return 0;return hx$(c$().db,$.betterAuthSecret)}async function hx$($,Z){let Q;try{Q=(await yx$`
2897
2897
  select id, "privateKey" from jwks
2898
2898
  `.execute($)).rows}catch(Y){if(Y?.code==="42P01")return 0;return console.warn("[local-mode] JWKS heal skipped \u2014 could not read jwks:",Y),0}let X=0;for(let Y of Q){let G=!0;try{await ea4({key:Z,data:JSON.parse(Y.privateKey)})}catch{G=!1}if(G)continue;try{await yx$`delete from jwks where id = ${Y.id}`.execute($),X++}catch(J){console.warn(`[local-mode] JWKS heal could not delete stale key ${Y.id}:`,J)}}return X}async function eT0(){return"local-mode-default"}function ux$(){try{return $s4().username||"local"}catch{return"local"}}function Xs4($){return $.charAt(0).toUpperCase()+$.slice(1)}async function Ys4(){let $=c$(),Z=await $.db.selectFrom("user").select($.db.fn.countAll().as("count")).executeTakeFirst();return Number(Z?.count??0)===0}async function Gs4(){if(!await Ys4())return!1;let Z=ux$(),Q=`${Z}@${gx$}`,X=Xs4(Z),Y=await eT0(),G=await G8.api.signUpEmail({body:{email:Q,password:Y,name:X}});if(!G?.user?.id)throw Error("Failed to create local admin user");let J=G.user.id,K=c$();await K.db.updateTable("user").set({role:"admin"}).where("id","=",J).execute();let W=`${Z}-local`.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),H=`${X} Local`;return await K.db.updateTable("organization").set({name:H,slug:W}).where("id","in",(F)=>F.selectFrom("member").select("organizationId").where("userId","=",J)).execute(),!0}async function cQ1(){let $=c$(),Z=ux$(),Q=await $.db.selectFrom("user").where("email","=",`${Z}@${gx$}`).selectAll().executeTakeFirst();if(Q)return Q;return $.db.selectFrom("user").where("email","=",`${Z}@${Zs4}`).selectAll().executeTakeFirst()}function fN(){return C0().localMode}function Ks4(){cx$()}function Ws4(){return Js4}var gx$="localhost.studio",Zs4="localhost.mesh",cx$,Js4;var Fx=L(()=>{WQ();j$();MG();Js4=new Promise(($)=>{if(cx$=$,!fN())$()})});var lx$=L(()=>{XT0()});function Fs4($){return $.type==="file"&&"mediaType"in $&&typeof $.mediaType==="string"&&Hs4.has($.mediaType)}function tx$($){let Z=$.match(/^data:([^;]+);base64,(.+)$/s);if(!Z)return null;let[,Q,X]=Z;try{let Y=atob(X),G=new Uint8Array(Y.length);for(let J=0;J<Y.length;J++)G[J]=Y.charCodeAt(J);return{mimeType:Q,bytes:G}}catch{return null}}function lQ1($){return{"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","application/pdf":"pdf","text/plain":"txt","text/html":"html","application/json":"json"}[$]??"bin"}async function Us4($,Z,Q,X){if(!X.objectStorage)return null;try{return await X.objectStorage.put(Z,$,{contentType:Q}),Z}catch(Y){return console.error("[file-materializer] Failed to upload file:",Y),null}}async function zs($,Z){if(!Z.objectStorage)return null;try{return await Z.objectStorage.presignedGetUrl($,Ns4)}catch(Q){return console.error("[file-materializer] Failed to generate presigned URL:",Q),null}}function ox$($){try{return decodeURIComponent($)}catch{return $}}function dx$($,Z){let Q=typeof $.filename==="string"&&$.filename.trim()?$.filename:`attachment.${lQ1(Z)}`,X=Q.match(Bs4);if(X?.[1])Q=ox$(X[1]);return[...Q.split(/[\\/]/).pop()??Q].filter((J)=>(J.codePointAt(0)??0)>=32).join("").trim()||`attachment.${lQ1(Z)}`}function ix$($,Z){if(!Z.has($))return Z.add($),$;let Q=$.lastIndexOf("."),X=Q>0?$.slice(0,Q):$,Y=Q>0?$.slice(Q):"";for(let G=2;;G++){let J=`${X} (${G})${Y}`;if(!Z.has(J))return Z.add(J),J}}async function px$($,Z,Q,X,Y){if(!Y||!X.orgFs)return console.warn("[file-materializer] uploads-volume write skipped",{hasThreadId:Boolean(Y),hasOrgFs:Boolean(X.orgFs)}),null;try{let G=`${Y}/${Q}`;return await X.orgFs.write("uploads",G,$,{actor:X.auth?.user?.id??"unknown",contentType:Z}),{key:nW("uploads",G),sandboxPath:`org/upload/${Q}`}}catch(G){return console.error("[file-materializer] uploads-volume write failed:",G),null}}async function Z20($,Z,Q){if(!Z.organization)return $;let X=Z.organization.slug;if(!X)return $;let Y=$.findLastIndex((P)=>P.role==="user");if(Y===-1)return $;let G=$[Y],J=G.parts.filter((P)=>P.type==="file"&&("url"in P)&&typeof P.url==="string"&&P.url.startsWith("data:")),W=Boolean(Q?.threadId&&Z.orgFs)?G.parts.flatMap((P)=>{if(P.type!=="text"||!("text"in P)||typeof P.text!=="string")return[];let A=P.text.match(Os4);if(!A?.[1]||A[2]===void 0)return[];return[{name:ox$(A[1]),content:A[2]}]}):[];if(J.length===0&&W.length===0)return $;let H=new Set,F=J.flatMap((P)=>{if(P.type!=="file"||!("url"in P)||typeof P.url!=="string")return[];let A=tx$(P.url);if(!A)return[];let I=ix$(dx$(P,A.mimeType),H);return[{dataUrl:P.url,parsed:A,filename:I}]}),U=W.map(({name:P,content:A})=>({filename:ix$(dx$({filename:P},"text/plain"),H),content:A})),B=(await Promise.all([...F.map(async({dataUrl:P,parsed:A,filename:I})=>{let V=await px$(A.bytes,A.mimeType,I,Z,Q?.threadId);if(!V)return null;return{dataUrl:P,studioStorageUrl:SN(V.key),redirectUrl:by(Z.baseUrl,X,V.key),filename:I,sandboxPath:V.sandboxPath}}),...U.map(async({filename:P,content:A})=>{let I=await px$(new TextEncoder().encode(A),pZ(P),P,Z,Q?.threadId);if(!I)return null;return{dataUrl:null,studioStorageUrl:SN(I.key),redirectUrl:by(Z.baseUrl,X,I.key),filename:P,sandboxPath:I.sandboxPath}})])).filter((P)=>P!==null);if(B.length===0)return $;let O=B.map((P)=>P.sandboxPath?`- ${P.filename}: ${P.sandboxPath} (tool URL: ${P.studioStorageUrl})`:`- ${P.filename}: ${P.studioStorageUrl}`).join(`